added libtomcrypt-1.03

This commit is contained in:
Tom St Denis
2005-06-09 00:08:13 +00:00
committed by Steffen Jaeckel
parent 65c1317eee
commit 3964a6523a
285 changed files with 5920 additions and 2287 deletions
+5 -1
View File
@@ -127,7 +127,7 @@ int SETUP(const unsigned char *key, int keylen, int num_rounds, symmetric_key *s
#endif
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(skey != NULL);
if (keylen != 16 && keylen != 24 && keylen != 32) {
return CRYPT_INVALID_KEYSIZE;
}
@@ -747,3 +747,7 @@ int ECB_KS(int *keysize)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -1018,3 +1018,7 @@ static const ulong32 rcon[] = {
0x10000000UL, 0x20000000UL, 0x40000000UL, 0x80000000UL,
0x1B000000UL, 0x36000000UL, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
};
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -1548,3 +1548,7 @@ int anubis_keysize(int *keysize)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -581,3 +581,7 @@ int blowfish_keysize(int *keysize)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -709,3 +709,7 @@ int cast5_keysize(int *keysize)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -1888,3 +1888,7 @@ int des3_keysize(int *keysize)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -845,3 +845,7 @@ int khazad_keysize(int *keysize)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -290,3 +290,7 @@ int noekeon_keysize(int *keysize)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -348,3 +348,7 @@ int rc2_keysize(int *keysize)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -308,3 +308,7 @@ int rc5_keysize(int *keysize)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -337,3 +337,7 @@ int rc6_keysize(int *keysize)
#endif /*RC6*/
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -481,3 +481,7 @@ int safer_sk128_test(void)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -62,3 +62,7 @@ const unsigned char safer_lbox[256] = {
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -549,3 +549,7 @@ int saferp_keysize(int *keysize)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -329,3 +329,7 @@ int skipjack_keysize(int *keysize)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+5 -1
View File
@@ -576,7 +576,7 @@ void twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_k
b = RORc(b ^ (t2 + t1 + k[3]), 1);
t2 = g1_func(b, skey);
t1 = g_func(a, key) + t2;
t1 = g_func(a, skey) + t2;
c = ROLc(c, 1) ^ (t1 + k[0]);
d = RORc(d ^ (t2 + t1 + k[1]), 1);
k -= 4;
@@ -700,3 +700,7 @@ int twofish_keysize(int *keysize)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -490,3 +490,7 @@ static const ulong32 rs_tab7[256] = {
#endif /* TWOFISH_ALL_TABLES */
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -201,3 +201,7 @@ int xtea_keysize(int *keysize)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4 -1
View File
@@ -293,7 +293,6 @@ int ccm_memory(int cipher,
#ifdef LTC_CLEAN_STACK
zeromem(skey, sizeof(*skey));
zeromem(B, sizeof(B));
zeromem(PAD, sizeof(PAD));
zeromem(CTRPAD, sizeof(CTRPAD));
#endif
@@ -304,3 +303,7 @@ int ccm_memory(int cipher,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -168,3 +168,7 @@ int ccm_test(void)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -32,3 +32,7 @@ int eax_addheader(eax_state *eax, const unsigned char *header,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -44,3 +44,7 @@ int eax_decrypt(eax_state *eax, const unsigned char *ct, unsigned char *pt,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
@@ -102,3 +102,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -88,3 +88,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -45,3 +45,7 @@ int eax_encrypt(eax_state *eax, const unsigned char *pt, unsigned char *ct,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
@@ -76,3 +76,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+5 -3
View File
@@ -108,11 +108,9 @@ int eax_init(eax_state *eax, int cipher,
/* note we don't finish the headeromac, this allows us to add more header later */
/* setup the CTR mode */
if ((err = ctr_start(cipher, eax->N, key, keylen, 0, &eax->ctr)) != CRYPT_OK) {
if ((err = ctr_start(cipher, eax->N, key, keylen, 0, CTR_COUNTER_BIG_ENDIAN, &eax->ctr)) != CRYPT_OK) {
goto LBL_ERR;
}
/* use big-endian counter */
eax->ctr.mode = 1;
/* setup the OMAC for the ciphertext */
if ((err = omac_init(&eax->ctomac, cipher, key, keylen)) != CRYPT_OK) {
@@ -140,3 +138,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -276,3 +276,7 @@ int eax_test(void)
}
#endif /* EAX_MODE */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+8 -1
View File
@@ -27,8 +27,11 @@
int gcm_add_aad(gcm_state *gcm,
const unsigned char *adata, unsigned long adatalen)
{
unsigned long x, y;
unsigned long x;
int err;
#ifdef LTC_FAST
unsigned long y;
#endif
LTC_ARGCHK(gcm != NULL);
if (adatalen > 0) {
@@ -115,3 +118,7 @@ int gcm_add_aad(gcm_state *gcm,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -88,3 +88,7 @@ int gcm_add_iv(gcm_state *gcm,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -75,3 +75,7 @@ int gcm_done(gcm_state *gcm,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+5
View File
@@ -31,6 +31,7 @@ static void gcm_rightshift(unsigned char *a)
static const unsigned char mask[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
static const unsigned char poly[] = { 0x00, 0xE1 };
/**
GCM GF multiplier (internal use only)
@param a First value
@@ -87,3 +88,7 @@ void gcm_mult_h(gcm_state *gcm, unsigned char *I)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+64 -7
View File
@@ -17,6 +17,46 @@
#ifdef GCM_MODE
#ifdef GCM_TABLES
/* this is x*2^128 mod p(x) ... the results are 16 bytes each stored in a packed format. Since only the
* lower 16 bits are not zero'ed I removed the upper 14 bytes */
static const unsigned char gcm_shift_table[256*2] = {
0x00, 0x00, 0x01, 0xc2, 0x03, 0x84, 0x02, 0x46, 0x07, 0x08, 0x06, 0xca, 0x04, 0x8c, 0x05, 0x4e,
0x0e, 0x10, 0x0f, 0xd2, 0x0d, 0x94, 0x0c, 0x56, 0x09, 0x18, 0x08, 0xda, 0x0a, 0x9c, 0x0b, 0x5e,
0x1c, 0x20, 0x1d, 0xe2, 0x1f, 0xa4, 0x1e, 0x66, 0x1b, 0x28, 0x1a, 0xea, 0x18, 0xac, 0x19, 0x6e,
0x12, 0x30, 0x13, 0xf2, 0x11, 0xb4, 0x10, 0x76, 0x15, 0x38, 0x14, 0xfa, 0x16, 0xbc, 0x17, 0x7e,
0x38, 0x40, 0x39, 0x82, 0x3b, 0xc4, 0x3a, 0x06, 0x3f, 0x48, 0x3e, 0x8a, 0x3c, 0xcc, 0x3d, 0x0e,
0x36, 0x50, 0x37, 0x92, 0x35, 0xd4, 0x34, 0x16, 0x31, 0x58, 0x30, 0x9a, 0x32, 0xdc, 0x33, 0x1e,
0x24, 0x60, 0x25, 0xa2, 0x27, 0xe4, 0x26, 0x26, 0x23, 0x68, 0x22, 0xaa, 0x20, 0xec, 0x21, 0x2e,
0x2a, 0x70, 0x2b, 0xb2, 0x29, 0xf4, 0x28, 0x36, 0x2d, 0x78, 0x2c, 0xba, 0x2e, 0xfc, 0x2f, 0x3e,
0x70, 0x80, 0x71, 0x42, 0x73, 0x04, 0x72, 0xc6, 0x77, 0x88, 0x76, 0x4a, 0x74, 0x0c, 0x75, 0xce,
0x7e, 0x90, 0x7f, 0x52, 0x7d, 0x14, 0x7c, 0xd6, 0x79, 0x98, 0x78, 0x5a, 0x7a, 0x1c, 0x7b, 0xde,
0x6c, 0xa0, 0x6d, 0x62, 0x6f, 0x24, 0x6e, 0xe6, 0x6b, 0xa8, 0x6a, 0x6a, 0x68, 0x2c, 0x69, 0xee,
0x62, 0xb0, 0x63, 0x72, 0x61, 0x34, 0x60, 0xf6, 0x65, 0xb8, 0x64, 0x7a, 0x66, 0x3c, 0x67, 0xfe,
0x48, 0xc0, 0x49, 0x02, 0x4b, 0x44, 0x4a, 0x86, 0x4f, 0xc8, 0x4e, 0x0a, 0x4c, 0x4c, 0x4d, 0x8e,
0x46, 0xd0, 0x47, 0x12, 0x45, 0x54, 0x44, 0x96, 0x41, 0xd8, 0x40, 0x1a, 0x42, 0x5c, 0x43, 0x9e,
0x54, 0xe0, 0x55, 0x22, 0x57, 0x64, 0x56, 0xa6, 0x53, 0xe8, 0x52, 0x2a, 0x50, 0x6c, 0x51, 0xae,
0x5a, 0xf0, 0x5b, 0x32, 0x59, 0x74, 0x58, 0xb6, 0x5d, 0xf8, 0x5c, 0x3a, 0x5e, 0x7c, 0x5f, 0xbe,
0xe1, 0x00, 0xe0, 0xc2, 0xe2, 0x84, 0xe3, 0x46, 0xe6, 0x08, 0xe7, 0xca, 0xe5, 0x8c, 0xe4, 0x4e,
0xef, 0x10, 0xee, 0xd2, 0xec, 0x94, 0xed, 0x56, 0xe8, 0x18, 0xe9, 0xda, 0xeb, 0x9c, 0xea, 0x5e,
0xfd, 0x20, 0xfc, 0xe2, 0xfe, 0xa4, 0xff, 0x66, 0xfa, 0x28, 0xfb, 0xea, 0xf9, 0xac, 0xf8, 0x6e,
0xf3, 0x30, 0xf2, 0xf2, 0xf0, 0xb4, 0xf1, 0x76, 0xf4, 0x38, 0xf5, 0xfa, 0xf7, 0xbc, 0xf6, 0x7e,
0xd9, 0x40, 0xd8, 0x82, 0xda, 0xc4, 0xdb, 0x06, 0xde, 0x48, 0xdf, 0x8a, 0xdd, 0xcc, 0xdc, 0x0e,
0xd7, 0x50, 0xd6, 0x92, 0xd4, 0xd4, 0xd5, 0x16, 0xd0, 0x58, 0xd1, 0x9a, 0xd3, 0xdc, 0xd2, 0x1e,
0xc5, 0x60, 0xc4, 0xa2, 0xc6, 0xe4, 0xc7, 0x26, 0xc2, 0x68, 0xc3, 0xaa, 0xc1, 0xec, 0xc0, 0x2e,
0xcb, 0x70, 0xca, 0xb2, 0xc8, 0xf4, 0xc9, 0x36, 0xcc, 0x78, 0xcd, 0xba, 0xcf, 0xfc, 0xce, 0x3e,
0x91, 0x80, 0x90, 0x42, 0x92, 0x04, 0x93, 0xc6, 0x96, 0x88, 0x97, 0x4a, 0x95, 0x0c, 0x94, 0xce,
0x9f, 0x90, 0x9e, 0x52, 0x9c, 0x14, 0x9d, 0xd6, 0x98, 0x98, 0x99, 0x5a, 0x9b, 0x1c, 0x9a, 0xde,
0x8d, 0xa0, 0x8c, 0x62, 0x8e, 0x24, 0x8f, 0xe6, 0x8a, 0xa8, 0x8b, 0x6a, 0x89, 0x2c, 0x88, 0xee,
0x83, 0xb0, 0x82, 0x72, 0x80, 0x34, 0x81, 0xf6, 0x84, 0xb8, 0x85, 0x7a, 0x87, 0x3c, 0x86, 0xfe,
0xa9, 0xc0, 0xa8, 0x02, 0xaa, 0x44, 0xab, 0x86, 0xae, 0xc8, 0xaf, 0x0a, 0xad, 0x4c, 0xac, 0x8e,
0xa7, 0xd0, 0xa6, 0x12, 0xa4, 0x54, 0xa5, 0x96, 0xa0, 0xd8, 0xa1, 0x1a, 0xa3, 0x5c, 0xa2, 0x9e,
0xb5, 0xe0, 0xb4, 0x22, 0xb6, 0x64, 0xb7, 0xa6, 0xb2, 0xe8, 0xb3, 0x2a, 0xb1, 0x6c, 0xb0, 0xae,
0xbb, 0xf0, 0xba, 0x32, 0xb8, 0x74, 0xb9, 0xb6, 0xbc, 0xf8, 0xbd, 0x3a, 0xbf, 0x7c, 0xbe, 0xbe };
#endif
/**
Initialize a GCM state
@param gcm The GCM state to initialize
@@ -31,7 +71,7 @@ int gcm_init(gcm_state *gcm, int cipher,
int err;
unsigned char B[16];
#ifdef GCM_TABLES
int x, y;
int x, y, z, t;
#endif
LTC_ARGCHK(gcm != NULL);
@@ -72,17 +112,34 @@ int gcm_init(gcm_state *gcm, int cipher,
#ifdef GCM_TABLES
/* setup tables */
/* generate the first table as it has no shifting (from which we make the other tables) */
zeromem(B, 16);
for (x = 0; x < 16; x++) {
for (y = 0; y < 256; y++) {
B[x] = y;
gcm_gf_mult(gcm->H, B, &gcm->PC[x][y][0]);
}
B[x] = 0;
for (y = 0; y < 256; y++) {
B[0] = y;
gcm_gf_mult(gcm->H, B, &gcm->PC[0][y][0]);
}
/* now generate the rest of the tables based the previous table */
for (x = 1; x < 16; x++) {
for (y = 0; y < 256; y++) {
/* now shift it right by 8 bits */
t = gcm->PC[x-1][y][15];
for (z = 15; z > 0; z--) {
gcm->PC[x][y][z] = gcm->PC[x-1][y][z-1];
}
gcm->PC[x][y][0] = gcm_shift_table[t<<1];
gcm->PC[x][y][1] ^= gcm_shift_table[(t<<1)+1];
}
}
#endif
return CRYPT_OK;
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -87,3 +87,7 @@ LTC_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -141,3 +141,7 @@ int gcm_process(gcm_state *gcm,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -38,3 +38,7 @@ int gcm_reset(gcm_state *gcm)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4 -1
View File
@@ -281,7 +281,6 @@ int gcm_test(void)
};
int idx, err;
unsigned long x, y;
gcm_state gcm;
unsigned char out[2][64], T[2][16];
/* find aes */
@@ -363,3 +362,7 @@ int gcm_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -71,3 +71,7 @@ int ocb_decrypt(ocb_state *ocb, const unsigned char *ct, unsigned char *pt)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
@@ -80,3 +80,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -74,3 +74,7 @@ LBL_ERR:
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -40,3 +40,7 @@ int ocb_done_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned long ptle
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -64,3 +64,7 @@ int ocb_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned char *ct)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
@@ -78,3 +78,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -127,3 +127,7 @@ int ocb_init(ocb_state *ocb, int cipher,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -36,3 +36,7 @@ int ocb_ntz(unsigned long x)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -33,3 +33,7 @@ void ocb_shift_xor(ocb_state *ocb, unsigned char *Z)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -231,3 +231,7 @@ int ocb_test(void)
-- hard to stream [you can't emit ciphertext until full block]
-- The setup is somewhat complicated...
*/
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -138,3 +138,7 @@ int s_ocb_done(ocb_state *ocb, const unsigned char *pt, unsigned long ptlen,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -291,3 +291,7 @@ int chc_test(void)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -51,3 +51,7 @@ int hash_file(int hash, const char *fname, unsigned char *out, unsigned long *ou
#endif
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -64,3 +64,7 @@ int hash_filehandle(int hash, FILE *in, unsigned char *out, unsigned long *outle
#endif
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -62,3 +62,7 @@ LBL_ERR:
return err;
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -80,3 +80,7 @@ LBL_ERR:
va_end(args);
return err;
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -5
View File
@@ -24,11 +24,9 @@ const struct ltc_hash_descriptor md2_desc =
16,
16,
/* DER encoding */
{ 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x02, 0x05, 0x00,
0x04, 0x10 },
18,
/* OID */
{ 1, 2, 840, 113549, 2, 2, },
6,
&md2_init,
&md2_process,
@@ -246,3 +244,7 @@ int md2_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -3
View File
@@ -24,9 +24,9 @@ const struct ltc_hash_descriptor md4_desc =
16,
64,
/* DER encoding (not yet supported) */
{ 0x00 },
0,
/* OID */
{ 1, 2, 840, 113549, 2, 4, },
6,
&md4_init,
&md4_process,
@@ -300,3 +300,7 @@ int md4_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -5
View File
@@ -25,11 +25,9 @@ const struct ltc_hash_descriptor md5_desc =
16,
64,
/* DER identifier */
{ 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
0x04, 0x10 },
18,
/* OID */
{ 1, 2, 840, 113549, 2, 5, },
6,
&md5_init,
&md5_process,
@@ -363,3 +361,7 @@ int md5_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -3
View File
@@ -30,9 +30,9 @@ const struct ltc_hash_descriptor rmd128_desc =
16,
64,
/* DER identifier (not supported) */
{ 0x00 },
0,
/* OID */
{ 1, 0, 10118, 3, 0, 50 },
6,
&rmd128_init,
&rmd128_process,
@@ -403,3 +403,7 @@ int rmd128_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -4
View File
@@ -30,10 +30,9 @@ const struct ltc_hash_descriptor rmd160_desc =
20,
64,
/* DER identifier */
{ 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 },
15,
/* OID */
{ 1, 3, 36, 3, 2, 1, },
6,
&rmd160_init,
&rmd160_process,
@@ -463,3 +462,7 @@ int rmd160_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -4
View File
@@ -25,10 +25,9 @@ const struct ltc_hash_descriptor sha1_desc =
20,
64,
/* DER identifier */
{ 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E,
0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 },
15,
/* OID */
{ 1, 3, 14, 3, 2, 26, },
6,
&sha1_init,
&sha1_process,
@@ -282,3 +281,7 @@ int sha1_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -3
View File
@@ -20,9 +20,9 @@ const struct ltc_hash_descriptor sha224_desc =
28,
64,
/* DER identifier (not supported) */
{ 0x00 },
0,
/* OID */
{ 2, 16, 840, 1, 101, 3, 4, 2, 4, },
9,
&sha224_init,
&sha256_process,
@@ -118,3 +118,7 @@ int sha224_test(void)
#endif
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -5
View File
@@ -24,11 +24,9 @@ const struct ltc_hash_descriptor sha256_desc =
32,
64,
/* DER identifier */
{ 0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
0x00, 0x04, 0x20 },
19,
/* OID */
{ 2, 16, 840, 1, 101, 3, 4, 2, 1, },
9,
&sha256_init,
&sha256_process,
@@ -335,3 +333,7 @@ int sha256_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -5
View File
@@ -20,11 +20,9 @@ const struct ltc_hash_descriptor sha384_desc =
48,
128,
/* DER identifier */
{ 0x30, 0x41, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05,
0x00, 0x04, 0x30 },
19,
/* OID */
{ 2, 16, 840, 1, 101, 3, 4, 2, 2, },
9,
&sha384_init,
&sha512_process,
@@ -130,3 +128,7 @@ int sha384_test(void)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -5
View File
@@ -24,11 +24,9 @@ const struct ltc_hash_descriptor sha512_desc =
64,
128,
/* DER identifier */
{ 0x30, 0x51, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86,
0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05,
0x00, 0x04, 0x40 },
19,
/* OID */
{ 2, 16, 840, 1, 101, 3, 4, 2, 3, },
9,
&sha512_init,
&sha512_process,
@@ -314,3 +312,7 @@ int sha512_test(void)
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -5
View File
@@ -25,11 +25,9 @@ const struct ltc_hash_descriptor tiger_desc =
24,
64,
/* DER identifier */
{ 0x30, 0x29, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06,
0x01, 0x04, 0x01, 0xDA, 0x47, 0x0C, 0x02, 0x05,
0x00, 0x04, 0x18 },
19,
/* OID */
{ 1, 3, 6, 1, 4, 1, 11591, 12, 2, },
9,
&tiger_init,
&tiger_process,
@@ -809,3 +807,7 @@ Hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFG
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -3
View File
@@ -25,9 +25,9 @@ const struct ltc_hash_descriptor whirlpool_desc =
64,
64,
/* DER encoding (not yet supported) */
{ 0x00 },
0,
/* OID */
{ 1, 0, 10118, 3, 0, 55 },
6,
&whirlpool_init,
&whirlpool_process,
@@ -307,3 +307,7 @@ int whirlpool_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -577,3 +577,7 @@ CONST64(0xca2dbf07ad5a8333),
CONST64(0x6302aa71c81949d9),
};
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -575,3 +575,7 @@ extern const char *mp_s_rmap;
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+6 -2
View File
@@ -16,8 +16,8 @@ extern "C" {
#endif
/* version */
#define CRYPT 0x0102
#define SCRYPT "1.02"
#define CRYPT 0x0103
#define SCRYPT "1.03"
/* max size of either a cipher/hash block or symmetric key [largest of the two] */
#define MAXBLOCKSIZE 128
@@ -79,3 +79,7 @@ enum {
#endif /* TOMCRYPT_H_ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -19,3 +19,7 @@ void crypt_argchk(char *v, char *s, int d);
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -106,3 +106,7 @@ int XMEMCMP(const void *s1, const void *s2, size_t n);
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+14 -3
View File
@@ -32,7 +32,7 @@ struct saferp_key {
#ifdef RIJNDAEL
struct rijndael_key {
ulong32 eK[64], dK[64];
ulong32 eK[60], dK[60];
int Nr;
};
#endif
@@ -599,8 +599,15 @@ int cbc_done(symmetric_CBC *cbc);
#endif
#ifdef CTR
int ctr_start(int cipher, const unsigned char *IV, const unsigned char *key,
int keylen, int num_rounds, symmetric_CTR *ctr);
#define CTR_COUNTER_LITTLE_ENDIAN 0
#define CTR_COUNTER_BIG_ENDIAN 1
int ctr_start( int cipher,
const unsigned char *IV,
const unsigned char *key, int keylen,
int num_rounds, int ctr_mode,
symmetric_CTR *ctr);
int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr);
int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr);
int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr);
@@ -617,3 +624,7 @@ int unregister_cipher(const struct ltc_cipher_descriptor *cipher);
int cipher_is_valid(int idx);
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+46 -8
View File
@@ -1,6 +1,3 @@
/* This header is meant to be included before mycrypt.h in projects where
* you don't want to throw all the defines in a makefile.
*/
#ifndef TOMCRYPT_CUSTOM_H_
#define TOMCRYPT_CUSTOM_H_
@@ -20,7 +17,9 @@
/* #define LTC_SMALL_CODE */
/* Enable self-test test vector checking */
#define LTC_TEST
#ifndef LTC_NO_TEST
#define LTC_TEST
#endif
/* clean the stack of functions which put private information on stack */
/* #define LTC_CLEAN_STACK */
@@ -38,6 +37,8 @@
/* #define LTC_NO_BSWAP */
/* ---> Symmetric Block Ciphers <--- */
#ifndef LTC_NO_CIPHERS
#define BLOWFISH
#define RC2
#define RC5
@@ -48,8 +49,12 @@
/* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format
* (saves 4KB of ram), _ALL_TABLES enables all tables during setup */
#define TWOFISH
#define TWOFISH_TABLES
/* #define TWOFISH_ALL_TABLES */
#ifndef LTC_NO_TABLES
#define TWOFISH_TABLES
/* #define TWOFISH_ALL_TABLES */
#else
#define TWOFISH_SMALL
#endif
/* #define TWOFISH_SMALL */
/* DES includes EDE triple-DES */
#define DES
@@ -61,15 +66,23 @@
#define ANUBIS
#define ANUBIS_TWEAK
#endif /* LTC_NO_CIPHERS */
/* ---> Block Cipher Modes of Operation <--- */
#ifndef LTC_NO_MODES
#define CFB
#define OFB
#define ECB
#define CBC
#define CTR
#endif /* LTC_NO_MODES */
/* ---> One-Way Hash Functions <--- */
#ifndef LTC_NO_HASHES
#define CHC_HASH
#define WHIRLPOOL
#define SHA512
@@ -84,7 +97,11 @@
#define RIPEMD128
#define RIPEMD160
#endif /* LTC_NO_HASHES */
/* ---> MAC functions <--- */
#ifndef LTC_NO_MACS
#define HMAC
#define OMAC
#define PMAC
@@ -95,6 +112,7 @@
#endif
/* ---> Encrypt + Authenticate Modes <--- */
#define EAX_MODE
#if defined(EAX_MODE) && !(defined(CTR) && defined(OMAC))
#error EAX_MODE requires CTR and OMAC mode
@@ -104,13 +122,20 @@
#define CCM_MODE
#define GCM_MODE
/* Use 64KiB tables */
#define GCM_TABLES
#ifndef LTC_NO_TABLES
#define GCM_TABLES
#endif
#endif /* LTC_NO_MACS */
/* Various tidbits of modern neatoness */
#define BASE64
/* --> Pseudo Random Number Generators <--- */
#ifndef LTC_NO_PRNGS
/* Yarrow */
#define YARROW
/* which descriptor of AES to use? */
@@ -142,7 +167,11 @@
/* try /dev/urandom before trying /dev/random */
#define TRY_URANDOM_FIRST
#endif /* LTC_NO_PRNGS */
/* ---> Public Key Crypto <--- */
#ifndef LTC_NO_PK
#define MRSA
/* Digital Signature Algorithm */
@@ -168,7 +197,6 @@
/* ECC */
#define MECC
/* Supported Key Sizes */
#define ECC160
#define ECC192
#define ECC224
#define ECC256
@@ -178,7 +206,11 @@
/* Include the MPI functionality? (required by the PK algorithms) */
#define MPI
#endif /* LTC_NO_PK */
/* PKCS #1 (RSA) and #5 (Password Handling) stuff */
#ifndef LTC_NO_PKCS
#define PKCS_1
#define PKCS_5
@@ -192,5 +224,11 @@
#error RSA/DSA requires ASN.1 DER functionality, make sure LTC_DER is enabled
#endif
#endif /* LTC_NO_PKCS */
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+24 -19
View File
@@ -132,10 +132,11 @@ extern struct ltc_hash_descriptor {
unsigned long hashsize;
/** Input block size in octets */
unsigned long blocksize;
/** ASN.1 DER identifier */
unsigned char DER[64];
/** ASN.1 OID */
unsigned long OID[16];
/** Length of DER encoding */
unsigned long DERlen;
unsigned long OIDlen;
/** Init a hash state
@param hash The hash to initialize
@return CRYPT_OK if successful
@@ -292,29 +293,29 @@ int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)
{ \
unsigned long n; \
int err; \
LTC_ARGCHK(md != NULL); \
LTC_ARGCHK(in != NULL); \
LTC_ARGCHK(md != NULL); \
LTC_ARGCHK(in != NULL); \
if (md-> state_var .curlen > sizeof(md-> state_var .buf)) { \
return CRYPT_INVALID_ARG; \
} \
while (inlen > 0) { \
if (md-> state_var .curlen == 0 && inlen >= block_size) { \
if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) { \
return err; \
} \
while (inlen > 0) { \
if (md-> state_var .curlen == 0 && inlen >= block_size) { \
if ((err = compress_name (md, (unsigned char *)in)) != CRYPT_OK) { \
return err; \
} \
md-> state_var .length += block_size * 8; \
in += block_size; \
inlen -= block_size; \
in += block_size; \
inlen -= block_size; \
} else { \
n = MIN(inlen, (block_size - md-> state_var .curlen)); \
memcpy(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \
n = MIN(inlen, (block_size - md-> state_var .curlen)); \
memcpy(md-> state_var .buf + md-> state_var.curlen, in, (size_t)n); \
md-> state_var .curlen += n; \
in += n; \
inlen -= n; \
in += n; \
inlen -= n; \
if (md-> state_var .curlen == block_size) { \
if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) {\
return err; \
} \
if ((err = compress_name (md, md-> state_var .buf)) != CRYPT_OK) { \
return err; \
} \
md-> state_var .length += 8*block_size; \
md-> state_var .curlen = 0; \
} \
@@ -322,3 +323,7 @@ int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)
} \
return CRYPT_OK; \
}
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -295,3 +295,7 @@ int pelican_memory(const unsigned char *key, unsigned long keylen,
unsigned char *out);
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+8 -4
View File
@@ -132,7 +132,7 @@ asm __volatile__ ( \
#ifdef ENDIAN_32BITWORD
#define STORE32L(x, y) \
{ unsigned long __t = (x); memcpy(y, &__t, 4); }
{ ulong32 __t = (x); memcpy(y, &__t, 4); }
#define LOAD32L(x, y) \
memcpy(&(x), y, 4);
@@ -152,7 +152,7 @@ asm __volatile__ ( \
#else /* 64-bit words then */
#define STORE32L(x, y) \
{ unsigned long __t = (x); memcpy(y, &__t, 4); }
{ ulong32 __t = (x); memcpy(y, &__t, 4); }
#define LOAD32L(x, y) \
{ memcpy(&(x), y, 4); x &= 0xFFFFFFFF; }
@@ -193,7 +193,7 @@ asm __volatile__ ( \
#ifdef ENDIAN_32BITWORD
#define STORE32H(x, y) \
{ unsigned long __t = (x); memcpy(y, &__t, 4); }
{ ulong32 __t = (x); memcpy(y, &__t, 4); }
#define LOAD32H(x, y) \
memcpy(&(x), y, 4);
@@ -213,7 +213,7 @@ asm __volatile__ ( \
#else /* 64-bit words then */
#define STORE32H(x, y) \
{ unsigned long __t = (x); memcpy(y, &__t, 4); }
{ ulong32 __t = (x); memcpy(y, &__t, 4); }
#define LOAD32H(x, y) \
{ memcpy(&(x), y, 4); x &= 0xFFFFFFFF; }
@@ -371,3 +371,7 @@ static inline unsigned long ROR64c(unsigned long word, const int i)
#else
#define byte(x, n) (((x) >> (8 * (n))) & 255)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -15,3 +15,7 @@ const char *error_to_string(int err);
int mpi_to_ltc_error(int err);
extern const char *crypt_build_settings;
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+107 -26
View File
@@ -84,9 +84,6 @@ int packet_valid_header(unsigned char *src, int section, int subsection);
#define MIN_RSA_SIZE 1024
#define MAX_RSA_SIZE 4096
/* Stack required for temps (plus padding) */
// #define RSA_STACK (8 + (MAX_RSA_SIZE/8))
typedef struct Rsa_key {
int type;
mp_int e, d, N, p, q, qP, dP, dQ;
@@ -123,26 +120,6 @@ int rsa_verify_hash(const unsigned char *sig, unsigned long siglen,
int hash_idx, unsigned long saltlen,
int *stat, rsa_key *key);
/* these use PKCS #1 v1.5 padding */
int rsa_v15_encrypt_key(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
prng_state *prng, int prng_idx,
rsa_key *key);
int rsa_v15_decrypt_key(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long outlen,
int *stat, rsa_key *key);
int rsa_v15_sign_hash(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *siglen,
int hash_idx, rsa_key *key);
int rsa_v15_verify_hash(const unsigned char *sig, unsigned long siglen,
const unsigned char *hash, unsigned long hashlen,
int hash_idx, int *stat,
rsa_key *key);
/* PKCS #1 import/export */
int rsa_export(unsigned char *out, unsigned long *outlen, int type, rsa_key *key);
int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
@@ -244,10 +221,19 @@ typedef struct {
int dsa_make_key(prng_state *prng, int wprng, 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,
mp_int *r, mp_int *s,
prng_state *prng, int wprng, dsa_key *key);
int dsa_sign_hash(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
prng_state *prng, int wprng, dsa_key *key);
int dsa_verify_hash_raw( mp_int *r, mp_int *s,
const unsigned char *hash, unsigned long hashlen,
int *stat, dsa_key *key);
int dsa_verify_hash(const unsigned char *sig, unsigned long siglen,
const unsigned char *hash, unsigned long hashlen,
int *stat, dsa_key *key);
@@ -262,9 +248,104 @@ int dsa_verify_key(dsa_key *key, int *stat);
#ifdef LTC_DER
/* DER handling */
enum {
LTC_ASN1_EOL,
LTC_ASN1_INTEGER,
LTC_ASN1_SHORT_INTEGER,
LTC_ASN1_BIT_STRING,
LTC_ASN1_OCTET_STRING,
LTC_ASN1_NULL,
LTC_ASN1_OBJECT_IDENTIFIER,
LTC_ASN1_IA5_STRING,
LTC_ASN1_PRINTABLE_STRING,
LTC_ASN1_SEQUENCE
};
typedef struct {
int type;
void *data;
unsigned long size;
} ltc_asn1_list;
#define LTC_SET_ASN1(list, index, Type, Data, Size) \
do { \
int LTC_MACRO_temp = (index); \
ltc_asn1_list *LTC_MACRO_list = (list); \
LTC_MACRO_list[LTC_MACRO_temp].type = (Type); \
LTC_MACRO_list[LTC_MACRO_temp].data = (Data); \
LTC_MACRO_list[LTC_MACRO_temp].size = (Size); \
} while (0);
/* SEQUENCE */
int der_encode_sequence(ltc_asn1_list *list, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_decode_sequence(const unsigned char *in, unsigned long inlen,
ltc_asn1_list *list, unsigned long outlen);
int der_length_sequence(ltc_asn1_list *list, unsigned long inlen,
unsigned long *outlen);
/* VA list handy helpers */
int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...);
int der_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...);
/* INTEGER */
int der_encode_integer(mp_int *num, unsigned char *out, unsigned long *outlen);
int der_decode_integer(const unsigned char *in, unsigned long *inlen, mp_int *num);
int der_decode_integer(const unsigned char *in, unsigned long inlen, mp_int *num);
int der_length_integer(mp_int *num, unsigned long *len);
int der_put_multi_integer(unsigned char *dst, unsigned long *outlen, mp_int *num, ...);
int der_get_multi_integer(const unsigned char *src, unsigned long *inlen, mp_int *num, ...);
/* INTEGER -- handy for 0..2^32-1 values */
int der_decode_short_integer(const unsigned char *in, unsigned long inlen, unsigned long *num);
int der_encode_short_integer(unsigned long num, unsigned char *out, unsigned long *outlen);
int der_length_short_integer(unsigned long num, unsigned long *outlen);
/* BIT STRING */
int der_encode_bit_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_decode_bit_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_length_bit_string(unsigned long nbits, unsigned long *outlen);
/* OCTET STRING */
int der_encode_octet_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_decode_octet_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_length_octet_string(unsigned long noctets, unsigned long *outlen);
/* OBJECT IDENTIFIER */
int der_encode_object_identifier(unsigned long *words, unsigned long nwords,
unsigned char *out, unsigned long *outlen);
int der_decode_object_identifier(const unsigned char *in, unsigned long inlen,
unsigned long *words, unsigned long *outlen);
int der_length_object_identifier(unsigned long *words, unsigned long nwords, unsigned long *outlen);
unsigned long der_object_identifier_bits(unsigned long x);
/* IA5 STRING */
int der_encode_ia5_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_decode_ia5_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen);
int der_ia5_char_encode(int c);
int der_ia5_value_decode(int v);
/* Printable STRING */
int der_encode_printable_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_decode_printable_string(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen);
int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen);
int der_printable_char_encode(int c);
int der_printable_value_decode(int v);
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+5 -27
View File
@@ -10,7 +10,7 @@ int pkcs_1_mgf1(const unsigned char *seed, unsigned long seedlen,
int pkcs_1_i2osp(mp_int *n, unsigned long modulus_len, unsigned char *out);
int pkcs_1_os2ip(mp_int *n, unsigned char *in, unsigned long inlen);
/* *** v2.0 padding */
/* *** 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,
@@ -34,32 +34,6 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
unsigned long saltlen, int hash_idx,
unsigned long modulus_bitlen, int *res);
/* *** v1.5 padding */
/* encryption padding */
int pkcs_1_v15_es_encode(const unsigned char *msg, unsigned long msglen,
unsigned long modulus_bitlen,
prng_state *prng, int prng_idx,
unsigned char *out, unsigned long *outlen);
/* note "outlen" is fixed, you have to tell this decoder how big
* the original message was. Unlike the OAEP decoder it cannot auto-detect it.
*/
int pkcs_1_v15_es_decode(const unsigned char *msg, unsigned long msglen,
unsigned long modulus_bitlen,
unsigned char *out, unsigned long outlen,
int *res);
/* signature padding */
int pkcs_1_v15_sa_encode(const unsigned char *msghash, unsigned long msghashlen,
int hash_idx, unsigned long modulus_bitlen,
unsigned char *out, unsigned long *outlen);
int pkcs_1_v15_sa_decode(const unsigned char *msghash, unsigned long msghashlen,
const unsigned char *sig, unsigned long siglen,
int hash_idx, unsigned long modulus_bitlen,
int *res);
#endif /* PKCS_1 */
/* ===> PKCS #5 -- Password Based Cryptography <=== */
@@ -78,3 +52,7 @@ int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
unsigned char *out, unsigned long *outlen);
#endif /* PKCS_5 */
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -188,3 +188,7 @@ unsigned long rng_get_bytes(unsigned char *out,
int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void));
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -992,3 +992,7 @@
#else
#define LTM_LAST
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+9 -1
View File
@@ -1,10 +1,14 @@
/* super class file for PK algos */
/* default ... include all MPI */
#ifndef SC_RSA_1
#define LTM_ALL
#endif
/* RSA only (does not support DH/DSA/ECC) */
// #define SC_RSA_1
/* #define SC_RSA_1 */
/* For reference.... On an Athlon64 optimizing for speed...
@@ -70,3 +74,7 @@
#endif
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -103,3 +103,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -87,3 +87,7 @@ int hmac_file(int hash, const char *fname,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -106,3 +106,7 @@ done:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -71,3 +71,7 @@ LBL_ERR:
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -86,3 +86,7 @@ LBL_ERR:
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -37,3 +37,7 @@ int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -310,3 +310,7 @@ Key First"
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -78,3 +78,7 @@ int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -77,3 +77,7 @@ int omac_file(int cipher,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+5 -1
View File
@@ -39,7 +39,7 @@ int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned l
}
#ifdef LTC_FAST
if (16 % sizeof(LTC_FAST_TYPE)) {
if (cipher_descriptor[cipher].block_length % sizeof(LTC_FAST_TYPE)) {
return CRYPT_INVALID_ARG;
}
#endif
@@ -93,3 +93,7 @@ int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned l
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -69,3 +69,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -84,3 +84,7 @@ LBL_ERR:
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+7 -2
View File
@@ -27,7 +27,8 @@
*/
int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
{
int err, n, x;
unsigned long n, x;
int err;
LTC_ARGCHK(omac != NULL);
LTC_ARGCHK(in != NULL);
@@ -57,7 +58,7 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
while (inlen != 0) {
/* ok if the block is full we xor in prev, encrypt and replace prev */
if (omac->buflen == omac->blklen) {
for (x = 0; x < omac->blklen; x++) {
for (x = 0; x < (unsigned long)omac->blklen; x++) {
omac->block[x] ^= omac->prev[x];
}
cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->block, omac->prev, &omac->key);
@@ -77,3 +78,7 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -104,3 +104,7 @@ int omac_test(void)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+16
View File
@@ -102,6 +102,12 @@ int pelican_process(pelican_state *pelmac, const unsigned char *in, unsigned lon
LTC_ARGCHK(pelmac != NULL);
LTC_ARGCHK(in != NULL);
/* check range */
if (pelmac->buflen < 0 || pelmac->buflen > 15) {
return CRYPT_INVALID_ARG;
}
#ifdef LTC_FAST
if (pelmac->buflen == 0) {
while (inlen & ~15) {
@@ -136,6 +142,12 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
{
LTC_ARGCHK(pelmac != NULL);
LTC_ARGCHK(out != NULL);
/* check range */
if (pelmac->buflen < 0 || pelmac->buflen > 16) {
return CRYPT_INVALID_ARG;
}
if (pelmac->buflen == 16) {
four_rounds(pelmac);
pelmac->buflen = 0;
@@ -147,3 +159,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -53,3 +53,7 @@ int pelican_memory(const unsigned char *key, unsigned long keylen,
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -114,3 +114,7 @@ int pelican_test(void)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -66,3 +66,7 @@ int pmac_done(pmac_state *state, unsigned char *out, unsigned long *outlen)
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */
+4
View File
@@ -78,3 +78,7 @@ int pmac_file(int cipher,
}
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */

Some files were not shown because too many files have changed in this diff Show More