Struct botan::MPI [−][src]
A big integer type
Implementations
impl MPI
[src]
pub fn new() -> Result<MPI>
[src]
Crate a new (zero-valued) MPI
pub fn new_from_bytes(val: &[u8]) -> Result<MPI>
[src]
Crate a new MPI setting value from an array of bytes (big-endian)
pub fn new_from_i32(val: i32) -> Result<MPI>
[src]
Crate a new MPI setting value from a i32
pub fn new_from_u32(val: u32) -> Result<MPI>
[src]
Crate a new MPI setting value from a u32
pub fn duplicate(&self) -> Result<MPI>
[src]
Crate a new MPI duplicating the value of self
pub fn set_i32(&mut self, val: i32) -> Result<()>
[src]
Set self to value specified with an i32
pub fn set_str(&mut self, val: &str) -> Result<()>
[src]
Set self to value specified with a string
pub fn set_bytes(&mut self, val: &[u8]) -> Result<()>
[src]
Set self to value specified with an array of bytes (big-endian)
pub fn clear(&self) -> Result<()>
[src]
Set self to zero
pub fn set_bit(&mut self, bit: usize) -> Result<()>
[src]
Set a specific bit of self
pub fn clear_bit(&mut self, bit: usize) -> Result<()>
[src]
Clear a specific bit of self
pub fn get_bit(&self, bit: usize) -> Result<bool>
[src]
Return the value of a bit in self
pub fn randomize(
&mut self,
rng: &RandomNumberGenerator,
bits: usize
) -> Result<()>
[src]
&mut self,
rng: &RandomNumberGenerator,
bits: usize
) -> Result<()>
Randomize self to an integer of specified bit size
pub fn random_range(
&mut self,
rng: &RandomNumberGenerator,
lower: &MPI,
upper: &MPI
) -> Result<()>
[src]
&mut self,
rng: &RandomNumberGenerator,
lower: &MPI,
upper: &MPI
) -> Result<()>
Randomize self to an integer within specified range
pub fn to_string(&self) -> Result<String>
[src]
Return value of self as decimal string
pub fn to_hex(&self) -> Result<String>
[src]
Return value of self as hex string
pub fn to_bin(&self) -> Result<Vec<u8>>
[src]
Return value of self as a byte array (big endian)
pub fn bit_count(&self) -> Result<usize>
[src]
Return number of significant bits
pub fn byte_count(&self) -> Result<usize>
[src]
Return number of significant bytes
pub fn to_u32(&self) -> Result<u32>
[src]
Return self as a u32, if it fits
pub fn is_positive(&self) -> Result<bool>
[src]
Return true if self is an integer >= 0
pub fn is_negative(&self) -> Result<bool>
[src]
Return true if self is an integer < 0
pub fn is_zero(&self) -> Result<bool>
[src]
Return true if self is an integer == 0
pub fn is_odd(&self) -> Result<bool>
[src]
Return true if self is odd
pub fn is_even(&self) -> Result<bool>
[src]
Return true if self is even
pub fn equals(&self, other: &MPI) -> Result<bool>
[src]
Return true if self equals other
pub fn compare(&self, other: &MPI) -> Result<Ordering>
[src]
Compare self with other
pub fn flip_sign(&mut self) -> Result<()>
[src]
Flip the sign of self
pub fn mp_add(&self, other: &MPI) -> Result<MPI>
[src]
Addition operator
pub fn mp_add_assign(&mut self, other: &MPI) -> Result<()>
[src]
Addition operator, assignment version
pub fn mp_add_u32(&self, other: u32) -> Result<MPI>
[src]
Addition operator
pub fn mp_add_u32_assign(&mut self, other: u32) -> Result<()>
[src]
Addition operator, assignment version
pub fn mp_sub(&self, other: &MPI) -> Result<MPI>
[src]
Subtraction operator
pub fn mp_sub_assign(&mut self, other: &MPI) -> Result<()>
[src]
Subtraction operator, assignment version
pub fn mp_sub_u32(&self, other: u32) -> Result<MPI>
[src]
Subtraction operator
pub fn mp_sub_u32_assign(&mut self, other: u32) -> Result<()>
[src]
Subtraction operator, assignment version
pub fn mp_mul(&self, other: &MPI) -> Result<MPI>
[src]
Multiplication operator
pub fn mp_mul_assign(&mut self, other: &MPI) -> Result<()>
[src]
Multiplication operator, assignment version
pub fn mp_shl(&self, shift: usize) -> Result<MPI>
[src]
Bitwise left shift
pub fn mp_shl_assign(&mut self, shift: usize) -> Result<()>
[src]
Bitwise left shift, assignment version
pub fn mp_shr(&self, shift: usize) -> Result<MPI>
[src]
Bitwise right shift
pub fn mp_shr_assign(&mut self, shift: usize) -> Result<()>
[src]
Bitwise right shift, assignment version
pub fn divrem(&self, z: &MPI) -> Result<(MPI, MPI)>
[src]
Division/modulo operator
pub fn swap(&mut self, other: &mut MPI) -> Result<()>
[src]
Swap two MPI values
pub fn is_prime(
&self,
rng: &RandomNumberGenerator,
test_prob: usize
) -> Result<bool>
[src]
&self,
rng: &RandomNumberGenerator,
test_prob: usize
) -> Result<bool>
Perform a primality test on self
Examples
use core::str::FromStr; let n = botan::MPI::from_str("1111111111111111111").unwrap(); let rng = botan::RandomNumberGenerator::new_system().unwrap(); assert!(n.is_prime(&rng, 128).unwrap());
pub fn gcd(x: &MPI, y: &MPI) -> Result<MPI>
[src]
Return the greatest common divisor of x and y
Examples
use core::str::FromStr; let x = botan::MPI::from_str("1111111111111111").unwrap(); let y = botan::MPI::from_str("111111111111").unwrap(); assert_eq!(botan::MPI::gcd(&x, &y).unwrap(), botan::MPI::from_str("1111").unwrap());
pub fn modular_inverse(x: &MPI, m: &MPI) -> Result<MPI>
[src]
Return the inverse of x modulo m, or 0 if gcd(x,m) > 1
pub fn powmod(x: &MPI, e: &MPI, m: &MPI) -> Result<MPI>
[src]
Return (x^e) mod m
Trait Implementations
impl<'a> Add<&'a MPI> for MPI
[src]
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: &MPI) -> MPI
[src]
impl<'a, 'b> Add<&'a MPI> for &'b MPI
[src]
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: &MPI) -> MPI
[src]
impl Add<u32> for MPI
[src]
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: u32) -> MPI
[src]
impl<'a> Add<u32> for &'a MPI
[src]
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: u32) -> MPI
[src]
impl<'a> AddAssign<&'a MPI> for MPI
[src]
fn add_assign(&mut self, other: &MPI)
[src]
impl AddAssign<u32> for MPI
[src]
fn add_assign(&mut self, other: u32)
[src]
impl Clone for MPI
[src]
impl Debug for MPI
[src]
impl Display for MPI
[src]
impl<'a, 'b> Div<&'b MPI> for &'a MPI
[src]
type Output = MPI
The resulting type after applying the /
operator.
fn div(self, other: &MPI) -> MPI
[src]
impl<'a> DivAssign<&'a MPI> for MPI
[src]
fn div_assign(&mut self, other: &'a MPI)
[src]
impl Drop for MPI
[src]
impl Eq for MPI
[src]
impl FromStr for MPI
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<MPI>
[src]
impl LowerHex for MPI
[src]
impl<'a> Mul<&'a MPI> for MPI
[src]
type Output = MPI
The resulting type after applying the *
operator.
fn mul(self, other: &MPI) -> MPI
[src]
impl<'a, 'b> Mul<&'a MPI> for &'b MPI
[src]
type Output = MPI
The resulting type after applying the *
operator.
fn mul(self, other: &MPI) -> MPI
[src]
impl<'a> MulAssign<&'a MPI> for MPI
[src]
fn mul_assign(&mut self, other: &MPI)
[src]
impl Neg for MPI
[src]
impl Ord for MPI
[src]
fn cmp(&self, other: &MPI) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<MPI> for MPI
[src]
impl PartialOrd<MPI> for MPI
[src]
fn partial_cmp(&self, other: &MPI) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, 'b> Rem<&'b MPI> for &'a MPI
[src]
type Output = MPI
The resulting type after applying the %
operator.
fn rem(self, other: &MPI) -> MPI
[src]
impl<'a> RemAssign<&'a MPI> for MPI
[src]
fn rem_assign(&mut self, other: &MPI)
[src]
impl<'a> Shl<usize> for &'a MPI
[src]
type Output = MPI
The resulting type after applying the <<
operator.
fn shl(self, shift: usize) -> MPI
[src]
impl ShlAssign<usize> for MPI
[src]
fn shl_assign(&mut self, shift: usize)
[src]
impl<'a> Shr<usize> for &'a MPI
[src]
type Output = MPI
The resulting type after applying the >>
operator.
fn shr(self, shift: usize) -> MPI
[src]
impl ShrAssign<usize> for MPI
[src]
fn shr_assign(&mut self, shift: usize)
[src]
impl<'a> Sub<&'a MPI> for MPI
[src]
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: &MPI) -> MPI
[src]
impl<'a, 'b> Sub<&'a MPI> for &'b MPI
[src]
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: &MPI) -> MPI
[src]
impl Sub<u32> for MPI
[src]
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: u32) -> MPI
[src]
impl<'a> Sub<u32> for &'a MPI
[src]
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: u32) -> MPI
[src]
impl<'a> SubAssign<&'a MPI> for MPI
[src]
fn sub_assign(&mut self, other: &MPI)
[src]
impl SubAssign<u32> for MPI
[src]
fn sub_assign(&mut self, other: u32)
[src]
impl UpperHex for MPI
[src]
Auto Trait Implementations
impl RefUnwindSafe for MPI
impl !Send for MPI
impl !Sync for MPI
impl Unpin for MPI
impl UnwindSafe for MPI
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,