added libtomcrypt-1.17

This commit is contained in:
Tom St Denis
2007-07-20 17:48:02 +00:00
committed by Steffen Jaeckel
parent e24b01d392
commit bbc52b9e1b
341 changed files with 4806 additions and 1740 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
* 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"
@@ -15,7 +15,7 @@
CCM support, process a block of memory, Tom St Denis
*/
#ifdef CCM_MODE
#ifdef LTC_CCM_MODE
/**
CCM encrypt/decrypt and produce an authentication tag
+2 -2
View File
@@ -6,7 +6,7 @@
* 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"
@@ -15,7 +15,7 @@
CCM support, process a block of memory, Tom St Denis
*/
#ifdef CCM_MODE
#ifdef LTC_CCM_MODE
int ccm_test(void)
{
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@file eax_addheader.c
@@ -14,7 +14,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
add header (metadata) to the stream
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
Decrypt data with the EAX protocol
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
Decrypt a block of memory and verify the provided MAC tag with EAX
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
Terminate an EAX session and get the tag.
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
Encrypt with EAX a block of data.
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
EAX encrypt and produce an authentication tag
+5 -5
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
Initialized an EAX state
@@ -66,7 +66,7 @@ int eax_init(eax_state *eax, int cipher,
return CRYPT_MEM;
}
/* N = OMAC_0K(nonce) */
/* N = LTC_OMAC_0K(nonce) */
zeromem(buf, MAXBLOCKSIZE);
if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
goto LBL_ERR;
@@ -86,7 +86,7 @@ int eax_init(eax_state *eax, int cipher,
goto LBL_ERR;
}
/* H = OMAC_1K(header) */
/* H = LTC_OMAC_1K(header) */
zeromem(buf, MAXBLOCKSIZE);
buf[blklen - 1] = 1;
@@ -112,7 +112,7 @@ int eax_init(eax_state *eax, int cipher,
goto LBL_ERR;
}
/* setup the OMAC for the ciphertext */
/* setup the LTC_OMAC for the ciphertext */
if ((err = omac_init(&eax->ctomac, cipher, key, keylen)) != CRYPT_OK) {
goto LBL_ERR;
}
+3 -3
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef EAX_MODE
#ifdef LTC_EAX_MODE
/**
Test the EAX implementation
@@ -275,7 +275,7 @@ int eax_test(void)
#endif /* LTC_TEST */
}
#endif /* EAX_MODE */
#endif /* LTC_EAX_MODE */
/* $Source$ */
/* $Revision$ */
+5 -5
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Add AAD to the GCM state
@@ -47,7 +47,7 @@ int gcm_add_aad(gcm_state *gcm,
}
/* in IV mode? */
if (gcm->mode == GCM_MODE_IV) {
if (gcm->mode == LTC_GCM_MODE_IV) {
/* let's process the IV */
if (gcm->ivmode || gcm->buflen != 12) {
for (x = 0; x < (unsigned long)gcm->buflen; x++) {
@@ -80,10 +80,10 @@ int gcm_add_aad(gcm_state *gcm,
zeromem(gcm->buf, 16);
gcm->buflen = 0;
gcm->totlen = 0;
gcm->mode = GCM_MODE_AAD;
gcm->mode = LTC_GCM_MODE_AAD;
}
if (gcm->mode != GCM_MODE_AAD || gcm->buflen >= 16) {
if (gcm->mode != LTC_GCM_MODE_AAD || gcm->buflen >= 16) {
return CRYPT_INVALID_ARG;
}
+3 -3
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Add IV data to the GCM state
@@ -36,7 +36,7 @@ int gcm_add_iv(gcm_state *gcm,
}
/* must be in IV mode */
if (gcm->mode != GCM_MODE_IV) {
if (gcm->mode != LTC_GCM_MODE_IV) {
return CRYPT_INVALID_ARG;
}
+3 -3
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Terminate a GCM stream
@@ -43,7 +43,7 @@ int gcm_done(gcm_state *gcm,
}
if (gcm->mode != GCM_MODE_TEXT) {
if (gcm->mode != LTC_GCM_MODE_TEXT) {
return CRYPT_INVALID_ARG;
}
+3 -3
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#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))
/* this is x*2^128 mod p(x) ... the results are 16 bytes each stored in a packed format. Since only the
* lower 16 bits are not zero'ed I removed the upper 14 bytes */
@@ -56,7 +56,7 @@ const unsigned char gcm_shift_table[256*2] = {
#endif
#if defined(GCM_MODE) || defined(LRW_MODE)
#if defined(LTC_GCM_MODE) || defined(LRW_MODE)
#ifndef LTC_FAST
/* right shift */
+5 -5
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Initialize a GCM state
@@ -30,7 +30,7 @@ int gcm_init(gcm_state *gcm, int cipher,
{
int err;
unsigned char B[16];
#ifdef GCM_TABLES
#ifdef LTC_GCM_TABLES
int x, y, z, t;
#endif
@@ -66,13 +66,13 @@ int gcm_init(gcm_state *gcm, int cipher,
zeromem(gcm->buf, sizeof(gcm->buf));
zeromem(gcm->X, sizeof(gcm->X));
gcm->cipher = cipher;
gcm->mode = GCM_MODE_IV;
gcm->mode = LTC_GCM_MODE_IV;
gcm->ivmode = 0;
gcm->buflen = 0;
gcm->totlen = 0;
gcm->pttotlen = 0;
#ifdef GCM_TABLES
#ifdef LTC_GCM_TABLES
/* setup tables */
/* generate the first table as it has no shifting (from which we make the other tables) */
+4 -4
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Process an entire GCM packet in one call.
@@ -65,7 +65,7 @@ int gcm_memory( int cipher,
#ifndef GCM_TABLES_SSE2
#ifndef LTC_GCM_TABLES_SSE2
orig = gcm = XMALLOC(sizeof(*gcm));
#else
orig = gcm = XMALLOC(sizeof(*gcm) + 16);
@@ -78,7 +78,7 @@ int gcm_memory( int cipher,
* 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
#ifdef LTC_GCM_TABLES_SSE2
if ((unsigned long)gcm & 15) {
gcm = (gcm_state *)((unsigned long)gcm + (16 - ((unsigned long)gcm & 15)));
}
+5 -5
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#if defined(GCM_MODE)
#if defined(LTC_GCM_MODE)
/**
GCM multiply by H
@param gcm The GCM state which holds the H value
@@ -24,9 +24,9 @@
void gcm_mult_h(gcm_state *gcm, unsigned char *I)
{
unsigned char T[16];
#ifdef GCM_TABLES
#ifdef LTC_GCM_TABLES
int x, y;
#ifdef GCM_TABLES_SSE2
#ifdef LTC_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]));
@@ -45,7 +45,7 @@ void gcm_mult_h(gcm_state *gcm, unsigned char *I)
}
#endif /* LTC_FAST */
}
#endif /* GCM_TABLES_SSE2 */
#endif /* LTC_GCM_TABLES_SSE2 */
#else
gcm_gf_mult(gcm->H, I, T);
#endif
+5 -5
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Process plaintext/ciphertext through GCM
@@ -50,7 +50,7 @@ int gcm_process(gcm_state *gcm,
}
/* in AAD mode? */
if (gcm->mode == GCM_MODE_AAD) {
if (gcm->mode == LTC_GCM_MODE_AAD) {
/* let's process the AAD */
if (gcm->buflen) {
gcm->totlen += gcm->buflen * CONST64(8);
@@ -67,10 +67,10 @@ int gcm_process(gcm_state *gcm,
}
gcm->buflen = 0;
gcm->mode = GCM_MODE_TEXT;
gcm->mode = LTC_GCM_MODE_TEXT;
}
if (gcm->mode != GCM_MODE_TEXT) {
if (gcm->mode != LTC_GCM_MODE_TEXT) {
return CRYPT_INVALID_ARG;
}
+3 -3
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Reset a GCM state to as if you just called gcm_init(). This saves the initialization time.
@@ -28,7 +28,7 @@ int gcm_reset(gcm_state *gcm)
zeromem(gcm->buf, sizeof(gcm->buf));
zeromem(gcm->X, sizeof(gcm->X));
gcm->mode = GCM_MODE_IV;
gcm->mode = LTC_GCM_MODE_IV;
gcm->ivmode = 0;
gcm->buflen = 0;
gcm->totlen = 0;
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef GCM_MODE
#ifdef LTC_GCM_MODE
/**
Test the GCM code
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Decrypt a block with OCB.
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Decrypt and compare the tag with OCB.
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Terminate a decrypting OCB state
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Terminate an encryption OCB state
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Encrypt a block of data with OCB.
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Encrypt and generate an authentication code for a buffer of memory
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
static const struct {
int len;
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -16,7 +16,7 @@
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Returns the number of leading zero bits [from lsb up]
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Compute the shift/xor for OCB (internal function)
+3 -3
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/**
Test the OCB protocol
@@ -222,7 +222,7 @@ int ocb_test(void)
#endif /* LTC_TEST */
}
#endif /* OCB_MODE */
#endif /* LTC_OCB_MODE */
/* some comments
+2 -2
View File
@@ -6,7 +6,7 @@
* 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
*/
/**
@@ -15,7 +15,7 @@
*/
#include "tomcrypt.h"
#ifdef OCB_MODE
#ifdef LTC_OCB_MODE
/* Since the last block is encrypted in CTR mode the same code can
* be used to finish a decrypt or encrypt stream. The only difference