Struct botan::MPI [−][src]
pub struct MPI { /* fields omitted */ }
A big integer type
Methods
impl MPI
[src]
impl MPI
pub fn new() -> Result<MPI>
[src]
pub fn new() -> Result<MPI>
Crate a new (zero-valued) MPI
pub fn new_from_bytes(val: &[u8]) -> Result<MPI>
[src]
pub fn new_from_bytes(val: &[u8]) -> Result<MPI>
Crate a new MPI setting value from an array of bytes (big-endian)
pub fn new_from_i32(val: i32) -> Result<MPI>
[src]
pub fn new_from_i32(val: i32) -> Result<MPI>
Crate a new MPI setting value from a i32
pub fn new_from_u32(val: u32) -> Result<MPI>
[src]
pub fn new_from_u32(val: u32) -> Result<MPI>
Crate a new MPI setting value from a u32
pub fn duplicate(&self) -> Result<MPI>
[src]
pub fn duplicate(&self) -> Result<MPI>
Crate a new MPI duplicating the value of self
pub fn set_i32(&mut self, val: i32) -> Result<()>
[src]
pub fn set_i32(&mut self, val: i32) -> Result<()>
Set self to value specified with an i32
pub fn set_str(&mut self, val: &str) -> Result<()>
[src]
pub fn set_str(&mut self, val: &str) -> Result<()>
Set self to value specified with a string
pub fn set_bytes(&mut self, val: &[u8]) -> Result<()>
[src]
pub fn set_bytes(&mut self, val: &[u8]) -> Result<()>
Set self to value specified with an array of bytes (big-endian)
pub fn clear(&self) -> Result<()>
[src]
pub fn clear(&self) -> Result<()>
Set self to zero
pub fn set_bit(&mut self, bit: usize) -> Result<()>
[src]
pub fn set_bit(&mut self, bit: usize) -> Result<()>
Set a specific bit of self
pub fn clear_bit(&mut self, bit: usize) -> Result<()>
[src]
pub fn clear_bit(&mut self, bit: usize) -> Result<()>
Clear a specific bit of self
pub fn get_bit(&self, bit: usize) -> Result<bool>
[src]
pub fn get_bit(&self, bit: usize) -> Result<bool>
Return the value of a bit in self
pub fn randomize(
&mut self,
rng: &RandomNumberGenerator,
bits: usize
) -> Result<()>
[src]
pub fn randomize(
&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]
pub fn random_range(
&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]
pub fn to_string(&self) -> Result<String>
Return value of self as decimal string
pub fn to_hex(&self) -> Result<String>
[src]
pub fn to_hex(&self) -> Result<String>
Return value of self as hex string
pub fn to_bin(&self) -> Result<Vec<u8>>
[src]
pub fn to_bin(&self) -> Result<Vec<u8>>
Return value of self as a byte array (big endian)
pub fn bit_count(&self) -> Result<usize>
[src]
pub fn bit_count(&self) -> Result<usize>
Return number of significant bits
pub fn byte_count(&self) -> Result<usize>
[src]
pub fn byte_count(&self) -> Result<usize>
Return number of significant bytes
pub fn to_u32(&self) -> Result<u32>
[src]
pub fn to_u32(&self) -> Result<u32>
Return self as a u32, if it fits
pub fn is_positive(&self) -> Result<bool>
[src]
pub fn is_positive(&self) -> Result<bool>
Return true if self is an integer >= 0
pub fn is_negative(&self) -> Result<bool>
[src]
pub fn is_negative(&self) -> Result<bool>
Return true if self is an integer < 0
pub fn is_zero(&self) -> Result<bool>
[src]
pub fn is_zero(&self) -> Result<bool>
Return true if self is an integer == 0
pub fn is_odd(&self) -> Result<bool>
[src]
pub fn is_odd(&self) -> Result<bool>
Return true if self is odd
pub fn is_even(&self) -> Result<bool>
[src]
pub fn is_even(&self) -> Result<bool>
Return true if self is even
pub fn equals(&self, other: &MPI) -> Result<bool>
[src]
pub fn equals(&self, other: &MPI) -> Result<bool>
Return true if self equals other
pub fn compare(&self, other: &MPI) -> Result<Ordering>
[src]
pub fn compare(&self, other: &MPI) -> Result<Ordering>
Compare self with other
pub fn flip_sign(&mut self) -> Result<()>
[src]
pub fn flip_sign(&mut self) -> Result<()>
Flip the sign of self
pub fn mp_add(&self, other: &MPI) -> Result<MPI>
[src]
pub fn mp_add(&self, other: &MPI) -> Result<MPI>
Addition operator
pub fn mp_add_assign(&mut self, other: &MPI) -> Result<()>
[src]
pub fn mp_add_assign(&mut self, other: &MPI) -> Result<()>
Addition operator, assignment version
pub fn mp_add_u32(&self, other: u32) -> Result<MPI>
[src]
pub fn mp_add_u32(&self, other: u32) -> Result<MPI>
Addition operator
pub fn mp_add_u32_assign(&mut self, other: u32) -> Result<()>
[src]
pub fn mp_add_u32_assign(&mut self, other: u32) -> Result<()>
Addition operator, assignment version
pub fn mp_sub(&self, other: &MPI) -> Result<MPI>
[src]
pub fn mp_sub(&self, other: &MPI) -> Result<MPI>
Subtraction operator
pub fn mp_sub_assign(&mut self, other: &MPI) -> Result<()>
[src]
pub fn mp_sub_assign(&mut self, other: &MPI) -> Result<()>
Subtraction operator, assignment version
pub fn mp_sub_u32(&self, other: u32) -> Result<MPI>
[src]
pub fn mp_sub_u32(&self, other: u32) -> Result<MPI>
Subtraction operator
pub fn mp_sub_u32_assign(&mut self, other: u32) -> Result<()>
[src]
pub fn mp_sub_u32_assign(&mut self, other: u32) -> Result<()>
Subtraction operator, assignment version
pub fn mp_mul(&self, other: &MPI) -> Result<MPI>
[src]
pub fn mp_mul(&self, other: &MPI) -> Result<MPI>
Multiplication operator
pub fn mp_mul_assign(&mut self, other: &MPI) -> Result<()>
[src]
pub fn mp_mul_assign(&mut self, other: &MPI) -> Result<()>
Multiplication operator, assignment version
pub fn mp_shl(&self, shift: usize) -> Result<MPI>
[src]
pub fn mp_shl(&self, shift: usize) -> Result<MPI>
Bitwise left shift
pub fn mp_shl_assign(&mut self, shift: usize) -> Result<()>
[src]
pub fn mp_shl_assign(&mut self, shift: usize) -> Result<()>
Bitwise left shift, assignment version
pub fn mp_shr(&self, shift: usize) -> Result<MPI>
[src]
pub fn mp_shr(&self, shift: usize) -> Result<MPI>
Bitwise right shift
pub fn mp_shr_assign(&mut self, shift: usize) -> Result<()>
[src]
pub fn mp_shr_assign(&mut self, shift: usize) -> Result<()>
Bitwise right shift, assignment version
pub fn divrem(&self, z: &MPI) -> Result<(MPI, MPI)>
[src]
pub fn divrem(&self, z: &MPI) -> Result<(MPI, MPI)>
Division/modulo operator
pub fn swap(&mut self, other: &mut MPI) -> Result<()>
[src]
pub fn swap(&mut self, other: &mut MPI) -> Result<()>
Swap two MPI values
pub fn is_prime(
&self,
rng: &RandomNumberGenerator,
test_prob: usize
) -> Result<bool>
[src]
pub fn is_prime(
&self,
rng: &RandomNumberGenerator,
test_prob: usize
) -> Result<bool>
Perform a primality test on self
Examples
use std::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]
pub fn gcd(x: &MPI, y: &MPI) -> Result<MPI>
Return the greatest common divisor of x and y
Examples
use std::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]
pub fn modular_inverse(x: &MPI, m: &MPI) -> Result<MPI>
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]
pub fn powmod(x: &MPI, e: &MPI, m: &MPI) -> Result<MPI>
Return (x^e) mod m
Trait Implementations
impl Drop for MPI
[src]
impl Drop for MPI
impl Clone for MPI
[src]
impl Clone for MPI
fn clone(&self) -> MPI
[src]
fn clone(&self) -> MPI
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialOrd for MPI
[src]
impl PartialOrd for MPI
fn partial_cmp(&self, other: &MPI) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &MPI) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq for MPI
[src]
impl PartialEq for MPI
fn eq(&self, other: &MPI) -> bool
[src]
fn eq(&self, other: &MPI) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl Eq for MPI
[src]
impl Eq for MPI
impl Ord for MPI
[src]
impl Ord for MPI
fn cmp(&self, other: &MPI) -> Ordering
[src]
fn cmp(&self, other: &MPI) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl FromStr for MPI
[src]
impl FromStr for MPI
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<MPI>
[src]
fn from_str(s: &str) -> Result<MPI>
Parses a string s
to return a value of this type. Read more
impl Debug for MPI
[src]
impl Debug for MPI
fn fmt(&self, formatter: &mut Formatter) -> Result
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Display for MPI
[src]
impl Display for MPI
fn fmt(&self, formatter: &mut Formatter) -> Result
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl UpperHex for MPI
[src]
impl UpperHex for MPI
impl LowerHex for MPI
[src]
impl LowerHex for MPI
impl<'a> Add<&'a MPI> for MPI
[src]
impl<'a> Add<&'a MPI> for MPI
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: &MPI) -> MPI
[src]
fn add(self, other: &MPI) -> MPI
Performs the +
operation.
impl<'a, 'b> Add<&'a MPI> for &'b MPI
[src]
impl<'a, 'b> Add<&'a MPI> for &'b MPI
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: &MPI) -> MPI
[src]
fn add(self, other: &MPI) -> MPI
Performs the +
operation.
impl Add<u32> for MPI
[src]
impl Add<u32> for MPI
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: u32) -> MPI
[src]
fn add(self, other: u32) -> MPI
Performs the +
operation.
impl<'a> Add<u32> for &'a MPI
[src]
impl<'a> Add<u32> for &'a MPI
type Output = MPI
The resulting type after applying the +
operator.
fn add(self, other: u32) -> MPI
[src]
fn add(self, other: u32) -> MPI
Performs the +
operation.
impl<'a> AddAssign<&'a MPI> for MPI
[src]
impl<'a> AddAssign<&'a MPI> for MPI
fn add_assign(&mut self, other: &MPI)
[src]
fn add_assign(&mut self, other: &MPI)
Performs the +=
operation.
impl AddAssign<u32> for MPI
[src]
impl AddAssign<u32> for MPI
fn add_assign(&mut self, other: u32)
[src]
fn add_assign(&mut self, other: u32)
Performs the +=
operation.
impl<'a> Sub<&'a MPI> for MPI
[src]
impl<'a> Sub<&'a MPI> for MPI
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: &MPI) -> MPI
[src]
fn sub(self, other: &MPI) -> MPI
Performs the -
operation.
impl<'a, 'b> Sub<&'a MPI> for &'b MPI
[src]
impl<'a, 'b> Sub<&'a MPI> for &'b MPI
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: &MPI) -> MPI
[src]
fn sub(self, other: &MPI) -> MPI
Performs the -
operation.
impl Sub<u32> for MPI
[src]
impl Sub<u32> for MPI
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: u32) -> MPI
[src]
fn sub(self, other: u32) -> MPI
Performs the -
operation.
impl<'a> Sub<u32> for &'a MPI
[src]
impl<'a> Sub<u32> for &'a MPI
type Output = MPI
The resulting type after applying the -
operator.
fn sub(self, other: u32) -> MPI
[src]
fn sub(self, other: u32) -> MPI
Performs the -
operation.
impl<'a> SubAssign<&'a MPI> for MPI
[src]
impl<'a> SubAssign<&'a MPI> for MPI
fn sub_assign(&mut self, other: &MPI)
[src]
fn sub_assign(&mut self, other: &MPI)
Performs the -=
operation.
impl SubAssign<u32> for MPI
[src]
impl SubAssign<u32> for MPI
fn sub_assign(&mut self, other: u32)
[src]
fn sub_assign(&mut self, other: u32)
Performs the -=
operation.
impl<'a> Mul<&'a MPI> for MPI
[src]
impl<'a> Mul<&'a MPI> for MPI
type Output = MPI
The resulting type after applying the *
operator.
fn mul(self, other: &MPI) -> MPI
[src]
fn mul(self, other: &MPI) -> MPI
Performs the *
operation.
impl<'a, 'b> Mul<&'a MPI> for &'b MPI
[src]
impl<'a, 'b> Mul<&'a MPI> for &'b MPI
type Output = MPI
The resulting type after applying the *
operator.
fn mul(self, other: &MPI) -> MPI
[src]
fn mul(self, other: &MPI) -> MPI
Performs the *
operation.
impl<'a> MulAssign<&'a MPI> for MPI
[src]
impl<'a> MulAssign<&'a MPI> for MPI
fn mul_assign(&mut self, other: &MPI)
[src]
fn mul_assign(&mut self, other: &MPI)
Performs the *=
operation.
impl<'a, 'b> Div<&'b MPI> for &'a MPI
[src]
impl<'a, 'b> Div<&'b MPI> for &'a MPI
type Output = MPI
The resulting type after applying the /
operator.
fn div(self, other: &MPI) -> MPI
[src]
fn div(self, other: &MPI) -> MPI
Performs the /
operation.
impl<'a> DivAssign<&'a MPI> for MPI
[src]
impl<'a> DivAssign<&'a MPI> for MPI
fn div_assign(&mut self, other: &'a MPI)
[src]
fn div_assign(&mut self, other: &'a MPI)
Performs the /=
operation.
impl<'a, 'b> Rem<&'b MPI> for &'a MPI
[src]
impl<'a, 'b> Rem<&'b MPI> for &'a MPI
type Output = MPI
The resulting type after applying the %
operator.
fn rem(self, other: &MPI) -> MPI
[src]
fn rem(self, other: &MPI) -> MPI
Performs the %
operation.
impl<'a> RemAssign<&'a MPI> for MPI
[src]
impl<'a> RemAssign<&'a MPI> for MPI
fn rem_assign(&mut self, other: &MPI)
[src]
fn rem_assign(&mut self, other: &MPI)
Performs the %=
operation.
impl<'a> Shl<usize> for &'a MPI
[src]
impl<'a> Shl<usize> for &'a MPI
type Output = MPI
The resulting type after applying the <<
operator.
fn shl(self, shift: usize) -> MPI
[src]
fn shl(self, shift: usize) -> MPI
Performs the <<
operation.
impl ShlAssign<usize> for MPI
[src]
impl ShlAssign<usize> for MPI
fn shl_assign(&mut self, shift: usize)
[src]
fn shl_assign(&mut self, shift: usize)
Performs the <<=
operation.
impl<'a> Shr<usize> for &'a MPI
[src]
impl<'a> Shr<usize> for &'a MPI
type Output = MPI
The resulting type after applying the >>
operator.
fn shr(self, shift: usize) -> MPI
[src]
fn shr(self, shift: usize) -> MPI
Performs the >>
operation.
impl ShrAssign<usize> for MPI
[src]
impl ShrAssign<usize> for MPI
fn shr_assign(&mut self, shift: usize)
[src]
fn shr_assign(&mut self, shift: usize)
Performs the >>=
operation.
impl Neg for MPI
[src]
impl Neg for MPI