Skip to main content

P384PrivateKey

Struct P384PrivateKey 

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

Represents a P-384 private scalar.

Implementations§

Source§

impl P384PrivateKey

Source

pub fn from_bytes(bytes: [u8; 48]) -> Result<Self>

Parses and validates a private scalar as a big-endian 48-byte value.

§Arguments
  • bytes: 48-byte private scalar encoding.
§Returns

Parsed P384PrivateKey when scalar is in the valid range (0, n).

Source

pub fn to_bytes(&self) -> Result<[u8; 48]>

Serializes the private scalar as canonical 48-byte big-endian octets.

§Arguments
  • self: Private key scalar to encode.
§Returns

48-byte scalar encoding used by SEC1/PKCS#8 wrappers.

§Errors

Returns Error::InvalidLength when internal scalar encoding cannot be represented in 48 bytes.

§Panics

This function does not panic.

Source

pub fn clear(&mut self)

Clears private scalar material by zeroing backing limbs in place.

§Arguments
  • self — Private key whose scalar memory is scrubbed.
§Returns

(); leaves the scalar in a cleared zero state.

§Panics

This function does not panic.

Source

pub fn public_key(&self) -> Result<P384PublicKey>

Computes the corresponding public key by scalar multiplication of the base point.

§Arguments
  • self: Private key used for base-point multiplication.
§Returns

Derived P384PublicKey.

Source

pub fn diffie_hellman(&self, peer: &P384PublicKey) -> Result<[u8; 48]>

Performs checked ECDH with peer public key and returns 48-byte x-coordinate secret.

§Arguments
  • self: Local private key.
  • peer: Peer public key to validate and use.
§Returns

48-byte shared secret from affine x-coordinate.

Source

pub fn sign_sha384(&self, message: &[u8]) -> Result<([u8; 48], [u8; 48])>

Signs a message with P-384 ECDSA using SHA-384 and deterministic nonce derivation.

§Arguments
  • message: Message bytes to hash and sign.
§Returns

Signature tuple (r, s) as 48-byte big-endian scalars.

Source

pub fn sign_sha384_auto( &self, message: &[u8], drbg: &mut HmacDrbgSha256, ) -> Result<([u8; 48], [u8; 48])>

Signs a message with P-384 ECDSA using SHA-384 and DRBG-generated nonce candidates.

§Arguments
  • message: Message bytes to hash and sign.
  • drbg: DRBG used to generate per-signature nonce candidates.
§Returns

Signature tuple (r, s) as 48-byte big-endian scalars.

Source

pub fn sign_digest(&self, digest: &[u8; 48]) -> Result<([u8; 48], [u8; 48])>

Signs a precomputed 48-byte digest with P-384 ECDSA using deterministic nonce derivation.

§Arguments
  • digest: Precomputed SHA-384 digest bytes to sign.
§Returns

Signature tuple (r, s) as 48-byte big-endian scalars.

Source

pub fn sign_digest_auto( &self, digest: &[u8; 48], drbg: &mut HmacDrbgSha256, ) -> Result<([u8; 48], [u8; 48])>

Signs a precomputed 48-byte digest with P-384 ECDSA using DRBG-generated nonce candidates.

§Arguments
  • digest: Precomputed SHA-384 digest bytes to sign.
  • drbg: DRBG used to generate per-signature nonce candidates.
§Returns

Signature tuple (r, s) as 48-byte big-endian scalars.

Trait Implementations§

Source§

impl Clone for P384PrivateKey

Source§

fn clone(&self) -> P384PrivateKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for P384PrivateKey

Source§

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

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

impl Drop for P384PrivateKey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl PartialEq for P384PrivateKey

Source§

fn eq(&self, other: &P384PrivateKey) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for P384PrivateKey

Source§

impl StructuralPartialEq for P384PrivateKey

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.