Struct CleartextSignedMessage

Source
pub struct CleartextSignedMessage { /* private fields */ }
Expand description

Implementation of a Cleartext Signed Message.

Ref https://www.rfc-editor.org/rfc/rfc9580.html#name-cleartext-signature-framewo

Implementations§

Source§

impl CleartextSignedMessage

Source

pub fn new<F>( text: &str, config: SignatureConfig, key: &impl SecretKeyTrait, key_pw: F, ) -> Result<Self>
where F: FnOnce() -> String,

Construct a new cleartext message and sign it using the given key.

Source

pub fn sign<R, F>( rng: R, text: &str, key: &impl SecretKeyTrait, key_pw: F, ) -> Result<Self>
where R: Rng + CryptoRng, F: FnOnce() -> String,

Sign the given text.

Source

pub fn new_many<F>(text: &str, signer: F) -> Result<Self>
where F: FnOnce(&[u8]) -> Result<Vec<Signature>>,

Sign the same message with multiple keys.

The signer function gets invoked with the normalized original text to be signed, and needs to produce the individual signatures.

Source

pub fn signatures(&self) -> &[StandaloneSignature]

The signature on the message.

Source

pub fn verify(&self, key: &impl PublicKeyTrait) -> Result<&StandaloneSignature>

Verify the signature against the normalized cleartext.

On success returns the first signature that verified against this key.

Source

pub fn verify_many<F>(&self, verifier: F) -> Result<()>
where F: Fn(usize, &StandaloneSignature, &[u8]) -> Result<()>,

Verify each signature, potentially against a different key.

Source

pub fn signed_text(&self) -> String

Normalizes the text to the format that was hashed for the signature. The output is normalized to “\r\n” line endings.

Source

pub fn text(&self) -> &str

The “cleartext framework”-encoded (i.e. dash-escaped) form of the message.

Source

pub fn from_armor<R: Read>(bytes: R) -> Result<(Self, Headers)>

Parse from an arbitrary reader, containing the text of the message.

Source

pub fn from_string(input: &str) -> Result<(Self, Headers)>

Parse from string, containing the text of the message.

Source

pub fn from_armor_buf<R: BufRead>(b: R) -> Result<(Self, Headers)>

Parse from a buffered reader, containing the text of the message.

Source

pub fn from_armor_after_header<R: BufRead>( b: R, headers: Headers, ) -> Result<(Self, Headers)>

Source

pub fn to_armored_writer( &self, writer: &mut impl Write, opts: ArmorOptions<'_>, ) -> Result<()>

Source

pub fn to_armored_bytes(&self, opts: ArmorOptions<'_>) -> Result<Vec<u8>>

Source

pub fn to_armored_string(&self, opts: ArmorOptions<'_>) -> Result<String>

Trait Implementations§

Source§

impl Clone for CleartextSignedMessage

Source§

fn clone(&self) -> CleartextSignedMessage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CleartextSignedMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CleartextSignedMessage

Source§

fn eq(&self, other: &CleartextSignedMessage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for CleartextSignedMessage

Source§

impl StructuralPartialEq for CleartextSignedMessage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V