Skip to main content

i2osp_zeroizing

Function i2osp_zeroizing 

Source
pub(crate) fn i2osp_zeroizing(
    input: BoxedUint,
    padded_len: usize,
) -> Zeroizing<Vec<u8>>
Expand description

Computes i2osp (Integer-to-Octet-String Primitive) with zeroization of the input and output buffers.

The input integer, temporary byte buffer, and returned vector are each zeroized on drop. The same input-width precondition as i2osp applies.

For RSA decryption, this computes EM = I2OSP(m, k), where padded_len is k, the public modulus length in octets.

draft-irtf-cfrg-rsa-guidance-10 §7.2 requires this conversion to be constant-time with respect to m. Serialization and copying in this function depend only on padded_len and the input’s storage precision. To satisfy that requirement, callers must ensure that both widths are independent of m’s value.