pub struct EcdhEsKeyWrapper { /* private fields */ }Available on crate features
signatures and key-wrapping only.Expand description
ECDH-ES+A256KW key wrapper (sender side).
Generates an ephemeral P-256 keypair, performs ECDH to derive a shared secret, runs HKDF-SHA256 to derive a 256-bit KEK, then wraps the content encryption key with AES Key Wrap (RFC 3394).
Implementations§
Source§impl EcdhEsKeyWrapper
impl EcdhEsKeyWrapper
Sourcepub fn new(recipient_public_key: PublicKey) -> Self
pub fn new(recipient_public_key: PublicKey) -> Self
Create a key wrapper for the given recipient public key.
The public key should be the recipient’s P-256 (secp256r1) public key.
Sourcepub fn wrap(&self, content_key: &[u8]) -> Result<WrappedKeyData>
pub fn wrap(&self, content_key: &[u8]) -> Result<WrappedKeyData>
Wrap a content encryption key for the recipient.
Performs ECDH-ES+A256KW:
- Generate ephemeral P-256 keypair
- ECDH key agreement with recipient’s public key
- HKDF-SHA256 to derive a 256-bit KEK
- AES Key Wrap (RFC 3394) the content encryption key
§Errors
Returns an error if the content key length is not a multiple of 8 bytes (as required by AES Key Wrap), or if any cryptographic operation fails.
Auto Trait Implementations§
impl Freeze for EcdhEsKeyWrapper
impl RefUnwindSafe for EcdhEsKeyWrapper
impl Send for EcdhEsKeyWrapper
impl Sync for EcdhEsKeyWrapper
impl Unpin for EcdhEsKeyWrapper
impl UnsafeUnpin for EcdhEsKeyWrapper
impl UnwindSafe for EcdhEsKeyWrapper
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