trim trailing spaces/clean up

This commit is contained in:
Steffen Jaeckel
2014-01-03 15:16:59 +01:00
committed by Steffen Jaeckel
parent d78aa37c10
commit 8e7777b554
80 changed files with 2073 additions and 2077 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ int f9_process(f9_state *f9, const unsigned char *in, unsigned long inlen)
f9->IV[f9->buflen++] ^= *in++;
--inlen;
}
return CRYPT_OK;
return CRYPT_OK;
}
#endif
+10 -10
View File
@@ -12,7 +12,7 @@
/**
@file hmac_done.c
LTC_HMAC support, terminate stream, Tom St Denis/Dobes Vandermeer
HMAC support, terminate stream, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
@@ -20,10 +20,10 @@
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
/**
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
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
@return CRYPT_OK if successful
*/
int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
@@ -47,22 +47,22 @@ int hmac_done(hmac_state *hmac, unsigned char *out, unsigned long *outlen)
/* allocate buffers */
buf = XMALLOC(LTC_HMAC_BLOCKSIZE);
isha = XMALLOC(hashsize);
if (buf == NULL || isha == NULL) {
if (buf == NULL || isha == NULL) {
if (buf != NULL) {
XFREE(buf);
}
}
if (isha != NULL) {
XFREE(isha);
}
}
return CRYPT_MEM;
}
/* Get the hash of the first LTC_HMAC vector plus the data */
/* 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 LTC_HMAC vector vector for step (3) */
/* Create the second HMAC vector vector for step (3) */
for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
buf[i] = hmac->key[i] ^ 0x5C;
}
+8 -8
View File
@@ -12,23 +12,23 @@
/**
@file hmac_file.c
LTC_HMAC support, process a file, Tom St Denis/Dobes Vandermeer
HMAC support, process a file, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
LTC_HMAC a file
HMAC a file
@param hash The index of the hash you wish to use
@param fname The name of the file you wish to LTC_HMAC
@param fname The name of the file you wish to HMAC
@param key The secret key
@param keylen The length of the secret key
@param out [out] The LTC_HMAC authentication tag
@param out [out] The 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
*/
int hmac_file(int hash, const char *fname,
const unsigned char *key, unsigned long keylen,
int hmac_file(int hash, const char *fname,
const unsigned char *key, unsigned long keylen,
unsigned char *out, unsigned long *outlen)
{
#ifdef LTC_NO_FILE
@@ -44,7 +44,7 @@ int hmac_file(int hash, const char *fname,
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
if((err = hash_is_valid(hash)) != CRYPT_OK) {
return err;
}
@@ -80,7 +80,7 @@ int hmac_file(int hash, const char *fname,
#ifdef LTC_CLEAN_STACK
/* clear memory */
zeromem(buf, sizeof(buf));
#endif
#endif
return CRYPT_OK;
#endif
}
+6 -6
View File
@@ -12,7 +12,7 @@
/**
@file hmac_init.c
LTC_HMAC support, initialize state, Tom St Denis/Dobes Vandermeer
HMAC support, initialize state, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
@@ -20,9 +20,9 @@
#define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
/**
Initialize an LTC_HMAC context.
@param hmac The LTC_HMAC state
@param hash The index of the hash you want to use
Initialize an HMAC context.
@param hmac The 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)
@return CRYPT_OK if successful
@@ -100,9 +100,9 @@ done:
#ifdef LTC_CLEAN_STACK
zeromem(buf, LTC_HMAC_BLOCKSIZE);
#endif
XFREE(buf);
return err;
return err;
}
#endif
+10 -10
View File
@@ -12,25 +12,25 @@
/**
@file hmac_memory.c
LTC_HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer
HMAC support, process a block of memory, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
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
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 LTC_HMAC
@param inlen The length of the data to LTC_HMAC (octets)
@param in The data to HMAC
@param inlen The length of the data to 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
*/
int hmac_memory(int hash,
int hmac_memory(int hash,
const unsigned char *key, unsigned long keylen,
const unsigned char *in, unsigned long inlen,
const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen)
{
hmac_state *hmac;
@@ -38,7 +38,7 @@ int hmac_memory(int hash,
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
/* make sure hash descriptor is valid */
@@ -77,7 +77,7 @@ LBL_ERR:
#endif
XFREE(hmac);
return err;
return err;
}
#endif
+11 -11
View File
@@ -13,24 +13,24 @@
/**
@file hmac_memory_multi.c
LTC_HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
HMAC support, process multiple blocks of memory, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
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
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 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)
@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)
@return CRYPT_OK if successful
*/
int hmac_memory_multi(int hash,
int hmac_memory_multi(int hash,
const unsigned char *key, unsigned long keylen,
unsigned char *out, unsigned long *outlen,
const unsigned char *in, unsigned long inlen, ...)
@@ -44,7 +44,7 @@ int hmac_memory_multi(int hash,
LTC_ARGCHK(key != NULL);
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
/* allocate ram for hmac state */
@@ -58,7 +58,7 @@ int hmac_memory_multi(int hash,
}
va_start(args, inlen);
curptr = in;
curptr = in;
curlen = inlen;
for (;;) {
/* process buf */
@@ -81,7 +81,7 @@ LBL_ERR:
#endif
XFREE(hmac);
va_end(args);
return err;
return err;
}
#endif
+5 -5
View File
@@ -12,16 +12,16 @@
/**
@file hmac_process.c
LTC_HMAC support, process data, Tom St Denis/Dobes Vandermeer
HMAC support, process data, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
/**
Process data through LTC_HMAC
/**
Process data through HMAC
@param hmac The hmac state
@param in The data to send through LTC_HMAC
@param inlen The length of the data to LTC_HMAC (octets)
@param in The data to send through HMAC
@param inlen The length of the data to HMAC (octets)
@return CRYPT_OK if successful
*/
int hmac_process(hmac_state *hmac, const unsigned char *in, unsigned long inlen)
+45 -45
View File
@@ -12,7 +12,7 @@
/**
@file hmac_test.c
LTC_HMAC support, self-test, Tom St Denis/Dobes Vandermeer
HMAC support, self-test, Tom St Denis/Dobes Vandermeer
*/
#ifdef LTC_HMAC
@@ -27,18 +27,18 @@ Request for Comments: 2202 IBM
Category: Informational R. Glenn
NIST
September 1997
Test Cases for LTC_HMAC-LTC_MD5 and LTC_HMAC-LTC_SHA-1
Test Cases for HMAC-MD5 and HMAC-SHA-1
*/
/**
LTC_HMAC self-test
HMAC self-test
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled.
*/
int hmac_test(void)
{
#ifndef LTC_TEST
return CRYPT_NOP;
#else
#else
unsigned char digest[MAXBLOCKSIZE];
int i;
@@ -52,7 +52,7 @@ int hmac_test(void)
unsigned char digest[MAXBLOCKSIZE];
} cases[] = {
/*
3. Test Cases for LTC_HMAC-LTC_SHA-1
3. Test Cases for HMAC-SHA-1
test_case = 1
key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
@@ -62,8 +62,8 @@ int hmac_test(void)
digest-96 = 0x4c1a03424b55e07fe7f27be1
*/
{ 5, "sha1",
{0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
{0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c}, 20,
"Test With Truncation", 20,
{0x4c, 0x1a, 0x03, 0x42, 0x4b, 0x55, 0xe0, 0x7f, 0xe7, 0xf2,
@@ -78,19 +78,19 @@ int hmac_test(void)
digest = 0xaa4ae5e15272d00e95705637ce8a3b55ed402112
*/
{ 6, "sha1",
{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, 80,
"Test Using Larger Than Block-Size Key - Hash Key First", 54,
{0xaa, 0x4a, 0xe5, 0xe1, 0x52, 0x72, 0xd0, 0x0e,
0x95, 0x70, 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55,
0x95, 0x70, 0x56, 0x37, 0xce, 0x8a, 0x3b, 0x55,
0xed, 0x40, 0x21, 0x12} },
/*
@@ -118,26 +118,26 @@ int hmac_test(void)
0x6b, 0xba, 0xa7, 0x96, 0x5c, 0x78, 0x08, 0xbb, 0xff, 0x1a, 0x91} },
/*
2. Test Cases for LTC_HMAC-LTC_MD5
2. Test Cases for HMAC-MD5
test_case = 1
key = 0x0b 0b 0b 0b
key = 0x0b 0b 0b 0b
0b 0b 0b 0b
0b 0b 0b 0b
0b 0b 0b 0b
key_len = 16
data = "Hi There"
data_len = 8
digest = 0x92 94 72 7a
36 38 bb 1c
13 f4 8e f8
digest = 0x92 94 72 7a
36 38 bb 1c
13 f4 8e f8
15 8b fc 9d
*/
{ 1, "md5",
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b}, 16,
"Hi There", 8,
{0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
{0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d} },
/*
test_case = 2
@@ -150,7 +150,7 @@ int hmac_test(void)
{ 2, "md5",
"Jefe", 4,
"what do ya want for nothing?", 28,
{0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
{0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38} },
/*
@@ -162,7 +162,7 @@ int hmac_test(void)
digest = 0x56be34521d144c88dbb8c733f0e8b3f6
*/
{ 3, "md5",
{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, 16,
{0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
@@ -189,12 +189,12 @@ int hmac_test(void)
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd}, 50,
{0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
{0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79} },
/*
test_case = 5
key = 0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
key_len = 16
@@ -204,10 +204,10 @@ int hmac_test(void)
digest-96 0x56461ef2342edc00f9bab995
*/
{ 5, "md5",
{0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
{0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c}, 16,
"Test With Truncation", 20,
{0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
{0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c} },
/*
@@ -215,25 +215,25 @@ int hmac_test(void)
test_case = 6
key = 0xaa repeated 80 times
key_len = 80
data = "Test Using Larger Than Block-Size Key - Hash
data = "Test Using Larger Than Block-Size Key - Hash
Key First"
data_len = 54
digest = 0x6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd
*/
{ 6, "md5",
{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xa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a, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, 80,
@@ -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("LTC_HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err));
printf("HMAC-%s test #%d, %s\n", cases[i].algo, cases[i].num, error_to_string(err));
#endif
return err;
}
@@ -294,7 +294,7 @@ Key First"
return CRYPT_ERROR;
#endif
} else {
/* printf("LTC_HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */
/* printf("HMAC-%s test #%d: Passed\n", cases[i].algo, cases[i].num); */
}
}
+5 -5
View File
@@ -10,16 +10,16 @@
*/
#include "tomcrypt.h"
/**
/**
@file omac_done.c
LTC_OMAC1 support, terminate a stream, Tom St Denis
OMAC1 support, terminate a stream, Tom St Denis
*/
#ifdef LTC_OMAC
/**
Terminate an LTC_OMAC stream
@param omac The LTC_OMAC state
Terminate an OMAC stream
@param omac The 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
@@ -65,7 +65,7 @@ int omac_done(omac_state *omac, unsigned char *out, unsigned long *outlen)
return err;
}
cipher_descriptor[omac->cipher_idx].done(&omac->key);
/* output it */
for (x = 0; x < (unsigned)omac->blklen && x < *outlen; x++) {
out[x] = omac->block[x];
+6 -6
View File
@@ -10,26 +10,26 @@
*/
#include "tomcrypt.h"
/**
/**
@file omac_file.c
LTC_OMAC1 support, process a file, Tom St Denis
OMAC1 support, process a file, Tom St Denis
*/
#ifdef LTC_OMAC
/**
LTC_OMAC a file
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 LTC_OMAC
@param filename The name of the file you wish to 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
*/
int omac_file(int cipher,
int omac_file(int cipher,
const unsigned char *key, unsigned long keylen,
const char *filename,
const char *filename,
unsigned char *out, unsigned long *outlen)
{
#ifdef LTC_NO_FILE
+5 -5
View File
@@ -10,17 +10,17 @@
*/
#include "tomcrypt.h"
/**
/**
@file omac_init.c
LTC_OMAC1 support, initialize state, by Tom St Denis
OMAC1 support, initialize state, by Tom St Denis
*/
#ifdef LTC_OMAC
/**
Initialize an LTC_OMAC state
@param omac The LTC_OMAC state to initialize
Initialize an OMAC state
@param omac The 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)
@@ -77,7 +77,7 @@ int omac_init(omac_state *omac, int cipher, const unsigned char *key, unsigned l
omac->Lu[x][y] = ((omac->Lu[x][y] << 1) | (omac->Lu[x][y+1] >> 7)) & 255;
}
omac->Lu[x][len - 1] = ((omac->Lu[x][len - 1] << 1) ^ (msb ? mask : 0)) & 255;
/* copy up as require */
if (x == 0) {
XMEMCPY(omac->Lu[1], omac->Lu[0], sizeof(omac->Lu[0]));
+7 -7
View File
@@ -10,25 +10,25 @@
*/
#include "tomcrypt.h"
/**
/**
@file omac_memory.c
LTC_OMAC1 support, process a block of memory, Tom St Denis
OMAC1 support, process a block of memory, Tom St Denis
*/
#ifdef LTC_OMAC
/**
LTC_OMAC a block of memory
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 LTC_OMAC
@param inlen The length of the data to send through LTC_OMAC (octets)
@param in The data to send through OMAC
@param inlen The length of the data to send through 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
*/
int omac_memory(int cipher,
int omac_memory(int cipher,
const unsigned char *key, unsigned long keylen,
const unsigned char *in, unsigned long inlen,
unsigned char *out, unsigned long *outlen)
@@ -75,7 +75,7 @@ LBL_ERR:
#endif
XFREE(omac);
return err;
return err;
}
#endif
+9 -9
View File
@@ -11,26 +11,26 @@
#include "tomcrypt.h"
#include <stdarg.h>
/**
/**
@file omac_memory_multi.c
LTC_OMAC1 support, process multiple blocks of memory, Tom St Denis
OMAC1 support, process multiple blocks of memory, Tom St Denis
*/
#ifdef LTC_OMAC
/**
LTC_OMAC multiple blocks of memory
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 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)
@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)
@return CRYPT_OK if successful
*/
int omac_memory_multi(int cipher,
int omac_memory_multi(int cipher,
const unsigned char *key, unsigned long keylen,
unsigned char *out, unsigned long *outlen,
const unsigned char *in, unsigned long inlen, ...)
@@ -57,7 +57,7 @@ int omac_memory_multi(int cipher,
goto LBL_ERR;
}
va_start(args, inlen);
curptr = in;
curptr = in;
curlen = inlen;
for (;;) {
/* process buf */
@@ -80,7 +80,7 @@ LBL_ERR:
#endif
XFREE(omac);
va_end(args);
return err;
return err;
}
#endif
+21 -25
View File
@@ -10,24 +10,24 @@
*/
#include "tomcrypt.h"
/**
/**
@file omac_process.c
LTC_OMAC1 support, process data, Tom St Denis
OMAC1 support, process data, Tom St Denis
*/
#ifdef LTC_OMAC
/**
Process data through LTC_OMAC
@param omac The LTC_OMAC state
@param in The input data to send through LTC_OMAC
/**
Process data through OMAC
@param omac The OMAC state
@param in The input data to send through 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,27 +42,23 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen)
}
#ifdef LTC_FAST
{
unsigned long blklen;
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 += blklen;
if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) {
return err;
}
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]));
}
inlen -= x;
}
}
in += blklen;
if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) {
return err;
}
}
inlen -= x;
}
#endif
while (inlen != 0) {
while (inlen != 0) {
/* ok if the block is full we xor in prev, encrypt and replace prev */
if (omac->buflen == omac->blklen) {
for (x = 0; x < (unsigned long)omac->blklen; x++) {
+18 -18
View File
@@ -10,15 +10,15 @@
*/
#include "tomcrypt.h"
/**
/**
@file omac_test.c
LTC_OMAC1 support, self-test, by Tom St Denis
OMAC1 support, self-test, by Tom St Denis
*/
#ifdef LTC_OMAC
/**
Test the LTC_OMAC setup
Test the OMAC setup
@return CRYPT_OK if successful, CRYPT_NOP if tests have been disabled
*/
int omac_test(void)
@@ -26,48 +26,48 @@ int omac_test(void)
#if !defined(LTC_TEST)
return CRYPT_NOP;
#else
static const struct {
static const struct {
int keylen, msglen;
unsigned char key[16], msg[64], tag[16];
} tests[] = {
{ 16, 0,
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
{ 0x00 },
{ 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28,
0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46 }
},
{ 16, 16,
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
{ 16, 16,
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c },
{ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a },
{ 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
{ 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c }
},
{ 16, 40,
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
{ 16, 40,
{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd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92,
{ 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92,
0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe }
}
@@ -77,7 +77,7 @@ int omac_test(void)
unsigned long len;
/* AES can be under rijndael or aes... try to find it */
/* AES can be under rijndael or aes... try to find it */
if ((idx = find_cipher("aes")) == -1) {
if ((idx = find_cipher("rijndael")) == -1) {
return CRYPT_NOP;
@@ -85,7 +85,7 @@ int omac_test(void)
}
for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
len = sizeof(out);
len = sizeof(out);
if ((err = omac_memory(idx, tests[x].key, tests[x].keylen, tests[x].msg, tests[x].msglen, out, &len)) != CRYPT_OK) {
return err;
}
@@ -101,7 +101,7 @@ int omac_test(void)
}
return CRYPT_OK;
#endif
}
}
#endif
+7 -7
View File
@@ -10,9 +10,9 @@
*/
#include "tomcrypt.h"
/**
/**
@file pelican.c
Pelican MAC, initialize state, by Tom St Denis
Pelican MAC, initialize state, by Tom St Denis
*/
#ifdef LTC_PELICAN
@@ -24,14 +24,14 @@
/**
Initialize a Pelican state
@param pelmac The Pelican state to initialize
@param key The secret key
@param key The secret key
@param keylen The length of the secret key (octets)
@return CRYPT_OK if successful
*/
int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long keylen)
{
int err;
LTC_ARGCHK(pelmac != NULL);
LTC_ARGCHK(key != NULL);
@@ -49,7 +49,7 @@ int pelican_init(pelican_state *pelmac, const unsigned char *key, unsigned long
aes_ecb_encrypt(pelmac->state, pelmac->state, &pelmac->K);
pelmac->buflen = 0;
return CRYPT_OK;
return CRYPT_OK;
}
static void four_rounds(pelican_state *pelmac)
@@ -90,7 +90,7 @@ static void four_rounds(pelican_state *pelmac)
STORE32H(s3, pelmac->state + 12);
}
/**
/**
Process a block of text through Pelican
@param pelmac The Pelican MAC state
@param in The input
@@ -156,7 +156,7 @@ int pelican_done(pelican_state *pelmac, unsigned char *out)
aes_ecb_encrypt(pelmac->state, out, &pelmac->K);
aes_done(&pelmac->K);
return CRYPT_OK;
}
}
#endif
+3 -3
View File
@@ -10,9 +10,9 @@
*/
#include "tomcrypt.h"
/**
/**
@file pmac_process.c
PMAC implementation, process data, by Tom St Denis
PMAC implementation, process data, by Tom St Denis
*/
@@ -62,7 +62,7 @@ int pmac_process(pmac_state *pmac, const unsigned char *in, unsigned long inlen)
}
#endif
while (inlen != 0) {
while (inlen != 0) {
/* ok if the block is full we xor in prev, encrypt and replace prev */
if (pmac->buflen == pmac->block_len) {
pmac_shift_xor(pmac);
+1 -1
View File
@@ -64,7 +64,7 @@ int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen)
xcbc->IV[xcbc->buflen++] ^= *in++;
--inlen;
}
return CRYPT_OK;
return CRYPT_OK;
}
#endif