aws_lc_rs::agreement

Struct PrivateKey

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

A private key for use (only) with agree. The signature of agree allows PrivateKey to be used for more than one key agreement.

Implementations§

Source§

impl PrivateKey

Source

pub fn generate(alg: &'static Algorithm) -> Result<Self, Unspecified>

Generate a new private key for the given algorithm.

§Errors

error::Unspecified when operation fails due to internal error.

Source

pub fn from_private_key_der( alg: &'static Algorithm, key_bytes: &[u8], ) -> Result<Self, KeyRejected>

Deserializes a DER-encoded private key structure to produce a agreement::PrivateKey.

This function is typically used to deserialize RFC 5915 encoded private keys, but it will attempt to automatically detect other key formats. This function supports unencrypted PKCS#8 PrivateKeyInfo structures as well as key type specific formats.

X25519 keys are not supported. See PrivateKey::as_der.

§Errors

error::KeyRejected if parsing failed or key otherwise unacceptable.

§Panics
Source

pub fn from_private_key( alg: &'static Algorithm, key_bytes: &[u8], ) -> Result<Self, KeyRejected>

Constructs an ECDH key from private 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.

§Errors

error::KeyRejected if parsing failed or key otherwise unacceptable.

Source

pub fn compute_public_key(&self) -> Result<PublicKey, Unspecified>

Computes the public key from the private key.

§Errors

error::Unspecified when operation fails due to internal error.

Source

pub fn algorithm(&self) -> &'static Algorithm

The algorithm for the private key.

Trait Implementations§

Source§

impl AsBigEndian<Curve25519SeedBin<'static>> for PrivateKey

Source§

fn as_be_bytes(&self) -> Result<Curve25519SeedBin<'static>, Unspecified>

Exposes the seed encoded as a big-endian fixed-length integer.

Only X25519 is supported.

§Errors

error::Unspecified if serialization failed.

Source§

impl AsBigEndian<EcPrivateKeyBin<'static>> for PrivateKey

Source§

fn as_be_bytes(&self) -> Result<EcPrivateKeyBin<'static>, Unspecified>

Exposes the private key encoded as a big-endian fixed-length integer.

X25519 is not supported.

§Errors

error::Unspecified if serialization failed.

Source§

impl AsDer<EcPrivateKeyRfc5915Der<'static>> for PrivateKey

Source§

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

Serializes the key as a DER-encoded ECPrivateKey (RFC 5915) structure.

X25519 is not supported.

§Errors

error::Unspecified if serialization failed.

Source§

impl Debug for PrivateKey

Source§

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

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

impl Send for PrivateKey

Source§

impl Sync for PrivateKey

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.