#include <stdio.h>Go to the source code of this file.
Data Structures | |
| struct | mpi |
| MPI structure. More... | |
Defines | |
| #define | XYSSL_ERR_MPI_FILE_IO_ERROR -0x0002 |
| #define | XYSSL_ERR_MPI_BAD_INPUT_DATA -0x0004 |
| #define | XYSSL_ERR_MPI_INVALID_CHARACTER -0x0006 |
| #define | XYSSL_ERR_MPI_BUFFER_TOO_SMALL -0x0008 |
| #define | XYSSL_ERR_MPI_NEGATIVE_VALUE -0x000A |
| #define | XYSSL_ERR_MPI_DIVISION_BY_ZERO -0x000C |
| #define | XYSSL_ERR_MPI_NOT_ACCEPTABLE -0x000E |
| #define | MPI_CHK(f) if( ( ret = f ) != 0 ) goto cleanup |
Typedefs | |
| typedef unsigned long | t_int |
| typedef unsigned long long | t_dbl |
Functions | |
| void | mpi_init (mpi *X,...) |
| Initialize one or more mpi. | |
| void | mpi_free (mpi *X,...) |
| Unallocate one or more mpi. | |
| int | mpi_grow (mpi *X, int nblimbs) |
| Enlarge to the specified number of limbs. | |
| int | mpi_copy (mpi *X, mpi *Y) |
| Copy the contents of Y into X. | |
| void | mpi_swap (mpi *X, mpi *Y) |
| Swap the contents of X and Y. | |
| int | mpi_lset (mpi *X, int z) |
| Set value from integer. | |
| int | mpi_lsb (mpi *X) |
| Return the number of least significant bits. | |
| int | mpi_msb (mpi *X) |
| Return the number of most significant bits. | |
| int | mpi_size (mpi *X) |
| Return the total size in bytes. | |
| int | mpi_read_string (mpi *X, int radix, char *s) |
| Import from an ASCII string. | |
| int | mpi_write_string (mpi *X, int radix, char *s, int *slen) |
| Export into an ASCII string. | |
| int | mpi_read_file (mpi *X, int radix, FILE *fin) |
| Read X from an opened file. | |
| int | mpi_write_file (char *p, mpi *X, int radix, FILE *fout) |
| Write X into an opened file, or stdout. | |
| int | mpi_read_binary (mpi *X, unsigned char *buf, int buflen) |
| Import X from unsigned binary data, big endian. | |
| int | mpi_write_binary (mpi *X, unsigned char *buf, int buflen) |
| Export X into unsigned binary data, big endian. | |
| int | mpi_shift_l (mpi *X, int count) |
| Left-shift: X <<= count. | |
| int | mpi_shift_r (mpi *X, int count) |
| Right-shift: X >>= count. | |
| int | mpi_cmp_abs (mpi *X, mpi *Y) |
| Compare unsigned values. | |
| int | mpi_cmp_mpi (mpi *X, mpi *Y) |
| Compare signed values. | |
| int | mpi_cmp_int (mpi *X, int z) |
| Compare signed values. | |
| int | mpi_add_abs (mpi *X, mpi *A, mpi *B) |
| Unsigned addition: X = |A| + |B|. | |
| int | mpi_sub_abs (mpi *X, mpi *A, mpi *B) |
| Unsigned substraction: X = |A| - |B|. | |
| int | mpi_add_mpi (mpi *X, mpi *A, mpi *B) |
| Signed addition: X = A + B. | |
| int | mpi_sub_mpi (mpi *X, mpi *A, mpi *B) |
| Signed substraction: X = A - B. | |
| int | mpi_add_int (mpi *X, mpi *A, int b) |
| Signed addition: X = A + b. | |
| int | mpi_sub_int (mpi *X, mpi *A, int b) |
| Signed substraction: X = A - b. | |
| int | mpi_mul_mpi (mpi *X, mpi *A, mpi *B) |
| Baseline multiplication: X = A * B. | |
| int | mpi_mul_int (mpi *X, mpi *A, t_int b) |
| Baseline multiplication: X = A * b. | |
| int | mpi_div_mpi (mpi *Q, mpi *R, mpi *A, mpi *B) |
| Division by mpi: A = Q * B + R. | |
| int | mpi_div_int (mpi *Q, mpi *R, mpi *A, int b) |
| Division by int: A = Q * b + R. | |
| int | mpi_mod_mpi (mpi *R, mpi *A, mpi *B) |
| Modulo: R = A mod B. | |
| int | mpi_mod_int (t_int *r, mpi *A, int b) |
| Modulo: r = A mod b. | |
| int | mpi_exp_mod (mpi *X, mpi *A, mpi *E, mpi *N, mpi *_RR) |
| Sliding-window exponentiation: X = A^E mod N. | |
| int | mpi_gcd (mpi *G, mpi *A, mpi *B) |
| Greatest common divisor: G = gcd(A, B). | |
| int | mpi_inv_mod (mpi *X, mpi *A, mpi *N) |
| Modular inverse: X = A^-1 mod N. | |
| int | mpi_is_prime (mpi *X, int(*f_rng)(void *), void *p_rng) |
| Miller-Rabin primality test. | |
| int | mpi_gen_prime (mpi *X, int nbits, int dh_flag, int(*f_rng)(void *), void *p_rng) |
| Prime number generation. | |
| int | mpi_self_test (int verbose) |
| Checkup routine. | |
Definition in file bignum.h.
Unsigned addition: X = |A| + |B|.
Signed addition: X = A + b.
Signed addition: X = A + B.
Compare unsigned values.
Compare signed values.
Compare signed values.
Copy the contents of Y into X.
Division by int: A = Q * b + R.
Referenced by main().
Division by mpi: A = Q * B + R.
Sliding-window exponentiation: X = A^E mod N.
Referenced by main().
Greatest common divisor: G = gcd(A, B).
Prime number generation.
| X | destination mpi | |
| nbits | required size of X in bits | |
| dh_flag | if 1, then (X-1)/2 will be prime too | |
| f_rng | RNG function | |
| p_rng | RNG parameter |
Referenced by main().
Enlarge to the specified number of limbs.
Modular inverse: X = A^-1 mod N.
Referenced by main().
Miller-Rabin primality test.
Referenced by main().
Set value from integer.
Modulo: r = A mod b.
Modulo: R = A mod B.
Baseline multiplication: X = A * b.
Baseline multiplication: X = A * B.
Referenced by main().
Import X from unsigned binary data, big endian.
| X | destination mpi | |
| buf | input buffer | |
| buflen | input buffer size |
Referenced by d2i_RSA_PUBKEY().
Left-shift: X <<= count.
Right-shift: X >>= count.
Unsigned substraction: X = |A| - |B|.
Signed substraction: X = A - b.
Referenced by main().
Signed substraction: X = A - B.
Export X into unsigned binary data, big endian.
| X | source mpi | |
| buf | output buffer | |
| buflen | output buffer size |
Export into an ASCII string.
| X | source mpi | |
| radix | output numeric base | |
| s | string buffer | |
| slen | string buffer size |
1.5.4