summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/mac/hmac
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2017-06-24 17:50:50 +0800
committerMatt Johnston <matt@ucc.asn.au>2017-06-24 17:50:50 +0800
commita79b61517bc7123250d0e2dc21dc18deccf0bb64 (patch)
treef95c80c6801abd286eaf370dd794859235d1be82 /libtomcrypt/src/mac/hmac
parent99361f54ca77e0d1ff821c02d7d8df3a87aafde5 (diff)
update to libtomcrypt 1.17 (with Dropbear changes)
Diffstat (limited to 'libtomcrypt/src/mac/hmac')
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_done.c27
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_file.c16
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_init.c36
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_memory.c16
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_memory_multi.c18
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_process.c16
-rw-r--r--libtomcrypt/src/mac/hmac/hmac_test.c26
7 files changed, 77 insertions, 78 deletions
diff --git a/libtomcrypt/src/mac/hmac/hmac_done.c b/libtomcrypt/src/mac/hmac/hmac_done.c
index f48d672..9046110 100644
--- a/libtomcrypt/src/mac/hmac/hmac_done.c
+++ b/libtomcrypt/src/mac/hmac/hmac_done.c
@@ -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$ */
diff --git a/libtomcrypt/src/mac/hmac/hmac_file.c b/libtomcrypt/src/mac/hmac/hmac_file.c
index d7c40b1..d9841bd 100644
--- a/libtomcrypt/src/mac/hmac/hmac_file.c
+++ b/libtomcrypt/src/mac/hmac/hmac_file.c
@@ -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$ */
diff --git a/libtomcrypt/src/mac/hmac/hmac_init.c b/libtomcrypt/src/mac/hmac/hmac_init.c
index a4a4377..262002e 100644
--- a/libtomcrypt/src/mac/hmac/hmac_init.c
+++ b/libtomcrypt/src/mac/hmac/hmac_init.c
@@ -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$ */
diff --git a/libtomcrypt/src/mac/hmac/hmac_memory.c b/libtomcrypt/src/mac/hmac/hmac_memory.c
index 7dc364a..9df80ea 100644
--- a/libtomcrypt/src/mac/hmac/hmac_memory.c
+++ b/libtomcrypt/src/mac/hmac/hmac_memory.c
@@ -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$ */
diff --git a/libtomcrypt/src/mac/hmac/hmac_memory_multi.c b/libtomcrypt/src/mac/hmac/hmac_memory_multi.c
index 2382502..c3d461b 100644
--- a/libtomcrypt/src/mac/hmac/hmac_memory_multi.c
+++ b/libtomcrypt/src/mac/hmac/hmac_memory_multi.c
@@ -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$ */
diff --git a/libtomcrypt/src/mac/hmac/hmac_process.c b/libtomcrypt/src/mac/hmac/hmac_process.c
index 04b5ee2..802de1f 100644
--- a/libtomcrypt/src/mac/hmac/hmac_process.c
+++ b/libtomcrypt/src/mac/hmac/hmac_process.c
@@ -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$ */
diff --git a/libtomcrypt/src/mac/hmac/hmac_test.c b/libtomcrypt/src/mac/hmac/hmac_test.c
index 4a03f87..af43da6 100644
--- a/libtomcrypt/src/mac/hmac/hmac_test.c
+++ b/libtomcrypt/src/mac/hmac/hmac_test.c
@@ -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$ */