Skip to main content

Ed25519Key

Struct Ed25519Key 

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

An Ed25519 private key for ed25519-sha256 signing (RFC 8463).

The signature is computed over the SHA-256 hash of the signed data, as RFC 8463 Section 3 requires.

Implementations§

Source§

impl Ed25519Key

Source

pub fn generate_pkcs8() -> Result<Vec<u8>>

Generates a new random Ed25519 key pair and returns it as PKCS #8 DER bytes, ready for from_pkcs8_der.

§Errors

Returns Error::Crypto with CryptoError::Library if key generation or encoding fails.

Source

pub fn from_pkcs8_der(pkcs8_der: &[u8]) -> Result<Self>

Loads an Ed25519 key pair from PKCS #8 v2 DER bytes (RFC 5958), checking that the embedded public key matches the private key. PKCS #8 v1 documents are rejected by ring; load them with from_pkcs8_maybe_unchecked_der.

§Errors

Returns Error::Crypto with CryptoError::Library if the key cannot be decoded.

Source

pub fn from_pkcs8_maybe_unchecked_der(pkcs8_der: &[u8]) -> Result<Self>

Loads an Ed25519 key pair from PKCS #8 v1 or v2 DER bytes. A v1 document (as produced by openssl genpkey -algorithm ED25519) carries no public key, so no consistency check is possible; v2 documents are checked as in from_pkcs8_der.

§Errors

Returns Error::Crypto with CryptoError::Library if the key cannot be decoded.

Source

pub fn from_seed_and_public_key(seed: &[u8], public_key: &[u8]) -> Result<Self>

Builds an Ed25519 key pair from its 32-byte seed (private key) and 32-byte public key.

§Errors

Returns Error::Crypto with CryptoError::Library if either value has the wrong length or the public key does not match the seed.

Source

pub fn public_key(&self) -> Vec<u8> ⓘ

Returns the 32-byte raw Ed25519 public key, as published in the p= tag of a DKIM key record.

Trait Implementations§

Source§

impl From<Ed25519Key> for DkimKey

Available on crate features aws-lc-rs or rust-crypto only.
Source§

fn from(key: Ed25519Key) -> Self

Converts to this type from the input type.
Source§

impl SigningKey for Ed25519Key

Source§

type Hasher = Sha256

The hash function used by the signature algorithm.
Source§

fn sign(&self, input: impl Writable) -> Result<Vec<u8>>

Signs the bytes written by input and returns the raw signature. Read more
Source§

fn algorithm(&self) -> Algorithm

Returns the signature algorithm written to the a= tag.
Source§

fn heap_size(&self) -> usize

Approximate heap memory owned by the key, in bytes, for weighing cache entries that hold it.
Source§

fn hash(&self, data: impl Writable) -> HashOutput

Hashes the bytes written by data with Self::Hasher.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more