Skip to main content

EcdhP256

Struct EcdhP256 

Source
pub struct EcdhP256;
Expand description

ECDH over P-256.

Implementations§

Source§

impl EcdhP256

Source

pub fn public_key_compressed(private_key: &[u8], out: &mut [u8]) -> Result<()>

Compute the public key in SEC1 compressed form (33 bytes).

Interoperates with TLS, COSE, and JOSE, which all prefer compressed points. KeyAgreement::agree accepts either form.

Trait Implementations§

Source§

impl Algorithm for EcdhP256

Source§

const ID: &'static str = "ecdh-p256"

Stable ontology identifier for this algorithm.
Source§

const NAME: &'static str = "ECDH P-256"

Human-facing display name (for example "SHA-256").
Source§

impl KeyAgreement for EcdhP256

Source§

const PUBLIC_KEY_LEN: usize = 65

SEC1 uncompressed: 0x04 || X || Y.

Source§

const PRIVATE_KEY_LEN: usize = 32

Private key (scalar) length in bytes.
Source§

const SHARED_SECRET_LEN: usize = 32

Shared secret length in bytes.
Source§

fn public_key(private_key: &[u8], out: &mut [u8]) -> Result<()>

Compute the public key for a private key.
Source§

fn agree( private_key: &[u8], peer_public_key: &[u8], out: &mut [u8], ) -> Result<()>

Compute the shared secret from our private key and their public key.
Source§

impl SelfTest for EcdhP256

Source§

fn self_test() -> Result<()>

Run the algorithm’s known-answer test. Read more

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.