added libtomcrypt-1.09

This commit is contained in:
Tom St Denis
2006-01-26 18:11:56 +00:00
committed by Steffen Jaeckel
parent 1eeff0bfb4
commit a3ce807bae
55 changed files with 2480 additions and 126 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ extern "C" {
#endif
/* version */
#define CRYPT 0x0108
#define SCRYPT "1.08"
#define CRYPT 0x0109
#define SCRYPT "1.09"
/* max size of either a cipher/hash block or symmetric key [largest of the two] */
#define MAXBLOCKSIZE 128
+84 -1
View File
@@ -167,6 +167,7 @@ typedef union Symmetric_key {
void *data;
} symmetric_key;
#ifdef ECB
/** A block cipher ECB structure */
typedef struct {
/** The index of the cipher chosen */
@@ -176,7 +177,9 @@ typedef struct {
/** The scheduled key */
symmetric_key key;
} symmetric_ECB;
#endif
#ifdef CFB
/** A block cipher CFB structure */
typedef struct {
/** The index of the cipher chosen */
@@ -192,7 +195,9 @@ typedef struct {
/** The scheduled key */
symmetric_key key;
} symmetric_CFB;
#endif
#ifdef OFB
/** A block cipher OFB structure */
typedef struct {
/** The index of the cipher chosen */
@@ -206,7 +211,9 @@ typedef struct {
/** The scheduled key */
symmetric_key key;
} symmetric_OFB;
#endif
#ifdef CBC
/** A block cipher CBC structure */
typedef struct {
/** The index of the cipher chosen */
@@ -218,7 +225,10 @@ typedef struct {
/** The scheduled key */
symmetric_key key;
} symmetric_CBC;
#endif
#ifdef CTR
/** A block cipher CTR structure */
typedef struct {
/** The index of the cipher chosen */
@@ -236,6 +246,35 @@ typedef struct {
/** The scheduled key */
symmetric_key key;
} symmetric_CTR;
#endif
#ifdef LRW_MODE
/** A LRW structure */
typedef struct {
/** The index of the cipher chosen (must be a 128-bit block cipher) */
int cipher;
/** The current IV */
unsigned char IV[16],
/** the tweak key */
tweak[16],
/** The current pad, it's the product of the first 15 bytes against the tweak key */
pad[16];
/** The scheduled symmetric key */
symmetric_key key;
#ifdef LRW_TABLES
/** The pre-computed multiplication table */
unsigned char PC[16][256][16];
#endif
} symmetric_LRW;
#endif
/** cipher descriptor table, last entry has "name == NULL" to mark the end of table */
extern struct ltc_cipher_descriptor {
@@ -339,6 +378,28 @@ extern struct ltc_cipher_descriptor {
*/
int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey);
/** Accelerated LRW
@param pt Plaintext
@param ct Ciphertext
@param blocks The number of complete blocks to process
@param IV The initial value (input/output)
@param tweak The LRW tweak
@param skey The scheduled key context
@return CRYPT_OK if successful
*/
int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey);
/** Accelerated LRW
@param ct Ciphertext
@param pt Plaintext
@param blocks The number of complete blocks to process
@param IV The initial value (input/output)
@param tweak The LRW tweak
@param skey The scheduled key context
@return CRYPT_OK if successful
*/
int (*accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey);
/** Accelerated CCM packet (one-shot)
@param key The secret key to use
@param keylen The length of the secret key (octets)
@@ -624,7 +685,29 @@ int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr);
int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr);
int ctr_done(symmetric_CTR *ctr);
#endif
#ifdef LRW_MODE
#define LRW_ENCRYPT 0
#define LRW_DECRYPT 1
int lrw_start( int cipher,
const unsigned char *IV,
const unsigned char *key, int keylen,
const unsigned char *tweak,
int num_rounds,
symmetric_LRW *lrw);
int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw);
int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw);
int lrw_getiv(unsigned char *IV, unsigned long *len, symmetric_LRW *lrw);
int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw);
int lrw_done(symmetric_LRW *lrw);
/* don't call */
int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw);
#endif
int find_cipher(const char *name);
int find_cipher_any(const char *name, int blocklen, int keylen);
int find_cipher_id(unsigned char ID);
+50 -1
View File
@@ -36,6 +36,45 @@
#define XQSORT qsort
#endif
/* Easy button? */
#ifdef LTC_EASY
#define LTC_NO_CIPHERS
#define RIJNDAEL
#define BLOWFISH
#define DES
#define CAST5
#define LTC_NO_MODES
#define ECB
#define CBC
#define CTR
#define LTC_NO_HASHES
#define SHA1
#define SHA512
#define SHA384
#define SHA256
#define SHA224
#define WHIRLPOOL
#define LTC_NO_MACS
#define HMAC
#define OMAC
#define CCM_MODE
#define LTC_NO_PRNGS
#define SPRNG
#define YARROW
#define DEVRANDOM
#define TRY_URANDOM_FIRST
#define LTC_NO_PK
#define MRSA
#define MECC
#endif
/* Use small code where possible */
/* #define LTC_SMALL_CODE */
@@ -101,6 +140,15 @@
#define CBC
#define CTR
/* LRW mode */
#define LRW_MODE
#ifndef LTC_NO_TABLES
/* like GCM mode this will enable 16 8x128 tables [64KB] that make
* seeking very fast.
*/
#define LRW_TABLES
#endif
#endif /* LTC_NO_MODES */
/* ---> One-Way Hash Functions <--- */
@@ -143,8 +191,9 @@
#define OCB_MODE
#define CCM_MODE
#define GCM_MODE
/* disabled waiting on test vectors */
/* #define NLS_MODE */
/* Use 64KiB tables */
#ifndef LTC_NO_TABLES
+46 -1
View File
@@ -212,6 +212,10 @@ int ccm_test(void);
#endif /* CCM_MODE */
#if defined(LRW_MODE) || defined(GCM_MODE)
void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c);
#endif
#ifdef GCM_MODE
#define GCM_ENCRYPT 0
@@ -243,7 +247,6 @@ typedef struct {
} gcm_state;
void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char *c);
void gcm_mult_h(gcm_state *gcm, unsigned char *I);
int gcm_init(gcm_state *gcm, int cipher,
@@ -297,6 +300,48 @@ int pelican_memory(const unsigned char *key, unsigned long keylen,
#endif
#ifdef NLS_MODE
#define NLS_ENCRYPT 0
#define NLS_DECRYPT 1
typedef struct {
ulong32 R[17]; /* Working storage for the shift register */
ulong32 M[8]; /* Working storage for MAC accumulation */
ulong32 CRC[8]; /* Working storage for CRC accumulation */
ulong32 initR[17]; /* saved register contents */
ulong32 konst; /* key dependent constant */
ulong32 sbuf; /* partial ulong32 encryption buffer */
ulong32 mbuf; /* partial ulong32 MAC buffer */
int nbuf; /* number of part-ulong32 stream bits buffered */
ulong32 CtrModF16; /* Multiprecision counter, modulo F16 */
ulong32 CtrMod232; /* Multiprecision counter, LSW */
} nls_state;
/* interface definitions */
int nls_key(nls_state *c, const unsigned char *key, unsigned long keylen); /* set key */
int nls_nonce(nls_state *c, const unsigned char *nonce, unsigned long noncelen); /* set IV */
int nls_maconly(nls_state *c, const unsigned char *buf, unsigned long nbytes); /* accumulate MAC */
int nls_encrypt(nls_state * c,
const unsigned char *pt, unsigned long nbytes,
unsigned char *ct); /* enc+MAC */
int nls_decrypt(nls_state * c,
const unsigned char *ct, unsigned long nbytes,
unsigned char *pt); /* dec+MAC */
int nls_finish(nls_state *c, unsigned char *buf, unsigned long nbytes); /* finalize MAC */
int nls_memory(const unsigned char *key, unsigned long keylen,
const unsigned char *IV, unsigned long IVlen,
const unsigned char *adata, unsigned long adatalen,
unsigned char *pt, unsigned long ptlen,
unsigned char *ct,
unsigned char *tag, unsigned long taglen,
int direction);
#endif
/* $Source$ */
/* $Revision$ */
/* $Date$ */