Struct ring::signature::EcdsaKeyPair

source ·
pub struct EcdsaKeyPair { /* private fields */ }
Expand description

An ECDSA key pair, used for signing.

Implementations§

source§

impl EcdsaKeyPair

source

pub fn generate_pkcs8( alg: &'static EcdsaSigningAlgorithm, 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 v1 OneAsymmetricKey with the public key included in the ECPrivateKey structure, as described in RFC 5958 Section 2 and RFC 5915. The ECPrivateKey structure will not have a parameters field so the generated key is compatible with PKCS#11.

source

pub fn from_pkcs8( alg: &'static EcdsaSigningAlgorithm, pkcs8: &[u8], ) -> Result<Self, KeyRejected>

Constructs an ECDSA key pair by parsing an unencrypted PKCS#8 v1 id-ecPublicKey ECPrivateKey key.

The input must be in PKCS#8 v1 format. It must contain the public key in the ECPrivateKey structure; from_pkcs8() will verify that the public key and the private key are consistent with each other. The algorithm identifier must identify the curve by name; it must not use an “explicit” encoding of the curve. The parameters field of the ECPrivateKey, if present, must be the same named curve that is in the algorithm identifier in the PKCS#8 header.

source

pub fn from_private_key_and_public_key( alg: &'static EcdsaSigningAlgorithm, private_key: &[u8], public_key: &[u8], ) -> Result<Self, KeyRejected>

Constructs an ECDSA key pair from the private key and public key bytes

The private key must encoded as a big-endian fixed-length integer. For example, a P-256 private key must be 32 bytes prefixed with leading zeros as needed.

The public key is encoding in uncompressed form using the Octet-String-to-Elliptic-Curve-Point algorithm in SEC 1: Elliptic Curve Cryptography, Version 2.0.

This is intended for use by code that deserializes key pairs. It is recommended to use EcdsaKeyPair::from_pkcs8() (with a PKCS#8-encoded key) instead.

source

pub fn sign( &self, rng: &dyn SecureRandom, message: &[u8], ) -> Result<Signature, Unspecified>

Deprecated. Returns the signature of the message using a random nonce generated by rng.

Trait Implementations§

source§

impl Debug for EcdsaKeyPair

source§

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

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

impl KeyPair for EcdsaKeyPair

source§

type PublicKey = PublicKey

The type of the public key.
source§

fn public_key(&self) -> &Self::PublicKey

The public key for the key pair.

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, 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, 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.