32 #ifndef __WINE_TOMCRYPT_H_ 33 #define __WINE_TOMCRYPT_H_ 78 #define CONST64(a,b) ((((ULONG64)(a)) << 32) | (b)) 87 #define STORE32H(x, y) \ 88 { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255); \ 89 (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } 91 #define LOAD32H(x, y) \ 92 { x = ((unsigned long)((y)[0] & 255)<<24) | \ 93 ((unsigned long)((y)[1] & 255)<<16) | \ 94 ((unsigned long)((y)[2] & 255)<<8) | \ 95 ((unsigned long)((y)[3] & 255)); } 97 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && !defined(INTEL_CC) 99 static inline unsigned ROR(
unsigned word,
int i)
103 :
"0" (
word),
"c" (
i));
110 #define ROR(x, y) ( ((((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)((y)&31)) | \ 111 ((unsigned long)(x)<<(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) 116 #define MIN(x, y) ( ((x)<(y))?(x):(y) ) 118 #define byte(x, n) (((x) >> (8 * (n))) & 255) 188 #define MP_DIGIT_BIT DIGIT_BIT 189 #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) 190 #define MP_DIGIT_MAX MP_MASK 203 #define MP_RANGE MP_VAL 209 #define LTM_PRIME_BBS 0x0001 210 #define LTM_PRIME_SAFE 0x0002 211 #define LTM_PRIME_2MSB_OFF 0x0004 212 #define LTM_PRIME_2MSB_ON 0x0008 222 #define MP_WARRAY (1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1)) 233 #define DIGIT(m,k) ((m)->dp[(k)]) 248 #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) 249 #define mp_iseven(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO) 250 #define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO) 371 #define PRIME_SIZE 256 399 #define mp_prime_random(a, t, size, bbs, cb, dat) mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat) 435 #define mp_read_raw(mp, str, len) mp_read_signed_bin((mp), (str), (len)) 436 #define mp_raw_size(mp) mp_signed_bin_size(mp) 437 #define mp_toraw(mp, str) mp_to_signed_bin((mp), (str)) 438 #define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len)) 439 #define mp_mag_size(mp) mp_unsigned_bin_size(mp) 440 #define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str)) 442 #define mp_tobinary(M, S) mp_toradix((M), (S), 2) 443 #define mp_tooctal(M, S) mp_toradix((M), (S), 8) 444 #define mp_todecimal(M, S) mp_toradix((M), (S), 10) 445 #define mp_tohex(M, S) mp_toradix((M), (S), 16) 453 #define MIN_RSA_SIZE 384 454 #define MAX_RSA_SIZE 16384 463 int rsa_exptmod(
const unsigned char *
in,
unsigned long inlen,
464 unsigned char *
out,
unsigned long *outlen,
int which,
struct tag_md2_state md2_state
void rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, rc2_key *key)
int mp_to_signed_bin(mp_int *a, unsigned char *b)
static size_t double int int int * sign
int rc2_setup(const unsigned char *key, int keylen, int bits, int num_rounds, rc2_key *skey)
int ltm_prime_callback(unsigned char *dst, int len, void *dat)
int mp_submod(mp_int *a, mp_int *b, mp_int *c, mp_int *d)
void rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, rc2_key *key)
struct tag_des3_key des3_key
int mp_or(mp_int *a, mp_int *b, mp_int *c)
struct tag_aes_key aes_key
void rsa_free(rsa_key *key)
int rc4_start(prng_state *prng)
int mp_neg(mp_int *a, mp_int *b)
int mp_fread(mp_int *a, int radix, FILE *stream)
int mp_sub(mp_int *a, mp_int *b, mp_int *c)
int mp_expt_d(mp_int *a, mp_digit b, mp_int *c)
__asm__("\n\t \
NewInt3Handler:\n\t \
pushl $" STR(REASON_INT3) "\n\t \
// call debugger loop\n\t \
jmp NewInt31Handler\n\t \
")
int mp_prime_rabin_miller_trials(int size)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
void des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const des3_key *key)
int rsa_exptmod(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen, int which, rsa_key *key)
int mp_n_root(mp_int *a, mp_digit b, mp_int *c)
int mp_sqrt(mp_int *arg, mp_int *ret)
void aes_ecb_encrypt(const unsigned char *pt, unsigned char *ct, aes_key *skey)
int rc4_ready(prng_state *prng)
int mp_reduce_is_2k(mp_int *a)
int md2_process(md2_state *md, const unsigned char *buf, unsigned long len)
int mp_radix_size(mp_int *a, int radix, int *size)
GLenum GLuint GLenum GLsizei const GLchar * buf
int mp_prime_next_prime(mp_int *a, int t, int bbs_style)
int mp_init_set_int(mp_int *a, unsigned long b)
int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback cb, void *dat)
int md2_done(md2_state *md, unsigned char *hash)
unsigned long rc4_read(unsigned char *buf, unsigned long len, prng_state *prng)
int mp_init_set(mp_int *a, mp_digit b)
int mp_addmod(mp_int *a, mp_int *b, mp_int *c, mp_int *d)
void des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const des_key *key)
int mp_dr_is_modulus(mp_int *a)
int mp_read_radix(mp_int *a, char *str, int radix)
int mp_jacobi(mp_int *a, mp_int *n, int *c)
struct tag_rc2_key rc2_key
char * mp_error_to_string(int code)
int mp_lcm(const mp_int *a, const mp_int *b, mp_int *c)
int mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
int mp_fwrite(mp_int *a, int radix, FILE *stream)
int mp_mod(const mp_int *a, mp_int *b, mp_int *c)
int mp_cmp(const mp_int *a, const mp_int *b)
GLboolean GLboolean GLboolean b
int mp_is_square(mp_int *arg, int *ret)
int mp_init_multi(mp_int *mp,...)
int md2_init(md2_state *md)
int mp_count_bits(const mp_int *a)
int mp_read_signed_bin(mp_int *a, unsigned char *b, int c)
int mp_toradix_n(mp_int *a, char *str, int radix, int maxlen)
int mp_mulmod(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
void mp_clear_multi(mp_int *mp,...)
int mp_invmod(const mp_int *a, mp_int *b, mp_int *c)
int rc4_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng)
int mp_exteuclid(mp_int *a, mp_int *b, mp_int *U1, mp_int *U2, mp_int *U3)
int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c)
int mp_set_int(mp_int *a, unsigned long b)
int mp_div_3(mp_int *a, mp_int *c, mp_digit *d)
union Prng_state prng_state
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
void des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const des3_key *key)
int mp_exptmod(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
struct tag_des_key des_key
int mp_gcd(const mp_int *a, const mp_int *b, mp_int *c)
int mp_cmp_d(const mp_int *a, mp_digit b)
static HMODULE MODULEINFO DWORD cb
int des3_setup(const unsigned char *key, int keylen, int num_rounds, des3_key *skey)
int mp_prime_fermat(mp_int *a, mp_int *b, int *result)
int mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
int mp_and(mp_int *a, mp_int *b, mp_int *c)
int mp_xor(mp_int *a, mp_int *b, mp_int *c)
int mp_unsigned_bin_size(const mp_int *a)
int des_setup(const unsigned char *key, int keylen, int num_rounds, des_key *skey)
int rsa_make_key(int size, long e, rsa_key *key)
GLboolean GLboolean GLboolean GLboolean a
int mp_add(mp_int *a, mp_int *b, mp_int *c)
void aes_ecb_decrypt(const unsigned char *ct, unsigned char *pt, aes_key *skey)
int mp_sub_d(mp_int *a, mp_digit b, mp_int *c)
unsigned long mp_get_int(const mp_int *a)
int aes_setup(const unsigned char *key, int keylen, int rounds, aes_key *skey)
int mp_toradix(mp_int *a, char *str, int radix)
int mp_rand(mp_int *a, int digits)
int mp_init_copy(mp_int *a, const mp_int *b)
static const int digits[]
int mp_copy(const mp_int *a, mp_int *b)
void des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const des_key *key)