Struct PrivateKey
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§
§impl PrivateKey
impl PrivateKey
pub fn generate(alg: &'static Algorithm) -> Result<PrivateKey, Unspecified>
pub fn generate(alg: &'static Algorithm) -> Result<PrivateKey, Unspecified>
Generate a new private key for the given algorithm.
§Errors
error::Unspecified
when operation fails due to internal error.
pub fn from_private_key_der(
alg: &'static Algorithm,
key_bytes: &[u8],
) -> Result<PrivateKey, KeyRejected>
pub fn from_private_key_der( alg: &'static Algorithm, key_bytes: &[u8], ) -> Result<PrivateKey, 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
pub fn from_private_key(
alg: &'static Algorithm,
key_bytes: &[u8],
) -> Result<PrivateKey, KeyRejected>
pub fn from_private_key( alg: &'static Algorithm, key_bytes: &[u8], ) -> Result<PrivateKey, 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.
pub fn compute_public_key(&self) -> Result<PublicKey, Unspecified>
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.
Trait Implementations§
§impl AsBigEndian<Curve25519SeedBin<'static>> for PrivateKey
impl AsBigEndian<Curve25519SeedBin<'static>> for PrivateKey
§fn as_be_bytes(&self) -> Result<Curve25519SeedBin<'static>, Unspecified>
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.
§impl AsBigEndian<EcPrivateKeyBin<'static>> for PrivateKey
impl AsBigEndian<EcPrivateKeyBin<'static>> for PrivateKey
§fn as_be_bytes(&self) -> Result<EcPrivateKeyBin<'static>, Unspecified>
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.
§impl AsDer<EcPrivateKeyRfc5915Der<'static>> for PrivateKey
impl AsDer<EcPrivateKeyRfc5915Der<'static>> for PrivateKey
§fn as_der(&self) -> Result<EcPrivateKeyRfc5915Der<'static>, Unspecified>
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.
§impl AsDer<Pkcs8V1Der<'static>> for PrivateKey
impl AsDer<Pkcs8V1Der<'static>> for PrivateKey
§fn as_der(&self) -> Result<Pkcs8V1Der<'static>, Unspecified>
fn as_der(&self) -> Result<Pkcs8V1Der<'static>, Unspecified>
Serializes the key as a PKCS #8 private key structure.
X25519 is not supported.
§Errors
error::Unspecified
if serialization failed.
§impl Debug for PrivateKey
impl Debug for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more