summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2014-06-22 20:11:46 -0700
committerDwayne Litzenberger <dlitz@dlitz.net>2014-06-22 20:15:21 -0700
commitde67e51324fc7ecfb553046938b2f734e48ce9e7 (patch)
tree014b569f4dbe757b474fe0cc8bbc5d050ad0f6aa
parent33859d41784c85a64da5b6cf8856f086b2c77b8f (diff)
parent780eb557aedd3de7689aa215b3f13082dc60e2e1 (diff)
downloadpycrypto-de67e51324fc7ecfb553046938b2f734e48ce9e7.tar.gz
Upgrade libtomcrypt 1.16 -> 1.17 (LP#1264130)
This should fix a FreeBSD build issue: https://bugs.launchpad.net/pycrypto/+bug/1264130 Thanks to Richard Mitchell <richard.j.mitchell@gmail.com> for suggesting how to fix this.
-rw-r--r--src/DES.c2
-rw-r--r--src/libtom/tomcrypt.h8
-rw-r--r--src/libtom/tomcrypt_cipher.h188
-rw-r--r--src/libtom/tomcrypt_custom.h201
-rw-r--r--src/libtom/tomcrypt_des.c24
-rw-r--r--src/libtom/tomcrypt_hash.h94
-rw-r--r--src/libtom/tomcrypt_mac.h41
-rw-r--r--src/libtom/tomcrypt_math.h8
-rw-r--r--src/libtom/tomcrypt_misc.h8
-rw-r--r--src/libtom/tomcrypt_pk.h52
-rw-r--r--src/libtom/tomcrypt_pkcs.h28
-rw-r--r--src/libtom/tomcrypt_prng.h32
12 files changed, 375 insertions, 311 deletions
diff --git a/src/DES.c b/src/DES.c
index c5c2416..2987956 100644
--- a/src/DES.c
+++ b/src/DES.c
@@ -33,8 +33,6 @@
/* Include the actial DES implementation */
#include "libtom/tomcrypt_des.c"
-#undef DES /* this is needed because tomcrypt_custom.h defines DES to an empty string */
-
#include <assert.h>
typedef struct {
diff --git a/src/libtom/tomcrypt.h b/src/libtom/tomcrypt.h
index 5e127dc..72ebdcb 100644
--- a/src/libtom/tomcrypt.h
+++ b/src/libtom/tomcrypt.h
@@ -16,8 +16,8 @@ extern "C" {
#endif
/* version */
-#define CRYPT 0x0116
-#define SCRYPT "1.16"
+#define CRYPT 0x0117
+#define SCRYPT "1.17"
/* max size of either a cipher/hash block or symmetric key [largest of the two] */
#define MAXBLOCKSIZE 128
@@ -83,5 +83,5 @@ enum {
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt.h,v $ */
-/* $Revision: 1.20 $ */
-/* $Date: 2006/11/26 01:45:14 $ */
+/* $Revision: 1.21 $ */
+/* $Date: 2006/12/16 19:34:05 $ */
diff --git a/src/libtom/tomcrypt_cipher.h b/src/libtom/tomcrypt_cipher.h
index e0cf94d..a4b3dcf 100644
--- a/src/libtom/tomcrypt_cipher.h
+++ b/src/libtom/tomcrypt_cipher.h
@@ -3,41 +3,41 @@
* We put each of the ciphers scheduled keys in their own structs then we put all of
* the key formats in one union. This makes the function prototypes easier to use.
*/
-#ifdef BLOWFISH
+#ifdef LTC_BLOWFISH
struct blowfish_key {
ulong32 S[4][256];
ulong32 K[18];
};
#endif
-#ifdef RC5
+#ifdef LTC_RC5
struct rc5_key {
int rounds;
ulong32 K[50];
};
#endif
-#ifdef RC6
+#ifdef LTC_RC6
struct rc6_key {
ulong32 K[44];
};
#endif
-#ifdef SAFERP
+#ifdef LTC_SAFERP
struct saferp_key {
unsigned char K[33][16];
long rounds;
};
#endif
-#ifdef RIJNDAEL
+#ifdef LTC_RIJNDAEL
struct rijndael_key {
ulong32 eK[60], dK[60];
int Nr;
};
#endif
-#ifdef KSEED
+#ifdef LTC_KSEED
struct kseed_key {
ulong32 K[32], dK[32];
};
@@ -51,14 +51,14 @@ struct kasumi_key {
};
#endif
-#ifdef XTEA
+#ifdef LTC_XTEA
struct xtea_key {
unsigned long A[32], B[32];
};
#endif
-#ifdef TWOFISH
-#ifndef TWOFISH_SMALL
+#ifdef LTC_TWOFISH
+#ifndef LTC_TWOFISH_SMALL
struct twofish_key {
ulong32 S[4][256], K[40];
};
@@ -70,24 +70,24 @@ struct xtea_key {
#endif
#endif
-#ifdef SAFER
-#define SAFER_K64_DEFAULT_NOF_ROUNDS 6
-#define SAFER_K128_DEFAULT_NOF_ROUNDS 10
-#define SAFER_SK64_DEFAULT_NOF_ROUNDS 8
-#define SAFER_SK128_DEFAULT_NOF_ROUNDS 10
-#define SAFER_MAX_NOF_ROUNDS 13
-#define SAFER_BLOCK_LEN 8
-#define SAFER_KEY_LEN (1 + SAFER_BLOCK_LEN * (1 + 2 * SAFER_MAX_NOF_ROUNDS))
-typedef unsigned char safer_block_t[SAFER_BLOCK_LEN];
-typedef unsigned char safer_key_t[SAFER_KEY_LEN];
+#ifdef LTC_SAFER
+#define LTC_SAFER_K64_DEFAULT_NOF_ROUNDS 6
+#define LTC_SAFER_K128_DEFAULT_NOF_ROUNDS 10
+#define LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS 8
+#define LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS 10
+#define LTC_SAFER_MAX_NOF_ROUNDS 13
+#define LTC_SAFER_BLOCK_LEN 8
+#define LTC_SAFER_KEY_LEN (1 + LTC_SAFER_BLOCK_LEN * (1 + 2 * LTC_SAFER_MAX_NOF_ROUNDS))
+typedef unsigned char safer_block_t[LTC_SAFER_BLOCK_LEN];
+typedef unsigned char safer_key_t[LTC_SAFER_KEY_LEN];
struct safer_key { safer_key_t key; };
#endif
-#ifdef RC2
+#ifdef LTC_RC2
struct rc2_key { unsigned xkey[64]; };
#endif
-#ifdef DES
+#ifdef LTC_DES
struct des_key {
ulong32 ek[32], dk[32];
};
@@ -97,32 +97,32 @@ struct des3_key {
};
#endif
-#ifdef CAST5
+#ifdef LTC_CAST5
struct cast5_key {
ulong32 K[32], keylen;
};
#endif
-#ifdef NOEKEON
+#ifdef LTC_NOEKEON
struct noekeon_key {
ulong32 K[4], dK[4];
};
#endif
-#ifdef SKIPJACK
+#ifdef LTC_SKIPJACK
struct skipjack_key {
unsigned char key[10];
};
#endif
-#ifdef KHAZAD
+#ifdef LTC_KHAZAD
struct khazad_key {
ulong64 roundKeyEnc[8 + 1];
ulong64 roundKeyDec[8 + 1];
};
#endif
-#ifdef ANUBIS
+#ifdef LTC_ANUBIS
struct anubis_key {
int keyBits;
int R;
@@ -131,59 +131,69 @@ struct anubis_key {
};
#endif
+#ifdef LTC_MULTI2
+struct multi2_key {
+ int N;
+ ulong32 uk[8];
+};
+#endif
+
typedef union Symmetric_key {
-#ifdef DES
+#ifdef LTC_DES
struct des_key des;
struct des3_key des3;
#endif
-#ifdef RC2
+#ifdef LTC_RC2
struct rc2_key rc2;
#endif
-#ifdef SAFER
+#ifdef LTC_SAFER
struct safer_key safer;
#endif
-#ifdef TWOFISH
+#ifdef LTC_TWOFISH
struct twofish_key twofish;
#endif
-#ifdef BLOWFISH
+#ifdef LTC_BLOWFISH
struct blowfish_key blowfish;
#endif
-#ifdef RC5
+#ifdef LTC_RC5
struct rc5_key rc5;
#endif
-#ifdef RC6
+#ifdef LTC_RC6
struct rc6_key rc6;
#endif
-#ifdef SAFERP
+#ifdef LTC_SAFERP
struct saferp_key saferp;
#endif
-#ifdef RIJNDAEL
+#ifdef LTC_RIJNDAEL
struct rijndael_key rijndael;
#endif
-#ifdef XTEA
+#ifdef LTC_XTEA
struct xtea_key xtea;
#endif
-#ifdef CAST5
+#ifdef LTC_CAST5
struct cast5_key cast5;
#endif
-#ifdef NOEKEON
+#ifdef LTC_NOEKEON
struct noekeon_key noekeon;
#endif
-#ifdef SKIPJACK
+#ifdef LTC_SKIPJACK
struct skipjack_key skipjack;
#endif
-#ifdef KHAZAD
+#ifdef LTC_KHAZAD
struct khazad_key khazad;
#endif
-#ifdef ANUBIS
+#ifdef LTC_ANUBIS
struct anubis_key anubis;
#endif
-#ifdef KSEED
+#ifdef LTC_KSEED
struct kseed_key kseed;
#endif
#ifdef LTC_KASUMI
struct kasumi_key kasumi;
#endif
+#ifdef LTC_MULTI2
+ struct multi2_key multi2;
+#endif
void *data;
} symmetric_key;
@@ -257,8 +267,11 @@ typedef struct {
blocklen,
/** The padding offset */
padlen,
- /** The mode (endianess) of the CTR, 0==little, 1==big */
- mode;
+ /** The mode (endianess) of the CTR, 0==little, 1==big */
+ mode,
+ /** counter width */
+ ctrlen;
+
/** The counter */
unsigned char ctr[MAXBLOCKSIZE],
/** The pad used to encrypt/decrypt */
@@ -315,7 +328,7 @@ typedef struct {
/** cipher descriptor table, last entry has "name == NULL" to mark the end of table */
-extern struct ltc_cipher_descriptor {
+static struct ltc_cipher_descriptor {
/** name of cipher */
char *name;
/** internal ID */
@@ -488,7 +501,7 @@ extern struct ltc_cipher_descriptor {
unsigned char *tag, unsigned long *taglen,
int direction);
- /** Accelerated one shot OMAC
+ /** Accelerated one shot LTC_OMAC
@param key The secret key
@param keylen The key length (octets)
@param in The message
@@ -532,7 +545,7 @@ extern struct ltc_cipher_descriptor {
unsigned char *out, unsigned long *outlen);
} cipher_descriptor[];
-#ifdef BLOWFISH
+#ifdef LTC_BLOWFISH
int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -542,7 +555,7 @@ int blowfish_keysize(int *keysize);
extern const struct ltc_cipher_descriptor blowfish_desc;
#endif
-#ifdef RC5
+#ifdef LTC_RC5
int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -552,7 +565,7 @@ int rc5_keysize(int *keysize);
extern const struct ltc_cipher_descriptor rc5_desc;
#endif
-#ifdef RC6
+#ifdef LTC_RC6
int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -562,7 +575,7 @@ int rc6_keysize(int *keysize);
extern const struct ltc_cipher_descriptor rc6_desc;
#endif
-#ifdef RC2
+#ifdef LTC_RC2
int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -572,7 +585,7 @@ int rc2_keysize(int *keysize);
extern const struct ltc_cipher_descriptor rc2_desc;
#endif
-#ifdef SAFERP
+#ifdef LTC_SAFERP
int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -582,7 +595,7 @@ int saferp_keysize(int *keysize);
extern const struct ltc_cipher_descriptor saferp_desc;
#endif
-#ifdef SAFER
+#ifdef LTC_SAFER
int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
@@ -598,7 +611,7 @@ int safer_128_keysize(int *keysize);
extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc;
#endif
-#ifdef RIJNDAEL
+#ifdef LTC_RIJNDAEL
/* make aes an alias */
#define aes_setup rijndael_setup
@@ -626,7 +639,7 @@ extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc;
extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc;
#endif
-#ifdef XTEA
+#ifdef LTC_XTEA
int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -636,7 +649,7 @@ int xtea_keysize(int *keysize);
extern const struct ltc_cipher_descriptor xtea_desc;
#endif
-#ifdef TWOFISH
+#ifdef LTC_TWOFISH
int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -646,7 +659,7 @@ int twofish_keysize(int *keysize);
extern const struct ltc_cipher_descriptor twofish_desc;
#endif
-#ifdef DES
+#ifdef LTC_DES
static int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
static int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
static int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -659,10 +672,10 @@ static int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetri
static int des3_test(void);
static void des3_done(symmetric_key *skey);
static int des3_keysize(int *keysize);
-/* extern const struct ltc_cipher_descriptor des_desc, des3_desc; */
+static const struct ltc_cipher_descriptor des_desc, des3_desc;
#endif
-#ifdef CAST5
+#ifdef LTC_CAST5
int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -672,7 +685,7 @@ int cast5_keysize(int *keysize);
extern const struct ltc_cipher_descriptor cast5_desc;
#endif
-#ifdef NOEKEON
+#ifdef LTC_NOEKEON
int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -682,7 +695,7 @@ int noekeon_keysize(int *keysize);
extern const struct ltc_cipher_descriptor noekeon_desc;
#endif
-#ifdef SKIPJACK
+#ifdef LTC_SKIPJACK
int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -692,7 +705,7 @@ int skipjack_keysize(int *keysize);
extern const struct ltc_cipher_descriptor skipjack_desc;
#endif
-#ifdef KHAZAD
+#ifdef LTC_KHAZAD
int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -702,7 +715,7 @@ int khazad_keysize(int *keysize);
extern const struct ltc_cipher_descriptor khazad_desc;
#endif
-#ifdef ANUBIS
+#ifdef LTC_ANUBIS
int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -712,7 +725,7 @@ int anubis_keysize(int *keysize);
extern const struct ltc_cipher_descriptor anubis_desc;
#endif
-#ifdef KSEED
+#ifdef LTC_KSEED
int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
@@ -732,6 +745,17 @@ int kasumi_keysize(int *keysize);
extern const struct ltc_cipher_descriptor kasumi_desc;
#endif
+
+#ifdef LTC_MULTI2
+int multi2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
+int multi2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
+int multi2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
+int multi2_test(void);
+void multi2_done(symmetric_key *skey);
+int multi2_keysize(int *keysize);
+extern const struct ltc_cipher_descriptor multi2_desc;
+#endif
+
#ifdef LTC_ECB_MODE
int ecb_start(int cipher, const unsigned char *key,
int keylen, int num_rounds, symmetric_ECB *ecb);
@@ -772,9 +796,9 @@ int cbc_done(symmetric_CBC *cbc);
#ifdef LTC_CTR_MODE
-#define CTR_COUNTER_LITTLE_ENDIAN 0
-#define CTR_COUNTER_BIG_ENDIAN 1
-#define LTC_CTR_RFC3686 2
+#define CTR_COUNTER_LITTLE_ENDIAN 0x0000
+#define CTR_COUNTER_BIG_ENDIAN 0x1000
+#define LTC_CTR_RFC3686 0x2000
int ctr_start( int cipher,
const unsigned char *IV,
@@ -824,6 +848,34 @@ int f8_done(symmetric_F8 *f8);
int f8_test_mode(void);
#endif
+#ifdef LTC_XTS_MODE
+typedef struct {
+ symmetric_key key1, key2;
+ int cipher;
+} symmetric_xts;
+
+int xts_start( int cipher,
+ const unsigned char *key1,
+ const unsigned char *key2,
+ unsigned long keylen,
+ int num_rounds,
+ symmetric_xts *xts);
+
+int xts_encrypt(
+ const unsigned char *pt, unsigned long ptlen,
+ unsigned char *ct,
+ const unsigned char *tweak,
+ symmetric_xts *xts);
+int xts_decrypt(
+ const unsigned char *ct, unsigned long ptlen,
+ unsigned char *pt,
+ const unsigned char *tweak,
+ symmetric_xts *xts);
+
+void xts_done(symmetric_xts *xts);
+int xts_test(void);
+void xts_mult_x(unsigned char *I);
+#endif
int find_cipher(const char *name);
int find_cipher_any(const char *name, int blocklen, int keylen);
@@ -835,5 +887,5 @@ int cipher_is_valid(int idx);
LTC_MUTEX_PROTO(ltc_cipher_mutex)
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cipher.h,v $ */
-/* $Revision: 1.46 $ */
-/* $Date: 2006/11/13 23:09:38 $ */
+/* $Revision: 1.54 $ */
+/* $Date: 2007/05/12 14:37:41 $ */
diff --git a/src/libtom/tomcrypt_custom.h b/src/libtom/tomcrypt_custom.h
index e08bc92..73ceaa0 100644
--- a/src/libtom/tomcrypt_custom.h
+++ b/src/libtom/tomcrypt_custom.h
@@ -69,10 +69,10 @@
/* Easy button? */
#ifdef LTC_EASY
#define LTC_NO_CIPHERS
- #define RIJNDAEL
- #define BLOWFISH
- #define DES
- #define CAST5
+ #define LTC_RIJNDAEL
+ #define LTC_BLOWFISH
+ #define LTC_DES
+ #define LTC_CAST5
#define LTC_NO_MODES
#define LTC_ECB_MODE
@@ -80,26 +80,26 @@
#define LTC_CTR_MODE
#define LTC_NO_HASHES
- #define SHA1
- #define SHA512
- #define SHA384
- #define SHA256
- #define SHA224
+ #define LTC_SHA1
+ #define LTC_SHA512
+ #define LTC_SHA384
+ #define LTC_SHA256
+ #define LTC_SHA224
#define LTC_NO_MACS
- #define HMAC
- #define OMAC
- #define CCM_MODE
+ #define LTC_HMAC
+ #define LTC_OMAC
+ #define LTC_CCM_MODE
#define LTC_NO_PRNGS
- #define SPRNG
- #define YARROW
- #define DEVRANDOM
+ #define LTC_SPRNG
+ #define LTC_YARROW
+ #define LTC_DEVRANDOM
#define TRY_URANDOM_FIRST
#define LTC_NO_PK
- #define MRSA
- #define MECC
+ #define LTC_MRSA
+ #define LTC_MECC
#endif
/* Use small code where possible */
@@ -128,33 +128,33 @@
/* ---> Symmetric Block Ciphers <--- */
#ifndef LTC_NO_CIPHERS
-#define BLOWFISH
-#define RC2
-#define RC5
-#define RC6
-#define SAFERP
-#define RIJNDAEL
-#define XTEA
+#define LTC_BLOWFISH
+#define LTC_RC2
+#define LTC_RC5
+#define LTC_RC6
+#define LTC_SAFERP
+#define LTC_RIJNDAEL
+#define LTC_XTEA
/* _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 LTC_TWOFISH
#ifndef LTC_NO_TABLES
- #define TWOFISH_TABLES
- /* #define TWOFISH_ALL_TABLES */
+ #define LTC_TWOFISH_TABLES
+ /* #define LTC_TWOFISH_ALL_TABLES */
#else
- #define TWOFISH_SMALL
+ #define LTC_TWOFISH_SMALL
#endif
-/* #define TWOFISH_SMALL */
-/* DES includes EDE triple-DES */
-#define DES
-#define CAST5
-#define NOEKEON
-#define SKIPJACK
-#define SAFER
-#define KHAZAD
-#define ANUBIS
-#define ANUBIS_TWEAK
-#define KSEED
+/* #define LTC_TWOFISH_SMALL */
+/* LTC_DES includes EDE triple-LTC_DES */
+#define LTC_DES
+#define LTC_CAST5
+#define LTC_NOEKEON
+#define LTC_SKIPJACK
+#define LTC_SAFER
+#define LTC_KHAZAD
+#define LTC_ANUBIS
+#define LTC_ANUBIS_TWEAK
+#define LTC_KSEED
#define LTC_KASUMI
#endif /* LTC_NO_CIPHERS */
@@ -181,26 +181,29 @@
#define LRW_TABLES
#endif
+/* XTS mode */
+#define LTC_XTS_MODE
+
#endif /* LTC_NO_MODES */
/* ---> One-Way Hash Functions <--- */
#ifndef LTC_NO_HASHES
-#define CHC_HASH
-#define WHIRLPOOL
-#define SHA512
-#define SHA384
-#define SHA256
-#define SHA224
-#define TIGER
-#define SHA1
-#define MD5
-#define MD4
-#define MD2
-#define RIPEMD128
-#define RIPEMD160
-#define RIPEMD256
-#define RIPEMD320
+#define LTC_CHC_HASH
+#define LTC_WHIRLPOOL
+#define LTC_SHA512
+#define LTC_SHA384
+#define LTC_SHA256
+#define LTC_SHA224
+#define LTC_TIGER
+#define LTC_SHA1
+#define LTC_MD5
+#define LTC_MD4
+#define LTC_MD2
+#define LTC_RIPEMD128
+#define LTC_RIPEMD160
+#define LTC_RIPEMD256
+#define LTC_RIPEMD320
#endif /* LTC_NO_HASHES */
@@ -212,69 +215,69 @@
#define LTC_PMAC
#define LTC_XCBC
#define LTC_F9_MODE
-#define PELICAN
+#define LTC_PELICAN
-#if defined(PELICAN) && !defined(RIJNDAEL)
- #error Pelican-MAC requires RIJNDAEL
+#if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL)
+ #error Pelican-MAC requires LTC_RIJNDAEL
#endif
/* ---> Encrypt + Authenticate Modes <--- */
-#define EAX_MODE
-#if defined(EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC))
- #error EAX_MODE requires CTR and OMAC mode
+#define LTC_EAX_MODE
+#if defined(LTC_EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC))
+ #error LTC_EAX_MODE requires CTR and LTC_OMAC mode
#endif
-#define OCB_MODE
-#define CCM_MODE
-#define GCM_MODE
+#define LTC_OCB_MODE
+#define LTC_CCM_MODE
+#define LTC_GCM_MODE
/* Use 64KiB tables */
#ifndef LTC_NO_TABLES
- #define GCM_TABLES
+ #define LTC_GCM_TABLES
#endif
/* USE SSE2? requires GCC works on x86_32 and x86_64*/
-#ifdef GCM_TABLES
-/* #define GCM_TABLES_SSE2 */
+#ifdef LTC_GCM_TABLES
+/* #define LTC_GCM_TABLES_SSE2 */
#endif
#endif /* LTC_NO_MACS */
/* Various tidbits of modern neatoness */
-#define BASE64
+#define LTC_BASE64
/* --> Pseudo Random Number Generators <--- */
#ifndef LTC_NO_PRNGS
/* Yarrow */
-#define YARROW
+#define LTC_YARROW
/* which descriptor of AES to use? */
/* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */
-#define YARROW_AES 0
+#define LTC_YARROW_AES 0
-#if defined(YARROW) && !defined(LTC_CTR_MODE)
- #error YARROW requires LTC_CTR_MODE chaining mode to be defined!
+#if defined(LTC_YARROW) && !defined(LTC_CTR_MODE)
+ #error LTC_YARROW requires LTC_CTR_MODE chaining mode to be defined!
#endif
/* a PRNG that simply reads from an available system source */
-#define SPRNG
+#define LTC_SPRNG
-/* The RC4 stream cipher */
-#define RC4
+/* The LTC_RC4 stream cipher */
+#define LTC_RC4
/* Fortuna PRNG */
-#define FORTUNA
+#define LTC_FORTUNA
/* reseed every N calls to the read function */
-#define FORTUNA_WD 10
+#define LTC_FORTUNA_WD 10
/* number of pools (4..32) can save a bit of ram by lowering the count */
-#define FORTUNA_POOLS 32
+#define LTC_FORTUNA_POOLS 32
-/* Greg's SOBER128 PRNG ;-0 */
-#define SOBER128
+/* Greg's LTC_SOBER128 PRNG ;-0 */
+#define LTC_SOBER128
/* the *nix style /dev/random device */
-#define DEVRANDOM
+#define LTC_DEVRANDOM
/* try /dev/urandom before trying /dev/random */
#define TRY_URANDOM_FIRST
@@ -284,10 +287,10 @@
#ifndef LTC_NO_MATH
/* LibTomMath */
-/* #define LTM_DESC */
+/* #define LTM_LTC_DESC */
/* TomsFastMath */
-/* #define TFM_DESC */
+/* #define TFM_LTC_DESC */
#endif /* LTC_NO_MATH */
@@ -295,37 +298,37 @@
#ifndef LTC_NO_PK
/* Include RSA support */
-#define MRSA
+#define LTC_MRSA
/* Include Katja (a Rabin variant like RSA) */
/* #define MKAT */
/* Digital Signature Algorithm */
-#define MDSA
+#define LTC_MDSA
/* ECC */
-#define MECC
+#define LTC_MECC
/* use Shamir's trick for point mul (speeds up signature verification) */
#define LTC_ECC_SHAMIR
-#if defined(TFM_DESC) && defined(MECC)
- #define MECC_ACCEL
+#if defined(TFM_LTC_DESC) && defined(LTC_MECC)
+ #define LTC_MECC_ACCEL
#endif
/* do we want fixed point ECC */
-/* #define MECC_FP */
+/* #define LTC_MECC_FP */
/* Timing Resistant? */
/* #define LTC_ECC_TIMING_RESISTANT */
#endif /* LTC_NO_PK */
-/* PKCS #1 (RSA) and #5 (Password Handling) stuff */
+/* LTC_PKCS #1 (RSA) and #5 (Password Handling) stuff */
#ifndef LTC_NO_PKCS
-#define PKCS_1
-#define PKCS_5
+#define LTC_PKCS_1
+#define LTC_PKCS_5
/* Include ASN.1 DER (required by DSA/RSA) */
#define LTC_DER
@@ -334,7 +337,7 @@
/* cleanup */
-#ifdef MECC
+#ifdef LTC_MECC
/* Supported ECC Key Sizes */
#ifndef LTC_NO_CURVES
#define ECC112
@@ -348,20 +351,20 @@
#endif
#endif
-#if defined(MECC) || defined(MRSA) || defined(MDSA) || defined(MKATJA)
+#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(MKATJA)
/* Include the MPI functionality? (required by the PK algorithms) */
#define MPI
#endif
-#ifdef MRSA
- #define PKCS_1
+#ifdef LTC_MRSA
+ #define LTC_PKCS_1
#endif
#if defined(LTC_DER) && !defined(MPI)
#error ASN.1 DER requires MPI functionality
#endif
-#if (defined(MDSA) || defined(MRSA) || defined(MECC) || defined(MKATJA)) && !defined(LTC_DER)
+#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(MKATJA)) && !defined(LTC_DER)
#error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled
#endif
@@ -391,7 +394,7 @@
/* Debuggers */
-/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and RC4 work (see the code) */
+/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and LTC_RC4 work (see the code) */
/* #define LTC_VALGRIND */
#endif
@@ -399,5 +402,5 @@
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */
-/* $Revision: 1.66 $ */
-/* $Date: 2006/12/04 02:50:11 $ */
+/* $Revision: 1.73 $ */
+/* $Date: 2007/05/12 14:37:41 $ */
diff --git a/src/libtom/tomcrypt_des.c b/src/libtom/tomcrypt_des.c
index 3cdc13f..d921ca5 100644
--- a/src/libtom/tomcrypt_des.c
+++ b/src/libtom/tomcrypt_des.c
@@ -6,16 +6,16 @@
* The library is free for all purposes without any express
* guarantee it works.
*
- * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
+ * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
/**
@file des.c
- DES code submitted by Dobes Vandermeer
+ LTC_DES code submitted by Dobes Vandermeer
*/
-#ifdef DES
+#ifdef LTC_DES
#define EN0 0
#define DE1 1
@@ -1519,7 +1519,7 @@ static void desfunc(ulong32 *block, const ulong32 *keys)
#endif
/**
- Initialize the DES block cipher
+ Initialize the LTC_DES block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -1546,7 +1546,7 @@ static int des_setup(const unsigned char *key, int keylen, int num_rounds, symme
}
/**
- Initialize the 3DES-EDE block cipher
+ Initialize the 3LTC_DES-EDE block cipher
@param key The symmetric key you wish to pass
@param keylen The key length in bytes
@param num_rounds The number of rounds desired (0 for default)
@@ -1578,7 +1578,7 @@ static int des3_setup(const unsigned char *key, int keylen, int num_rounds, symm
}
/**
- Encrypts a block of text with DES
+ Encrypts a block of text with LTC_DES
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -1599,7 +1599,7 @@ static int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric
}
/**
- Decrypts a block of text with DES
+ Decrypts a block of text with LTC_DES
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -1620,7 +1620,7 @@ static int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric
}
/**
- Encrypts a block of text with 3DES-EDE
+ Encrypts a block of text with 3LTC_DES-EDE
@param pt The input plaintext (8 bytes)
@param ct The output ciphertext (8 bytes)
@param skey The key as scheduled
@@ -1644,7 +1644,7 @@ static int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetri
}
/**
- Decrypts a block of text with 3DES-EDE
+ Decrypts a block of text with 3LTC_DES-EDE
@param ct The input ciphertext (8 bytes)
@param pt The output plaintext (8 bytes)
@param skey The key as scheduled
@@ -1667,7 +1667,7 @@ static int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetri
}
/**
- Performs a self-test of the DES block cipher
+ Performs a self-test of the LTC_DES block cipher
@return CRYPT_OK if functional, CRYPT_NOP if self-test has been disabled
*/
static int des_test(void)
@@ -1898,5 +1898,5 @@ static int des3_keysize(int *keysize)
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/des.c,v $ */
-/* $Revision: 1.13 $ */
-/* $Date: 2006/11/08 23:01:06 $ */
+/* $Revision: 1.15 $ */
+/* $Date: 2007/05/12 14:20:27 $ */
diff --git a/src/libtom/tomcrypt_hash.h b/src/libtom/tomcrypt_hash.h
index d9916ac..ac1e713 100644
--- a/src/libtom/tomcrypt_hash.h
+++ b/src/libtom/tomcrypt_hash.h
@@ -1,5 +1,5 @@
/* ---- HASH FUNCTIONS ---- */
-#ifdef SHA512
+#ifdef LTC_SHA512
struct sha512_state {
ulong64 length, state[8];
unsigned long curlen;
@@ -7,7 +7,7 @@ struct sha512_state {
};
#endif
-#ifdef SHA256
+#ifdef LTC_SHA256
struct sha256_state {
ulong64 length;
ulong32 state[8], curlen;
@@ -15,7 +15,7 @@ struct sha256_state {
};
#endif
-#ifdef SHA1
+#ifdef LTC_SHA1
struct sha1_state {
ulong64 length;
ulong32 state[5], curlen;
@@ -23,7 +23,7 @@ struct sha1_state {
};
#endif
-#ifdef MD5
+#ifdef LTC_MD5
struct md5_state {
ulong64 length;
ulong32 state[4], curlen;
@@ -31,7 +31,7 @@ struct md5_state {
};
#endif
-#ifdef MD4
+#ifdef LTC_MD4
struct md4_state {
ulong64 length;
ulong32 state[4], curlen;
@@ -39,7 +39,7 @@ struct md4_state {
};
#endif
-#ifdef TIGER
+#ifdef LTC_TIGER
struct tiger_state {
ulong64 state[3], length;
unsigned long curlen;
@@ -47,14 +47,14 @@ struct tiger_state {
};
#endif
-#ifdef MD2
+#ifdef LTC_MD2
struct md2_state {
unsigned char chksum[16], X[48], buf[16];
unsigned long curlen;
};
#endif
-#ifdef RIPEMD128
+#ifdef LTC_RIPEMD128
struct rmd128_state {
ulong64 length;
unsigned char buf[64];
@@ -62,7 +62,7 @@ struct rmd128_state {
};
#endif
-#ifdef RIPEMD160
+#ifdef LTC_RIPEMD160
struct rmd160_state {
ulong64 length;
unsigned char buf[64];
@@ -70,7 +70,7 @@ struct rmd160_state {
};
#endif
-#ifdef RIPEMD256
+#ifdef LTC_RIPEMD256
struct rmd256_state {
ulong64 length;
unsigned char buf[64];
@@ -78,7 +78,7 @@ struct rmd256_state {
};
#endif
-#ifdef RIPEMD320
+#ifdef LTC_RIPEMD320
struct rmd320_state {
ulong64 length;
unsigned char buf[64];
@@ -86,7 +86,7 @@ struct rmd320_state {
};
#endif
-#ifdef WHIRLPOOL
+#ifdef LTC_WHIRLPOOL
struct whirlpool_state {
ulong64 length, state[8];
unsigned char buf[64];
@@ -94,7 +94,7 @@ struct whirlpool_state {
};
#endif
-#ifdef CHC_HASH
+#ifdef LTC_CHC_HASH
struct chc_state {
ulong64 length;
unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE];
@@ -104,43 +104,43 @@ struct chc_state {
typedef union Hash_state {
char dummy[1];
-#ifdef CHC_HASH
+#ifdef LTC_CHC_HASH
struct chc_state chc;
#endif
-#ifdef WHIRLPOOL
+#ifdef LTC_WHIRLPOOL
struct whirlpool_state whirlpool;
#endif
-#ifdef SHA512
+#ifdef LTC_SHA512
struct sha512_state sha512;
#endif
-#ifdef SHA256
+#ifdef LTC_SHA256
struct sha256_state sha256;
#endif
-#ifdef SHA1
+#ifdef LTC_SHA1
struct sha1_state sha1;
#endif
-#ifdef MD5
+#ifdef LTC_MD5
struct md5_state md5;
#endif
-#ifdef MD4
+#ifdef LTC_MD4
struct md4_state md4;
#endif
-#ifdef MD2
+#ifdef LTC_MD2
struct md2_state md2;
#endif
-#ifdef TIGER
+#ifdef LTC_TIGER
struct tiger_state tiger;
#endif
-#ifdef RIPEMD128
+#ifdef LTC_RIPEMD128
struct rmd128_state rmd128;
#endif
-#ifdef RIPEMD160
+#ifdef LTC_RIPEMD160
struct rmd160_state rmd160;
#endif
-#ifdef RIPEMD256
+#ifdef LTC_RIPEMD256
struct rmd256_state rmd256;
#endif
-#ifdef RIPEMD320
+#ifdef LTC_RIPEMD320
struct rmd320_state rmd320;
#endif
void *data;
@@ -191,7 +191,7 @@ extern struct ltc_hash_descriptor {
} hash_descriptor[];
-#ifdef CHC_HASH
+#ifdef LTC_CHC_HASH
int chc_register(int cipher);
int chc_init(hash_state * md);
int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen);
@@ -200,7 +200,7 @@ int chc_test(void);
extern const struct ltc_hash_descriptor chc_desc;
#endif
-#ifdef WHIRLPOOL
+#ifdef LTC_WHIRLPOOL
int whirlpool_init(hash_state * md);
int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int whirlpool_done(hash_state * md, unsigned char *hash);
@@ -208,7 +208,7 @@ int whirlpool_test(void);
extern const struct ltc_hash_descriptor whirlpool_desc;
#endif
-#ifdef SHA512
+#ifdef LTC_SHA512
int sha512_init(hash_state * md);
int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int sha512_done(hash_state * md, unsigned char *hash);
@@ -216,9 +216,9 @@ int sha512_test(void);
extern const struct ltc_hash_descriptor sha512_desc;
#endif
-#ifdef SHA384
-#ifndef SHA512
- #error SHA512 is required for SHA384
+#ifdef LTC_SHA384
+#ifndef LTC_SHA512
+ #error LTC_SHA512 is required for LTC_SHA384
#endif
int sha384_init(hash_state * md);
#define sha384_process sha512_process
@@ -227,16 +227,16 @@ int sha384_test(void);
extern const struct ltc_hash_descriptor sha384_desc;
#endif
-#ifdef SHA256
+#ifdef LTC_SHA256
int sha256_init(hash_state * md);
int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int sha256_done(hash_state * md, unsigned char *hash);
int sha256_test(void);
extern const struct ltc_hash_descriptor sha256_desc;
-#ifdef SHA224
-#ifndef SHA256
- #error SHA256 is required for SHA224
+#ifdef LTC_SHA224
+#ifndef LTC_SHA256
+ #error LTC_SHA256 is required for LTC_SHA224
#endif
int sha224_init(hash_state * md);
#define sha224_process sha256_process
@@ -246,7 +246,7 @@ extern const struct ltc_hash_descriptor sha224_desc;
#endif
#endif
-#ifdef SHA1
+#ifdef LTC_SHA1
int sha1_init(hash_state * md);
int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int sha1_done(hash_state * md, unsigned char *hash);
@@ -254,7 +254,7 @@ int sha1_test(void);
extern const struct ltc_hash_descriptor sha1_desc;
#endif
-#ifdef MD5
+#ifdef LTC_MD5
int md5_init(hash_state * md);
int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int md5_done(hash_state * md, unsigned char *hash);
@@ -262,7 +262,7 @@ int md5_test(void);
extern const struct ltc_hash_descriptor md5_desc;
#endif
-#ifdef MD4
+#ifdef LTC_MD4
int md4_init(hash_state * md);
int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int md4_done(hash_state * md, unsigned char *hash);
@@ -270,7 +270,7 @@ int md4_test(void);
extern const struct ltc_hash_descriptor md4_desc;
#endif
-#ifdef MD2
+#ifdef LTC_MD2
int md2_init(hash_state * md);
int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int md2_done(hash_state * md, unsigned char *hash);
@@ -278,7 +278,7 @@ int md2_test(void);
extern const struct ltc_hash_descriptor md2_desc;
#endif
-#ifdef TIGER
+#ifdef LTC_TIGER
int tiger_init(hash_state * md);
int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int tiger_done(hash_state * md, unsigned char *hash);
@@ -286,7 +286,7 @@ int tiger_test(void);
extern const struct ltc_hash_descriptor tiger_desc;
#endif
-#ifdef RIPEMD128
+#ifdef LTC_RIPEMD128
int rmd128_init(hash_state * md);
int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int rmd128_done(hash_state * md, unsigned char *hash);
@@ -294,7 +294,7 @@ int rmd128_test(void);
extern const struct ltc_hash_descriptor rmd128_desc;
#endif
-#ifdef RIPEMD160
+#ifdef LTC_RIPEMD160
int rmd160_init(hash_state * md);
int rmd160_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int rmd160_done(hash_state * md, unsigned char *hash);
@@ -302,7 +302,7 @@ int rmd160_test(void);
extern const struct ltc_hash_descriptor rmd160_desc;
#endif
-#ifdef RIPEMD256
+#ifdef LTC_RIPEMD256
int rmd256_init(hash_state * md);
int rmd256_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int rmd256_done(hash_state * md, unsigned char *hash);
@@ -310,7 +310,7 @@ int rmd256_test(void);
extern const struct ltc_hash_descriptor rmd256_desc;
#endif
-#ifdef RIPEMD320
+#ifdef LTC_RIPEMD320
int rmd320_init(hash_state * md);
int rmd320_process(hash_state * md, const unsigned char *in, unsigned long inlen);
int rmd320_done(hash_state * md, unsigned char *hash);
@@ -375,5 +375,5 @@ int func_name (hash_state * md, const unsigned char *in, unsigned long inlen)
}
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_hash.h,v $ */
-/* $Revision: 1.19 $ */
-/* $Date: 2006/11/05 01:36:43 $ */
+/* $Revision: 1.22 $ */
+/* $Date: 2007/05/12 14:32:35 $ */
diff --git a/src/libtom/tomcrypt_mac.h b/src/libtom/tomcrypt_mac.h
index 42bf680..7ad9516 100644
--- a/src/libtom/tomcrypt_mac.h
+++ b/src/libtom/tomcrypt_mac.h
@@ -51,7 +51,7 @@ int omac_file(int cipher,
const char *filename,
unsigned char *out, unsigned long *outlen);
int omac_test(void);
-#endif /* OMAC */
+#endif /* LTC_OMAC */
#ifdef LTC_PMAC
@@ -96,10 +96,10 @@ void pmac_shift_xor(pmac_state *pmac);
#endif /* PMAC */
-#ifdef EAX_MODE
+#ifdef LTC_EAX_MODE
#if !(defined(LTC_OMAC) && defined(LTC_CTR_MODE))
- #error EAX_MODE requires OMAC and CTR
+ #error LTC_EAX_MODE requires LTC_OMAC and CTR
#endif
typedef struct {
@@ -137,7 +137,7 @@ int eax_decrypt_verify_memory(int cipher,
int eax_test(void);
#endif /* EAX MODE */
-#ifdef OCB_MODE
+#ifdef LTC_OCB_MODE
typedef struct {
unsigned char L[MAXBLOCKSIZE], /* L value */
Ls[32][MAXBLOCKSIZE], /* L shifted by i bits to the left */
@@ -191,9 +191,9 @@ int ocb_ntz(unsigned long x);
int s_ocb_done(ocb_state *ocb, const unsigned char *pt, unsigned long ptlen,
unsigned char *ct, unsigned char *tag, unsigned long *taglen, int mode);
-#endif /* OCB_MODE */
+#endif /* LTC_OCB_MODE */
-#ifdef CCM_MODE
+#ifdef LTC_CCM_MODE
#define CCM_ENCRYPT 0
#define CCM_DECRYPT 1
@@ -210,26 +210,26 @@ int ccm_memory(int cipher,
int ccm_test(void);
-#endif /* CCM_MODE */
+#endif /* LTC_CCM_MODE */
-#if defined(LRW_MODE) || defined(GCM_MODE)
+#if defined(LRW_MODE) || defined(LTC_GCM_MODE)
void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c);
#endif
/* table shared between GCM and LRW */
-#if defined(GCM_TABLES) || defined(LRW_TABLES) || ((defined(GCM_MODE) || defined(GCM_MODE)) && defined(LTC_FAST))
+#if defined(LTC_GCM_TABLES) || defined(LRW_TABLES) || ((defined(LTC_GCM_MODE) || defined(LTC_GCM_MODE)) && defined(LTC_FAST))
extern const unsigned char gcm_shift_table[];
#endif
-#ifdef GCM_MODE
+#ifdef LTC_GCM_MODE
#define GCM_ENCRYPT 0
#define GCM_DECRYPT 1
-#define GCM_MODE_IV 0
-#define GCM_MODE_AAD 1
-#define GCM_MODE_TEXT 2
+#define LTC_GCM_MODE_IV 0
+#define LTC_GCM_MODE_AAD 1
+#define LTC_GCM_MODE_TEXT 2
typedef struct {
symmetric_key K;
@@ -247,9 +247,9 @@ typedef struct {
ulong64 totlen, /* 64-bit counter used for IV and AAD */
pttotlen; /* 64-bit counter for the PT */
-#ifdef GCM_TABLES
+#ifdef LTC_GCM_TABLES
unsigned char PC[16][256][16] /* 16 tables of 8x128 */
-#ifdef GCM_TABLES_SSE2
+#ifdef LTC_GCM_TABLES_SSE2
__attribute__ ((aligned (16)))
#endif
;
@@ -287,9 +287,9 @@ int gcm_memory( int cipher,
int direction);
int gcm_test(void);
-#endif /* GCM_MODE */
+#endif /* LTC_GCM_MODE */
-#ifdef PELICAN
+#ifdef LTC_PELICAN
typedef struct pelican_state
{
@@ -311,6 +311,9 @@ int pelican_memory(const unsigned char *key, unsigned long keylen,
#ifdef LTC_XCBC
+/* add this to "keylen" to xcbc_init to use a pure three-key XCBC MAC */
+#define LTC_XCBC_PURE 0x8000UL
+
typedef struct {
unsigned char K[3][MAXBLOCKSIZE],
IV[MAXBLOCKSIZE];
@@ -377,5 +380,5 @@ int f9_test(void);
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_mac.h,v $ */
-/* $Revision: 1.20 $ */
-/* $Date: 2006/11/08 21:57:04 $ */
+/* $Revision: 1.23 $ */
+/* $Date: 2007/05/12 14:37:41 $ */
diff --git a/src/libtom/tomcrypt_math.h b/src/libtom/tomcrypt_math.h
index c996e41..a05d7ff 100644
--- a/src/libtom/tomcrypt_math.h
+++ b/src/libtom/tomcrypt_math.h
@@ -7,11 +7,11 @@
#define LTC_MP_NO 0
#define LTC_MP_YES 1
-#ifndef MECC
+#ifndef LTC_MECC
typedef void ecc_point;
#endif
-#ifndef MRSA
+#ifndef LTC_MRSA
typedef void rsa_key;
#endif
@@ -496,5 +496,5 @@ extern const ltc_math_descriptor gmp_desc;
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_math.h,v $ */
-/* $Revision: 1.43 $ */
-/* $Date: 2006/12/02 19:23:13 $ */
+/* $Revision: 1.44 $ */
+/* $Date: 2007/05/12 14:32:35 $ */
diff --git a/src/libtom/tomcrypt_misc.h b/src/libtom/tomcrypt_misc.h
index 0b444f8..f5384ca 100644
--- a/src/libtom/tomcrypt_misc.h
+++ b/src/libtom/tomcrypt_misc.h
@@ -1,5 +1,5 @@
-/* ---- BASE64 Routines ---- */
-#ifdef BASE64
+/* ---- LTC_BASE64 Routines ---- */
+#ifdef LTC_BASE64
int base64_encode(const unsigned char *in, unsigned long len,
unsigned char *out, unsigned long *outlen);
@@ -19,5 +19,5 @@ extern const char *crypt_build_settings;
int crypt_fsa(void *mp, ...);
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_misc.h,v $ */
-/* $Revision: 1.4 $ */
-/* $Date: 2006/11/06 03:03:01 $ */
+/* $Revision: 1.5 $ */
+/* $Date: 2007/05/12 14:32:35 $ */
diff --git a/src/libtom/tomcrypt_pk.h b/src/libtom/tomcrypt_pk.h
index 3a0d7ab..800fab3 100644
--- a/src/libtom/tomcrypt_pk.h
+++ b/src/libtom/tomcrypt_pk.h
@@ -8,13 +8,13 @@ enum {
int rand_prime(void *N, long len, prng_state *prng, int wprng);
/* ---- RSA ---- */
-#ifdef MRSA
+#ifdef LTC_MRSA
/* Min and Max RSA key sizes (in bits) */
#define MIN_RSA_SIZE 1024
#define MAX_RSA_SIZE 4096
-/** RSA PKCS style key */
+/** RSA LTC_PKCS style key */
typedef struct Rsa_key {
/** Type of key, PK_PRIVATE or PK_PUBLIC */
int type;
@@ -44,20 +44,20 @@ int rsa_exptmod(const unsigned char *in, unsigned long inlen,
void rsa_free(rsa_key *key);
-/* These use PKCS #1 v2.0 padding */
+/* These use LTC_PKCS #1 v2.0 padding */
#define rsa_encrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, _key) \
- rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_PKCS_1_OAEP, _key)
+ rsa_encrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _prng, _prng_idx, _hash_idx, LTC_LTC_PKCS_1_OAEP, _key)
#define rsa_decrypt_key(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, _stat, _key) \
- rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_PKCS_1_OAEP, _stat, _key)
+ rsa_decrypt_key_ex(_in, _inlen, _out, _outlen, _lparam, _lparamlen, _hash_idx, LTC_LTC_PKCS_1_OAEP, _stat, _key)
#define rsa_sign_hash(_in, _inlen, _out, _outlen, _prng, _prng_idx, _hash_idx, _saltlen, _key) \
- rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_PKCS_1_PSS, _prng, _prng_idx, _hash_idx, _saltlen, _key)
+ rsa_sign_hash_ex(_in, _inlen, _out, _outlen, LTC_LTC_PKCS_1_PSS, _prng, _prng_idx, _hash_idx, _saltlen, _key)
#define rsa_verify_hash(_sig, _siglen, _hash, _hashlen, _hash_idx, _saltlen, _stat, _key) \
- rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key)
+ rsa_verify_hash_ex(_sig, _siglen, _hash, _hashlen, LTC_LTC_PKCS_1_PSS, _hash_idx, _saltlen, _stat, _key)
-/* These can be switched between PKCS #1 v2.x and PKCS #1 v1.5 paddings */
+/* These can be switched between LTC_PKCS #1 v2.x and LTC_PKCS #1 v1.5 paddings */
int rsa_encrypt_key_ex(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
const unsigned char *lparam, unsigned long lparamlen,
@@ -82,7 +82,7 @@ int rsa_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
int hash_idx, unsigned long saltlen,
int *stat, rsa_key *key);
-/* PKCS #1 import/export */
+/* LTC_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);
@@ -95,7 +95,7 @@ int rsa_import(const unsigned char *in, unsigned long inlen, rsa_key *key);
#define MIN_KAT_SIZE 1024
#define MAX_KAT_SIZE 4096
-/** Katja PKCS style key */
+/** Katja LTC_PKCS style key */
typedef struct KAT_key {
/** Type of key, PK_PRIVATE or PK_PUBLIC */
int type;
@@ -125,7 +125,7 @@ int katja_exptmod(const unsigned char *in, unsigned long inlen,
void katja_free(katja_key *key);
-/* These use PKCS #1 v2.0 padding */
+/* These use LTC_PKCS #1 v2.0 padding */
int katja_encrypt_key(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen,
const unsigned char *lparam, unsigned long lparamlen,
@@ -137,14 +137,14 @@ int katja_decrypt_key(const unsigned char *in, unsigned long inlen,
int hash_idx, int *stat,
katja_key *key);
-/* PKCS #1 import/export */
+/* LTC_PKCS #1 import/export */
int katja_export(unsigned char *out, unsigned long *outlen, int type, katja_key *key);
int katja_import(const unsigned char *in, unsigned long inlen, katja_key *key);
#endif
/* ---- ECC Routines ---- */
-#ifdef MECC
+#ifdef LTC_MECC
/* size of our temp buffers for exported keys */
#define ECC_BUF_SIZE 256
@@ -251,7 +251,7 @@ void ltc_ecc_del_point(ecc_point *p);
int ltc_ecc_is_valid_idx(int n);
/* point ops (mp == montgomery digit) */
-#if !defined(MECC_ACCEL) || defined(LTM_DESC) || defined(GMP_DESC)
+#if !defined(LTC_MECC_ACCEL) || defined(LTM_LTC_DESC) || defined(GMP_LTC_DESC)
/* R = 2P */
int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp);
@@ -259,11 +259,18 @@ int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void
int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp);
#endif
-#if defined(MECC_FP)
+#if defined(LTC_MECC_FP)
+/* optimized point multiplication using fixed point cache (HAC algorithm 14.117) */
int ltc_ecc_fp_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
+
+/* functions for saving/loading/freeing/adding to fixed point cache */
int ltc_ecc_fp_save_state(unsigned char **out, unsigned long *outlen);
int ltc_ecc_fp_restore_state(unsigned char *in, unsigned long inlen);
void ltc_ecc_fp_free(void);
+int ltc_ecc_fp_add_point(ecc_point *g, void *modulus, int lock);
+
+/* lock/unlock all points currently in fixed point cache */
+void ltc_ecc_fp_tablelock(int lock);
#endif
/* R = kG */
@@ -276,7 +283,8 @@ int ltc_ecc_mul2add(ecc_point *A, void *kA,
ecc_point *C,
void *modulus);
-#ifdef MECC_FP
+#ifdef LTC_MECC_FP
+/* Shamir's trick with optimized point multiplication using fixed point cache */
int ltc_ecc_fp_mul2add(ecc_point *A, void *kA,
ecc_point *B, void *kB,
ecc_point *C, void *modulus);
@@ -290,13 +298,13 @@ int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
#endif
-#ifdef MDSA
+#ifdef LTC_MDSA
/* Max diff between group and modulus size in bytes */
-#define MDSA_DELTA 512
+#define LTC_MDSA_DELTA 512
/* Max DSA group size in bytes (default allows 4k-bit groups) */
-#define MDSA_MAX_GROUP 512
+#define LTC_MDSA_MAX_GROUP 512
/** DSA key structure */
typedef struct {
@@ -496,7 +504,7 @@ int der_printable_char_encode(int c);
int der_printable_value_decode(int v);
/* UTF-8 */
-#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED)) && !defined(LTC_NO_WCHAR)
+#if (defined(SIZE_MAX) || __STDC_VERSION__ >= 199901L || defined(WCHAR_MAX) || defined(_WCHAR_T) || defined(_WCHAR_T_DEFINED) || defined (__WCHAR_TYPE__)) && !defined(LTC_NO_WCHAR)
#include <wchar.h>
#else
typedef ulong32 wchar_t;
@@ -540,5 +548,5 @@ int der_length_utctime(ltc_utctime *utctime, unsigned long *outlen);
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pk.h,v $ */
-/* $Revision: 1.77 $ */
-/* $Date: 2006/12/03 00:39:56 $ */
+/* $Revision: 1.81 $ */
+/* $Date: 2007/05/12 14:32:35 $ */
diff --git a/src/libtom/tomcrypt_pkcs.h b/src/libtom/tomcrypt_pkcs.h
index 71bcdb9..84fb82a 100644
--- a/src/libtom/tomcrypt_pkcs.h
+++ b/src/libtom/tomcrypt_pkcs.h
@@ -1,19 +1,19 @@
-/* PKCS Header Info */
+/* LTC_PKCS Header Info */
-/* ===> PKCS #1 -- RSA Cryptography <=== */
-#ifdef PKCS_1
+/* ===> LTC_PKCS #1 -- RSA Cryptography <=== */
+#ifdef LTC_PKCS_1
enum ltc_pkcs_1_v1_5_blocks
{
- LTC_PKCS_1_EMSA = 1, /* Block type 1 (PKCS #1 v1.5 signature padding) */
- LTC_PKCS_1_EME = 2 /* Block type 2 (PKCS #1 v1.5 encryption padding) */
+ LTC_LTC_PKCS_1_EMSA = 1, /* Block type 1 (LTC_PKCS #1 v1.5 signature padding) */
+ LTC_LTC_PKCS_1_EME = 2 /* Block type 2 (LTC_PKCS #1 v1.5 encryption padding) */
};
enum ltc_pkcs_1_paddings
{
- LTC_PKCS_1_V1_5 = 1, /* PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
- LTC_PKCS_1_OAEP = 2, /* PKCS #1 v2.0 encryption padding */
- LTC_PKCS_1_PSS = 3 /* PKCS #1 v2.1 signature padding */
+ LTC_LTC_PKCS_1_V1_5 = 1, /* LTC_PKCS #1 v1.5 padding (\sa ltc_pkcs_1_v1_5_blocks) */
+ LTC_LTC_PKCS_1_OAEP = 2, /* LTC_PKCS #1 v2.0 encryption padding */
+ LTC_LTC_PKCS_1_PSS = 3 /* LTC_PKCS #1 v2.1 signature padding */
};
int pkcs_1_mgf1( int hash_idx,
@@ -65,10 +65,10 @@ int pkcs_1_pss_decode(const unsigned char *msghash, unsigned long msghashlen,
unsigned long saltlen, int hash_idx,
unsigned long modulus_bitlen, int *res);
-#endif /* PKCS_1 */
+#endif /* LTC_PKCS_1 */
-/* ===> PKCS #5 -- Password Based Cryptography <=== */
-#ifdef PKCS_5
+/* ===> LTC_PKCS #5 -- Password Based Cryptography <=== */
+#ifdef LTC_PKCS_5
/* Algorithm #1 (old) */
int pkcs_5_alg1(const unsigned char *password, unsigned long password_len,
@@ -82,8 +82,8 @@ int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
int iteration_count, int hash_idx,
unsigned char *out, unsigned long *outlen);
-#endif /* PKCS_5 */
+#endif /* LTC_PKCS_5 */
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_pkcs.h,v $ */
-/* $Revision: 1.7 $ */
-/* $Date: 2006/11/15 12:44:59 $ */
+/* $Revision: 1.8 $ */
+/* $Date: 2007/05/12 14:32:35 $ */
diff --git a/src/libtom/tomcrypt_prng.h b/src/libtom/tomcrypt_prng.h
index dd640c9..f3e3e55 100644
--- a/src/libtom/tomcrypt_prng.h
+++ b/src/libtom/tomcrypt_prng.h
@@ -1,5 +1,5 @@
/* ---- PRNG Stuff ---- */
-#ifdef YARROW
+#ifdef LTC_YARROW
struct yarrow_prng {
int cipher, hash;
unsigned char pool[MAXBLOCKSIZE];
@@ -8,16 +8,16 @@ struct yarrow_prng {
};
#endif
-#ifdef RC4
+#ifdef LTC_RC4
struct rc4_prng {
int x, y;
unsigned char buf[256];
};
#endif
-#ifdef FORTUNA
+#ifdef LTC_FORTUNA
struct fortuna_prng {
- hash_state pool[FORTUNA_POOLS]; /* the pools */
+ hash_state pool[LTC_FORTUNA_POOLS]; /* the pools */
symmetric_key skey;
@@ -33,7 +33,7 @@ struct fortuna_prng {
};
#endif
-#ifdef SOBER128
+#ifdef LTC_SOBER128
struct sober128_prng {
ulong32 R[17], /* Working storage for the shift register */
initR[17], /* saved register contents */
@@ -49,16 +49,16 @@ struct sober128_prng {
typedef union Prng_state {
char dummy[1];
-#ifdef YARROW
+#ifdef LTC_YARROW
struct yarrow_prng yarrow;
#endif
-#ifdef RC4
+#ifdef LTC_RC4
struct rc4_prng rc4;
#endif
-#ifdef FORTUNA
+#ifdef LTC_FORTUNA
struct fortuna_prng fortuna;
#endif
-#ifdef SOBER128
+#ifdef LTC_SOBER128
struct sober128_prng sober128;
#endif
} prng_state;
@@ -118,7 +118,7 @@ extern struct ltc_prng_descriptor {
int (*test)(void);
} prng_descriptor[];
-#ifdef YARROW
+#ifdef LTC_YARROW
int yarrow_start(prng_state *prng);
int yarrow_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng);
int yarrow_ready(prng_state *prng);
@@ -130,7 +130,7 @@ int yarrow_test(void);
extern const struct ltc_prng_descriptor yarrow_desc;
#endif
-#ifdef FORTUNA
+#ifdef LTC_FORTUNA
int fortuna_start(prng_state *prng);
int fortuna_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng);
int fortuna_ready(prng_state *prng);
@@ -142,7 +142,7 @@ int fortuna_test(void);
extern const struct ltc_prng_descriptor fortuna_desc;
#endif
-#ifdef RC4
+#ifdef LTC_RC4
int rc4_start(prng_state *prng);
int rc4_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng);
int rc4_ready(prng_state *prng);
@@ -154,7 +154,7 @@ int rc4_test(void);
extern const struct ltc_prng_descriptor rc4_desc;
#endif
-#ifdef SPRNG
+#ifdef LTC_SPRNG
int sprng_start(prng_state *prng);
int sprng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng);
int sprng_ready(prng_state *prng);
@@ -166,7 +166,7 @@ int sprng_test(void);
extern const struct ltc_prng_descriptor sprng_desc;
#endif
-#ifdef SOBER128
+#ifdef LTC_SOBER128
int sober128_start(prng_state *prng);
int sober128_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng);
int sober128_ready(prng_state *prng);
@@ -195,5 +195,5 @@ int rng_make_prng(int bits, int wprng, prng_state *prng, void (*callback)(void))
/* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_prng.h,v $ */
-/* $Revision: 1.8 $ */
-/* $Date: 2006/11/05 01:36:43 $ */
+/* $Revision: 1.9 $ */
+/* $Date: 2007/05/12 14:32:35 $ */