Struct aws_lc_rs::agreement::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>,

§

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

§

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.