Module bn

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 boring::bn::BigNum;
use boring::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 impelementation
BigNumContext
Temporary storage for BigNums on the secure heap
BigNumContextRef
A borrowed reference to a BigNumContext.
BigNumRef
A borrowed reference to a BigNum.
MsbOption
Options for the most significant bits of a randomly generated BigNum.