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
impl Ed25519Key
Sourcepub fn generate_pkcs8() -> Result<Vec<u8>>
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.
Sourcepub fn from_pkcs8_der(pkcs8_der: &[u8]) -> Result<Self>
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.
Sourcepub fn from_pkcs8_maybe_unchecked_der(pkcs8_der: &[u8]) -> Result<Self>
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.
Sourcepub fn from_seed_and_public_key(seed: &[u8], public_key: &[u8]) -> Result<Self>
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.
Sourcepub fn public_key(&self) -> Vec<u8> ⓘ
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.
impl From<Ed25519Key> for DkimKey
aws-lc-rs or rust-crypto only.Source§fn from(key: Ed25519Key) -> Self
fn from(key: Ed25519Key) -> Self
Source§impl SigningKey for Ed25519Key
impl SigningKey for Ed25519Key
Source§fn sign(&self, input: impl Writable) -> Result<Vec<u8>>
fn sign(&self, input: impl Writable) -> Result<Vec<u8>>
input and returns the raw signature. Read moreSource§fn heap_size(&self) -> usize
fn heap_size(&self) -> usize
Source§fn hash(&self, data: impl Writable) -> HashOutput
fn hash(&self, data: impl Writable) -> HashOutput
data with Self::Hasher.Auto Trait Implementations§
impl Freeze for Ed25519Key
impl RefUnwindSafe for Ed25519Key
impl Send for Ed25519Key
impl Sync for Ed25519Key
impl Unpin for Ed25519Key
impl UnsafeUnpin for Ed25519Key
impl UnwindSafe for Ed25519Key
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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