added libtomcrypt-1.14

This commit is contained in:
Tom St Denis 2006-08-30 23:30:00 +00:00 committed by Steffen Jaeckel
parent 1eed98f629
commit 479cc9c261
64 changed files with 240 additions and 124 deletions

View File

@ -23,7 +23,7 @@ PROJECT_NAME = LibTomCrypt
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = 1.13 PROJECT_NUMBER = 1.14
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put. # base path where the generated documentation will be put.

2
TODO
View File

@ -1,2 +1,4 @@
- long term, start moving macros like CTR over to LTC_CTR to make LTC a bit more "drop-in-able". - long term, start moving macros like CTR over to LTC_CTR to make LTC a bit more "drop-in-able".
- F8 mode could use some LTC_FAST love

24
changes
View File

@ -1,3 +1,23 @@
August 0x1E, 0x07D6
v1.14 -- Renamed the chaining mode macros from XXX to LTC_XXX_MODE. Should help avoid polluting the macro name space.
-- clean up of SHA-256
-- Chris Colman pointed out that der_decode_sequence_* allows LTC_ASN1_SETOF to accept SEQUENCEs and vice versa.
Decoder [non-flexi decoder that is] is more strict now and requires a match.
-- Steffen Jaeckel pointed out a typo in the user manual (re: rsa_exptmod). Fixed. This disproves the notion that
nobody reads it. :-)
-- Made GCM a bit more portable w.r.t. handling the CTR IV (e.g. & with 255)
-- Add LTC_VERBOSE if you really want to see what test is doing :-)
-- Added SSE2 support to GCM [use GCM_TABLES_SSE2 to enable], shaves 2 cycles per byte on Opteron processors
Shaved 4 cycles on a Prescott (Intel P4)
Requires you align your gcm_state on a 16 byte boundary, see gcm_memory() for more info
-- Added missing prototype for f8_test_mode()
-- two fixes to CCM for corner cases [L+noncelen > 15] and fixing the CTR pad to encrypt the CBC-MAC tag
-- Franz Glasner pointed out the ARGTYPE=4 is not actually valid. Fixed.
-- Fixed bug in f8_start() if your key < saltkey unspecified behaviour occurs. :-(
-- Documented F8 mode. Yeah, because you read the manual.
-- Minor updates to the technotes.
June 17th, 2005 June 17th, 2005
v1.13 -- Fixed to fortuna_start() to clean up state if an error occurs. Not really useful at this stage (sha256 can't fail) but useful v1.13 -- Fixed to fortuna_start() to clean up state if an error occurs. Not really useful at this stage (sha256 can't fail) but useful
if I ever make fortuna pluggable if I ever make fortuna pluggable
@ -1464,6 +1484,6 @@ v0.02 -- Changed RC5 to only allow 12 to 24 rounds
v0.01 -- We will call this the first version. v0.01 -- We will call this the first version.
/* $Source: /cvs/libtom/libtomcrypt/changes,v $ */ /* $Source: /cvs/libtom/libtomcrypt/changes,v $ */
/* $Revision: 1.213 $ */ /* $Revision: 1.224 $ */
/* $Date: 2006/06/18 01:42:59 $ */ /* $Date: 2006/08/30 23:23:20 $ */

View File

@ -47,7 +47,7 @@
\def\gap{\vspace{0.5ex}} \def\gap{\vspace{0.5ex}}
\makeindex \makeindex
\begin{document} \begin{document}
\title{LibTomCrypt \\ Version 1.13} \title{LibTomCrypt \\ Version 1.14}
\author{Tom St Denis \\ \author{Tom St Denis \\
\\ \\
tomstdenis@gmail.com \\ tomstdenis@gmail.com \\
@ -1007,6 +1007,55 @@ To terminate the LRW state use the following:
int lrw_done(symmetric_LRW *lrw); int lrw_done(symmetric_LRW *lrw);
\end{verbatim} \end{verbatim}
\subsection{F8 Mode}
\index{F8 Mode}
The F8 Chaining mode (see RFC 3711 for instance) is yet another chaining mode for block ciphers. It behaves much like CTR mode in that it XORs a keystream
against the plaintext to encrypt. F8 mode comes with the additional twist that the counter value is secret, encrypted by a \textit{salt key}. We
initialize F8 mode with the fuollowing function call:
\index{f8\_start()}
\begin{verbatim}
int f8_start( int cipher, const unsigned char *IV,
const unsigned char *key, int keylen,
const unsigned char *salt_key, int skeylen,
int num_rounds, symmetric_F8 *f8);
\end{verbatim}
This will start the F8 mode state using ``key'' as the secret key, ``IV'' as the counter. It uses the ``salt\_key`` as IV encryption key (``m'' in the RFC 3711).
The salt\_key can be shorter than the secret key but it should not be longer.
To encrypt or decrypt data we use the following two functions:
\index{f8\_encrypt()} \index{f8\_decrypt()}
\begin{verbatim}
int f8_encrypt(const unsigned char *pt, unsigned char *ct,
unsigned long len, symmetric_F8 *f8);
int f8_decrypt(const unsigned char *ct, unsigned char *pt,
unsigned long len, symmetric_F8 *f8);
\end{verbatim}
These will encrypt or decrypt a variable length array of bytes using the F8 mode state specified. The length is specified in bytes and does not have to be a multiple
of the ciphers block size.
To change or retrieve the current counter IV value use the following functions:
\index{f8\_getiv()}
\index{f8\_setiv()}
\begin{verbatim}
int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8);
int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8);
\end{verbatim}
These work with the current IV value only and not the encrypted IV value specifed during the call to f8\_start(). The purpose of these two functions is to be
able to seek within a current session only. If you want to change the session IV you will have to call f8\_done() and then start a new state with
f8\_start().
To terminate an F8 state call the following function:
\index{f8\_done()}
\begin{verbatim}
int f8_done(symmetric_F8 *f8);
\end{verbatim}
\vbox{}
\section{Encrypt and Authenticate Modes} \section{Encrypt and Authenticate Modes}
\subsection{EAX Mode} \subsection{EAX Mode}
@ -2719,8 +2768,7 @@ To do raw work with the RSA function call:
\begin{verbatim} \begin{verbatim}
int rsa_exptmod(const unsigned char *in, unsigned long inlen, int rsa_exptmod(const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen, unsigned char *out, unsigned long *outlen,
int which, prng_state *prng, int prng_idx, int which, rsa_key *key);
rsa_key *key);
\end{verbatim} \end{verbatim}
This loads the bignum from ``in'' as a big endian word in the format PKCS specifies, raises it to either ``e'' or ``d'' and stores the result This loads the bignum from ``in'' as a big endian word in the format PKCS specifies, raises it to either ``e'' or ``d'' and stores the result
in ``out'' and the size of the result in ``outlen''. ``which'' is set to {\bf PK\_PUBLIC} to use ``e'' in ``out'' and the size of the result in ``outlen''. ``which'' is set to {\bf PK\_PUBLIC} to use ``e''
@ -5241,5 +5289,5 @@ Since the function is given the entire RSA key (for private keys only) CRT is po
\end{document} \end{document}
% $Source: /cvs/libtom/libtomcrypt/crypt.tex,v $ % $Source: /cvs/libtom/libtomcrypt/crypt.tex,v $
% $Revision: 1.74 $ % $Revision: 1.77 $
% $Date: 2006/06/18 01:35:41 $ % $Date: 2006/08/30 23:23:20 $

View File

@ -16,13 +16,6 @@ reg_algs();
extern ltc_math_descriptor EXT_MATH_LIB; extern ltc_math_descriptor EXT_MATH_LIB;
ltc_mp = EXT_MATH_LIB; ltc_mp = EXT_MATH_LIB;
#endif #endif
time_cipher();
time_hash();
time_encmacs();
time_rsa();
time_ecc();
time_ecc();
return 0;
time_keysched(); time_keysched();
time_cipher(); time_cipher();
time_cipher2(); time_cipher2();

Binary file not shown.

View File

@ -4,7 +4,7 @@
# Modified by Clay Culver # Modified by Clay Culver
# The version # The version
VERSION=1.13 VERSION=1.14
# Compiler and Linker Names # Compiler and Linker Names
#CC=gcc #CC=gcc
@ -367,5 +367,5 @@ zipup: no_oops docs
# $Source: /cvs/libtom/libtomcrypt/makefile,v $ # $Source: /cvs/libtom/libtomcrypt/makefile,v $
# $Revision: 1.126 $ # $Revision: 1.127 $
# $Date: 2006/06/16 23:52:08 $ # $Date: 2006/06/29 01:59:34 $

View File

@ -6,7 +6,7 @@
# Tom St Denis # Tom St Denis
# The version # The version
VERSION=0:113 VERSION=0:114
# Compiler and Linker Names # Compiler and Linker Names
CC=libtool --mode=compile --tag=CC gcc CC=libtool --mode=compile --tag=CC gcc
@ -265,5 +265,5 @@ timing: library testprof/$(LIBTEST) $(TIMINGS)
gcc -o $(TIMING) $(TIMINGS) -ltomcrypt_prof -ltomcrypt $(EXTRALIBS) gcc -o $(TIMING) $(TIMINGS) -ltomcrypt_prof -ltomcrypt $(EXTRALIBS)
# $Source: /cvs/libtom/libtomcrypt/makefile.shared,v $ # $Source: /cvs/libtom/libtomcrypt/makefile.shared,v $
# $Revision: 1.58 $ # $Revision: 1.59 $
# $Date: 2006/06/16 23:52:08 $ # $Date: 2006/06/29 01:59:34 $

View File

@ -12,7 +12,7 @@ You can disable whole classes of algorithms on the command line with the LTC_NO_
The following build with GCC 3.4.4 on an AMD64 box gets you AES, CTR mode, SHA-256, HMAC, Yarrow, full RSA PKCS #1, PKCS #5 and ASN.1 DER in The following build with GCC 3.4.4 on an AMD64 box gets you AES, CTR mode, SHA-256, HMAC, Yarrow, full RSA PKCS #1, PKCS #5 and ASN.1 DER in
roughly 40KB of code (49KB on the ARMv4) (both excluding the math library). roughly 40KB of code (49KB on the ARMv4) (both excluding the math library).
CFLAGS="-DLTC_NO_CIPHERS -DLTC_NO_HASHES -DLTC_NO_PRNGS -DLTC_NO_MACS -DLTC_NO_MODES -DLTC_NO_PK -DRIJNDAEL -DCTR -DSHA256 \ CFLAGS="-DLTC_NO_CIPHERS -DLTC_NO_HASHES -DLTC_NO_PRNGS -DLTC_NO_MACS -DLTC_NO_MODES -DLTC_NO_PK -DRIJNDAEL -DLTC_CTR_MODE -DSHA256 \
-DHMAC -DYARROW -DMRSA -DMPI -DTFM_DESC -DARGTYPE=3 -Os -DLTC_SMALL_CODE -fomit-frame-pointer" make IGNORE_SPEED=1 -DHMAC -DYARROW -DMRSA -DMPI -DTFM_DESC -DARGTYPE=3 -Os -DLTC_SMALL_CODE -fomit-frame-pointer" make IGNORE_SPEED=1
Obviously this won't get you performance but if you need to pack a crypto lib in a device with limited means it's more than enough... Obviously this won't get you performance but if you need to pack a crypto lib in a device with limited means it's more than enough...

View File

@ -1,5 +1,5 @@
Tech Note #7 Tech Note #7
Quick building for testing with LTM Quick building for testing with LTM
EXTRALIBS=-ltommath CFLAGS="-g3 -DLTC_NO_ASM" make -j3 IGNORE_SPEED=1 test EXTRALIBS=-ltommath CFLAGS="-g3 -DLTC_NO_ASM -DUSE_LTM -DLTM_DESC" make -j3 IGNORE_SPEED=1 test

View File

@ -308,7 +308,6 @@ int ECB_ENC(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
LOAD32H(s2, pt + 8); s2 ^= rk[2]; LOAD32H(s2, pt + 8); s2 ^= rk[2];
LOAD32H(s3, pt + 12); s3 ^= rk[3]; LOAD32H(s3, pt + 12); s3 ^= rk[3];
#ifdef LTC_SMALL_CODE #ifdef LTC_SMALL_CODE
for (r = 0; ; r++) { for (r = 0; ; r++) {

View File

@ -117,6 +117,11 @@ int ccm_memory(int cipher,
L = 15 - noncelen; L = 15 - noncelen;
} }
/* decrease noncelen to match L */
if ((noncelen + L) > 15) {
noncelen = 15 - L;
}
/* allocate mem for the symmetric key */ /* allocate mem for the symmetric key */
if (uskey == NULL) { if (uskey == NULL) {
skey = XMALLOC(sizeof(*skey)); skey = XMALLOC(sizeof(*skey));
@ -308,8 +313,10 @@ int ccm_memory(int cipher,
} }
} }
/* setup CTR for the TAG */ /* setup CTR for the TAG (zero the count) */
ctr[14] = ctr[15] = 0x00; for (y = 15; y > 15 - L; y--) {
ctr[y] = 0x00;
}
if ((err = cipher_descriptor[cipher].ecb_encrypt(ctr, CTRPAD, skey)) != CRYPT_OK) { if ((err = cipher_descriptor[cipher].ecb_encrypt(ctr, CTRPAD, skey)) != CRYPT_OK) {
goto error; goto error;
} }

View File

@ -43,6 +43,7 @@ int gcm_memory( int cipher,
unsigned char *tag, unsigned long *taglen, unsigned char *tag, unsigned long *taglen,
int direction) int direction)
{ {
void *orig;
gcm_state *gcm; gcm_state *gcm;
int err; int err;
@ -63,11 +64,26 @@ int gcm_memory( int cipher,
} }
gcm = XMALLOC(sizeof(*gcm));
#ifndef GCM_TABLES_SSE2
orig = gcm = XMALLOC(sizeof(*gcm));
#else
orig = gcm = XMALLOC(sizeof(*gcm) + 16);
#endif
if (gcm == NULL) { if (gcm == NULL) {
return CRYPT_MEM; return CRYPT_MEM;
} }
/* Force GCM to be on a multiple of 16 so we can use 128-bit aligned operations
* note that we only modify gcm and keep orig intact. This code is not portable
* but again it's only for SSE2 anyways, so who cares?
*/
#ifdef GCM_TABLES_SSE2
if ((unsigned long)gcm & 15) {
gcm = (gcm_state *)((unsigned long)gcm + (16 - ((unsigned long)gcm & 15)));
}
#endif
if ((err = gcm_init(gcm, cipher, key, keylen)) != CRYPT_OK) { if ((err = gcm_init(gcm, cipher, key, keylen)) != CRYPT_OK) {
goto LTC_ERR; goto LTC_ERR;
} }
@ -82,7 +98,7 @@ int gcm_memory( int cipher,
} }
err = gcm_done(gcm, tag, taglen); err = gcm_done(gcm, tag, taglen);
LTC_ERR: LTC_ERR:
XFREE(gcm); XFREE(orig);
return err; return err;
} }
#endif #endif

View File

@ -26,6 +26,13 @@ void gcm_mult_h(gcm_state *gcm, unsigned char *I)
unsigned char T[16]; unsigned char T[16];
#ifdef GCM_TABLES #ifdef GCM_TABLES
int x, y; int x, y;
#ifdef GCM_TABLES_SSE2
asm("movdqa (%0),%%xmm0"::"r"(&gcm->PC[0][I[0]][0]));
for (x = 1; x < 16; x++) {
asm("pxor (%0),%%xmm0"::"r"(&gcm->PC[x][I[x]][0]));
}
asm("movdqa %%xmm0,(%0)"::"r"(&T));
#else
XMEMCPY(T, &gcm->PC[0][I[0]][0], 16); XMEMCPY(T, &gcm->PC[0][I[0]][0], 16);
for (x = 1; x < 16; x++) { for (x = 1; x < 16; x++) {
#ifdef LTC_FAST #ifdef LTC_FAST
@ -36,8 +43,9 @@ void gcm_mult_h(gcm_state *gcm, unsigned char *I)
for (y = 0; y < 16; y++) { for (y = 0; y < 16; y++) {
T[y] ^= gcm->PC[x][I[x]][y]; T[y] ^= gcm->PC[x][I[x]][y];
} }
#endif #endif /* LTC_FAST */
} }
#endif /* GCM_TABLES_SSE2 */
#else #else
gcm_gf_mult(gcm->H, I, T); gcm_gf_mult(gcm->H, I, T);
#endif #endif

View File

@ -59,7 +59,7 @@ int gcm_process(gcm_state *gcm,
/* increment counter */ /* increment counter */
for (y = 15; y >= 12; y--) { for (y = 15; y >= 12; y--) {
if (++gcm->Y[y]) { break; } if (++gcm->Y[y] & 255) { break; }
} }
/* encrypt the counter */ /* encrypt the counter */
if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) { if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) {
@ -89,7 +89,7 @@ int gcm_process(gcm_state *gcm,
gcm_mult_h(gcm, gcm->X); gcm_mult_h(gcm, gcm->X);
/* increment counter */ /* increment counter */
for (y = 15; y >= 12; y--) { for (y = 15; y >= 12; y--) {
if (++gcm->Y[y]) { break; } if (++gcm->Y[y] & 255) { break; }
} }
if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) { if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) {
return err; return err;
@ -107,7 +107,7 @@ int gcm_process(gcm_state *gcm,
gcm_mult_h(gcm, gcm->X); gcm_mult_h(gcm, gcm->X);
/* increment counter */ /* increment counter */
for (y = 15; y >= 12; y--) { for (y = 15; y >= 12; y--) {
if (++gcm->Y[y]) { break; } if (++gcm->Y[y] & 255) { break; }
} }
if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) { if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) {
return err; return err;
@ -125,7 +125,7 @@ int gcm_process(gcm_state *gcm,
/* increment counter */ /* increment counter */
for (y = 15; y >= 12; y--) { for (y = 15; y >= 12; y--) {
if (++gcm->Y[y]) { break; } if (++gcm->Y[y] & 255) { break; }
} }
if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) { if ((err = cipher_descriptor[gcm->cipher].ecb_encrypt(gcm->Y, gcm->buf, &gcm->K)) != CRYPT_OK) {
return err; return err;

View File

@ -37,7 +37,7 @@ const struct ltc_hash_descriptor sha256_desc =
#ifdef LTC_SMALL_CODE #ifdef LTC_SMALL_CODE
/* the K array */ /* the K array */
static const unsigned long K[64] = { static const ulong32 K[64] = {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,

View File

@ -16,8 +16,8 @@ extern "C" {
#endif #endif
/* version */ /* version */
#define CRYPT 0x0113 #define CRYPT 0x0114
#define SCRYPT "1.13" #define SCRYPT "1.14"
/* max size of either a cipher/hash block or symmetric key [largest of the two] */ /* max size of either a cipher/hash block or symmetric key [largest of the two] */
#define MAXBLOCKSIZE 128 #define MAXBLOCKSIZE 128

View File

@ -27,8 +27,8 @@ void crypt_argchk(char *v, char *s, int d);
#elif ARGTYPE == 4 #elif ARGTYPE == 4
#define LTC_ARGCHK(x) return CRYPT_INVALID_ARG; #define LTC_ARGCHK(x) if (!(x)) return CRYPT_INVALID_ARG;
#define LTC_ARGCHKVD(x) return; #define LTC_ARGCHKVD(x) if (!(x)) return;
#endif #endif

View File

@ -167,7 +167,7 @@ typedef union Symmetric_key {
void *data; void *data;
} symmetric_key; } symmetric_key;
#ifdef ECB #ifdef LTC_ECB_MODE
/** A block cipher ECB structure */ /** A block cipher ECB structure */
typedef struct { typedef struct {
/** The index of the cipher chosen */ /** The index of the cipher chosen */
@ -179,7 +179,7 @@ typedef struct {
} symmetric_ECB; } symmetric_ECB;
#endif #endif
#ifdef CFB #ifdef LTC_CFB_MODE
/** A block cipher CFB structure */ /** A block cipher CFB structure */
typedef struct { typedef struct {
/** The index of the cipher chosen */ /** The index of the cipher chosen */
@ -197,7 +197,7 @@ typedef struct {
} symmetric_CFB; } symmetric_CFB;
#endif #endif
#ifdef OFB #ifdef LTC_OFB_MODE
/** A block cipher OFB structure */ /** A block cipher OFB structure */
typedef struct { typedef struct {
/** The index of the cipher chosen */ /** The index of the cipher chosen */
@ -213,7 +213,7 @@ typedef struct {
} symmetric_OFB; } symmetric_OFB;
#endif #endif
#ifdef CBC #ifdef LTC_CBC_MODE
/** A block cipher CBC structure */ /** A block cipher CBC structure */
typedef struct { typedef struct {
/** The index of the cipher chosen */ /** The index of the cipher chosen */
@ -228,7 +228,7 @@ typedef struct {
#endif #endif
#ifdef CTR #ifdef LTC_CTR_MODE
/** A block cipher CTR structure */ /** A block cipher CTR structure */
typedef struct { typedef struct {
/** The index of the cipher chosen */ /** The index of the cipher chosen */
@ -249,7 +249,7 @@ typedef struct {
#endif #endif
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** A LRW structure */ /** A LRW structure */
typedef struct { typedef struct {
/** The index of the cipher chosen (must be a 128-bit block cipher) */ /** The index of the cipher chosen (must be a 128-bit block cipher) */
@ -649,7 +649,7 @@ int anubis_keysize(int *keysize);
extern const struct ltc_cipher_descriptor anubis_desc; extern const struct ltc_cipher_descriptor anubis_desc;
#endif #endif
#ifdef ECB #ifdef LTC_ECB_MODE
int ecb_start(int cipher, const unsigned char *key, int ecb_start(int cipher, const unsigned char *key,
int keylen, int num_rounds, symmetric_ECB *ecb); int keylen, int num_rounds, symmetric_ECB *ecb);
int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb); int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb);
@ -657,7 +657,7 @@ int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, s
int ecb_done(symmetric_ECB *ecb); int ecb_done(symmetric_ECB *ecb);
#endif #endif
#ifdef CFB #ifdef LTC_CFB_MODE
int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key, int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
int keylen, int num_rounds, symmetric_CFB *cfb); int keylen, int num_rounds, symmetric_CFB *cfb);
int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb); int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb);
@ -667,7 +667,7 @@ int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb);
int cfb_done(symmetric_CFB *cfb); int cfb_done(symmetric_CFB *cfb);
#endif #endif
#ifdef OFB #ifdef LTC_OFB_MODE
int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key, int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key,
int keylen, int num_rounds, symmetric_OFB *ofb); int keylen, int num_rounds, symmetric_OFB *ofb);
int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb); int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb);
@ -677,7 +677,7 @@ int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb);
int ofb_done(symmetric_OFB *ofb); int ofb_done(symmetric_OFB *ofb);
#endif #endif
#ifdef CBC #ifdef LTC_CBC_MODE
int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key, int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key,
int keylen, int num_rounds, symmetric_CBC *cbc); int keylen, int num_rounds, symmetric_CBC *cbc);
int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc); int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc);
@ -687,7 +687,7 @@ int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc);
int cbc_done(symmetric_CBC *cbc); int cbc_done(symmetric_CBC *cbc);
#endif #endif
#ifdef CTR #ifdef LTC_CTR_MODE
#define CTR_COUNTER_LITTLE_ENDIAN 0 #define CTR_COUNTER_LITTLE_ENDIAN 0
#define CTR_COUNTER_BIG_ENDIAN 1 #define CTR_COUNTER_BIG_ENDIAN 1
@ -704,7 +704,7 @@ int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr);
int ctr_done(symmetric_CTR *ctr); int ctr_done(symmetric_CTR *ctr);
#endif #endif
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
#define LRW_ENCRYPT 0 #define LRW_ENCRYPT 0
#define LRW_DECRYPT 1 #define LRW_DECRYPT 1
@ -736,6 +736,7 @@ int f8_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, sy
int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8); int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8);
int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8); int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8);
int f8_done(symmetric_F8 *f8); int f8_done(symmetric_F8 *f8);
int f8_test_mode(void);
#endif #endif

View File

@ -45,9 +45,9 @@
#define CAST5 #define CAST5
#define LTC_NO_MODES #define LTC_NO_MODES
#define ECB #define LTC_ECB_MODE
#define CBC #define LTC_CBC_MODE
#define CTR #define LTC_CTR_MODE
#define LTC_NO_HASHES #define LTC_NO_HASHES
#define SHA1 #define SHA1
@ -55,7 +55,6 @@
#define SHA384 #define SHA384
#define SHA256 #define SHA256
#define SHA224 #define SHA224
#define WHIRLPOOL
#define LTC_NO_MACS #define LTC_NO_MACS
#define HMAC #define HMAC
@ -73,8 +72,6 @@
#define MECC #define MECC
#endif #endif
/* Use small code where possible */ /* Use small code where possible */
/* #define LTC_SMALL_CODE */ /* #define LTC_SMALL_CODE */
@ -134,17 +131,17 @@
/* ---> Block Cipher Modes of Operation <--- */ /* ---> Block Cipher Modes of Operation <--- */
#ifndef LTC_NO_MODES #ifndef LTC_NO_MODES
#define CFB #define LTC_CFB_MODE
#define OFB #define LTC_OFB_MODE
#define ECB #define LTC_ECB_MODE
#define CBC #define LTC_CBC_MODE
#define CTR #define LTC_CTR_MODE
/* F8 chaining mode */ /* F8 chaining mode */
#define LTC_F8_MODE #define LTC_F8_MODE
/* LRW mode */ /* LRW mode */
#define LRW_MODE #define LTC_LRW_MODE
#ifndef LTC_NO_TABLES #ifndef LTC_NO_TABLES
/* like GCM mode this will enable 16 8x128 tables [64KB] that make /* like GCM mode this will enable 16 8x128 tables [64KB] that make
* seeking very fast. * seeking very fast.
@ -188,7 +185,7 @@
/* ---> Encrypt + Authenticate Modes <--- */ /* ---> Encrypt + Authenticate Modes <--- */
#define EAX_MODE #define EAX_MODE
#if defined(EAX_MODE) && !(defined(CTR) && defined(OMAC)) #if defined(EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(OMAC))
#error EAX_MODE requires CTR and OMAC mode #error EAX_MODE requires CTR and OMAC mode
#endif #endif
@ -201,6 +198,11 @@
#define GCM_TABLES #define GCM_TABLES
#endif #endif
/* USE SSE2? requires GCC works on x86_32 and x86_64*/
#ifdef GCM_TABLES
/* #define GCM_TABLES_SSE2 */
#endif
#endif /* LTC_NO_MACS */ #endif /* LTC_NO_MACS */
/* Various tidbits of modern neatoness */ /* Various tidbits of modern neatoness */
@ -215,8 +217,8 @@
/* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */ /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */
#define YARROW_AES 0 #define YARROW_AES 0
#if defined(YARROW) && !defined(CTR) #if defined(YARROW) && !defined(LTC_CTR_MODE)
#error YARROW requires CTR chaining mode to be defined! #error YARROW requires LTC_CTR_MODE chaining mode to be defined!
#endif #endif
/* a PRNG that simply reads from an available system source */ /* a PRNG that simply reads from an available system source */

View File

@ -98,7 +98,7 @@ void pmac_shift_xor(pmac_state *pmac);
#ifdef EAX_MODE #ifdef EAX_MODE
#if !(defined(OMAC) && defined(CTR)) #if !(defined(OMAC) && defined(LTC_CTR_MODE))
#error EAX_MODE requires OMAC and CTR #error EAX_MODE requires OMAC and CTR
#endif #endif
@ -248,9 +248,12 @@ typedef struct {
pttotlen; /* 64-bit counter for the PT */ pttotlen; /* 64-bit counter for the PT */
#ifdef GCM_TABLES #ifdef GCM_TABLES
unsigned char PC[16][256][16]; /* 16 tables of 8x128 */ unsigned char PC[16][256][16] /* 16 tables of 8x128 */
#ifdef GCM_TABLES_SSE2
__attribute__ ((aligned (16)))
#endif
;
#endif #endif
} gcm_state; } gcm_state;
void gcm_mult_h(gcm_state *gcm, unsigned char *I); void gcm_mult_h(gcm_state *gcm, unsigned char *I);

View File

@ -55,7 +55,7 @@ int hmac_test(void)
3. Test Cases for HMAC-SHA-1 3. Test Cases for HMAC-SHA-1
test_case = 1 test_case = 1
key = 0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
key_len = 20 key_len = 20
data = "Hi Ther 20 data = "Hi Ther 20
digest = 0x4c1a03424b55e07fe7f27be1d58bb9324a9a5a04 digest = 0x4c1a03424b55e07fe7f27be1d58bb9324a9a5a04

View File

@ -153,19 +153,19 @@ const char *crypt_build_settings =
#endif #endif
"\nBlock Chaining Modes:\n" "\nBlock Chaining Modes:\n"
#if defined(CFB) #if defined(LTC_CFB_MODE)
" CFB\n" " CFB\n"
#endif #endif
#if defined(OFB) #if defined(LTC_OFB_MODE)
" OFB\n" " OFB\n"
#endif #endif
#if defined(ECB) #if defined(LTC_ECB_MODE)
" ECB\n" " ECB\n"
#endif #endif
#if defined(CBC) #if defined(LTC_CBC_MODE)
" CBC\n" " CBC\n"
#endif #endif
#if defined(CTR) #if defined(LTC_CTR_MODE)
" CTR\n" " CTR\n"
#endif #endif
#if defined(LRW_MODE) #if defined(LRW_MODE)

View File

@ -16,7 +16,7 @@
*/ */
#ifdef CBC #ifdef LTC_CBC_MODE
/** /**
CBC decrypt CBC decrypt

View File

@ -15,7 +15,7 @@
CBC implementation, finish chain, Tom St Denis CBC implementation, finish chain, Tom St Denis
*/ */
#ifdef CBC #ifdef LTC_CBC_MODE
/** Terminate the chain /** Terminate the chain
@param cbc The CBC chain to terminate @param cbc The CBC chain to terminate

View File

@ -16,7 +16,7 @@
*/ */
#ifdef CBC #ifdef LTC_CBC_MODE
/** /**
CBC encrypt CBC encrypt

View File

@ -15,7 +15,7 @@
CBC implementation, get IV, Tom St Denis CBC implementation, get IV, Tom St Denis
*/ */
#ifdef CBC #ifdef LTC_CBC_MODE
/** /**
Get the current initial vector Get the current initial vector

View File

@ -16,7 +16,7 @@
*/ */
#ifdef CBC #ifdef LTC_CBC_MODE
/** /**
Set an initial vector Set an initial vector

View File

@ -15,7 +15,7 @@
CBC implementation, start chain, Tom St Denis CBC implementation, start chain, Tom St Denis
*/ */
#ifdef CBC #ifdef LTC_CBC_MODE
/** /**
Initialize a CBC context Initialize a CBC context

View File

@ -15,7 +15,7 @@
CFB implementation, decrypt data, Tom St Denis CFB implementation, decrypt data, Tom St Denis
*/ */
#ifdef CFB #ifdef LTC_CFB_MODE
/** /**
CFB decrypt CFB decrypt

View File

@ -15,7 +15,7 @@
CFB implementation, finish chain, Tom St Denis CFB implementation, finish chain, Tom St Denis
*/ */
#ifdef CFB #ifdef LTC_CFB_MODE
/** Terminate the chain /** Terminate the chain
@param cfb The CFB chain to terminate @param cfb The CFB chain to terminate

View File

@ -15,7 +15,7 @@
CFB implementation, encrypt data, Tom St Denis CFB implementation, encrypt data, Tom St Denis
*/ */
#ifdef CFB #ifdef LTC_CFB_MODE
/** /**
CFB encrypt CFB encrypt

View File

@ -15,7 +15,7 @@
CFB implementation, get IV, Tom St Denis CFB implementation, get IV, Tom St Denis
*/ */
#ifdef CFB #ifdef LTC_CFB_MODE
/** /**
Get the current initial vector Get the current initial vector

View File

@ -14,7 +14,8 @@
@file cfb_setiv.c @file cfb_setiv.c
CFB implementation, set IV, Tom St Denis CFB implementation, set IV, Tom St Denis
*/ */
#ifdef CFB
#ifdef LTC_CFB_MODE
/** /**
Set an initial vector Set an initial vector

View File

@ -16,7 +16,7 @@
*/ */
#ifdef CFB #ifdef LTC_CFB_MODE
/** /**
Initialize a CFB context Initialize a CFB context

View File

@ -15,7 +15,7 @@
CTR implementation, decrypt data, Tom St Denis CTR implementation, decrypt data, Tom St Denis
*/ */
#ifdef CTR #ifdef LTC_CTR_MODE
/** /**
CTR decrypt CTR decrypt

View File

@ -15,7 +15,7 @@
CTR implementation, finish chain, Tom St Denis CTR implementation, finish chain, Tom St Denis
*/ */
#ifdef CTR #ifdef LTC_CTR_MODE
/** Terminate the chain /** Terminate the chain
@param ctr The CTR chain to terminate @param ctr The CTR chain to terminate

View File

@ -16,7 +16,7 @@
*/ */
#ifdef CTR #ifdef LTC_CTR_MODE
/** /**
CTR encrypt CTR encrypt

View File

@ -15,7 +15,7 @@
CTR implementation, get IV, Tom St Denis CTR implementation, get IV, Tom St Denis
*/ */
#ifdef CTR #ifdef LTC_CTR_MODE
/** /**
Get the current initial vector Get the current initial vector

View File

@ -15,7 +15,7 @@
CTR implementation, set IV, Tom St Denis CTR implementation, set IV, Tom St Denis
*/ */
#ifdef CTR #ifdef LTC_CTR_MODE
/** /**
Set an initial vector Set an initial vector

View File

@ -16,7 +16,7 @@
*/ */
#ifdef CTR #ifdef LTC_CTR_MODE
/** /**
Initialize a CTR context Initialize a CTR context

View File

@ -15,7 +15,7 @@
ECB implementation, decrypt a block, Tom St Denis ECB implementation, decrypt a block, Tom St Denis
*/ */
#ifdef ECB #ifdef LTC_ECB_MODE
/** /**
ECB decrypt ECB decrypt

View File

@ -15,7 +15,7 @@
ECB implementation, finish chain, Tom St Denis ECB implementation, finish chain, Tom St Denis
*/ */
#ifdef ECB #ifdef LTC_ECB_MODE
/** Terminate the chain /** Terminate the chain
@param ecb The ECB chain to terminate @param ecb The ECB chain to terminate

View File

@ -15,7 +15,7 @@
ECB implementation, encrypt a block, Tom St Denis ECB implementation, encrypt a block, Tom St Denis
*/ */
#ifdef ECB #ifdef LTC_ECB_MODE
/** /**
ECB encrypt ECB encrypt

View File

@ -16,7 +16,7 @@
*/ */
#ifdef ECB #ifdef LTC_ECB_MODE
/** /**
Initialize a ECB context Initialize a ECB context

View File

@ -54,6 +54,7 @@ int f8_start( int cipher, const unsigned char *IV,
f8->padlen = f8->blocklen; f8->padlen = f8->blocklen;
/* now get key ^ salt_key [extend salt_ket with 0x55 as required to match length] */ /* now get key ^ salt_key [extend salt_ket with 0x55 as required to match length] */
zeromem(tkey, sizeof(tkey));
for (x = 0; x < keylen && x < (int)sizeof(tkey); x++) { for (x = 0; x < keylen && x < (int)sizeof(tkey); x++) {
tkey[x] = key[x]; tkey[x] = key[x];
} }

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, Decrypt blocks, Tom St Denis LRW_MODE implementation, Decrypt blocks, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
LRW decrypt blocks LRW decrypt blocks

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, Free resources, Tom St Denis LRW_MODE implementation, Free resources, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
Terminate a LRW state Terminate a LRW state

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, Encrypt blocks, Tom St Denis LRW_MODE implementation, Encrypt blocks, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
LRW encrypt blocks LRW encrypt blocks

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, Retrieve the current IV, Tom St Denis LRW_MODE implementation, Retrieve the current IV, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
Get the IV for LRW Get the IV for LRW

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, Encrypt/decrypt blocks, Tom St Denis LRW_MODE implementation, Encrypt/decrypt blocks, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
Process blocks with LRW, since decrypt/encrypt are largely the same they share this code. Process blocks with LRW, since decrypt/encrypt are largely the same they share this code.

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, Set the current IV, Tom St Denis LRW_MODE implementation, Set the current IV, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
Set the IV for LRW Set the IV for LRW

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, start mode, Tom St Denis LRW_MODE implementation, start mode, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
Initialize the LRW context Initialize the LRW context

View File

@ -15,7 +15,7 @@
LRW_MODE implementation, test LRW, Tom St Denis LRW_MODE implementation, test LRW, Tom St Denis
*/ */
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
/** /**
Test LRW against specs Test LRW against specs

View File

@ -15,7 +15,7 @@
OFB implementation, decrypt data, Tom St Denis OFB implementation, decrypt data, Tom St Denis
*/ */
#ifdef OFB #ifdef LTC_OFB_MODE
/** /**
OFB decrypt OFB decrypt

View File

@ -15,7 +15,7 @@
OFB implementation, finish chain, Tom St Denis OFB implementation, finish chain, Tom St Denis
*/ */
#ifdef OFB #ifdef LTC_OFB_MODE
/** Terminate the chain /** Terminate the chain
@param ofb The OFB chain to terminate @param ofb The OFB chain to terminate

View File

@ -15,7 +15,7 @@
OFB implementation, encrypt data, Tom St Denis OFB implementation, encrypt data, Tom St Denis
*/ */
#ifdef OFB #ifdef LTC_OFB_MODE
/** /**
OFB encrypt OFB encrypt

View File

@ -15,7 +15,7 @@
OFB implementation, get IV, Tom St Denis OFB implementation, get IV, Tom St Denis
*/ */
#ifdef OFB #ifdef LTC_OFB_MODE
/** /**
Get the current initial vector Get the current initial vector

View File

@ -15,7 +15,7 @@
OFB implementation, set IV, Tom St Denis OFB implementation, set IV, Tom St Denis
*/ */
#ifdef OFB #ifdef LTC_OFB_MODE
/** /**
Set an initial vector Set an initial vector

View File

@ -16,7 +16,7 @@
*/ */
#ifdef OFB #ifdef LTC_OFB_MODE
/** /**
Initialize a OFB context Initialize a OFB context

View File

@ -218,6 +218,12 @@ int der_decode_sequence_ex(const unsigned char *in, unsigned long inlen,
case LTC_ASN1_SETOF: case LTC_ASN1_SETOF:
case LTC_ASN1_SEQUENCE: case LTC_ASN1_SEQUENCE:
/* detect if we have the right type */
if ((type == LTC_ASN1_SETOF && (in[x] & 0x3F) != 0x31) || (type == LTC_ASN1_SEQUENCE && (in[x] & 0x3F) != 0x30)) {
err = CRYPT_INVALID_PACKET;
goto LBL_ERR;
}
z = inlen; z = inlen;
if ((err = der_decode_sequence(in + x, z, data, size)) != CRYPT_OK) { if ((err = der_decode_sequence(in + x, z, data, size)) != CRYPT_OK) {
if (!ordered) { continue; } if (!ordered) { continue; }

View File

@ -5,16 +5,16 @@ int modes_test(void)
{ {
unsigned char pt[64], ct[64], tmp[64], key[16], iv[16], iv2[16]; unsigned char pt[64], ct[64], tmp[64], key[16], iv[16], iv2[16];
int cipher_idx; int cipher_idx;
#ifdef CBC #ifdef LTC_CBC_MODE
symmetric_CBC cbc; symmetric_CBC cbc;
#endif #endif
#ifdef CFB #ifdef LTC_CFB_MODE
symmetric_CFB cfb; symmetric_CFB cfb;
#endif #endif
#ifdef OFB #ifdef LTC_OFB_MODE
symmetric_OFB ofb; symmetric_OFB ofb;
#endif #endif
#ifdef CTR #ifdef LTC_CTR_MODE
symmetric_CTR ctr; symmetric_CTR ctr;
#endif #endif
unsigned long l; unsigned long l;
@ -35,11 +35,11 @@ int modes_test(void)
DO(f8_test_mode()); DO(f8_test_mode());
#endif #endif
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
DO(lrw_test()); DO(lrw_test());
#endif #endif
#ifdef CBC #ifdef LTC_CBC_MODE
/* test CBC mode */ /* test CBC mode */
/* encode the block */ /* encode the block */
DO(cbc_start(cipher_idx, iv, key, 16, 0, &cbc)); DO(cbc_start(cipher_idx, iv, key, 16, 0, &cbc));
@ -61,7 +61,7 @@ int modes_test(void)
} }
#endif #endif
#ifdef CFB #ifdef LTC_CFB_MODE
/* test CFB mode */ /* test CFB mode */
/* encode the block */ /* encode the block */
DO(cfb_start(cipher_idx, iv, key, 16, 0, &cfb)); DO(cfb_start(cipher_idx, iv, key, 16, 0, &cfb));
@ -84,7 +84,7 @@ int modes_test(void)
} }
#endif #endif
#ifdef OFB #ifdef LTC_OFB_MODE
/* test OFB mode */ /* test OFB mode */
/* encode the block */ /* encode the block */
DO(ofb_start(cipher_idx, iv, key, 16, 0, &ofb)); DO(ofb_start(cipher_idx, iv, key, 16, 0, &ofb));
@ -106,7 +106,7 @@ int modes_test(void)
} }
#endif #endif
#ifdef CTR #ifdef LTC_CTR_MODE
/* test CTR mode */ /* test CTR mode */
/* encode the block */ /* encode the block */
DO(ctr_start(cipher_idx, iv, key, 16, 0, CTR_COUNTER_LITTLE_ENDIAN, &ctr)); DO(ctr_start(cipher_idx, iv, key, 16, 0, CTR_COUNTER_LITTLE_ENDIAN, &ctr));

View File

@ -18,7 +18,12 @@ typedef struct {
extern prng_state yarrow_prng; extern prng_state yarrow_prng;
void run_cmd(int res, int line, char *file, char *cmd); void run_cmd(int res, int line, char *file, char *cmd);
#define DO(x) { run_cmd((x), __LINE__, __FILE__, #x); }
#ifdef LTC_VERBOSE
#define DO(x) do { fprintf(stderr, "%s:\n", #x); run_cmd((x), __LINE__, __FILE__, #x); } while (0);
#else
#define DO(x) do { run_cmd((x), __LINE__, __FILE__, #x); } while (0);
#endif
/* TESTS */ /* TESTS */
int cipher_hash_test(void); int cipher_hash_test(void);

View File

@ -347,7 +347,7 @@ int time_cipher(void)
return 0; return 0;
} }
#ifdef CBC #ifdef LTC_CBC_MODE
int time_cipher2(void) int time_cipher2(void)
{ {
unsigned long x, y1; unsigned long x, y1;
@ -422,7 +422,7 @@ int time_cipher2(void)
int time_cipher2(void) { fprintf(stderr, "NO CBC\n"); return 0; } int time_cipher2(void) { fprintf(stderr, "NO CBC\n"); return 0; }
#endif #endif
#ifdef CTR #ifdef LTC_CTR_MODE
int time_cipher3(void) int time_cipher3(void)
{ {
unsigned long x, y1; unsigned long x, y1;
@ -497,7 +497,7 @@ int time_cipher3(void)
int time_cipher3(void) { fprintf(stderr, "NO CTR\n"); return 0; } int time_cipher3(void) { fprintf(stderr, "NO CTR\n"); return 0; }
#endif #endif
#ifdef LRW_MODE #ifdef LTC_LRW_MODE
int time_cipher4(void) int time_cipher4(void)
{ {
unsigned long x, y1; unsigned long x, y1;
@ -1157,7 +1157,11 @@ void time_encmacs_(unsigned long MAC_SIZE)
fprintf(stderr, "GCM (no-precomp)\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024)); fprintf(stderr, "GCM (no-precomp)\t%9llu\n", t2/(ulong64)(MAC_SIZE*1024));
{ {
gcm_state gcm; gcm_state gcm
#ifdef GCM_TABLES_SSE2
__attribute__ ((aligned (16)))
#endif
;
if ((err = gcm_init(&gcm, cipher_idx, key, 16)) != CRYPT_OK) { fprintf(stderr, "gcm_init: %s\n", error_to_string(err)); exit(EXIT_FAILURE); } if ((err = gcm_init(&gcm, cipher_idx, key, 16)) != CRYPT_OK) { fprintf(stderr, "gcm_init: %s\n", error_to_string(err)); exit(EXIT_FAILURE); }
t2 = -1; t2 = -1;