Struct Ed25519KeyPair

pub struct Ed25519KeyPair { /* private fields */ }
Expand description

An Ed25519 key pair, for signing.

Implementations§

§

impl Ed25519KeyPair

pub fn generate() -> Result<Ed25519KeyPair, Unspecified>

Generates a new key pair and returns the key pair.

§Errors

error::Unspecified if key generation fails.

pub fn generate_pkcs8(_rng: &dyn SecureRandom) -> Result<Document, Unspecified>

Generates a new key pair and returns the key pair serialized as a PKCS#8 document.

The PKCS#8 document will be a v2 OneAsymmetricKey with the public key, as described in RFC 5958 Section 2; see RFC 8410 Section 10.3 for an example.

§ring Compatibility

The ring 0.16.x API did not produce encoded v2 documents that were compliant with RFC 5958. The aws-lc-ring implementation produces PKCS#8 v2 encoded documents that are compliant per the RFC specification.

Our implementation ignores the SecureRandom parameter.

§Errors

error::Unspecified if rng cannot provide enough bits or if there’s an internal error.

pub fn to_pkcs8(&self) -> Result<Document, Unspecified>

Serializes this Ed25519KeyPair into a PKCS#8 v2 document.

§Errors

error::Unspecified on internal error.

pub fn generate_pkcs8v1( _rng: &dyn SecureRandom, ) -> Result<Document, Unspecified>

Generates a Ed25519KeyPair using the rng provided, then serializes that key as a PKCS#8 document.

The PKCS#8 document will be a v1 PrivateKeyInfo structure (RFC5208). Use this method when needing to produce documents that are compatible with the OpenSSL CLI.

§ring Compatibility

Our implementation ignores the SecureRandom parameter.

§Errors

error::Unspecified if rng cannot provide enough bits or if there’s an internal error.

pub fn to_pkcs8v1(&self) -> Result<Document, Unspecified>

Serializes this Ed25519KeyPair into a PKCS#8 v1 document.

§Errors

error::Unspecified on internal error.

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

Constructs an Ed25519 key pair from the private key seed seed and its public key public_key.

It is recommended to use Ed25519KeyPair::from_pkcs8() instead.

The private and public keys will be verified to be consistent with each other. This helps avoid misuse of the key (e.g. accidentally swapping the private key and public key, or using the wrong private key for the public key). This also detects any corruption of the public or private key.

§Errors

error::KeyRejected if parse error, or if key is otherwise unacceptable.

pub fn from_seed_unchecked(seed: &[u8]) -> Result<Ed25519KeyPair, KeyRejected>

Constructs an Ed25519 key pair from the private key seed seed.

It is recommended to use Ed25519KeyPair::from_pkcs8() instead. If the public key is available, prefer to use Ed25519KeyPair::from_seed_and_public_key() as it will verify the validity of the key pair.

CAUTION: Both an Ed25519 seed and its public key are 32-bytes. If the bytes of a public key are provided this function will create an (effectively) invalid Ed25519KeyPair. This problem is undetectable by the API.

§Errors

error::KeyRejected if parse error, or if key is otherwise unacceptable.

pub fn from_pkcs8(pkcs8: &[u8]) -> Result<Ed25519KeyPair, KeyRejected>

Constructs an Ed25519 key pair by parsing an unencrypted PKCS#8 v1 or v2 Ed25519 private key.

openssl genpkey -algorithm ED25519 generates PKCS#8 v1 keys.

§Ring Compatibility
  • This method accepts either v1 or v2 encoded keys, if a v2 encoded key is provided, with the public key component present, it will be verified to match the one derived from the encoded private key.
  • The ring 0.16.x API did not produce encoded v2 documents that were compliant with RFC 5958. The aws-lc-ring implementation produces PKCS#8 v2 encoded documents that are compliant per the RFC specification.
§Errors

error::KeyRejected on parse error, or if key is otherwise unacceptable.

pub fn from_pkcs8_maybe_unchecked( pkcs8: &[u8], ) -> Result<Ed25519KeyPair, KeyRejected>

Constructs an Ed25519 key pair by parsing an unencrypted PKCS#8 v1 or v2 Ed25519 private key.

openssl genpkey -algorithm ED25519 generates PKCS# v1 keys.

§Ring Compatibility
  • This method accepts either v1 or v2 encoded keys, if a v2 encoded key is provided, with the public key component present, it will be verified to match the one derived from the encoded private key.
  • The ring 0.16.x API did not produce encoded v2 documents that were compliant with RFC 5958. The aws-lc-ring implementation produces PKCS#8 v2 encoded documents that are compliant per the RFC specification.
§Errors

error::KeyRejected on parse error, or if key is otherwise unacceptable.

pub fn sign(&self, msg: &[u8]) -> Signature

Returns the signature of the message msg.

§Panics

Panics if the message is unable to be signed

pub fn try_sign(&self, msg: &[u8]) -> Result<Signature, Unspecified>

Returns the signature of the message msg.

§Errors

Returns error::Unspecified if the signing operation fails.

pub fn seed(&self) -> Result<Seed<'static>, Unspecified>

Provides the private key “seed” for this Ed25519 key pair.

For serialization of the key pair, Ed25519KeyPair::to_pkcs8() is preferred.

§Errors

Currently the function cannot fail, but it might in future implementations.

Trait Implementations§

§

impl AsDer<Pkcs8V1Der<'static>> for Ed25519KeyPair

§

fn as_der(&self) -> Result<Pkcs8V1Der<'static>, Unspecified>

Serializes this Ed25519KeyPair into a PKCS#8 v1 document.

§Errors

error::Unspecified on internal error.

§

impl AsDer<Pkcs8V2Der<'static>> for Ed25519KeyPair

§

fn as_der(&self) -> Result<Pkcs8V2Der<'static>, Unspecified>

Serializes this Ed25519KeyPair into a PKCS#8 v1 document.

§Errors

error::Unspecified on internal error.

§

impl Debug for Ed25519KeyPair

§

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

Formats the value using the given formatter. Read more
§

impl KeyPair for Ed25519KeyPair

§

type PublicKey = PublicKey

The type of the public key.
§

fn public_key(&self) -> &<Ed25519KeyPair as KeyPair>::PublicKey

The public key for the key pair.
§

impl Send for Ed25519KeyPair

§

impl Sync for Ed25519KeyPair

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> RamaInto<U> for T
where U: RamaFrom<T>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaInto<U> for T
where U: RamaFrom<T>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryInto<U> for T
where U: RamaTryFrom<T>,

§

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

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U> RamaTryInto<U> for T
where U: RamaTryFrom<T>,

§

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

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,