Module bn

Source
Expand description

BigNum implementation

Large numbers are important for a cryptographic library. OpenSSL implementation of BigNum uses dynamically assigned memory to store an array of bit chunks. This allows numbers of any size to be compared and mathematical functions performed.

OpenSSL wiki describes the BIGNUM data structure.

§Examples

use openssl::bn::BigNum;
use openssl::error::ErrorStack;

fn main() -> Result<(), ErrorStack> {
  let a = BigNum::new()?; // a = 0
  let b = BigNum::from_dec_str("1234567890123456789012345")?;
  let c = &a * &b;
  assert_eq!(a, c);
  Ok(())
}

Structs§

BigNum
Dynamically sized large number implementation
BigNumContext
Temporary storage for BigNums on the secure heap
BigNumContextRef
Reference to BigNumContext
BigNumRef
Reference to a BigNum
MsbOption
Options for the most significant bits of a randomly generated BigNum.