Struct p256_cortex_m4::SecretKey
source · pub struct SecretKey(/* private fields */);
Expand description
NIST P-256 secret key.
The internal representation is as little-endian (native) words.
Implementations§
source§impl SecretKey
impl SecretKey
sourcepub fn random(rng: impl CryptoRng + RngCore) -> Self
pub fn random(rng: impl CryptoRng + RngCore) -> Self
Generate a random SecretKey
.
The implementation uses rejection sampling.
sourcepub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self>
pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self>
Verifies that there are 32 bytes that correspond to a big-endian integer in the range 1..=n-1.
sourcepub unsafe fn to_bytes(&self) -> [u8; 32]
pub unsafe fn to_bytes(&self) -> [u8; 32]
Convert endianness to obtain the big-endian representation of the secret scalar as 32 bytes.
“unsafe” because the caller is responsible for keeping the value secret.
sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Calculate associated public key.
sourcepub fn sign_prehashed(
&self,
prehashed_message: &[u8],
rng: impl CryptoRng + RngCore
) -> Signature
pub fn sign_prehashed( &self, prehashed_message: &[u8], rng: impl CryptoRng + RngCore ) -> Signature
Non-deterministic signature on message assumed to be hashed, if needed.
Internally, draws 256-bit k
repeatedly, until signing succeeds.
sourcepub fn agree(&self, other: &PublicKey) -> SharedSecret
pub fn agree(&self, other: &PublicKey) -> SharedSecret
ECDH key agreement.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations§
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
Mutably borrows from an owned value. Read more