ltc_math_descriptor

Struct ltc_math_descriptor 

Source
#[repr(C)]
pub struct ltc_math_descriptor {
Show 52 fields pub name: *const c_char, pub bits_per_digit: c_int, pub init: Option<unsafe extern "C" fn(a: *mut *mut c_void) -> c_int>, pub init_copy: Option<unsafe extern "C" fn(dst: *mut *mut c_void, src: *mut c_void) -> c_int>, pub deinit: Option<unsafe extern "C" fn(a: *mut c_void)>, pub neg: Option<unsafe extern "C" fn(src: *mut c_void, dst: *mut c_void) -> c_int>, pub copy: Option<unsafe extern "C" fn(src: *mut c_void, dst: *mut c_void) -> c_int>, pub set_int: Option<unsafe extern "C" fn(a: *mut c_void, n: ltc_mp_digit) -> c_int>, pub get_int: Option<unsafe extern "C" fn(a: *mut c_void) -> c_ulong>, pub get_digit: Option<unsafe extern "C" fn(a: *mut c_void, n: c_int) -> ltc_mp_digit>, pub get_digit_count: Option<unsafe extern "C" fn(a: *mut c_void) -> c_int>, pub compare: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>, pub compare_d: Option<unsafe extern "C" fn(a: *mut c_void, n: ltc_mp_digit) -> c_int>, pub count_bits: Option<unsafe extern "C" fn(a: *mut c_void) -> c_int>, pub count_lsb_bits: Option<unsafe extern "C" fn(a: *mut c_void) -> c_int>, pub twoexpt: Option<unsafe extern "C" fn(a: *mut c_void, n: c_int) -> c_int>, pub read_radix: Option<unsafe extern "C" fn(a: *mut c_void, str: *const c_char, radix: c_int) -> c_int>, pub write_radix: Option<unsafe extern "C" fn(a: *mut c_void, str: *mut c_char, radix: c_int) -> c_int>, pub unsigned_size: Option<unsafe extern "C" fn(a: *mut c_void) -> c_ulong>, pub unsigned_write: Option<unsafe extern "C" fn(src: *mut c_void, dst: *mut c_uchar) -> c_int>, pub unsigned_read: Option<unsafe extern "C" fn(dst: *mut c_void, src: *mut c_uchar, len: c_ulong) -> c_int>, pub add: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub addi: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut c_void) -> c_int>, pub sub: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub subi: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut c_void) -> c_int>, pub mul: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub muli: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut c_void) -> c_int>, pub sqr: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>, pub mpdiv: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>, pub div_2: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>, pub modi: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut ltc_mp_digit) -> c_int>, pub gcd: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub lcm: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub mulmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>, pub sqrmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub invmod: Option<unsafe extern "C" fn(arg1: *mut c_void, arg2: *mut c_void, arg3: *mut c_void) -> c_int>, pub montgomery_setup: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut *mut c_void) -> c_int>, pub montgomery_normalization: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>, pub montgomery_reduce: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>, pub montgomery_deinit: Option<unsafe extern "C" fn(a: *mut c_void)>, pub exptmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>, pub isprime: Option<unsafe extern "C" fn(a: *mut c_void, b: c_int, c: *mut c_int) -> c_int>, pub ecc_ptmul: Option<unsafe extern "C" fn(k: *mut c_void, G: *mut ecc_point, R: *mut ecc_point, modulus: *mut c_void, map: c_int) -> c_int>, pub ecc_ptadd: Option<unsafe extern "C" fn(P: *mut ecc_point, Q: *mut ecc_point, R: *mut ecc_point, modulus: *mut c_void, mp: *mut c_void) -> c_int>, pub ecc_ptdbl: Option<unsafe extern "C" fn(P: *mut ecc_point, R: *mut ecc_point, modulus: *mut c_void, mp: *mut c_void) -> c_int>, pub ecc_map: Option<unsafe extern "C" fn(P: *mut ecc_point, modulus: *mut c_void, mp: *mut c_void) -> c_int>, pub ecc_mul2add: Option<unsafe extern "C" fn(A: *mut ecc_point, kA: *mut c_void, B: *mut ecc_point, kB: *mut c_void, C: *mut ecc_point, modulus: *mut c_void) -> c_int>, pub rsa_keygen: Option<unsafe extern "C" fn(prng: *mut prng_state, wprng: c_int, size: c_int, e: c_long, key: *mut rsa_key) -> c_int>, pub rsa_me: Option<unsafe extern "C" fn(in_: *const c_uchar, inlen: c_ulong, out: *mut c_uchar, outlen: *mut c_ulong, which: c_int, key: *mut rsa_key) -> c_int>, pub addmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>, pub submod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>, pub rand: Option<unsafe extern "C" fn(a: *mut c_void, size: c_int) -> c_int>,
}
Expand description

math descriptor

Fields§

§name: *const c_char

Name of the math provider

§bits_per_digit: c_int

Bits per digit, amount of bits must fit in an unsigned long

§init: Option<unsafe extern "C" fn(a: *mut *mut c_void) -> c_int>

initialize a bignum @param a The number to initialize @return CRYPT_OK on success

§init_copy: Option<unsafe extern "C" fn(dst: *mut *mut c_void, src: *mut c_void) -> c_int>

init copy @param dst The number to initialize and write to @param src The number to copy from @return CRYPT_OK on success

§deinit: Option<unsafe extern "C" fn(a: *mut c_void)>

deinit @param a The number to free @return CRYPT_OK on success

§neg: Option<unsafe extern "C" fn(src: *mut c_void, dst: *mut c_void) -> c_int>

negate @param src The number to negate @param dst The destination @return CRYPT_OK on success

§copy: Option<unsafe extern "C" fn(src: *mut c_void, dst: *mut c_void) -> c_int>

copy @param src The number to copy from @param dst The number to write to @return CRYPT_OK on success

§set_int: Option<unsafe extern "C" fn(a: *mut c_void, n: ltc_mp_digit) -> c_int>

set small constant @param a Number to write to @param n Source upto bits_per_digit (actually meant for very small constants) @return CRYPT_OK on success

§get_int: Option<unsafe extern "C" fn(a: *mut c_void) -> c_ulong>

get small constant @param a Small number to read, only fetches up to bits_per_digit from the number @return The lower bits_per_digit of the integer (unsigned)

§get_digit: Option<unsafe extern "C" fn(a: *mut c_void, n: c_int) -> ltc_mp_digit>

get digit n @param a The number to read from @param n The number of the digit to fetch @return The bits_per_digit sized n’th digit of a

§get_digit_count: Option<unsafe extern "C" fn(a: *mut c_void) -> c_int>

Get the number of digits that represent the number @param a The number to count @return The number of digits used to represent the number

§compare: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>

compare two integers @param a The left side integer @param b The right side integer @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison)

§compare_d: Option<unsafe extern "C" fn(a: *mut c_void, n: ltc_mp_digit) -> c_int>

compare against int @param a The left side integer @param b The right side integer (upto bits_per_digit) @return LTC_MP_LT if a < b, LTC_MP_GT if a > b and LTC_MP_EQ otherwise. (signed comparison)

§count_bits: Option<unsafe extern "C" fn(a: *mut c_void) -> c_int>

Count the number of bits used to represent the integer @param a The integer to count @return The number of bits required to represent the integer

§count_lsb_bits: Option<unsafe extern "C" fn(a: *mut c_void) -> c_int>

Count the number of LSB bits which are zero @param a The integer to count @return The number of contiguous zero LSB bits

§twoexpt: Option<unsafe extern "C" fn(a: *mut c_void, n: c_int) -> c_int>

Compute a power of two @param a The integer to store the power in @param n The power of two you want to store (a = 2^n) @return CRYPT_OK on success

§read_radix: Option<unsafe extern "C" fn(a: *mut c_void, str: *const c_char, radix: c_int) -> c_int>

read ascii string @param a The integer to store into @param str The string to read @param radix The radix the integer has been represented in (2-64) @return CRYPT_OK on success

§write_radix: Option<unsafe extern "C" fn(a: *mut c_void, str: *mut c_char, radix: c_int) -> c_int>

write number to string @param a The integer to store @param str The destination for the string @param radix The radix the integer is to be represented in (2-64) @return CRYPT_OK on success

§unsigned_size: Option<unsafe extern "C" fn(a: *mut c_void) -> c_ulong>

get size as unsigned char string @param a The integer to get the size (when stored in array of octets) @return The length of the integer in octets

§unsigned_write: Option<unsafe extern "C" fn(src: *mut c_void, dst: *mut c_uchar) -> c_int>

store an integer as an array of octets @param src The integer to store @param dst The buffer to store the integer in @return CRYPT_OK on success

§unsigned_read: Option<unsafe extern "C" fn(dst: *mut c_void, src: *mut c_uchar, len: c_ulong) -> c_int>

read an array of octets and store as integer @param dst The integer to load @param src The array of octets @param len The number of octets @return CRYPT_OK on success

§add: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

add two integers @param a The first source integer @param b The second source integer @param c The destination of “a + b” @return CRYPT_OK on success

§addi: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut c_void) -> c_int>

add two integers @param a The first source integer @param b The second source integer (single digit of upto bits_per_digit in length) @param c The destination of “a + b” @return CRYPT_OK on success

§sub: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

subtract two integers @param a The first source integer @param b The second source integer @param c The destination of “a - b” @return CRYPT_OK on success

§subi: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut c_void) -> c_int>

subtract two integers @param a The first source integer @param b The second source integer (single digit of upto bits_per_digit in length) @param c The destination of “a - b” @return CRYPT_OK on success

§mul: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

multiply two integers @param a The first source integer @param b The second source integer (single digit of upto bits_per_digit in length) @param c The destination of “a * b” @return CRYPT_OK on success

§muli: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut c_void) -> c_int>

multiply two integers @param a The first source integer @param b The second source integer (single digit of upto bits_per_digit in length) @param c The destination of “a * b” @return CRYPT_OK on success

§sqr: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>

Square an integer @param a The integer to square @param b The destination @return CRYPT_OK on success

§mpdiv: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>

Divide an integer @param a The dividend @param b The divisor @param c The quotient (can be NULL to signify don’t care) @param d The remainder (can be NULL to signify don’t care) @return CRYPT_OK on success

§div_2: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>

divide by two @param a The integer to divide (shift right) @param b The destination @return CRYPT_OK on success

§modi: Option<unsafe extern "C" fn(a: *mut c_void, b: ltc_mp_digit, c: *mut ltc_mp_digit) -> c_int>

Get remainder (small value) @param a The integer to reduce @param b The modulus (upto bits_per_digit in length) @param c The destination for the residue @return CRYPT_OK on success

§gcd: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

gcd @param a The first integer @param b The second integer @param c The destination for (a, b) @return CRYPT_OK on success

§lcm: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

lcm @param a The first integer @param b The second integer @param c The destination for [a, b] @return CRYPT_OK on success

§mulmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>

Modular multiplication @param a The first source @param b The second source @param c The modulus @param d The destination (a*b mod c) @return CRYPT_OK on success

§sqrmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

Modular squaring @param a The first source @param b The modulus @param c The destination (a*a mod b) @return CRYPT_OK on success

§invmod: Option<unsafe extern "C" fn(arg1: *mut c_void, arg2: *mut c_void, arg3: *mut c_void) -> c_int>

Modular inversion @param a The value to invert @param b The modulus @param c The destination (1/a mod b) @return CRYPT_OK on success

§montgomery_setup: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut *mut c_void) -> c_int>

setup Montgomery @param a The modulus @param b The destination for the reduction digit @return CRYPT_OK on success

§montgomery_normalization: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void) -> c_int>

get normalization value @param a The destination for the normalization value @param b The modulus @return CRYPT_OK on success

§montgomery_reduce: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void) -> c_int>

reduce a number @param a The number [and dest] to reduce @param b The modulus @param c The value “b” from montgomery_setup() @return CRYPT_OK on success

§montgomery_deinit: Option<unsafe extern "C" fn(a: *mut c_void)>

clean up (frees memory) @param a The value “b” from montgomery_setup() @return CRYPT_OK on success

§exptmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>

Modular exponentiation @param a The base integer @param b The power (can be negative) integer @param c The modulus integer @param d The destination @return CRYPT_OK on success

§isprime: Option<unsafe extern "C" fn(a: *mut c_void, b: c_int, c: *mut c_int) -> c_int>

Primality testing @param a The integer to test @param b The number of Miller-Rabin tests that shall be executed @param c The destination of the result (FP_YES if prime) @return CRYPT_OK on success

§ecc_ptmul: Option<unsafe extern "C" fn(k: *mut c_void, G: *mut ecc_point, R: *mut ecc_point, modulus: *mut c_void, map: c_int) -> c_int>

ECC GF(p) point multiplication (from the NIST curves) @param k The integer to multiply the point by @param G The point to multiply @param R The destination for kG @param modulus The modulus for the field @param map Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only) @return CRYPT_OK on success

§ecc_ptadd: Option<unsafe extern "C" fn(P: *mut ecc_point, Q: *mut ecc_point, R: *mut ecc_point, modulus: *mut c_void, mp: *mut c_void) -> c_int>

ECC GF(p) point addition @param P The first point @param Q The second point @param R The destination of P + Q @param modulus The modulus @param mp The “b” value from montgomery_setup() @return CRYPT_OK on success

§ecc_ptdbl: Option<unsafe extern "C" fn(P: *mut ecc_point, R: *mut ecc_point, modulus: *mut c_void, mp: *mut c_void) -> c_int>

ECC GF(p) point double @param P The first point @param R The destination of 2P @param modulus The modulus @param mp The “b” value from montgomery_setup() @return CRYPT_OK on success

§ecc_map: Option<unsafe extern "C" fn(P: *mut ecc_point, modulus: *mut c_void, mp: *mut c_void) -> c_int>

ECC mapping from projective to affine, currently uses (x,y,z) => (x/z^2, y/z^3, 1) @param P The point to map @param modulus The modulus @param mp The “b” value from montgomery_setup() @return CRYPT_OK on success @remark The mapping can be different but keep in mind a ecc_point only has three integers (x,y,z) so if you use a different mapping you have to make it fit.

§ecc_mul2add: Option<unsafe extern "C" fn(A: *mut ecc_point, kA: *mut c_void, B: *mut ecc_point, kB: *mut c_void, C: *mut ecc_point, modulus: *mut c_void) -> c_int>

Computes kAA + kBB = C using Shamir’s Trick @param A First point to multiply @param kA What to multiple A by @param B Second point to multiply @param kB What to multiple B by @param C [out] Destination point (can overlap with A or B) @param modulus Modulus for curve @return CRYPT_OK on success

§rsa_keygen: Option<unsafe extern "C" fn(prng: *mut prng_state, wprng: c_int, size: c_int, e: c_long, key: *mut rsa_key) -> c_int>

RSA Key Generation @param prng An active PRNG state @param wprng The index of the PRNG desired @param size The size of the key in octets @param e The “e” value (public key). e==65537 is a good choice @param key [out] Destination of a newly created private key pair @return CRYPT_OK if successful, upon error all allocated ram is freed

§rsa_me: Option<unsafe extern "C" fn(in_: *const c_uchar, inlen: c_ulong, out: *mut c_uchar, outlen: *mut c_ulong, which: c_int, key: *mut rsa_key) -> c_int>

RSA exponentiation @param in The octet array representing the base @param inlen The length of the input @param out The destination (to be stored in an octet array format) @param outlen The length of the output buffer and the resulting size (zero padded to the size of the modulus) @param which PK_PUBLIC for public RSA and PK_PRIVATE for private RSA @param key The RSA key to use @return CRYPT_OK on success

§addmod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>

Modular addition @param a The first source @param b The second source @param c The modulus @param d The destination (a + b mod c) @return CRYPT_OK on success

§submod: Option<unsafe extern "C" fn(a: *mut c_void, b: *mut c_void, c: *mut c_void, d: *mut c_void) -> c_int>

Modular substraction @param a The first source @param b The second source @param c The modulus @param d The destination (a - b mod c) @return CRYPT_OK on success

§rand: Option<unsafe extern "C" fn(a: *mut c_void, size: c_int) -> c_int>

Make a pseudo-random mpi @param a The mpi to make random @param size The desired length @return CRYPT_OK on success

Trait Implementations§

Source§

impl Clone for ltc_math_descriptor

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ltc_math_descriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for ltc_math_descriptor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.