[−][src]Struct sequoia_openpgp::serialize::stream::Signer
Signs a packet stream.
For every signing key, a signer writes a one-pass-signature packet, then hashes and emits the data stream, then for every key writes a signature packet.
Implementations
impl<'a> Signer<'a>
[src]
pub fn new<S>(inner: Message<'a, Cookie>, signer: S) -> Self where
S: Signer + 'a,
[src]
S: Signer + 'a,
Creates a signer.
Example
extern crate sequoia_openpgp as openpgp; use std::io::{Read, Write}; use openpgp::serialize::stream::{Message, Signer, LiteralWriter}; use openpgp::policy::StandardPolicy; let p = &StandardPolicy::new(); let p = &StandardPolicy::new(); let mut o = vec![]; { let message = Message::new(&mut o); let signer = Signer::new(message, signing_keypair).build()?; let mut ls = LiteralWriter::new(signer).build()?; ls.write_all(b"Make it so, number one!")?; ls.finalize()?; } // Now check the signature. struct Helper<'a>(&'a openpgp::Cert); impl<'a> VerificationHelper for Helper<'a> { fn get_public_keys(&mut self, _: &[openpgp::KeyHandle]) -> openpgp::Result<Vec<openpgp::Cert>> { Ok(vec![self.0.clone()]) } fn check(&mut self, structure: MessageStructure) -> openpgp::Result<()> { if let MessageLayer::SignatureGroup { ref results } = structure.iter().nth(0).unwrap() { results.get(0).unwrap().as_ref().unwrap(); Ok(()) } else { panic!() } } } let mut verifier = Verifier::from_bytes(p, &o, Helper(&cert), None)?; let mut message = String::new(); verifier.read_to_string(&mut message)?; assert_eq!(&message, "Make it so, number one!");
pub fn hash_algo(self, algo: HashAlgorithm) -> Result<Self>
[src]
Sets the hash algorithm to use for the signatures.
pub fn add_signer<S>(self, signer: S) -> Self where
S: Signer + 'a,
[src]
S: Signer + 'a,
Adds an additional signer.
pub fn add_intended_recipient(self, recipient: &Cert) -> Self
[src]
Adds an intended recipient.
This signer emits signatures indicating the intended recipients of the encryption container containing the signature. This prevents forwarding a signed message using a different encryption context.
pub fn detached(self) -> Self
[src]
Creates a signer for a detached signature.
Example
extern crate sequoia_openpgp as openpgp; use std::io::{Read, Write}; use openpgp::serialize::stream::{Message, Signer, LiteralWriter}; use sequoia_openpgp::policy::StandardPolicy; let p = &StandardPolicy::new(); let mut o = vec![]; { let message = Message::new(&mut o); let mut signer = Signer::new(message, signing_keypair).detached().build()?; signer.write_all(b"Make it so, number one!")?; // In reality, just io::copy() the file to be signed. signer.finalize()?; } // Now check the signature. struct Helper<'a>(&'a openpgp::Cert); impl<'a> VerificationHelper for Helper<'a> { fn get_public_keys(&mut self, _: &[openpgp::KeyHandle]) -> openpgp::Result<Vec<openpgp::Cert>> { Ok(vec![self.0.clone()]) } fn check(&mut self, structure: MessageStructure) -> openpgp::Result<()> { if let MessageLayer::SignatureGroup { ref results } = structure.iter().nth(0).unwrap() { results.get(0).unwrap().as_ref().unwrap(); Ok(()) } else { panic!() } } } let mut verifier = DetachedVerifier::from_bytes(p, &o, Helper(&cert), None)?; verifier.verify_bytes(b"Make it so, number one!")?;
pub fn creation_time(self, creation_time: SystemTime) -> Self
[src]
Sets the signature's creation time to time
.
Note: it is up to the caller to make sure the signing keys are
actually valid as of time
.
pub fn build(self) -> Result<Message<'a, Cookie>>
[src]
Finalizes the signer, returning the writer stack.
Trait Implementations
impl<'a> Debug for Signer<'a>
[src]
impl<'a> Drop for Signer<'a>
[src]
impl<'a> Write for Signer<'a>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Signer<'a>
impl<'a> !Send for Signer<'a>
impl<'a> !Sync for Signer<'a>
impl<'a> Unpin for Signer<'a>
impl<'a> !UnwindSafe for Signer<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,