update to libtomcrypt 1.17 (with Dropbear changes)

This commit is contained in:
Matt Johnston
2017-06-24 17:50:50 +08:00
parent 99361f54ca
commit a79b61517b
353 changed files with 4095 additions and 2649 deletions

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"
@@ -71,7 +71,7 @@ int f9_done(f9_state *f9, unsigned char *out, unsigned long *outlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_done.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/09 01:53:32 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -78,6 +78,6 @@ int f9_file(int cipher,
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_file.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/21 00:18:23 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -64,7 +64,7 @@ done:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_init.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/08 22:54:18 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -66,6 +66,6 @@ done:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_memory.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/21 23:02:42 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
#include <stdarg.h>
@@ -85,6 +85,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_memory_multi.c,v $ */
/* $Revision: 1.2 $ */
/* $Date: 2006/11/08 21:50:13 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -72,7 +72,7 @@ int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_process.c,v $ */
/* $Revision: 1.3 $ */
/* $Date: 2006/12/16 17:41:21 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -72,7 +72,7 @@ int f9_test(void)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_test.c,v $ */
/* $Revision: 1.8 $ */
/* $Date: 2006/11/21 23:02:42 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,24 +6,24 @@
* 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 hmac_done.c
HMAC support, terminate stream, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, terminate stream, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
#define HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
/**
Terminate an HMAC session
@param hmac The HMAC state
@param out [out] The destination of the HMAC authentication tag
@param outlen [in/out] The max size and resulting size of the HMAC authentication tag
Terminate an LTC_HMAC session
@param hmac The LTC_HMAC state
@param out [out] The destination of the LTC_HMAC authentication tag
@param outlen [in/out] The max size and resulting size of the LTC_HMAC authentication tag
@return CRYPT_OK if successful
*/
int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
@@ -44,13 +44,12 @@ int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
/* get the hash message digest size */
hashsize = hash_descriptor[hash].hashsize;
/* Get the hash of the first HMAC vector plus the data */
if ((err = hash_descriptor[hash].done(&hmac->md, isha)) != CRYPT_OK) {
goto LBL_ERR;
}
/* Create the second HMAC vector vector for step (3) */
for(i=0; i < HMAC_BLOCKSIZE; i++) {
/* Create the second LTC_HMAC vector vector for step (3) */
for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
buf[i] = hmac->key[i] ^ 0x5C;
}
@@ -58,7 +57,7 @@ int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
if ((err = hash_descriptor[hash].init(&hmac->md)) != CRYPT_OK) {
goto LBL_ERR;
}
if ((err = hash_descriptor[hash].process(&hmac->md, buf, HMAC_BLOCKSIZE)) != CRYPT_OK) {
if ((err = hash_descriptor[hash].process(&hmac->md, buf, LTC_HMAC_BLOCKSIZE)) != CRYPT_OK) {
goto LBL_ERR;
}
if ((err = hash_descriptor[hash].process(&hmac->md, isha, hashsize)) != CRYPT_OK) {
@@ -88,6 +87,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_done.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,24 +6,24 @@
* 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 hmac_file.c
HMAC support, process a file, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, process a file, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
HMAC a file
LTC_HMAC a file
@param hash The index of the hash you wish to use
@param fname The name of the file you wish to HMAC
@param fname The name of the file you wish to LTC_HMAC
@param key The secret key
@param keylen The length of the secret key
@param out [out] The HMAC authentication tag
@param out [out] The LTC_HMAC authentication tag
@param outlen [in/out] The max size and resulting size of the authentication tag
@return CRYPT_OK if successful, CRYPT_NOP if file support has been disabled
*/
@@ -89,6 +89,6 @@ int hmac_file(int hash, const char *fname,
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_file.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,22 +6,22 @@
* 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 hmac_init.c
HMAC support, initialize state, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, initialize state, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
#define HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
/**
Initialize an HMAC context.
@param hmac The HMAC state
Initialize an LTC_HMAC context.
@param hmac The LTC_HMAC state
@param hash The index of the hash you want to use
@param key The secret key
@param keylen The length of the secret key (octets)
@@ -50,30 +50,30 @@ int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned lon
}
/* allocate memory for key */
hmac->key = XMALLOC(HMAC_BLOCKSIZE);
hmac->key = XMALLOC(LTC_HMAC_BLOCKSIZE);
if (hmac->key == NULL) {
return CRYPT_MEM;
}
/* (1) make sure we have a large enough key */
if(keylen > HMAC_BLOCKSIZE) {
z = HMAC_BLOCKSIZE;
if(keylen > LTC_HMAC_BLOCKSIZE) {
z = LTC_HMAC_BLOCKSIZE;
if ((err = hash_memory(hash, key, keylen, hmac->key, &z)) != CRYPT_OK) {
goto LBL_ERR;
}
if(hashsize < HMAC_BLOCKSIZE) {
zeromem((hmac->key) + hashsize, (size_t)(HMAC_BLOCKSIZE - hashsize));
if(hashsize < LTC_HMAC_BLOCKSIZE) {
zeromem((hmac->key) + hashsize, (size_t)(LTC_HMAC_BLOCKSIZE - hashsize));
}
keylen = hashsize;
} else {
XMEMCPY(hmac->key, key, (size_t)keylen);
if(keylen < HMAC_BLOCKSIZE) {
zeromem((hmac->key) + keylen, (size_t)(HMAC_BLOCKSIZE - keylen));
if(keylen < LTC_HMAC_BLOCKSIZE) {
zeromem((hmac->key) + keylen, (size_t)(LTC_HMAC_BLOCKSIZE - keylen));
}
}
/* Create the initial vector for step (3) */
for(i=0; i < HMAC_BLOCKSIZE; i++) {
for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
buf[i] = hmac->key[i] ^ 0x36;
}
@@ -82,7 +82,7 @@ int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned lon
goto LBL_ERR;
}
if ((err = hash_descriptor[hash].process(&hmac->md, buf, HMAC_BLOCKSIZE)) != CRYPT_OK) {
if ((err = hash_descriptor[hash].process(&hmac->md, buf, LTC_HMAC_BLOCKSIZE)) != CRYPT_OK) {
goto LBL_ERR;
}
goto done;
@@ -91,7 +91,7 @@ LBL_ERR:
XFREE(hmac->key);
done:
#ifdef LTC_CLEAN_STACK
zeromem(buf, HMAC_BLOCKSIZE);
zeromem(buf, LTC_HMAC_BLOCKSIZE);
#endif
return err;
@@ -99,6 +99,6 @@ done:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_init.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,24 +6,24 @@
* 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 hmac_memory.c
HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
HMAC a block of memory to produce the authentication tag
LTC_HMAC a block of memory to produce the authentication tag
@param hash The index of the hash to use
@param key The secret key
@param keylen The length of the secret key (octets)
@param in The data to HMAC
@param inlen The length of the data to HMAC (octets)
@param in The data to LTC_HMAC
@param inlen The length of the data to LTC_HMAC (octets)
@param out [out] Destination of the authentication tag
@param outlen [in/out] Max size and resulting size of authentication tag
@return CRYPT_OK if successful
@@ -83,6 +83,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_memory.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,28 +6,28 @@
* 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"
#include <stdarg.h>
/**
@file hmac_memory_multi.c
HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
HMAC multiple blocks of memory to produce the authentication tag
LTC_HMAC multiple blocks of memory to produce the authentication tag
@param hash The index of the hash to use
@param key The secret key
@param keylen The length of the secret key (octets)
@param out [out] Destination of the authentication tag
@param outlen [in/out] Max size and resulting size of authentication tag
@param in The data to HMAC
@param inlen The length of the data to HMAC (octets)
@param ... tuples of (data,len) pairs to HMAC, terminated with a (NULL,x) (x=don't care)
@param in The data to LTC_HMAC
@param inlen The length of the data to LTC_HMAC (octets)
@param ... tuples of (data,len) pairs to LTC_HMAC, terminated with a (NULL,x) (x=don't care)
@return CRYPT_OK if successful
*/
int hmac_memory_multi(int hash,
@@ -87,6 +87,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_memory_multi.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,22 +6,22 @@
* 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 hmac_process.c
HMAC support, process data, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, process data, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
Process data through HMAC
Process data through LTC_HMAC
@param hmac The hmac state
@param in The data to send through HMAC
@param inlen The length of the data to HMAC (octets)
@param in The data to send through LTC_HMAC
@param inlen The length of the data to LTC_HMAC (octets)
@return CRYPT_OK if successful
*/
int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen)
@@ -38,6 +38,6 @@ int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_process.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,18 +6,18 @@
* 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 hmac_test.c
HMAC support, self-test, Tom St Denis/Dobes Vandermeer
LTC_HMAC support, self-test, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
#define HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
/*
TEST CASES SOURCE:
@@ -27,11 +27,11 @@ Request for Comments: 2202 IBM
Category: Informational R. Glenn
NIST
September 1997
Test Cases for HMAC-MD5 and HMAC-SHA-1
Test Cases for LTC_HMAC-LTC_MD5 and LTC_HMAC-LTC_SHA-1
*/
/**
HMAC self-test
LTC_HMAC self-test
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled.
*/
int hmac_test(void)
@@ -52,7 +52,7 @@ int hmac_test(void)
unsigned char digest[MAXBLOCKSIZE];
} cases[] = {
/*
3. Test Cases for HMAC-SHA-1
3. Test Cases for LTC_HMAC-LTC_SHA-1
test_case = 1
key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
@@ -118,7 +118,7 @@ int hmac_test(void)
0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91} },
/*
2. Test Cases for HMAC-MD5
2. Test Cases for LTC_HMAC-LTC_MD5
test_case = 1
key = 0x0b 0b 0b 0b
@@ -272,7 +272,7 @@ Key First"
outlen = sizeof(digest);
if((err = hmac_memory(hash, cases[i].key, cases[i].keylen, cases[i].data, cases[i].datalen, digest, &outlen)) != CRYPT_OK) {
#if 0
printf("HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err));
printf("LTC_HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err));
#endif
return err;
}
@@ -281,7 +281,7 @@ Key First"
failed++;
#if 0
unsigned int j;
printf("\nHMAC-%s test #%d:\n", cases[i].algo, cases[i].num);
printf("\nLTC_HMAC-%s test #%d:\n", cases[i].algo, cases[i].num);
printf( "Result: 0x");
for(j=0; j < hash_descriptor[hash].hashsize; j++) {
printf("%2x ", digest[j]);
@@ -294,7 +294,7 @@ Key First"
return CRYPT_ERROR;
#endif
} else {
/* printf("HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */
/* printf("LTC_HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */
}
}
@@ -311,6 +311,6 @@ Key First"
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/hmac/hmac_test.c,v $ */
/* $Revision: 1.7 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,20 +6,20 @@
* 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 omac_done.c
OMAC1 support, terminate a stream, Tom St Denis
LTC_OMAC1 support, terminate a stream, Tom St Denis
*/
#ifdef LTC_OMAC
/**
Terminate an OMAC stream
@param omac The OMAC state
Terminate an LTC_OMAC stream
@param omac The LTC_OMAC state
@param out [out] Destination for the authentication tag
@param outlen [in/out] The max size and resulting size of the authentication tag
@return CRYPT_OK if successful
@@ -81,6 +81,6 @@ int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_done.c,v $ */
/* $Revision: 1.7 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,23 +6,23 @@
* 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 omac_file.c
OMAC1 support, process a file, Tom St Denis
LTC_OMAC1 support, process a file, Tom St Denis
*/
#ifdef LTC_OMAC
/**
OMAC a file
LTC_OMAC a file
@param cipher The index of the cipher desired
@param key The secret key
@param keylen The length of the secret key (octets)
@param filename The name of the file you wish to OMAC
@param filename The name of the file you wish to LTC_OMAC
@param out [out] Where the authentication tag is to be stored
@param outlen [in/out] The max size and resulting size of the authentication tag
@return CRYPT_OK if successful, CRYPT_NOP if file support has been disabled
@@ -78,6 +78,6 @@ int omac_file(int cipher,
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_file.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,21 +6,21 @@
* 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 omac_init.c
OMAC1 support, initialize state, by Tom St Denis
LTC_OMAC1 support, initialize state, by Tom St Denis
*/
#ifdef LTC_OMAC
/**
Initialize an OMAC state
@param omac The OMAC state to initialize
Initialize an LTC_OMAC state
@param omac The LTC_OMAC state to initialize
@param cipher The index of the desired cipher
@param key The secret key
@param keylen The length of the secret key (octets)
@@ -96,6 +96,6 @@ int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned l
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_init.c,v $ */
/* $Revision: 1.10 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,24 +6,24 @@
* 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 omac_memory.c
OMAC1 support, process a block of memory, Tom St Denis
LTC_OMAC1 support, process a block of memory, Tom St Denis
*/
#ifdef LTC_OMAC
/**
OMAC a block of memory
LTC_OMAC a block of memory
@param cipher The index of the desired cipher
@param key The secret key
@param keylen The length of the secret key (octets)
@param in The data to send through OMAC
@param inlen The length of the data to send through OMAC (octets)
@param in The data to send through LTC_OMAC
@param inlen The length of the data to send through LTC_OMAC (octets)
@param out [out] The destination of the authentication tag
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
@return CRYPT_OK if successful
@@ -80,6 +80,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_memory.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/08 23:01:06 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,28 +6,28 @@
* 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"
#include <stdarg.h>
/**
@file omac_memory_multi.c
OMAC1 support, process multiple blocks of memory, Tom St Denis
LTC_OMAC1 support, process multiple blocks of memory, Tom St Denis
*/
#ifdef LTC_OMAC
/**
OMAC multiple blocks of memory
LTC_OMAC multiple blocks of memory
@param cipher The index of the desired cipher
@param key The secret key
@param keylen The length of the secret key (octets)
@param out [out] The destination of the authentication tag
@param outlen [in/out] The max size and resulting size of the authentication tag (octets)
@param in The data to send through OMAC
@param inlen The length of the data to send through OMAC (octets)
@param ... tuples of (data,len) pairs to OMAC, terminated with a (NULL,x) (x=don't care)
@param in The data to send through LTC_OMAC
@param inlen The length of the data to send through LTC_OMAC (octets)
@param ... tuples of (data,len) pairs to LTC_OMAC, terminated with a (NULL,x) (x=don't care)
@return CRYPT_OK if successful
*/
int omac_memory_multi(int cipher,
@@ -85,6 +85,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_memory_multi.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,28 +6,28 @@
* 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 omac_process.c
OMAC1 support, process data, Tom St Denis
LTC_OMAC1 support, process data, Tom St Denis
*/
#ifdef LTC_OMAC
/**
Process data through OMAC
@param omac The OMAC state
@param in The input data to send through OMAC
Process data through LTC_OMAC
@param omac The LTC_OMAC state
@param in The input data to send through LTC_OMAC
@param inlen The length of the input (octets)
@return CRYPT_OK if successful
*/
int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
{
unsigned long n, x;
unsigned long n, x, blklen;
int err;
LTC_ARGCHK(omac != NULL);
@@ -42,13 +42,14 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
}
#ifdef LTC_FAST
if (omac->buflen == 0 && inlen > 16) {
int y;
for (x = 0; x < (inlen - 16); x += 16) {
for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
blklen = cipher_descriptor[omac->cipher_idx].block_length;
if (omac->buflen == 0 && inlen > blklen) {
unsigned long y;
for (x = 0; x < (inlen - blklen); x += blklen) {
for (y = 0; y < blklen; y += sizeof(LTC_FAST_TYPE)) {
*((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y]));
}
in += 16;
in += blklen;
if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) {
return err;
}
@@ -83,6 +84,6 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_process.c,v $ */
/* $Revision: 1.9 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

View File

@@ -6,19 +6,19 @@
* 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 omac_test.c
OMAC1 support, self-test, by Tom St Denis
LTC_OMAC1 support, self-test, by Tom St Denis
*/
#ifdef LTC_OMAC
/**
Test the OMAC setup
Test the LTC_OMAC setup
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled
*/
int omac_test(void)
@@ -105,6 +105,6 @@ int omac_test(void)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_test.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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 @@
Pelican MAC, initialize state, by Tom St Denis
*/
#ifdef PELICAN
#ifdef LTC_PELICAN
#define ENCRYPT_ONLY
#define PELI_TAB
@@ -160,6 +160,6 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pelican/pelican.c,v $ */
/* $Revision: 1.18 $ */
/* $Date: 2006/04/02 13:19:10 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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 @@
Pelican MAC, MAC a block of memory, by Tom St Denis
*/
#ifdef PELICAN
#ifdef LTC_PELICAN
/**
Pelican block of memory
@@ -54,6 +54,6 @@ int pelican_memory(const unsigned char *key, unsigned long keylen,
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pelican/pelican_memory.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/03/31 14:15:35 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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 @@
Pelican MAC, test, by Tom St Denis
*/
#ifdef PELICAN
#ifdef LTC_PELICAN
int pelican_test(void)
{
@@ -115,6 +115,6 @@ int pelican_test(void)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pelican/pelican_test.c,v $ */
/* $Revision: 1.12 $ */
/* $Date: 2006/11/21 00:18:23 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -69,6 +69,6 @@ int pmac_done(pmac_state *state, unsigned char *out, unsigned long *outlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_done.c,v $ */
/* $Revision: 1.8 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -79,6 +79,6 @@ int pmac_file(int cipher,
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_file.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -142,6 +142,6 @@ error:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_init.c,v $ */
/* $Revision: 1.7 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -69,6 +69,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_memory.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
#include <stdarg.h>
@@ -84,6 +84,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_memory_multi.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -34,6 +34,6 @@ int pmac_ntz(unsigned long x)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_ntz.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -95,6 +95,6 @@ int pmac_process(pmac_state *pmac, const unsigned char *in, unsigned long inlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_process.c,v $ */
/* $Revision: 1.8 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -39,6 +39,6 @@ void pmac_shift_xor(pmac_state *pmac)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_shift_xor.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -19,7 +19,7 @@
#ifdef LTC_PMAC
/**
Test the OMAC implementation
Test the LTC_OMAC implementation
@return CRYPT_OK if successful, CRYPT_NOP if testing has been disabled
*/
int pmac_test(void)
@@ -160,6 +160,6 @@ int pmac_test(void)
/* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_test.c,v $ */
/* $Revision: 1.6 $ */
/* $Date: 2006/11/03 00:39:49 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -71,7 +71,7 @@ int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_done.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/07 03:23:46 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -78,6 +78,6 @@ int xcbc_file(int cipher,
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_file.c,v $ */
/* $Revision: 1.1 $ */
/* $Date: 2006/11/03 01:56:41 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -28,6 +28,7 @@ int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned l
{
int x, y, err;
symmetric_key *skey;
unsigned long k1;
LTC_ARGCHK(xcbc != NULL);
LTC_ARGCHK(key != NULL);
@@ -43,26 +44,45 @@ int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned l
}
#endif
/* schedule the user key */
skey = XCALLOC(1, sizeof(*skey));
if (skey == NULL) {
return CRYPT_MEM;
}
skey = NULL;
if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, skey)) != CRYPT_OK) {
goto done;
}
/* are we in pure XCBC mode with three keys? */
if (keylen & LTC_XCBC_PURE) {
keylen &= ~LTC_XCBC_PURE;
if (keylen < 2UL*cipher_descriptor[cipher].block_length) {
return CRYPT_INVALID_ARG;
}
k1 = keylen - 2*cipher_descriptor[cipher].block_length;
XMEMCPY(xcbc->K[0], key, k1);
XMEMCPY(xcbc->K[1], key+k1, cipher_descriptor[cipher].block_length);
XMEMCPY(xcbc->K[2], key+k1 + cipher_descriptor[cipher].block_length, cipher_descriptor[cipher].block_length);
} else {
/* use the key expansion */
k1 = cipher_descriptor[cipher].block_length;
/* schedule the user key */
skey = XCALLOC(1, sizeof(*skey));
if (skey == NULL) {
return CRYPT_MEM;
}
if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, skey)) != CRYPT_OK) {
goto done;
}
/* make the three keys */
for (y = 0; y < 3; y++) {
for (x = 0; x < cipher_descriptor[cipher].block_length; x++) {
xcbc->K[y][x] = y + 1;
}
cipher_descriptor[cipher].ecb_encrypt(xcbc->K[y], xcbc->K[y], skey);
/* make the three keys */
for (y = 0; y < 3; y++) {
for (x = 0; x < cipher_descriptor[cipher].block_length; x++) {
xcbc->K[y][x] = y + 1;
}
cipher_descriptor[cipher].ecb_encrypt(xcbc->K[y], xcbc->K[y], skey);
}
}
/* setup K1 */
err = cipher_descriptor[cipher].setup(xcbc->K[0], cipher_descriptor[cipher].block_length, 0, &xcbc->key);
err = cipher_descriptor[cipher].setup(xcbc->K[0], k1, 0, &xcbc->key);
/* setup struct */
zeromem(xcbc->IV, cipher_descriptor[cipher].block_length);
@@ -71,16 +91,18 @@ int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned l
xcbc->buflen = 0;
done:
cipher_descriptor[cipher].done(skey);
if (skey != NULL) {
#ifdef LTC_CLEAN_STACK
zeromem(skey, sizeof(*skey));
zeromem(skey, sizeof(*skey));
#endif
XFREE(skey);
XFREE(skey);
}
return err;
}
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_init.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/07 03:23:46 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -66,6 +66,6 @@ done:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_memory.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/11/21 23:02:42 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
#include <stdarg.h>
@@ -85,6 +85,6 @@ LBL_ERR:
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_memory_multi.c,v $ */
/* $Revision: 1.1 $ */
/* $Date: 2006/11/03 01:53:25 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -69,7 +69,7 @@ int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_process.c,v $ */
/* $Revision: 1.9 $ */
/* $Date: 2006/11/09 22:43:52 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */

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"
@@ -122,7 +122,7 @@ int xcbc_test(void)
#endif
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_test.c,v $ */
/* $Revision: 1.5 $ */
/* $Date: 2006/11/21 23:02:42 $ */
/* $Source$ */
/* $Revision$ */
/* $Date$ */