summaryrefslogtreecommitdiffstats
path: root/libtomcrypt/headers
diff options
context:
space:
mode:
Diffstat (limited to 'libtomcrypt/headers')
-rw-r--r--libtomcrypt/headers/tomcrypt.h1
-rw-r--r--libtomcrypt/headers/tomcrypt_cfg.h5
-rw-r--r--libtomcrypt/headers/tomcrypt_hash.h11
-rw-r--r--libtomcrypt/headers/tomcrypt_math.h483
-rw-r--r--libtomcrypt/headers/tomcrypt_pk.h191
-rw-r--r--libtomcrypt/headers/tomcrypt_pkcs.h8
6 files changed, 34 insertions, 665 deletions
diff --git a/libtomcrypt/headers/tomcrypt.h b/libtomcrypt/headers/tomcrypt.h
index f3eb925..51fe804 100644
--- a/libtomcrypt/headers/tomcrypt.h
+++ b/libtomcrypt/headers/tomcrypt.h
@@ -63,6 +63,7 @@ enum {
#include <tomcrypt_cfg.h>
#include <tomcrypt_macros.h>
+#include <tomcrypt_math.h>
#include <tomcrypt_pk.h>
#include <tomcrypt_hash.h>
#include <tomcrypt_misc.h>
diff --git a/libtomcrypt/headers/tomcrypt_cfg.h b/libtomcrypt/headers/tomcrypt_cfg.h
index 7feae6e..b750c8b 100644
--- a/libtomcrypt/headers/tomcrypt_cfg.h
+++ b/libtomcrypt/headers/tomcrypt_cfg.h
@@ -19,6 +19,8 @@
#define LTC_EXPORT
#endif
+LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
+
/* certain platforms use macros for these, making the prototypes broken */
#ifndef LTC_NO_PROTOTYPES
@@ -28,9 +30,6 @@ LTC_EXPORT void * LTC_CALL XREALLOC(void *p, size_t n);
LTC_EXPORT void * LTC_CALL XCALLOC(size_t n, size_t s);
LTC_EXPORT void LTC_CALL XFREE(void *p);
-LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
-
-
/* change the clock function too */
LTC_EXPORT clock_t LTC_CALL XCLOCK(void);
diff --git a/libtomcrypt/headers/tomcrypt_hash.h b/libtomcrypt/headers/tomcrypt_hash.h
index 9c7af13..5eaa97c 100644
--- a/libtomcrypt/headers/tomcrypt_hash.h
+++ b/libtomcrypt/headers/tomcrypt_hash.h
@@ -8,6 +8,11 @@ int hash_memory(int hash,
int hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
const unsigned char *in, unsigned long inlen, ...);
-/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */
-/* $Revision: 1.22 $ */
-/* $Date: 2007/05/12 14:32:35 $ */
+typedef struct Oid {
+ unsigned long OID[16];
+ /** Length of DER encoding */
+ unsigned long OIDlen;
+} oid_st;
+
+int hash_get_oid(int hash, oid_st* st);
+
diff --git a/libtomcrypt/headers/tomcrypt_math.h b/libtomcrypt/headers/tomcrypt_math.h
index a05d7ff..3ee9523 100644
--- a/libtomcrypt/headers/tomcrypt_math.h
+++ b/libtomcrypt/headers/tomcrypt_math.h
@@ -15,486 +15,7 @@
typedef void rsa_key;
#endif
-/** math descriptor */
-typedef struct {
- /** Name of the math provider */
- char *name;
+#include <tommath.h>
- /** Bits per digit, amount of bits must fit in an unsigned long */
- int bits_per_digit;
+typedef mp_int* mp_int_t;
-/* ---- init/deinit functions ---- */
-
- /** initialize a bignum
- @param a The number to initialize
- @return CRYPT_OK on success
- */
- int (*init)(void **a);
-
- /** init copy
- @param dst The number to initialize and write to
- @param src The number to copy from
- @return CRYPT_OK on success
- */
- int (*init_copy)(void **dst, void *src);
-
- /** deinit
- @param a The number to free
- @return CRYPT_OK on success
- */
- void (*deinit)(void *a);
-
-/* ---- data movement ---- */
-
- /** negate
- @param src The number to negate
- @param dst The destination
- @return CRYPT_OK on success
- */
- int (*neg)(void *src, void *dst);
-
- /** copy
- @param src The number to copy from
- @param dst The number to write to
- @return CRYPT_OK on success
- */
- int (*copy)(void *src, void *dst);
-
-/* ---- trivial low level functions ---- */
-
- /** 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 succcess
- */
- int (*set_int)(void *a, unsigned long n);
-
- /** get small constant
- @param a Number to read, only fetches upto bits_per_digit from the number
- @return The lower bits_per_digit of the integer (unsigned)
- */
- unsigned long (*get_int)(void *a);
-
- /** 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
- */
- unsigned long (*get_digit)(void *a, int n);
-
- /** 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
- */
- int (*get_digit_count)(void *a);
-
- /** 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)
- */
- int (*compare)(void *a, void *b);
-
- /** 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)
- */
- int (*compare_d)(void *a, unsigned long n);
-
- /** 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
- */
- int (*count_bits)(void * a);
-
- /** Count the number of LSB bits which are zero
- @param a The integer to count
- @return The number of contiguous zero LSB bits
- */
- int (*count_lsb_bits)(void *a);
-
- /** 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
- */
- int (*twoexpt)(void *a , int n);
-
-/* ---- radix conversions ---- */
-
- /** 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
- */
- int (*read_radix)(void *a, const char *str, int radix);
-
- /** 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
- */
- int (*write_radix)(void *a, char *str, int radix);
-
- /** 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
- */
- unsigned long (*unsigned_size)(void *a);
-
- /** 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
- */
- int (*unsigned_write)(void *src, unsigned char *dst);
-
- /** 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
- */
- int (*unsigned_read)(void *dst, unsigned char *src, unsigned long len);
-
-/* ---- basic math ---- */
-
- /** 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
- */
- int (*add)(void *a, void *b, void *c);
-
-
- /** 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
- */
- int (*addi)(void *a, unsigned long b, void *c);
-
- /** 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
- */
- int (*sub)(void *a, void *b, void *c);
-
- /** 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
- */
- int (*subi)(void *a, unsigned long b, void *c);
-
- /** 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
- */
- int (*mul)(void *a, void *b, void *c);
-
- /** 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
- */
- int (*muli)(void *a, unsigned long b, void *c);
-
- /** Square an integer
- @param a The integer to square
- @param b The destination
- @return CRYPT_OK on success
- */
- int (*sqr)(void *a, void *b);
-
- /** 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
- */
- int (*mpdiv)(void *a, void *b, void *c, void *d);
-
- /** divide by two
- @param a The integer to divide (shift right)
- @param b The destination
- @return CRYPT_OK on success
- */
- int (*div_2)(void *a, void *b);
-
- /** 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
- */
- int (*modi)(void *a, unsigned long b, unsigned long *c);
-
- /** gcd
- @param a The first integer
- @param b The second integer
- @param c The destination for (a, b)
- @return CRYPT_OK on success
- */
- int (*gcd)(void *a, void *b, void *c);
-
- /** lcm
- @param a The first integer
- @param b The second integer
- @param c The destination for [a, b]
- @return CRYPT_OK on success
- */
- int (*lcm)(void *a, void *b, void *c);
-
- /** 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
- */
- int (*mulmod)(void *a, void *b, void *c, void *d);
-
- /** Modular squaring
- @param a The first source
- @param b The modulus
- @param c The destination (a*a mod b)
- @return CRYPT_OK on success
- */
- int (*sqrmod)(void *a, void *b, void *c);
-
- /** 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
- */
- int (*invmod)(void *, void *, void *);
-
-/* ---- reduction ---- */
-
- /** setup montgomery
- @param a The modulus
- @param b The destination for the reduction digit
- @return CRYPT_OK on success
- */
- int (*montgomery_setup)(void *a, void **b);
-
- /** get normalization value
- @param a The destination for the normalization value
- @param b The modulus
- @return CRYPT_OK on success
- */
- int (*montgomery_normalization)(void *a, void *b);
-
- /** 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
- */
- int (*montgomery_reduce)(void *a, void *b, void *c);
-
- /** clean up (frees memory)
- @param a The value "b" from montgomery_setup()
- @return CRYPT_OK on success
- */
- void (*montgomery_deinit)(void *a);
-
-/* ---- exponentiation ---- */
-
- /** 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
- */
- int (*exptmod)(void *a, void *b, void *c, void *d);
-
- /** Primality testing
- @param a The integer to test
- @param b The destination of the result (FP_YES if prime)
- @return CRYPT_OK on success
- */
- int (*isprime)(void *a, int *b);
-
-/* ---- (optional) ecc point math ---- */
-
- /** 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
- */
- int (*ecc_ptmul)(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
-
- /** 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
- */
- int (*ecc_ptadd)(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp);
-
- /** 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
- */
- int (*ecc_ptdbl)(ecc_point *P, ecc_point *R, void *modulus, void *mp);
-
- /** 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.
- */
- int (*ecc_map)(ecc_point *P, void *modulus, void *mp);
-
- /** Computes kA*A + kB*B = 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
- */
- int (*ecc_mul2add)(ecc_point *A, void *kA,
- ecc_point *B, void *kB,
- ecc_point *C,
- void *modulus);
-
-/* ---- (optional) rsa optimized math (for internal CRT) ---- */
-
- /** RSA Key Generation
- @param prng An active PRNG state
- @param wprng The index of the PRNG desired
- @param size The size of the modulus (key size) desired (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
- */
- int (*rsa_keygen)(prng_state *prng, int wprng, int size, long e, rsa_key *key);
-
-
- /** 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
- */
- int (*rsa_me)(const unsigned char *in, unsigned long inlen,
- unsigned char *out, unsigned long *outlen, int which,
- rsa_key *key);
-} ltc_math_descriptor;
-
-extern ltc_math_descriptor ltc_mp;
-
-int ltc_init_multi(void **a, ...);
-void ltc_deinit_multi(void *a, ...);
-
-#ifdef LTM_DESC
-extern const ltc_math_descriptor ltm_desc;
-#endif
-
-#ifdef TFM_DESC
-extern const ltc_math_descriptor tfm_desc;
-#endif
-
-#ifdef GMP_DESC
-extern const ltc_math_descriptor gmp_desc;
-#endif
-
-#if !defined(DESC_DEF_ONLY) && defined(LTC_SOURCE)
-
-#define MP_DIGIT_BIT ltc_mp.bits_per_digit
-
-/* some handy macros */
-#define mp_init(a) ltc_mp.init(a)
-#define mp_init_multi ltc_init_multi
-#define mp_clear(a) ltc_mp.deinit(a)
-#define mp_clear_multi ltc_deinit_multi
-#define mp_init_copy(a, b) ltc_mp.init_copy(a, b)
-
-#define mp_neg(a, b) ltc_mp.neg(a, b)
-#define mp_copy(a, b) ltc_mp.copy(a, b)
-
-#define mp_set(a, b) ltc_mp.set_int(a, b)
-#define mp_set_int(a, b) ltc_mp.set_int(a, b)
-#define mp_get_int(a) ltc_mp.get_int(a)
-#define mp_get_digit(a, n) ltc_mp.get_digit(a, n)
-#define mp_get_digit_count(a) ltc_mp.get_digit_count(a)
-#define mp_cmp(a, b) ltc_mp.compare(a, b)
-#define mp_cmp_d(a, b) ltc_mp.compare_d(a, b)
-#define mp_count_bits(a) ltc_mp.count_bits(a)
-#define mp_cnt_lsb(a) ltc_mp.count_lsb_bits(a)
-#define mp_2expt(a, b) ltc_mp.twoexpt(a, b)
-
-#define mp_read_radix(a, b, c) ltc_mp.read_radix(a, b, c)
-#define mp_toradix(a, b, c) ltc_mp.write_radix(a, b, c)
-#define mp_unsigned_bin_size(a) ltc_mp.unsigned_size(a)
-#define mp_to_unsigned_bin(a, b) ltc_mp.unsigned_write(a, b)
-#define mp_read_unsigned_bin(a, b, c) ltc_mp.unsigned_read(a, b, c)
-
-#define mp_add(a, b, c) ltc_mp.add(a, b, c)
-#define mp_add_d(a, b, c) ltc_mp.addi(a, b, c)
-#define mp_sub(a, b, c) ltc_mp.sub(a, b, c)
-#define mp_sub_d(a, b, c) ltc_mp.subi(a, b, c)
-#define mp_mul(a, b, c) ltc_mp.mul(a, b, c)
-#define mp_mul_d(a, b, c) ltc_mp.muli(a, b, c)
-#define mp_sqr(a, b) ltc_mp.sqr(a, b)
-#define mp_div(a, b, c, d) ltc_mp.mpdiv(a, b, c, d)
-#define mp_div_2(a, b) ltc_mp.div_2(a, b)
-#define mp_mod(a, b, c) ltc_mp.mpdiv(a, b, NULL, c)
-#define mp_mod_d(a, b, c) ltc_mp.modi(a, b, c)
-#define mp_gcd(a, b, c) ltc_mp.gcd(a, b, c)
-#define mp_lcm(a, b, c) ltc_mp.lcm(a, b, c)
-
-#define mp_mulmod(a, b, c, d) ltc_mp.mulmod(a, b, c, d)
-#define mp_sqrmod(a, b, c) ltc_mp.sqrmod(a, b, c)
-#define mp_invmod(a, b, c) ltc_mp.invmod(a, b, c)
-
-#define mp_montgomery_setup(a, b) ltc_mp.montgomery_setup(a, b)
-#define mp_montgomery_normalization(a, b) ltc_mp.montgomery_normalization(a, b)
-#define mp_montgomery_reduce(a, b, c) ltc_mp.montgomery_reduce(a, b, c)
-#define mp_montgomery_free(a) ltc_mp.montgomery_deinit(a)
-
-#define mp_exptmod(a,b,c,d) ltc_mp.exptmod(a,b,c,d)
-#define mp_prime_is_prime(a, b, c) ltc_mp.isprime(a, c)
-
-#define mp_iszero(a) (mp_cmp_d(a, 0) == LTC_MP_EQ ? LTC_MP_YES : LTC_MP_NO)
-#define mp_isodd(a) (mp_get_digit_count(a) > 0 ? (mp_get_digit(a, 0) & 1 ? LTC_MP_YES : LTC_MP_NO) : LTC_MP_NO)
-#define mp_exch(a, b) do { void *ABC__tmp = a; a = b; b = ABC__tmp; } while(0);
-
-#define mp_tohex(a, b) mp_toradix(a, b, 16)
-
-#endif
-
-/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_math.h,v $ */
-/* $Revision: 1.44 $ */
-/* $Date: 2007/05/12 14:32:35 $ */
diff --git a/libtomcrypt/headers/tomcrypt_pk.h b/libtomcrypt/headers/tomcrypt_pk.h
index 4cd1d48..6d6f32f 100644
--- a/libtomcrypt/headers/tomcrypt_pk.h
+++ b/libtomcrypt/headers/tomcrypt_pk.h
@@ -19,21 +19,21 @@ typedef struct Rsa_key {
/** Type of key, PK_PRIVATE or PK_PUBLIC */
int type;
/** The public exponent */
- void *e;
+ mp_int e;
/** The private exponent */
- void *d;
+ mp_int d;
/** The modulus */
- void *N;
+ mp_int N;
/** The p factor of N */
- void *p;
+ mp_int p;
/** The q factor of N */
- void *q;
+ mp_int q;
/** The 1/q mod p CRT param */
- void *qP;
+ mp_int qP;
/** The d mod (p - 1) CRT param */
- void *dP;
+ mp_int dP;
/** The d mod (q - 1) CRT param */
- void *dQ;
+ mp_int dQ;
} rsa_key;
int rsa_make_key(int size, long e, rsa_key *key);
@@ -87,159 +87,6 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
#endif
-/* ---- ECC Routines ---- */
-#ifdef LTC_MECC
-
-/* size of our temp buffers for exported keys */
-#define ECC_BUF_SIZE 256
-
-/* max private key size */
-#define ECC_MAXSIZE 66
-
-/** Structure defines a NIST GF(p) curve */
-typedef struct {
- /** The size of the curve in octets */
- int size;
-
- /** name of curve */
- char *name;
-
- /** The prime that defines the field the curve is in (encoded in hex) */
- char *prime;
-
- /** The fields B param (hex) */
- char *B;
-
- /** The order of the curve (hex) */
- char *order;
-
- /** The x co-ordinate of the base point on the curve (hex) */
- char *Gx;
-
- /** The y co-ordinate of the base point on the curve (hex) */
- char *Gy;
-} ltc_ecc_set_type;
-
-/** A point on a ECC curve, stored in Jacbobian format such that (x,y,z) => (x/z^2, y/z^3, 1) when interpretted as affine */
-typedef struct {
- /** The x co-ordinate */
- void *x;
-
- /** The y co-ordinate */
- void *y;
-
- /** The z co-ordinate */
- void *z;
-} ecc_point;
-
-/** An ECC key */
-typedef struct {
- /** Type of key, PK_PRIVATE or PK_PUBLIC */
- int type;
-
- /** Index into the ltc_ecc_sets[] for the parameters of this curve; if -1, then this key is using user supplied curve in dp */
- int idx;
-
- /** pointer to domain parameters; either points to NIST curves (identified by idx >= 0) or user supplied curve */
- const ltc_ecc_set_type *dp;
-
- /** The public key */
- ecc_point pubkey;
-
- /** The private key */
- void *k;
-} ecc_key;
-
-/** the ECC params provided */
-extern const ltc_ecc_set_type ltc_ecc_sets[];
-
-int ecc_test(void);
-void ecc_sizes(int *low, int *high);
-int ecc_get_size(ecc_key *key);
-
-int ecc_make_key(int keysize, ecc_key *key);
-int ecc_make_key_ex(ecc_key *key, const ltc_ecc_set_type *dp);
-void ecc_free(ecc_key *key);
-
-int ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key);
-int ecc_import(const unsigned char *in, unsigned long inlen, ecc_key *key);
-int ecc_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, const ltc_ecc_set_type *dp);
-
-int ecc_ansi_x963_export(ecc_key *key, unsigned char *out, unsigned long *outlen);
-int ecc_ansi_x963_import(const unsigned char *in, unsigned long inlen, ecc_key *key);
-int ecc_ansi_x963_import_ex(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp);
-
-int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key,
- unsigned char *out, unsigned long *outlen);
-
-int ecc_encrypt_key(const unsigned char *in, unsigned long inlen,
- unsigned char *out, unsigned long *outlen,
- int hash, ecc_key *key);
-
-int ecc_decrypt_key(const unsigned char *in, unsigned long inlen,
- unsigned char *out, unsigned long *outlen,
- ecc_key *key);
-
-int ecc_sign_hash(const unsigned char *in, unsigned long inlen,
- unsigned char *out, unsigned long *outlen,
- ecc_key *key);
-
-int ecc_verify_hash(const unsigned char *sig, unsigned long siglen,
- const unsigned char *hash, unsigned long hashlen,
- int *stat, ecc_key *key);
-
-/* low level functions */
-ecc_point *ltc_ecc_new_point(void);
-void ltc_ecc_del_point(ecc_point *p);
-int ltc_ecc_is_valid_idx(int n);
-
-/* point ops (mp == montgomery digit) */
-#if !defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC) || defined(GMP_LTC_DESC)
-/* R = 2P */
-int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp);
-
-/* R = P + Q */
-int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp);
-#endif
-
-#if defined(LTC_MECC_FP)
-/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */
-int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
-
-/* functions for saving/loading/freeing/adding to fixed point cache */
-int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen);
-int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen);
-void ltc_ecc_fp_free(void);
-int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock);
-
-/* lock/unlock all points currently in fixed point cache */
-void ltc_ecc_fp_tablelock(int lock);
-#endif
-
-/* R = kG */
-int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
-
-#ifdef LTC_ECC_SHAMIR
-/* kA*A + kB*B = C */
-int ltc_ecc_mul2add(ecc_point *A, void *kA,
- ecc_point *B, void *kB,
- ecc_point *C,
- void *modulus);
-
-#ifdef LTC_MECC_FP
-/* Shamir's trick with optimized point multiplication using fixed point cache */
-int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
- ecc_point *B, void *kB,
- ecc_point *C, void *modulus);
-#endif
-
-#endif
-
-
-/* map P to affine from projective */
-int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
-
-#endif
#ifdef LTC_MDSA
@@ -258,33 +105,33 @@ typedef struct {
int qord;
/** The generator */
- void *g;
+ mp_int g;
/** The prime used to generate the sub-group */
- void *q;
+ mp_int q;
/** The large prime that generats the field the contains the sub-group */
- void *p;
+ mp_int p;
/** The private key */
- void *x;
+ mp_int x;
/** The public key */
- void *y;
+ mp_int y;
} dsa_key;
int dsa_make_key(int group_size, int modulus_size, dsa_key *key);
void dsa_free(dsa_key *key);
int dsa_sign_hash_raw(const unsigned char *in, unsigned long inlen,
- void *r, void *s,
+ mp_int_t r, mp_int_t s,
dsa_key *key);
int dsa_sign_hash(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
dsa_key *key);
-int dsa_verify_hash_raw( void *r, void *s,
+int dsa_verify_hash_raw( mp_int_t r, mp_int_t s,
const unsigned char *hash, unsigned long hashlen,
int *stat, dsa_key *key);
@@ -304,7 +151,7 @@ int dsa_import(const unsigned char *in, unsigned long inlen, dsa_key *key);
int dsa_export(unsigned char *out, unsigned long *outlen, int type, dsa_key *key);
int dsa_verify_key(dsa_key *key, int *stat);
-int dsa_shared_secret(void *private_key, void *base,
+int dsa_shared_secret(void *private_key, mp_int_t base,
dsa_key *public_key,
unsigned char *out, unsigned long *outlen);
#endif
@@ -394,9 +241,9 @@ int der_encode_boolean(int in,
int der_decode_boolean(const unsigned char *in, unsigned long inlen,
int *out);
/* INTEGER */
-int der_encode_integer(void *num, unsigned char *out, unsigned long *outlen);
-int der_decode_integer(const unsigned char *in, unsigned long inlen, void *num);
-int der_length_integer(void *num, unsigned long *len);
+int der_encode_integer(mp_int_t num, unsigned char *out, unsigned long *outlen);
+int der_decode_integer(const unsigned char *in, unsigned long inlen, mp_int_t num);
+int der_length_integer(mp_int_t num, unsigned long *len);
/* INTEGER -- handy for 0..2^32-1 values */
int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num);
diff --git a/libtomcrypt/headers/tomcrypt_pkcs.h b/libtomcrypt/headers/tomcrypt_pkcs.h
index 841583f..8e43942 100644
--- a/libtomcrypt/headers/tomcrypt_pkcs.h
+++ b/libtomcrypt/headers/tomcrypt_pkcs.h
@@ -28,8 +28,6 @@ int pkcs_1_v1_5_encode(const unsigned char *msg,
unsigned long msglen,
int block_type,
unsigned long modulus_bitlen,
- prng_state *prng,
- int prng_idx,
unsigned char *out,
unsigned long *outlen);
@@ -44,8 +42,7 @@ int pkcs_1_v1_5_decode(const unsigned char *msg,
/* *** v2.1 padding */
int pkcs_1_oaep_encode(const unsigned char *msg, unsigned long msglen,
const unsigned char *lparam, unsigned long lparamlen,
- unsigned long modulus_bitlen, prng_state *prng,
- int prng_idx, int hash_idx,
+ unsigned long modulus_bitlen, int hash_idx,
unsigned char *out, unsigned long *outlen);
int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
@@ -55,8 +52,7 @@ int pkcs_1_oaep_decode(const unsigned char *msg, unsigned long msglen,
int *res);
int pkcs_1_pss_encode(const unsigned char *msghash, unsigned long msghashlen,
- unsigned long saltlen, prng_state *prng,
- int prng_idx, int hash_idx,
+ unsigned long saltlen, int hash_idx,
unsigned long modulus_bitlen,
unsigned char *out, unsigned long *outlen);