Skip to main content

oaep_encrypt_with

Function oaep_encrypt_with 

Source
pub fn oaep_encrypt_with<H: Hasher, MGF: Hasher>(
    pk: &RsaPublicKey,
    msg: &[u8],
    label: &[u8],
    rng: &mut dyn FnMut(&mut [u8]),
) -> Vec<u8> 
Expand description

OAEP encrypt a message with RSA, generic over the label hash H and the MGF1 hash MGF (RFC 8017 §7.1.1).

label can be empty (common case). rng fills buffers with random bytes. The seed length equals H::OUTPUT_LEN (the label-hash size), per RFC 8017 §7.1.1 step 2(d).

Panics if the message is longer than k - 2*hLen - 2 bytes, where k is the modulus byte length and hLen = H::OUTPUT_LEN.