Struct ruma_signatures::Signature[][src]

pub struct Signature {
    pub algorithm: Algorithm,
    pub signature: Vec<u8>,
    pub version: String,
}

A digital signature.

Fields

algorithm: Algorithm

The cryptographic algorithm that generated this signature.

signature: Vec<u8>

The signature data.

version: String

The “version” of the key identifier for the public key used to generate this signature.

Implementations

impl Signature[src]

pub fn new(id: &str, bytes: &[u8]) -> Result<Self, Error>[src]

Creates a signature from raw bytes.

While a signature can be created directly using struct literal syntax, this constructor can be used to automatically determine the algorithm and version from a key identifier in the form algorithm:version, e.g. “ed25519:1”.

This constructor will ensure that the version does not contain characters that violate the guidelines in the specification. Because it may be necessary to represent signatures with versions that don’t adhere to these guidelines, it’s possible to simply use the struct literal syntax to construct a Signature with an arbitrary key.

Parameters

  • id: A key identifier, e.g. “ed25519:1”.
  • bytes: The digital signature, as a series of bytes.

Errors

Returns an error if:

  • The key ID specifies an unknown algorithm.
  • The key ID is malformed.
  • The key ID contains a version with invalid characters.

pub fn algorithm(&self) -> &Algorithm[src]

The algorithm used to generate the signature.

pub fn as_bytes(&self) -> &[u8][src]

The raw bytes of the signature.

pub fn base64(&self) -> String[src]

A Base64 encoding of the signature.

Uses the standard character set with no padding.

pub fn id(&self) -> String[src]

The key identifier, a string containing the signature algorithm and the key “version” separated by a colon, e.g. “ed25519:1”.

pub fn version(&self) -> &str[src]

The “version” of the key used for this signature.

Versions are used as an identifier to distinguish signatures generated from different keys but using the same algorithm on the same homeserver.

Trait Implementations

impl Clone for Signature[src]

impl Debug for Signature[src]

impl Eq for Signature[src]

impl Hash for Signature[src]

impl PartialEq<Signature> for Signature[src]

impl StructuralEq for Signature[src]

impl StructuralPartialEq for Signature[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.