![]() |
TrinityCore
|
#include <tomcrypt_math.h>
Public Attributes | |
char * | name |
int | bits_per_digit |
int(* | init )(void **a) |
int(* | init_copy )(void **dst, void *src) |
void(* | deinit )(void *a) |
int(* | neg )(void *src, void *dst) |
int(* | copy )(void *src, void *dst) |
int(* | set_int )(void *a, unsigned long n) |
unsigned long(* | get_int )(void *a) |
unsigned long(* | get_digit )(void *a, int n) |
int(* | get_digit_count )(void *a) |
int(* | compare )(void *a, void *b) |
int(* | compare_d )(void *a, unsigned long n) |
int(* | count_bits )(void *a) |
int(* | count_lsb_bits )(void *a) |
int(* | twoexpt )(void *a, int n) |
int(* | read_radix )(void *a, const char *str, int radix) |
int(* | write_radix )(void *a, char *str, int radix) |
unsigned long(* | unsigned_size )(void *a) |
int(* | unsigned_write )(void *src, unsigned char *dst) |
int(* | unsigned_read )(void *dst, unsigned char *src, unsigned long len) |
int(* | add )(void *a, void *b, void *c) |
int(* | addi )(void *a, unsigned long b, void *c) |
int(* | sub )(void *a, void *b, void *c) |
int(* | subi )(void *a, unsigned long b, void *c) |
int(* | mul )(void *a, void *b, void *c) |
int(* | muli )(void *a, unsigned long b, void *c) |
int(* | sqr )(void *a, void *b) |
int(* | mpdiv )(void *a, void *b, void *c, void *d) |
int(* | div_2 )(void *a, void *b) |
int(* | modi )(void *a, unsigned long b, unsigned long *c) |
int(* | gcd )(void *a, void *b, void *c) |
int(* | lcm )(void *a, void *b, void *c) |
int(* | mulmod )(void *a, void *b, void *c, void *d) |
int(* | sqrmod )(void *a, void *b, void *c) |
int(* | invmod )(void *, void *, void *) |
int(* | montgomery_setup )(void *a, void **b) |
int(* | montgomery_normalization )(void *a, void *b) |
int(* | montgomery_reduce )(void *a, void *b, void *c) |
void(* | montgomery_deinit )(void *a) |
int(* | exptmod )(void *a, void *b, void *c, void *d) |
int(* | isprime )(void *a, int *b) |
int(* | ecc_ptmul )(void *k, ecc_point *G, ecc_point *R, void *modulus, int map) |
int(* | ecc_ptadd )(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp) |
int(* | ecc_ptdbl )(ecc_point *P, ecc_point *R, void *modulus, void *mp) |
int(* | ecc_map )(ecc_point *P, void *modulus, void *mp) |
int(* | ecc_mul2add )(ecc_point *A, void *kA, ecc_point *B, void *kB, ecc_point *C, void *modulus) |
int(* | rsa_keygen )(prng_state *prng, int wprng, int size, long e, rsa_key *key) |
int(* | rsa_me )(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen, int which, rsa_key *key) |
math descriptor
int(* ltc_math_descriptor::add)(void *a, void *b, void *c) |
add two integers
a | The first source integer |
b | The second source integer |
c | The destination of "a + b" |
int(* ltc_math_descriptor::addi)(void *a, unsigned long b, void *c) |
add two integers
a | The first source integer |
b | The second source integer (single digit of upto bits_per_digit in length) |
c | The destination of "a + b" |
int ltc_math_descriptor::bits_per_digit |
Bits per digit, amount of bits must fit in an unsigned long
int(* ltc_math_descriptor::compare)(void *a, void *b) |
compare two integers
a | The left side integer |
b | The right side integer |
int(* ltc_math_descriptor::compare_d)(void *a, unsigned long n) |
compare against int
a | The left side integer |
b | The right side integer (upto bits_per_digit) |
int(* ltc_math_descriptor::copy)(void *src, void *dst) |
copy
src | The number to copy from |
dst | The number to write to |
int(* ltc_math_descriptor::count_bits)(void *a) |
Count the number of bits used to represent the integer
a | The integer to count |
int(* ltc_math_descriptor::count_lsb_bits)(void *a) |
Count the number of LSB bits which are zero
a | The integer to count |
void(* ltc_math_descriptor::deinit)(void *a) |
deinit
a | The number to free |
int(* ltc_math_descriptor::div_2)(void *a, void *b) |
divide by two
a | The integer to divide (shift right) |
b | The destination |
ECC mapping from projective to affine, currently uses (x,y,z) => (x/z^2, y/z^3, 1)
P | The point to map |
modulus | The modulus |
mp | The "b" value from montgomery_setup() |
int(* ltc_math_descriptor::ecc_mul2add)(ecc_point *A, void *kA, ecc_point *B, void *kB, ecc_point *C, void *modulus) |
Computes kA*A + kB*B = C using Shamir's Trick
A | First point to multiply |
kA | What to multiple A by |
B | Second point to multiply |
kB | What to multiple B by |
C | [out] Destination point (can overlap with A or B |
modulus | Modulus for curve |
int(* ltc_math_descriptor::ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp) |
ECC GF(p) point addition
P | The first point |
Q | The second point |
R | The destination of P + Q |
modulus | The modulus |
mp | The "b" value from montgomery_setup() |
ECC GF(p) point double
P | The first point |
R | The destination of 2P |
modulus | The modulus |
mp | The "b" value from montgomery_setup() |
ECC GF(p) point multiplication (from the NIST curves)
k | The integer to multiply the point by |
G | The point to multiply |
R | The destination for kG |
modulus | The modulus for the field |
map | Boolean indicated whether to map back to affine or not (can be ignored if you work in affine only) |
int(* ltc_math_descriptor::exptmod)(void *a, void *b, void *c, void *d) |
Modular exponentiation
a | The base integer |
b | The power (can be negative) integer |
c | The modulus integer |
d | The destination |
int(* ltc_math_descriptor::gcd)(void *a, void *b, void *c) |
gcd
a | The first integer |
b | The second integer |
c | The destination for (a, b) |
unsigned long(* ltc_math_descriptor::get_digit)(void *a, int n) |
get digit n
a | The number to read from |
n | The number of the digit to fetch |
int(* ltc_math_descriptor::get_digit_count)(void *a) |
Get the number of digits that represent the number
a | The number to count |
unsigned long(* ltc_math_descriptor::get_int)(void *a) |
get small constant
a | Number to read, only fetches upto bits_per_digit from the number |
int(* ltc_math_descriptor::init)(void **a) |
initialize a bignum
a | The number to initialize |
int(* ltc_math_descriptor::init_copy)(void **dst, void *src) |
init copy
dst | The number to initialize and write to |
src | The number to copy from |
int(* ltc_math_descriptor::invmod)(void *, void *, void *) |
Modular inversion
a | The value to invert |
b | The modulus |
c | The destination (1/a mod b) |
int(* ltc_math_descriptor::isprime)(void *a, int *b) |
Primality testing
a | The integer to test |
b | The destination of the result (FP_YES if prime) |
int(* ltc_math_descriptor::lcm)(void *a, void *b, void *c) |
lcm
a | The first integer |
b | The second integer |
c | The destination for [a, b] |
int(* ltc_math_descriptor::modi)(void *a, unsigned long b, unsigned long *c) |
Get remainder (small value)
a | The integer to reduce |
b | The modulus (upto bits_per_digit in length) |
c | The destination for the residue |
void(* ltc_math_descriptor::montgomery_deinit)(void *a) |
clean up (frees memory)
a | The value "b" from montgomery_setup() |
int(* ltc_math_descriptor::montgomery_normalization)(void *a, void *b) |
get normalization value
a | The destination for the normalization value |
b | The modulus |
int(* ltc_math_descriptor::montgomery_reduce)(void *a, void *b, void *c) |
reduce a number
a | The number [and dest] to reduce |
b | The modulus |
c | The value "b" from montgomery_setup() |
int(* ltc_math_descriptor::montgomery_setup)(void *a, void **b) |
setup montgomery
a | The modulus |
b | The destination for the reduction digit |
int(* ltc_math_descriptor::mpdiv)(void *a, void *b, void *c, void *d) |
Divide an integer
a | The dividend |
b | The divisor |
c | The quotient (can be NULL to signify don't care) |
d | The remainder (can be NULL to signify don't care) |
int(* ltc_math_descriptor::mul)(void *a, void *b, void *c) |
multiply two integers
a | The first source integer |
b | The second source integer (single digit of upto bits_per_digit in length) |
c | The destination of "a * b" |
int(* ltc_math_descriptor::muli)(void *a, unsigned long b, void *c) |
multiply two integers
a | The first source integer |
b | The second source integer (single digit of upto bits_per_digit in length) |
c | The destination of "a * b" |
int(* ltc_math_descriptor::mulmod)(void *a, void *b, void *c, void *d) |
Modular multiplication
a | The first source |
b | The second source |
c | The modulus |
d | The destination (a*b mod c) |
char* ltc_math_descriptor::name |
Name of the math provider
int(* ltc_math_descriptor::neg)(void *src, void *dst) |
negate
src | The number to negate |
dst | The destination |
int(* ltc_math_descriptor::read_radix)(void *a, const char *str, int radix) |
read ascii string
a | The integer to store into |
str | The string to read |
radix | The radix the integer has been represented in (2-64) |
int(* ltc_math_descriptor::rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key) |
RSA Key Generation
prng | An active PRNG state |
wprng | The index of the PRNG desired |
size | The size of the modulus (key size) desired (octets) |
e | The "e" value (public key). e==65537 is a good choice |
key | [out] Destination of a newly created private key pair |
int(* ltc_math_descriptor::rsa_me)(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen, int which, rsa_key *key) |
RSA exponentiation
in | The octet array representing the base |
inlen | The length of the input |
out | The destination (to be stored in an octet array format) |
outlen | The length of the output buffer and the resulting size (zero padded to the size of the modulus) |
which | PK_PUBLIC for public RSA and PK_PRIVATE for private RSA |
key | The RSA key to use |
int(* ltc_math_descriptor::set_int)(void *a, unsigned long n) |
set small constant
a | Number to write to |
n | Source upto bits_per_digit (actually meant for very small constants) |
int(* ltc_math_descriptor::sqr)(void *a, void *b) |
Square an integer
a | The integer to square |
b | The destination |
int(* ltc_math_descriptor::sqrmod)(void *a, void *b, void *c) |
Modular squaring
a | The first source |
b | The modulus |
c | The destination (a*a mod b) |
int(* ltc_math_descriptor::sub)(void *a, void *b, void *c) |
subtract two integers
a | The first source integer |
b | The second source integer |
c | The destination of "a - b" |
int(* ltc_math_descriptor::subi)(void *a, unsigned long b, void *c) |
subtract two integers
a | The first source integer |
b | The second source integer (single digit of upto bits_per_digit in length) |
c | The destination of "a - b" |
int(* ltc_math_descriptor::twoexpt)(void *a, int n) |
Compute a power of two
a | The integer to store the power in |
n | The power of two you want to store (a = 2^n) |
int(* ltc_math_descriptor::unsigned_read)(void *dst, unsigned char *src, unsigned long len) |
read an array of octets and store as integer
dst | The integer to load |
src | The array of octets |
len | The number of octets |
unsigned long(* ltc_math_descriptor::unsigned_size)(void *a) |
get size as unsigned char string
a | The integer to get the size (when stored in array of octets) |
int(* ltc_math_descriptor::unsigned_write)(void *src, unsigned char *dst) |
store an integer as an array of octets
src | The integer to store |
dst | The buffer to store the integer in |
int(* ltc_math_descriptor::write_radix)(void *a, char *str, int radix) |
write number to string
a | The integer to store |
str | The destination for the string |
radix | The radix the integer is to be represented in (2-64) |