Skip to main content

os2ip

Function os2ip 

Source
pub(crate) fn os2ip(input: &[u8], bits_precision: u32) -> Result<BoxedUint>
Expand description

Octet-String-to-Integer Primitive (OS2IP) from RFC8017 §4.2.

Interprets input as a big-endian nonnegative integer with bits_precision bits of storage precision. bits_precision must be a multiple of [Limb::BITS]. This is a caller-established precondition, checked by a debug assertion. Returns an error if input exceeds that storage width, even if the excess bytes are zero.

For RSA operations, use the public modulus’s storage precision. Ciphertext length and representative range checks remain the caller’s responsibility.

Use os2ip_zeroizing when decoding secret values.