added libtomcrypt-0.86
This commit is contained in:
parent
f5331baa9f
commit
f9afcba638
41
aes.c
41
aes.c
@ -90,7 +90,11 @@ int rijndael_setup(const unsigned char *key, int keylen, int rounds, symmetric_k
|
||||
LOAD32H(rk[4], key + 16);
|
||||
LOAD32H(rk[5], key + 20);
|
||||
for (;;) {
|
||||
temp = rk[ 5];
|
||||
#ifdef _MSC_VER
|
||||
temp = skey->rijndael.eK[rk - skey->rijndael.eK + 5];
|
||||
#else
|
||||
temp = rk[5];
|
||||
#endif
|
||||
rk[ 6] = rk[ 0] ^
|
||||
(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
@ -113,7 +117,11 @@ int rijndael_setup(const unsigned char *key, int keylen, int rounds, symmetric_k
|
||||
LOAD32H(rk[6], key + 24);
|
||||
LOAD32H(rk[7], key + 28);
|
||||
for (;;) {
|
||||
temp = rk[ 7];
|
||||
#ifdef _MSC_VER
|
||||
temp = skey->rijndael.eK[rk - skey->rijndael.eK + 7];
|
||||
#else
|
||||
temp = rk[7];
|
||||
#endif
|
||||
rk[ 8] = rk[ 0] ^
|
||||
(Te4[(temp >> 16) & 0xff] & 0xff000000) ^
|
||||
(Te4[(temp >> 8) & 0xff] & 0x00ff0000) ^
|
||||
@ -278,6 +286,15 @@ void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_
|
||||
*/
|
||||
r = Nr >> 1;
|
||||
for (;;) {
|
||||
|
||||
/* Both of these blocks are equivalent except the top is more friendlier for x86 processors */
|
||||
#if 1
|
||||
t0 = rk[4]; t1 = rk[5]; t2 = rk[6]; t3 = rk[7];
|
||||
t1 ^= Te3[(s0 ) & 0xFF]; t2 ^= Te2[(s0 >> 8) & 0xFF]; t3 ^= Te1[(s0 >> 16) & 0xFF]; t0 ^= Te0[(s0 >> 24)];
|
||||
t2 ^= Te3[(s1 ) & 0xFF]; t3 ^= Te2[(s1 >> 8) & 0xFF]; t0 ^= Te1[(s1 >> 16) & 0xFF]; t1 ^= Te0[(s1 >> 24)];
|
||||
t3 ^= Te3[(s2 ) & 0xFF]; t0 ^= Te2[(s2 >> 8) & 0xFF]; t1 ^= Te1[(s2 >> 16) & 0xFF]; t2 ^= Te0[(s2 >> 24)];
|
||||
t0 ^= Te3[(s3 ) & 0xFF]; t1 ^= Te2[(s3 >> 8) & 0xFF]; t2 ^= Te1[(s3 >> 16) & 0xFF]; t3 ^= Te0[(s3 >> 24)];
|
||||
#else
|
||||
t0 =
|
||||
Te0[(s0 >> 24) ] ^
|
||||
Te1[(s1 >> 16) & 0xff] ^
|
||||
@ -302,12 +319,21 @@ void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_
|
||||
Te2[(s1 >> 8) & 0xff] ^
|
||||
Te3[(s2 ) & 0xff] ^
|
||||
rk[7];
|
||||
|
||||
#endif
|
||||
|
||||
rk += 8;
|
||||
if (--r == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* this second half optimization actually makes it slower on the Athlon, use with caution. */
|
||||
#if 0
|
||||
s1 = rk[1]; s2 = rk[2]; s3 = rk[3]; s0 = rk[0];
|
||||
s1 ^= Te3[(t0 ) & 0xFF]; s2 ^= Te2[(t0 >> 8) & 0xFF]; s3 ^= Te1[(t0 >> 16) & 0xFF]; s0 ^= Te0[(t0 >> 24)];
|
||||
s2 ^= Te3[(t1 ) & 0xFF]; s3 ^= Te2[(t1 >> 8) & 0xFF]; s0 ^= Te1[(t1 >> 16) & 0xFF]; s1 ^= Te0[(t1 >> 24)];
|
||||
s3 ^= Te3[(t2 ) & 0xFF]; s0 ^= Te2[(t2 >> 8) & 0xFF]; s1 ^= Te1[(t2 >> 16) & 0xFF]; s2 ^= Te0[(t2 >> 24)];
|
||||
s0 ^= Te3[(t3 ) & 0xFF]; s1 ^= Te2[(t3 >> 8) & 0xFF]; s2 ^= Te1[(t3 >> 16) & 0xFF]; s3 ^= Te0[(t3 >> 24)];
|
||||
#else
|
||||
s0 =
|
||||
Te0[(t0 >> 24) ] ^
|
||||
Te1[(t1 >> 16) & 0xff] ^
|
||||
@ -332,6 +358,7 @@ void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_
|
||||
Te2[(t1 >> 8) & 0xff] ^
|
||||
Te3[(t2 ) & 0xff] ^
|
||||
rk[3];
|
||||
#endif
|
||||
}
|
||||
#endif /* SMALL_CODE */
|
||||
/*
|
||||
@ -562,7 +589,7 @@ int rijndael_test(void)
|
||||
#ifndef LTC_TEST
|
||||
return CRYPT_NOP;
|
||||
#else
|
||||
int errno;
|
||||
int err;
|
||||
static const struct {
|
||||
int keylen;
|
||||
unsigned char key[32], pt[16], ct[16];
|
||||
@ -602,8 +629,8 @@ int rijndael_test(void)
|
||||
|
||||
for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
|
||||
zeromem(&key, sizeof(key));
|
||||
if ((errno = rijndael_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) {
|
||||
return errno;
|
||||
if ((err = rijndael_setup(tests[i].key, tests[i].keylen, 0, &key)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
rijndael_ecb_encrypt(tests[i].pt, tmp[0], &key);
|
||||
|
11
changes
11
changes
@ -1,3 +1,14 @@
|
||||
Jun 15th, 2003
|
||||
v0.86 -- Fixed up AES to workaround MSVC optimizer bug
|
||||
-- Merged in fresh LTM base [based on v0.20] so there are no warnings with MSVC
|
||||
-- Wrote x86_prof which will time the hashes and ciphers downto cycles per byte.
|
||||
-- Fixed up demos/encrypt to remove serpent_desc from the list
|
||||
-- Re-enabled MSVC optimizations w00t w00t
|
||||
-- Replaced "errno" with "err" in all functions that had it so it wouldn't clash
|
||||
with the global "errno"
|
||||
-- Removed a set of unused variables from certain functions
|
||||
-- Removed {#line 0 "..."} stuff from mpi.c to comply with ISO C :-)
|
||||
|
||||
Jun 11th, 2003
|
||||
v0.85 -- Swapped in a new AES routine
|
||||
-- Removed Serpent
|
||||
|
@ -47,7 +47,7 @@
|
||||
\def\gap{\vspace{0.5ex}}
|
||||
\makeindex
|
||||
\begin{document}
|
||||
\title{A Tiny Crypto Library, \\ LibTomCrypt \\ Version 0.85}
|
||||
\title{A Tiny Crypto Library, \\ LibTomCrypt \\ Version 0.86}
|
||||
\author{Tom St Denis \\
|
||||
Algonquin College \\
|
||||
\\
|
||||
|
@ -13,7 +13,7 @@ int errno;
|
||||
|
||||
static const struct _cipher_descriptor *ciphers[] = {
|
||||
&blowfish_desc, &xtea_desc, &rc5_desc, &rc6_desc,
|
||||
&saferp_desc, &serpent_desc, &rijndael_desc,
|
||||
&saferp_desc, &rijndael_desc,
|
||||
&twofish_desc, &safer_k64_desc, &safer_sk64_desc,
|
||||
&safer_k128_desc, &safer_sk128_desc, &rc2_desc,
|
||||
&des_desc, &des3_desc, &cast5_desc, NULL
|
||||
|
28
demos/test.c
28
demos/test.c
@ -1335,30 +1335,30 @@ register_all_algs (void)
|
||||
|
||||
register_cipher (&null_desc);
|
||||
|
||||
#ifdef TIGER
|
||||
register_hash (&tiger_desc);
|
||||
#endif
|
||||
#ifdef MD2
|
||||
register_hash (&md2_desc);
|
||||
#endif
|
||||
#ifdef MD4
|
||||
register_hash (&md4_desc);
|
||||
#endif
|
||||
#ifdef MD5
|
||||
register_hash (&md5_desc);
|
||||
#endif
|
||||
#ifdef SHA1
|
||||
register_hash (&sha1_desc);
|
||||
#endif
|
||||
#ifdef SHA256
|
||||
register_hash (&sha256_desc);
|
||||
#endif
|
||||
#ifdef TIGER
|
||||
register_hash (&tiger_desc);
|
||||
#endif
|
||||
#ifdef MD5
|
||||
register_hash (&md5_desc);
|
||||
#endif
|
||||
#ifdef SHA384
|
||||
register_hash (&sha384_desc);
|
||||
#endif
|
||||
#ifdef SHA512
|
||||
register_hash (&sha512_desc);
|
||||
#endif
|
||||
#ifdef MD4
|
||||
register_hash (&md4_desc);
|
||||
#endif
|
||||
#ifdef MD2
|
||||
register_hash (&md2_desc);
|
||||
#endif
|
||||
|
||||
#ifdef YARROW
|
||||
register_prng (&yarrow_desc);
|
||||
@ -1709,7 +1709,7 @@ main (void)
|
||||
#endif
|
||||
|
||||
register_all_algs ();
|
||||
|
||||
|
||||
if ((errnum = yarrow_start (&prng)) != CRYPT_OK) {
|
||||
printf ("yarrow_start: %s\n", error_to_string (errnum));
|
||||
}
|
||||
@ -1738,7 +1738,7 @@ main (void)
|
||||
cfb_tests ();
|
||||
|
||||
rng_tests ();
|
||||
//test_prime();
|
||||
test_prime();
|
||||
|
||||
#ifdef KR
|
||||
kr_test ();
|
||||
|
47
demos/timer.asm
Normal file
47
demos/timer.asm
Normal file
@ -0,0 +1,47 @@
|
||||
; x86 timer in NASM
|
||||
;
|
||||
; Tom St Denis, tomstdenis@iahu.ca
|
||||
[bits 32]
|
||||
[section .data]
|
||||
time dd 0, 0
|
||||
|
||||
[section .text]
|
||||
|
||||
%ifdef USE_ELF
|
||||
[global t_start]
|
||||
t_start:
|
||||
%else
|
||||
[global _t_start]
|
||||
_t_start:
|
||||
%endif
|
||||
push eax
|
||||
push ebx
|
||||
push ecx
|
||||
push edx
|
||||
cpuid
|
||||
rdtsc
|
||||
mov [time+0],edx
|
||||
mov [time+4],eax
|
||||
pop edx
|
||||
pop ecx
|
||||
pop ebx
|
||||
pop eax
|
||||
ret
|
||||
|
||||
%ifdef USE_ELF
|
||||
[global t_read]
|
||||
t_read:
|
||||
%else
|
||||
[global _t_read]
|
||||
_t_read:
|
||||
%endif
|
||||
push ebx
|
||||
push ecx
|
||||
cpuid
|
||||
rdtsc
|
||||
sub eax,[time+4]
|
||||
sbb edx,[time+0]
|
||||
pop ecx
|
||||
pop ebx
|
||||
ret
|
||||
|
200
demos/x86_prof.c
Normal file
200
demos/x86_prof.c
Normal file
@ -0,0 +1,200 @@
|
||||
#include <mycrypt.h>
|
||||
|
||||
extern void t_start(void);
|
||||
extern ulong64 t_read(void);
|
||||
|
||||
void reg_algs(void)
|
||||
{
|
||||
#ifdef RIJNDAEL
|
||||
register_cipher (&aes_desc);
|
||||
#endif
|
||||
#ifdef BLOWFISH
|
||||
register_cipher (&blowfish_desc);
|
||||
#endif
|
||||
#ifdef XTEA
|
||||
register_cipher (&xtea_desc);
|
||||
#endif
|
||||
#ifdef RC5
|
||||
register_cipher (&rc5_desc);
|
||||
#endif
|
||||
#ifdef RC6
|
||||
register_cipher (&rc6_desc);
|
||||
#endif
|
||||
#ifdef SAFERP
|
||||
register_cipher (&saferp_desc);
|
||||
#endif
|
||||
#ifdef TWOFISH
|
||||
register_cipher (&twofish_desc);
|
||||
#endif
|
||||
#ifdef SAFER
|
||||
register_cipher (&safer_k64_desc);
|
||||
register_cipher (&safer_sk64_desc);
|
||||
register_cipher (&safer_k128_desc);
|
||||
register_cipher (&safer_sk128_desc);
|
||||
#endif
|
||||
#ifdef RC2
|
||||
register_cipher (&rc2_desc);
|
||||
#endif
|
||||
#ifdef DES
|
||||
register_cipher (&des_desc);
|
||||
register_cipher (&des3_desc);
|
||||
#endif
|
||||
#ifdef CAST5
|
||||
register_cipher (&cast5_desc);
|
||||
#endif
|
||||
#ifdef NOEKEON
|
||||
register_cipher (&noekeon_desc);
|
||||
#endif
|
||||
|
||||
#ifdef TIGER
|
||||
register_hash (&tiger_desc);
|
||||
#endif
|
||||
#ifdef MD2
|
||||
register_hash (&md2_desc);
|
||||
#endif
|
||||
#ifdef MD4
|
||||
register_hash (&md4_desc);
|
||||
#endif
|
||||
#ifdef MD5
|
||||
register_hash (&md5_desc);
|
||||
#endif
|
||||
#ifdef SHA1
|
||||
register_hash (&sha1_desc);
|
||||
#endif
|
||||
#ifdef SHA256
|
||||
register_hash (&sha256_desc);
|
||||
#endif
|
||||
#ifdef SHA384
|
||||
register_hash (&sha384_desc);
|
||||
#endif
|
||||
#ifdef SHA512
|
||||
register_hash (&sha512_desc);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#define TIMES 20
|
||||
|
||||
int time_cipher(void)
|
||||
{
|
||||
unsigned long x, y1;
|
||||
ulong64 t1, t2;
|
||||
symmetric_key skey;
|
||||
void (*func) (const unsigned char *, unsigned char *, symmetric_key *);
|
||||
unsigned char key[MAXBLOCKSIZE], pt[MAXBLOCKSIZE];
|
||||
|
||||
|
||||
printf ("\n\nECB Time Trials for the Symmetric Ciphers:\n");
|
||||
for (x = 0; cipher_descriptor[x].name != NULL; x++) {
|
||||
cipher_descriptor[x].setup (key, cipher_descriptor[x].min_key_length, 0,
|
||||
&skey);
|
||||
|
||||
#define DO1 func(pt,pt,&skey);
|
||||
#define DO2 DO1 DO1
|
||||
#define DO4 DO2 DO2
|
||||
#define DO8 DO4 DO4
|
||||
#define DO16 DO8 DO8
|
||||
#define DO32 DO16 DO16
|
||||
#define DO64 DO32 DO32
|
||||
#define DO128 DO64 DO64
|
||||
#define DO256 DO128 DO128
|
||||
|
||||
func = cipher_descriptor[x].ecb_encrypt;
|
||||
y1 = 1<<TIMES;
|
||||
t_start();
|
||||
do {
|
||||
DO256;
|
||||
} while ((y1 -= 256) > 0);
|
||||
t1 = t_read();
|
||||
|
||||
func = cipher_descriptor[x].ecb_decrypt;
|
||||
y1 = 1<<TIMES;
|
||||
t_start();
|
||||
do {
|
||||
DO256;
|
||||
} while ((y1 -= 256) > 0);
|
||||
t2 = t_read();
|
||||
|
||||
t1 = ((t1 * CONST64(1000)) >> TIMES) / ((ulong64)cipher_descriptor[x].block_length);
|
||||
t2 = ((t2 * CONST64(1000)) >> TIMES) / ((ulong64)cipher_descriptor[x].block_length);
|
||||
|
||||
printf
|
||||
("%-20s: Encrypt at %5.3f, Decrypt at %5.3f\n", cipher_descriptor[x].name, t1/1000.0, t2/1000.0);
|
||||
|
||||
#undef DO256
|
||||
#undef DO128
|
||||
#undef DO64
|
||||
#undef DO32
|
||||
#undef DO16
|
||||
#undef DO8
|
||||
#undef DO4
|
||||
#undef DO2
|
||||
#undef DO1
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int time_hash(void)
|
||||
{
|
||||
unsigned long x, y1, len;
|
||||
ulong64 t1;
|
||||
hash_state md;
|
||||
void (*func)(hash_state *, const unsigned char *, unsigned long);
|
||||
unsigned char pt[MAXBLOCKSIZE];
|
||||
|
||||
|
||||
printf ("HASH Time Trials for:\n");
|
||||
for (x = 0; hash_descriptor[x].name != NULL; x++) {
|
||||
hash_descriptor[x].init(&md);
|
||||
|
||||
#define DO1 func(&md,pt,len);
|
||||
#define DO2 DO1 DO1
|
||||
#define DO4 DO2 DO2
|
||||
#define DO8 DO4 DO4
|
||||
#define DO16 DO8 DO8
|
||||
#define DO32 DO16 DO16
|
||||
#define DO64 DO32 DO32
|
||||
#define DO128 DO64 DO64
|
||||
#define DO256 DO128 DO128
|
||||
|
||||
func = hash_descriptor[x].process;
|
||||
len = hash_descriptor[x].blocksize;
|
||||
y1 = 1<<TIMES;
|
||||
t_start();
|
||||
do {
|
||||
DO256;
|
||||
} while ((y1 -= 256) > 0);
|
||||
t1 = t_read();
|
||||
|
||||
t1 = ((t1 * CONST64(1000)) >> TIMES) / ((ulong64)hash_descriptor[x].blocksize);
|
||||
|
||||
printf
|
||||
("%-20s: Process at %5.3f\n", hash_descriptor[x].name, t1 / 1000.0);
|
||||
|
||||
#undef DO256
|
||||
#undef DO128
|
||||
#undef DO64
|
||||
#undef DO32
|
||||
#undef DO16
|
||||
#undef DO8
|
||||
#undef DO4
|
||||
#undef DO2
|
||||
#undef DO1
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
reg_algs();
|
||||
|
||||
printf("Timings for ciphers and hashes. Times are listed as cycles per byte processed.\n\n");
|
||||
|
||||
time_hash();
|
||||
time_cipher();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
2
des.c
2
des.c
@ -488,7 +488,7 @@ void des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *
|
||||
|
||||
void des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key)
|
||||
{
|
||||
unsigned long work[2], *k[3];
|
||||
unsigned long work[2];
|
||||
|
||||
_ARGCHK(pt != NULL);
|
||||
_ARGCHK(ct != NULL);
|
||||
|
2
ecc.c
2
ecc.c
@ -908,7 +908,7 @@ int ecc_shared_secret(ecc_key *private_key, ecc_key *public_key,
|
||||
unsigned long x, y;
|
||||
ecc_point *result;
|
||||
mp_int prime;
|
||||
int res, err;
|
||||
int res;
|
||||
|
||||
_ARGCHK(private_key != NULL);
|
||||
_ARGCHK(public_key != NULL);
|
||||
|
56
makefile
56
makefile
@ -9,7 +9,7 @@
|
||||
# a build. This is easy to remedy though, for those that have problems.
|
||||
|
||||
# The version
|
||||
VERSION=0.85
|
||||
VERSION=0.86
|
||||
|
||||
#ch1-01-1
|
||||
# Compiler and Linker Names
|
||||
@ -28,6 +28,10 @@ CFLAGS += -c -I./ -Wall -Wsign-compare -W -Wno-unused -Wshadow -Werror
|
||||
# optimize for SPEED
|
||||
#CFLAGS += -O3 -funroll-loops
|
||||
|
||||
#add -fomit-frame-pointer. v3.2 is buggy for certain platforms so this is used for files it is known to work for
|
||||
#default is off but you may enable this to get further performance [make sure you run the test suite!]
|
||||
#EXT_CFLAGS = -fomit-frame-pointer
|
||||
|
||||
# optimize for SIZE
|
||||
CFLAGS += -Os
|
||||
|
||||
@ -43,6 +47,7 @@ TEST=test
|
||||
HASH=hashsum
|
||||
CRYPT=encrypt
|
||||
SMALL=small
|
||||
PROF=x86_prof
|
||||
|
||||
#LIBPATH-The directory for libtomcrypt to be installed to.
|
||||
#INCPATH-The directory to install the header files for libtomcrypt.
|
||||
@ -63,6 +68,7 @@ TESTOBJECTS=demos/test.o
|
||||
HASHOBJECTS=demos/hashsum.o
|
||||
CRYPTOBJECTS=demos/encrypt.o
|
||||
SMALLOBJECTS=demos/small.o
|
||||
PROFS=demos/x86_prof.o
|
||||
|
||||
#Files left over from making the crypt.pdf.
|
||||
LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind
|
||||
@ -85,6 +91,43 @@ dh.o: dh.c dh_sys.c
|
||||
aes.o: aes.c aes_tab.c
|
||||
sha512.o: sha512.c sha384.c
|
||||
|
||||
#These are objects that are known to build with -fomit-frame-pointer successfully
|
||||
aes.o: aes.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c aes.c
|
||||
|
||||
blowfish.o: blowfish.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c blowfish.c
|
||||
|
||||
cast5.o: cast5.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c cast5.c
|
||||
|
||||
des.o: des.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c des.c
|
||||
|
||||
twofish.o: twofish.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c twofish.c
|
||||
|
||||
md2.o: md2.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c md2.c
|
||||
|
||||
md4.o: md4.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c md4.c
|
||||
|
||||
md5.o: md5.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c md5.c
|
||||
|
||||
sha1.o: sha1.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c sha1.c
|
||||
|
||||
sha256.o: sha256.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c sha256.c
|
||||
|
||||
sha512.o: sha512.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c sha512.c
|
||||
|
||||
tiger.o: tiger.c
|
||||
$(CC) $(CFLAGS) $(EXT_CFLAGS) -c tiger.c
|
||||
|
||||
#This rule makes the libtomcrypt library.
|
||||
library: $(OBJECTS)
|
||||
$(AR) $(ARFLAGS) $(LIBNAME) $(OBJECTS)
|
||||
@ -105,6 +148,15 @@ crypt: library $(CRYPTOBJECTS)
|
||||
#makes the small program
|
||||
small: library $(SMALLOBJECTS)
|
||||
$(CC) $(SMALLOBJECTS) $(LIBNAME) -o $(SMALL) $(WARN)
|
||||
|
||||
x86_prof: library $(PROFS)
|
||||
nasm -f coff demos/timer.asm
|
||||
$(CC) demos/x86_prof.o demos/timer.o $(LIBNAME) -o $(PROF)
|
||||
|
||||
#for linux
|
||||
x86_profl: library $(PROFS)
|
||||
nasm -f elf -DUSE_ELF demos/timer.asm
|
||||
$(CC) demos/x86_prof.o demos/timer.o $(LIBNAME) -o $(PROF)
|
||||
|
||||
#This rule installs the library and the header files. This must be run
|
||||
#as root in order to have a high enough permission to write to the correct
|
||||
@ -122,7 +174,7 @@ install: library docs
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TESTOBJECTS) $(HASHOBJECTS) $(CRYPTOBJECTS) $(SMALLOBJECTS) $(LEFTOVERS) $(LIBNAME)
|
||||
rm -f $(TEST) $(HASH) $(COMPRESSED)
|
||||
rm -f *stackdump *.lib *.exe *.obj demos/*.obj *.bat
|
||||
rm -f *stackdump *.lib *.exe *.obj demos/*.obj demos/*.o *.bat
|
||||
|
||||
#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
|
||||
#from the clean command! This is because most people would like to keep the
|
||||
|
@ -3,7 +3,7 @@
|
||||
#Tom St Denis
|
||||
|
||||
# note optimizations are turned off because it causes a bug in aes.c that cannot be rectified [right away]
|
||||
CFLAGS = /I. /Od /G3 /DWIN32 /W3
|
||||
CFLAGS = /I. /Ox /DWIN32 /W3
|
||||
|
||||
default: library
|
||||
|
||||
@ -21,4 +21,8 @@ test.obj: demos/test.c
|
||||
cl $(CFLAGS) /c demos/test.c
|
||||
|
||||
test: library test.obj
|
||||
cl test.obj tomcrypt.lib advapi32.lib
|
||||
cl test.obj tomcrypt.lib advapi32.lib
|
||||
|
||||
x86_prof: demos/x86_prof.c library
|
||||
nasm -f win32 demos/timer.asm
|
||||
cl $(CFLAGS) demos/x86_prof.c demos/timer.obj tomcrypt.lib advapi32.lib
|
134
mpi.c
134
mpi.c
@ -1,5 +1,4 @@
|
||||
/* Start: bn_fast_mp_invmod.c */
|
||||
#line 0 "bn_fast_mp_invmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -14,8 +13,7 @@
|
||||
*
|
||||
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
|
||||
*/
|
||||
#include "mycrypt.h"
|
||||
#include <tommath.h>
|
||||
#include "mycrypt.h"
|
||||
|
||||
/* computes the modular inverse via binary extended euclidean algorithm,
|
||||
* that is c = 1/a mod b
|
||||
@ -152,7 +150,6 @@ __ERR:mp_clear_multi (&x, &y, &u, &v, &B, &D, NULL);
|
||||
/* End: bn_fast_mp_invmod.c */
|
||||
|
||||
/* Start: bn_fast_mp_montgomery_reduce.c */
|
||||
#line 0 "bn_fast_mp_montgomery_reduce.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -279,7 +276,7 @@ fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
_W = W + n->used;
|
||||
|
||||
for (ix = 0; ix < n->used + 1; ix++) {
|
||||
*tmpx++ = *_W++ & ((mp_word) MP_MASK);
|
||||
*tmpx++ = (mp_digit)(*_W++ & ((mp_word) MP_MASK));
|
||||
}
|
||||
|
||||
/* zero oldused digits, if the input a was larger than
|
||||
@ -303,7 +300,6 @@ fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
/* End: bn_fast_mp_montgomery_reduce.c */
|
||||
|
||||
/* Start: bn_fast_s_mp_mul_digs.c */
|
||||
#line 0 "bn_fast_s_mp_mul_digs.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -431,7 +427,6 @@ fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
/* End: bn_fast_s_mp_mul_digs.c */
|
||||
|
||||
/* Start: bn_fast_s_mp_mul_high_digs.c */
|
||||
#line 0 "bn_fast_s_mp_mul_high_digs.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -531,7 +526,6 @@ fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
/* End: bn_fast_s_mp_mul_high_digs.c */
|
||||
|
||||
/* Start: bn_fast_s_mp_sqr.c */
|
||||
#line 0 "bn_fast_s_mp_sqr.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -665,7 +659,6 @@ fast_s_mp_sqr (mp_int * a, mp_int * b)
|
||||
/* End: bn_fast_s_mp_sqr.c */
|
||||
|
||||
/* Start: bn_mp_2expt.c */
|
||||
#line 0 "bn_mp_2expt.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -705,7 +698,6 @@ mp_2expt (mp_int * a, int b)
|
||||
/* End: bn_mp_2expt.c */
|
||||
|
||||
/* Start: bn_mp_abs.c */
|
||||
#line 0 "bn_mp_abs.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -740,7 +732,6 @@ mp_abs (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_abs.c */
|
||||
|
||||
/* Start: bn_mp_add.c */
|
||||
#line 0 "bn_mp_add.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -793,7 +784,6 @@ mp_add (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_add.c */
|
||||
|
||||
/* Start: bn_mp_add_d.c */
|
||||
#line 0 "bn_mp_add_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -830,7 +820,6 @@ mp_add_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
/* End: bn_mp_add_d.c */
|
||||
|
||||
/* Start: bn_mp_addmod.c */
|
||||
#line 0 "bn_mp_addmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -870,7 +859,6 @@ mp_addmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
/* End: bn_mp_addmod.c */
|
||||
|
||||
/* Start: bn_mp_and.c */
|
||||
#line 0 "bn_mp_and.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -926,7 +914,6 @@ mp_and (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_and.c */
|
||||
|
||||
/* Start: bn_mp_clamp.c */
|
||||
#line 0 "bn_mp_clamp.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -964,7 +951,6 @@ mp_clamp (mp_int * a)
|
||||
/* End: bn_mp_clamp.c */
|
||||
|
||||
/* Start: bn_mp_clear.c */
|
||||
#line 0 "bn_mp_clear.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1002,7 +988,6 @@ mp_clear (mp_int * a)
|
||||
/* End: bn_mp_clear.c */
|
||||
|
||||
/* Start: bn_mp_cmp.c */
|
||||
#line 0 "bn_mp_cmp.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1044,7 +1029,6 @@ mp_cmp (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_cmp.c */
|
||||
|
||||
/* Start: bn_mp_cmp_d.c */
|
||||
#line 0 "bn_mp_cmp_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1086,7 +1070,6 @@ mp_cmp_d (mp_int * a, mp_digit b)
|
||||
/* End: bn_mp_cmp_d.c */
|
||||
|
||||
/* Start: bn_mp_cmp_mag.c */
|
||||
#line 0 "bn_mp_cmp_mag.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1134,7 +1117,6 @@ mp_cmp_mag (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_cmp_mag.c */
|
||||
|
||||
/* Start: bn_mp_copy.c */
|
||||
#line 0 "bn_mp_copy.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1193,7 +1175,6 @@ mp_copy (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_copy.c */
|
||||
|
||||
/* Start: bn_mp_count_bits.c */
|
||||
#line 0 "bn_mp_count_bits.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1237,7 +1218,6 @@ mp_count_bits (mp_int * a)
|
||||
/* End: bn_mp_count_bits.c */
|
||||
|
||||
/* Start: bn_mp_div.c */
|
||||
#line 0 "bn_mp_div.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1442,7 +1422,6 @@ __Q:mp_clear (&q);
|
||||
/* End: bn_mp_div.c */
|
||||
|
||||
/* Start: bn_mp_div_2.c */
|
||||
#line 0 "bn_mp_div_2.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1510,7 +1489,6 @@ mp_div_2 (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_div_2.c */
|
||||
|
||||
/* Start: bn_mp_div_2d.c */
|
||||
#line 0 "bn_mp_div_2d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1604,7 +1582,6 @@ mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d)
|
||||
/* End: bn_mp_div_2d.c */
|
||||
|
||||
/* Start: bn_mp_div_3.c */
|
||||
#line 0 "bn_mp_div_3.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1653,11 +1630,11 @@ mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
|
||||
} else {
|
||||
t = 0;
|
||||
}
|
||||
q.dp[ix] = t;
|
||||
q.dp[ix] = (mp_digit)t;
|
||||
}
|
||||
|
||||
if (d != NULL) {
|
||||
*d = w;
|
||||
*d = (mp_digit)w;
|
||||
}
|
||||
|
||||
if (c != NULL) {
|
||||
@ -1673,7 +1650,6 @@ mp_div_3 (mp_int * a, mp_int *c, mp_digit * d)
|
||||
/* End: bn_mp_div_3.c */
|
||||
|
||||
/* Start: bn_mp_div_d.c */
|
||||
#line 0 "bn_mp_div_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1722,11 +1698,11 @@ mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
|
||||
} else {
|
||||
t = 0;
|
||||
}
|
||||
q.dp[ix] = t;
|
||||
q.dp[ix] = (mp_digit)t;
|
||||
}
|
||||
|
||||
if (d != NULL) {
|
||||
*d = w;
|
||||
*d = (mp_digit)w;
|
||||
}
|
||||
|
||||
if (c != NULL) {
|
||||
@ -1742,7 +1718,6 @@ mp_div_d (mp_int * a, mp_digit b, mp_int * c, mp_digit * d)
|
||||
/* End: bn_mp_div_d.c */
|
||||
|
||||
/* Start: bn_mp_dr_is_modulus.c */
|
||||
#line 0 "bn_mp_dr_is_modulus.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1781,7 +1756,6 @@ int mp_dr_is_modulus(mp_int *a)
|
||||
/* End: bn_mp_dr_is_modulus.c */
|
||||
|
||||
/* Start: bn_mp_dr_reduce.c */
|
||||
#line 0 "bn_mp_dr_reduce.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1844,8 +1818,8 @@ top:
|
||||
/* compute (x mod B**m) + mp * [x/B**m] inline and inplace */
|
||||
for (i = 0; i < m; i++) {
|
||||
r = ((mp_word)*tmpx2++) * ((mp_word)k) + *tmpx1 + mu;
|
||||
*tmpx1++ = r & MP_MASK;
|
||||
mu = r >> ((mp_word)DIGIT_BIT);
|
||||
*tmpx1++ = (mp_digit)(r & MP_MASK);
|
||||
mu = (mp_digit)(r >> ((mp_word)DIGIT_BIT));
|
||||
}
|
||||
|
||||
/* set final carry */
|
||||
@ -1872,7 +1846,6 @@ top:
|
||||
/* End: bn_mp_dr_reduce.c */
|
||||
|
||||
/* Start: bn_mp_dr_setup.c */
|
||||
#line 0 "bn_mp_dr_setup.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1903,7 +1876,6 @@ void mp_dr_setup(mp_int *a, mp_digit *d)
|
||||
/* End: bn_mp_dr_setup.c */
|
||||
|
||||
/* Start: bn_mp_exch.c */
|
||||
#line 0 "bn_mp_exch.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1936,7 +1908,6 @@ mp_exch (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_exch.c */
|
||||
|
||||
/* Start: bn_mp_expt_d.c */
|
||||
#line 0 "bn_mp_expt_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -1993,7 +1964,6 @@ mp_expt_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
/* End: bn_mp_expt_d.c */
|
||||
|
||||
/* Start: bn_mp_exptmod.c */
|
||||
#line 0 "bn_mp_exptmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2073,7 +2043,6 @@ mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y)
|
||||
/* End: bn_mp_exptmod.c */
|
||||
|
||||
/* Start: bn_mp_exptmod_fast.c */
|
||||
#line 0 "bn_mp_exptmod_fast.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2156,7 +2125,6 @@ mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode)
|
||||
if (((P->used * 2 + 1) < MP_WARRAY) &&
|
||||
P->used < (1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
|
||||
redux = fast_mp_montgomery_reduce;
|
||||
|
||||
} else {
|
||||
/* use slower baselien method */
|
||||
redux = mp_montgomery_reduce;
|
||||
@ -2343,7 +2311,6 @@ __M:
|
||||
/* End: bn_mp_exptmod_fast.c */
|
||||
|
||||
/* Start: bn_mp_gcd.c */
|
||||
#line 0 "bn_mp_gcd.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2467,7 +2434,6 @@ __U:mp_clear (&v);
|
||||
/* End: bn_mp_gcd.c */
|
||||
|
||||
/* Start: bn_mp_grow.c */
|
||||
#line 0 "bn_mp_grow.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2513,7 +2479,6 @@ mp_grow (mp_int * a, int size)
|
||||
/* End: bn_mp_grow.c */
|
||||
|
||||
/* Start: bn_mp_init.c */
|
||||
#line 0 "bn_mp_init.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2552,7 +2517,6 @@ mp_init (mp_int * a)
|
||||
/* End: bn_mp_init.c */
|
||||
|
||||
/* Start: bn_mp_init_copy.c */
|
||||
#line 0 "bn_mp_init_copy.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2584,7 +2548,6 @@ mp_init_copy (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_init_copy.c */
|
||||
|
||||
/* Start: bn_mp_init_size.c */
|
||||
#line 0 "bn_mp_init_size.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2624,7 +2587,6 @@ mp_init_size (mp_int * a, int size)
|
||||
/* End: bn_mp_init_size.c */
|
||||
|
||||
/* Start: bn_mp_invmod.c */
|
||||
#line 0 "bn_mp_invmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2795,7 +2757,6 @@ __ERR:mp_clear_multi (&x, &y, &u, &v, &A, &B, &C, &D, NULL);
|
||||
/* End: bn_mp_invmod.c */
|
||||
|
||||
/* Start: bn_mp_jacobi.c */
|
||||
#line 0 "bn_mp_jacobi.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -2914,7 +2875,6 @@ __A1:mp_clear (&a1);
|
||||
/* End: bn_mp_jacobi.c */
|
||||
|
||||
/* Start: bn_mp_karatsuba_mul.c */
|
||||
#line 0 "bn_mp_karatsuba_mul.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3084,7 +3044,6 @@ ERR:
|
||||
/* End: bn_mp_karatsuba_mul.c */
|
||||
|
||||
/* Start: bn_mp_karatsuba_sqr.c */
|
||||
#line 0 "bn_mp_karatsuba_sqr.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3205,7 +3164,6 @@ ERR:
|
||||
/* End: bn_mp_karatsuba_sqr.c */
|
||||
|
||||
/* Start: bn_mp_lcm.c */
|
||||
#line 0 "bn_mp_lcm.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3252,7 +3210,6 @@ mp_lcm (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_lcm.c */
|
||||
|
||||
/* Start: bn_mp_lshd.c */
|
||||
#line 0 "bn_mp_lshd.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3319,7 +3276,6 @@ mp_lshd (mp_int * a, int b)
|
||||
/* End: bn_mp_lshd.c */
|
||||
|
||||
/* Start: bn_mp_mod.c */
|
||||
#line 0 "bn_mp_mod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3367,7 +3323,6 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_mod.c */
|
||||
|
||||
/* Start: bn_mp_mod_2d.c */
|
||||
#line 0 "bn_mp_mod_2d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3422,7 +3377,6 @@ mp_mod_2d (mp_int * a, int b, mp_int * c)
|
||||
/* End: bn_mp_mod_2d.c */
|
||||
|
||||
/* Start: bn_mp_mod_d.c */
|
||||
#line 0 "bn_mp_mod_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3448,7 +3402,6 @@ mp_mod_d (mp_int * a, mp_digit b, mp_digit * c)
|
||||
/* End: bn_mp_mod_d.c */
|
||||
|
||||
/* Start: bn_mp_montgomery_calc_normalization.c */
|
||||
#line 0 "bn_mp_montgomery_calc_normalization.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3506,7 +3459,6 @@ mp_montgomery_calc_normalization (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_montgomery_calc_normalization.c */
|
||||
|
||||
/* Start: bn_mp_montgomery_reduce.c */
|
||||
#line 0 "bn_mp_montgomery_reduce.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3570,10 +3522,10 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
|
||||
/* Multiply and add in place */
|
||||
for (iy = 0; iy < n->used; iy++) {
|
||||
r = ((mp_word) mu) * ((mp_word) * tmpn++) +
|
||||
((mp_word) u) + ((mp_word) * tmpx);
|
||||
u = (r >> ((mp_word) DIGIT_BIT));
|
||||
*tmpx++ = (r & ((mp_word) MP_MASK));
|
||||
r = ((mp_word) mu) * ((mp_word) * tmpn++) +
|
||||
((mp_word) u) + ((mp_word) * tmpx);
|
||||
u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
|
||||
*tmpx++ = (mp_digit)(r & ((mp_word) MP_MASK));
|
||||
}
|
||||
/* propagate carries */
|
||||
while (u) {
|
||||
@ -3599,7 +3551,6 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
|
||||
/* End: bn_mp_montgomery_reduce.c */
|
||||
|
||||
/* Start: bn_mp_montgomery_setup.c */
|
||||
#line 0 "bn_mp_montgomery_setup.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3657,7 +3608,6 @@ mp_montgomery_setup (mp_int * n, mp_digit * rho)
|
||||
/* End: bn_mp_montgomery_setup.c */
|
||||
|
||||
/* Start: bn_mp_mul.c */
|
||||
#line 0 "bn_mp_mul.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3711,7 +3661,6 @@ mp_mul (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_mul.c */
|
||||
|
||||
/* Start: bn_mp_mul_2.c */
|
||||
#line 0 "bn_mp_mul_2.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3793,7 +3742,6 @@ mp_mul_2 (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_mul_2.c */
|
||||
|
||||
/* Start: bn_mp_mul_2d.c */
|
||||
#line 0 "bn_mp_mul_2d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3877,7 +3825,6 @@ mp_mul_2d (mp_int * a, int b, mp_int * c)
|
||||
/* End: bn_mp_mul_2d.c */
|
||||
|
||||
/* Start: bn_mp_mul_d.c */
|
||||
#line 0 "bn_mp_mul_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3953,7 +3900,6 @@ mp_mul_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
/* End: bn_mp_mul_d.c */
|
||||
|
||||
/* Start: bn_mp_mulmod.c */
|
||||
#line 0 "bn_mp_mulmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -3994,7 +3940,6 @@ mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
/* End: bn_mp_mulmod.c */
|
||||
|
||||
/* Start: bn_mp_multi.c */
|
||||
#line 0 "bn_mp_multi.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4063,7 +4008,6 @@ void mp_clear_multi(mp_int *mp, ...)
|
||||
/* End: bn_mp_multi.c */
|
||||
|
||||
/* Start: bn_mp_n_root.c */
|
||||
#line 0 "bn_mp_n_root.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4187,7 +4131,6 @@ __T1:mp_clear (&t1);
|
||||
/* End: bn_mp_n_root.c */
|
||||
|
||||
/* Start: bn_mp_neg.c */
|
||||
#line 0 "bn_mp_neg.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4219,7 +4162,6 @@ mp_neg (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_neg.c */
|
||||
|
||||
/* Start: bn_mp_or.c */
|
||||
#line 0 "bn_mp_or.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4269,7 +4211,6 @@ mp_or (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_or.c */
|
||||
|
||||
/* Start: bn_mp_prime_fermat.c */
|
||||
#line 0 "bn_mp_prime_fermat.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4326,7 +4267,6 @@ __T:mp_clear (&t);
|
||||
/* End: bn_mp_prime_fermat.c */
|
||||
|
||||
/* Start: bn_mp_prime_is_divisible.c */
|
||||
#line 0 "bn_mp_prime_is_divisible.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4381,7 +4321,6 @@ mp_prime_is_divisible (mp_int * a, int *result)
|
||||
/* End: bn_mp_prime_is_divisible.c */
|
||||
|
||||
/* Start: bn_mp_prime_is_prime.c */
|
||||
#line 0 "bn_mp_prime_is_prime.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4462,7 +4401,6 @@ __B:mp_clear (&b);
|
||||
/* End: bn_mp_prime_is_prime.c */
|
||||
|
||||
/* Start: bn_mp_prime_miller_rabin.c */
|
||||
#line 0 "bn_mp_prime_miller_rabin.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4557,7 +4495,6 @@ __N1:mp_clear (&n1);
|
||||
/* End: bn_mp_prime_miller_rabin.c */
|
||||
|
||||
/* Start: bn_mp_prime_next_prime.c */
|
||||
#line 0 "bn_mp_prime_next_prime.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4616,7 +4553,6 @@ int mp_prime_next_prime(mp_int *a, int t)
|
||||
/* End: bn_mp_prime_next_prime.c */
|
||||
|
||||
/* Start: bn_mp_rand.c */
|
||||
#line 0 "bn_mp_rand.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4670,7 +4606,6 @@ mp_rand (mp_int * a, int digits)
|
||||
/* End: bn_mp_rand.c */
|
||||
|
||||
/* Start: bn_mp_read_signed_bin.c */
|
||||
#line 0 "bn_mp_read_signed_bin.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4703,7 +4638,6 @@ mp_read_signed_bin (mp_int * a, unsigned char *b, int c)
|
||||
/* End: bn_mp_read_signed_bin.c */
|
||||
|
||||
/* Start: bn_mp_read_unsigned_bin.c */
|
||||
#line 0 "bn_mp_read_unsigned_bin.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4747,7 +4681,6 @@ mp_read_unsigned_bin (mp_int * a, unsigned char *b, int c)
|
||||
/* End: bn_mp_read_unsigned_bin.c */
|
||||
|
||||
/* Start: bn_mp_reduce.c */
|
||||
#line 0 "bn_mp_reduce.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4782,8 +4715,8 @@ mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
|
||||
/* q1 = x / b**(k-1) */
|
||||
mp_rshd (&q, um - 1);
|
||||
|
||||
/* according to HAC this is optimization is ok */
|
||||
if (((unsigned long) m->used) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
|
||||
/* according to HAC this optimization is ok */
|
||||
if (((unsigned long) um) > (((mp_digit)1) << (DIGIT_BIT - 1))) {
|
||||
if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) {
|
||||
goto CLEANUP;
|
||||
}
|
||||
@ -4823,7 +4756,7 @@ mp_reduce (mp_int * x, mp_int * m, mp_int * mu)
|
||||
/* Back off if it's too big */
|
||||
while (mp_cmp (x, m) != MP_LT) {
|
||||
if ((res = s_mp_sub (x, m, x)) != MP_OKAY) {
|
||||
break;
|
||||
goto CLEANUP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4836,7 +4769,6 @@ CLEANUP:
|
||||
/* End: bn_mp_reduce.c */
|
||||
|
||||
/* Start: bn_mp_reduce_2k.c */
|
||||
#line 0 "bn_mp_reduce_2k.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4897,7 +4829,6 @@ ERR:
|
||||
/* End: bn_mp_reduce_2k.c */
|
||||
|
||||
/* Start: bn_mp_reduce_2k_setup.c */
|
||||
#line 0 "bn_mp_reduce_2k_setup.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4944,7 +4875,6 @@ mp_reduce_2k_setup(mp_int *a, mp_digit *d)
|
||||
/* End: bn_mp_reduce_2k_setup.c */
|
||||
|
||||
/* Start: bn_mp_reduce_is_2k.c */
|
||||
#line 0 "bn_mp_reduce_is_2k.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -4987,7 +4917,6 @@ mp_reduce_is_2k(mp_int *a)
|
||||
/* End: bn_mp_reduce_is_2k.c */
|
||||
|
||||
/* Start: bn_mp_reduce_setup.c */
|
||||
#line 0 "bn_mp_reduce_setup.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5021,7 +4950,6 @@ mp_reduce_setup (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_reduce_setup.c */
|
||||
|
||||
/* Start: bn_mp_rshd.c */
|
||||
#line 0 "bn_mp_rshd.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5093,7 +5021,6 @@ mp_rshd (mp_int * a, int b)
|
||||
/* End: bn_mp_rshd.c */
|
||||
|
||||
/* Start: bn_mp_set.c */
|
||||
#line 0 "bn_mp_set.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5122,7 +5049,6 @@ mp_set (mp_int * a, mp_digit b)
|
||||
/* End: bn_mp_set.c */
|
||||
|
||||
/* Start: bn_mp_set_int.c */
|
||||
#line 0 "bn_mp_set_int.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5169,7 +5095,6 @@ mp_set_int (mp_int * a, unsigned int b)
|
||||
/* End: bn_mp_set_int.c */
|
||||
|
||||
/* Start: bn_mp_shrink.c */
|
||||
#line 0 "bn_mp_shrink.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5202,7 +5127,6 @@ mp_shrink (mp_int * a)
|
||||
/* End: bn_mp_shrink.c */
|
||||
|
||||
/* Start: bn_mp_signed_bin_size.c */
|
||||
#line 0 "bn_mp_signed_bin_size.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5229,7 +5153,6 @@ mp_signed_bin_size (mp_int * a)
|
||||
/* End: bn_mp_signed_bin_size.c */
|
||||
|
||||
/* Start: bn_mp_sqr.c */
|
||||
#line 0 "bn_mp_sqr.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5273,7 +5196,6 @@ mp_sqr (mp_int * a, mp_int * b)
|
||||
/* End: bn_mp_sqr.c */
|
||||
|
||||
/* Start: bn_mp_sqrmod.c */
|
||||
#line 0 "bn_mp_sqrmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5314,7 +5236,6 @@ mp_sqrmod (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_sqrmod.c */
|
||||
|
||||
/* Start: bn_mp_sub.c */
|
||||
#line 0 "bn_mp_sub.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5372,7 +5293,6 @@ mp_sub (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_sub.c */
|
||||
|
||||
/* Start: bn_mp_sub_d.c */
|
||||
#line 0 "bn_mp_sub_d.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5410,7 +5330,6 @@ mp_sub_d (mp_int * a, mp_digit b, mp_int * c)
|
||||
/* End: bn_mp_sub_d.c */
|
||||
|
||||
/* Start: bn_mp_submod.c */
|
||||
#line 0 "bn_mp_submod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5451,7 +5370,6 @@ mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
|
||||
/* End: bn_mp_submod.c */
|
||||
|
||||
/* Start: bn_mp_to_signed_bin.c */
|
||||
#line 0 "bn_mp_to_signed_bin.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5484,7 +5402,6 @@ mp_to_signed_bin (mp_int * a, unsigned char *b)
|
||||
/* End: bn_mp_to_signed_bin.c */
|
||||
|
||||
/* Start: bn_mp_to_unsigned_bin.c */
|
||||
#line 0 "bn_mp_to_unsigned_bin.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5532,7 +5449,6 @@ mp_to_unsigned_bin (mp_int * a, unsigned char *b)
|
||||
/* End: bn_mp_to_unsigned_bin.c */
|
||||
|
||||
/* Start: bn_mp_toom_mul.c */
|
||||
#line 0 "bn_mp_toom_mul.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -5810,7 +5726,6 @@ ERR:
|
||||
/* End: bn_mp_toom_mul.c */
|
||||
|
||||
/* Start: bn_mp_toom_sqr.c */
|
||||
#line 0 "bn_mp_toom_sqr.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6035,7 +5950,6 @@ ERR:
|
||||
/* End: bn_mp_toom_sqr.c */
|
||||
|
||||
/* Start: bn_mp_unsigned_bin_size.c */
|
||||
#line 0 "bn_mp_unsigned_bin_size.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6063,7 +5977,6 @@ mp_unsigned_bin_size (mp_int * a)
|
||||
/* End: bn_mp_unsigned_bin_size.c */
|
||||
|
||||
/* Start: bn_mp_xor.c */
|
||||
#line 0 "bn_mp_xor.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6113,7 +6026,6 @@ mp_xor (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_mp_xor.c */
|
||||
|
||||
/* Start: bn_mp_zero.c */
|
||||
#line 0 "bn_mp_zero.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6142,7 +6054,6 @@ mp_zero (mp_int * a)
|
||||
/* End: bn_mp_zero.c */
|
||||
|
||||
/* Start: bn_prime_tab.c */
|
||||
#line 0 "bn_prime_tab.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6202,7 +6113,6 @@ const mp_digit __prime_tab[] = {
|
||||
/* End: bn_prime_tab.c */
|
||||
|
||||
/* Start: bn_radix.c */
|
||||
#line 0 "bn_radix.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6429,7 +6339,6 @@ int mp_fwrite(mp_int *a, int radix, FILE *stream)
|
||||
/* End: bn_radix.c */
|
||||
|
||||
/* Start: bn_reverse.c */
|
||||
#line 0 "bn_reverse.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6467,7 +6376,6 @@ bn_reverse (unsigned char *s, int len)
|
||||
/* End: bn_reverse.c */
|
||||
|
||||
/* Start: bn_s_mp_add.c */
|
||||
#line 0 "bn_s_mp_add.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6575,7 +6483,6 @@ s_mp_add (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_s_mp_add.c */
|
||||
|
||||
/* Start: bn_s_mp_exptmod.c */
|
||||
#line 0 "bn_s_mp_exptmod.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6796,7 +6703,6 @@ __M:
|
||||
/* End: bn_s_mp_exptmod.c */
|
||||
|
||||
/* Start: bn_s_mp_mul_digs.c */
|
||||
#line 0 "bn_s_mp_mul_digs.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6886,7 +6792,6 @@ s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
/* End: bn_s_mp_mul_digs.c */
|
||||
|
||||
/* Start: bn_s_mp_mul_high_digs.c */
|
||||
#line 0 "bn_s_mp_mul_high_digs.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -6963,7 +6868,6 @@ s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
|
||||
/* End: bn_s_mp_mul_high_digs.c */
|
||||
|
||||
/* Start: bn_s_mp_sqr.c */
|
||||
#line 0 "bn_s_mp_sqr.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -7005,7 +6909,7 @@ s_mp_sqr (mp_int * a, mp_int * b)
|
||||
t.dp[2*ix] = (mp_digit) (r & ((mp_word) MP_MASK));
|
||||
|
||||
/* get the carry */
|
||||
u = (r >> ((mp_word) DIGIT_BIT));
|
||||
u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
|
||||
|
||||
/* left hand side of A[ix] * A[iy] */
|
||||
tmpx = a->dp[ix];
|
||||
@ -7026,13 +6930,13 @@ s_mp_sqr (mp_int * a, mp_int * b)
|
||||
*tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
|
||||
|
||||
/* get carry */
|
||||
u = (r >> ((mp_word) DIGIT_BIT));
|
||||
u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
|
||||
}
|
||||
/* propagate upwards */
|
||||
while (u != ((mp_digit) 0)) {
|
||||
r = ((mp_word) * tmpt) + ((mp_word) u);
|
||||
*tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
|
||||
u = (r >> ((mp_word) DIGIT_BIT));
|
||||
u = (mp_digit)(r >> ((mp_word) DIGIT_BIT));
|
||||
}
|
||||
}
|
||||
|
||||
@ -7045,7 +6949,6 @@ s_mp_sqr (mp_int * a, mp_int * b)
|
||||
/* End: bn_s_mp_sqr.c */
|
||||
|
||||
/* Start: bn_s_mp_sub.c */
|
||||
#line 0 "bn_s_mp_sub.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
@ -7133,7 +7036,6 @@ s_mp_sub (mp_int * a, mp_int * b, mp_int * c)
|
||||
/* End: bn_s_mp_sub.c */
|
||||
|
||||
/* Start: bncore.c */
|
||||
#line 0 "bncore.c"
|
||||
/* LibTomMath, multiple-precision integer library -- Tom St Denis
|
||||
*
|
||||
* LibTomMath is library that provides for multiple-precision
|
||||
|
@ -16,8 +16,8 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* version */
|
||||
#define CRYPT 0x0085
|
||||
#define SCRYPT "0.85"
|
||||
#define CRYPT 0x0086
|
||||
#define SCRYPT "0.86"
|
||||
|
||||
/* max size of either a cipher/hash block or symmetric key [largest of the two] */
|
||||
#define MAXBLOCKSIZE 128
|
||||
|
@ -23,7 +23,7 @@ extern clock_t XCLOCK(void);
|
||||
|
||||
/* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code */
|
||||
/* detect x86-32 machines somewhat */
|
||||
#if (defined(_MSC_VER) && defined(WIN32)) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__)))
|
||||
#if (defined(_MSC_VER) && defined(WIN32)) || (defined(__GNUC__) && (defined(__DJGPP__) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__i386__)))
|
||||
#define ENDIAN_LITTLE
|
||||
#define ENDIAN_32BITWORD
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define MYCRYPT_CUSTOM_H_
|
||||
|
||||
#ifdef CRYPT
|
||||
#error mycrypt_custom.h should be included before mycrypt.h
|
||||
#error mycrypt_custom.h should be included before mycrypt.h
|
||||
#endif
|
||||
|
||||
#define XMALLOC malloc
|
||||
|
@ -12,7 +12,7 @@ extern void zeromem(void *dst, size_t len);
|
||||
extern void burn_stack(unsigned long len);
|
||||
|
||||
/* ch1-01-1*/
|
||||
extern const char *error_to_string(int errno);
|
||||
extern const char *error_to_string(int err);
|
||||
/* ch1-01-1*/
|
||||
|
||||
extern const char *crypt_build_settings;
|
||||
|
6
safer+.c
6
safer+.c
@ -446,11 +446,11 @@ int saferp_test(void)
|
||||
|
||||
unsigned char buf[2][16];
|
||||
symmetric_key skey;
|
||||
int errno, i;
|
||||
int err, i;
|
||||
|
||||
for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) {
|
||||
if ((errno = saferp_setup(tests[i].key, tests[i].keylen, 0, &skey)) != CRYPT_OK) {
|
||||
return errno;
|
||||
if ((err = saferp_setup(tests[i].key, tests[i].keylen, 0, &skey)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
saferp_ecb_encrypt(tests[i].pt, buf[0], &skey);
|
||||
saferp_ecb_decrypt(buf[0], buf[1], &skey);
|
||||
|
2
sha1.c
2
sha1.c
@ -25,7 +25,7 @@ static void _sha1_compress(hash_state *md)
|
||||
static void sha1_compress(hash_state *md)
|
||||
#endif
|
||||
{
|
||||
unsigned long a,b,c,d,e,W[80],i,j,j2,j3;
|
||||
unsigned long a,b,c,d,e,W[80],i,j;
|
||||
|
||||
_ARGCHK(md != NULL);
|
||||
|
||||
|
2
sha512.c
2
sha512.c
@ -152,7 +152,7 @@ void sha512_process(hash_state * md, const unsigned char *buf, unsigned long len
|
||||
buf += n;
|
||||
len -= n;
|
||||
|
||||
/* is 64 bytes full? */
|
||||
/* is 128 bytes full? */
|
||||
if (md->sha512.curlen == 128) {
|
||||
sha512_compress(md);
|
||||
md->sha512.length += 1024;
|
||||
|
@ -37,12 +37,12 @@ static const char *err_2_str[] =
|
||||
"Invalid size for prime."
|
||||
};
|
||||
|
||||
const char *error_to_string(int errno)
|
||||
const char *error_to_string(int err)
|
||||
{
|
||||
if (errno < 0 || errno >= (int)(sizeof(err_2_str)/sizeof(err_2_str[0]))) {
|
||||
if (err < 0 || err >= (int)(sizeof(err_2_str)/sizeof(err_2_str[0]))) {
|
||||
return "Invalid error code.";
|
||||
} else {
|
||||
return err_2_str[errno];
|
||||
return err_2_str[err];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user