mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-26 14:21:49 +00:00
Import code from previous AssetBuilder version
This commit is contained in:
75
thirdparty/libtomcrypt/mac/xcbc/xcbc_done.c
vendored
Normal file
75
thirdparty/libtomcrypt/mac/xcbc/xcbc_done.c
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file xcbc_done.c
|
||||
XCBC Support, terminate the state
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/** Terminate the XCBC-MAC state
|
||||
@param xcbc XCBC state to terminate
|
||||
@param out [out] Destination for the MAC tag
|
||||
@param outlen [in/out] Destination size and final tag size
|
||||
Return CRYPT_OK on success
|
||||
*/
|
||||
int xcbc_done(xcbc_state *xcbc, unsigned char *out, unsigned long *outlen)
|
||||
{
|
||||
int err, x;
|
||||
LTC_ARGCHK(xcbc != NULL);
|
||||
LTC_ARGCHK(out != NULL);
|
||||
|
||||
/* check structure */
|
||||
if ((err = cipher_is_valid(xcbc->cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((xcbc->blocksize > cipher_descriptor[xcbc->cipher].block_length) || (xcbc->blocksize < 0) ||
|
||||
(xcbc->buflen > xcbc->blocksize) || (xcbc->buflen < 0)) {
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* which key do we use? */
|
||||
if (xcbc->buflen == xcbc->blocksize) {
|
||||
/* k2 */
|
||||
for (x = 0; x < xcbc->blocksize; x++) {
|
||||
xcbc->IV[x] ^= xcbc->K[1][x];
|
||||
}
|
||||
} else {
|
||||
xcbc->IV[xcbc->buflen] ^= 0x80;
|
||||
/* k3 */
|
||||
for (x = 0; x < xcbc->blocksize; x++) {
|
||||
xcbc->IV[x] ^= xcbc->K[2][x];
|
||||
}
|
||||
}
|
||||
|
||||
/* encrypt */
|
||||
cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
|
||||
cipher_descriptor[xcbc->cipher].done(&xcbc->key);
|
||||
|
||||
/* extract tag */
|
||||
for (x = 0; x < xcbc->blocksize && (unsigned long)x < *outlen; x++) {
|
||||
out[x] = xcbc->IV[x];
|
||||
}
|
||||
*outlen = x;
|
||||
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(xcbc, sizeof(*xcbc));
|
||||
#endif
|
||||
return CRYPT_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
||||
|
97
thirdparty/libtomcrypt/mac/xcbc/xcbc_file.c
vendored
Normal file
97
thirdparty/libtomcrypt/mac/xcbc/xcbc_file.c
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file xcbc_file.c
|
||||
XCBC support, process a file, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/**
|
||||
XCBC 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 XCBC
|
||||
@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 xcbc_file(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const char *filename,
|
||||
unsigned char *out, unsigned long *outlen)
|
||||
{
|
||||
#ifdef LTC_NO_FILE
|
||||
LTC_UNUSED_PARAM(cipher);
|
||||
LTC_UNUSED_PARAM(key);
|
||||
LTC_UNUSED_PARAM(keylen);
|
||||
LTC_UNUSED_PARAM(filename);
|
||||
LTC_UNUSED_PARAM(out);
|
||||
LTC_UNUSED_PARAM(outlen);
|
||||
return CRYPT_NOP;
|
||||
#else
|
||||
size_t x;
|
||||
int err;
|
||||
xcbc_state xcbc;
|
||||
FILE *in;
|
||||
unsigned char *buf;
|
||||
|
||||
LTC_ARGCHK(key != NULL);
|
||||
LTC_ARGCHK(filename != NULL);
|
||||
LTC_ARGCHK(out != NULL);
|
||||
LTC_ARGCHK(outlen != NULL);
|
||||
|
||||
if ((buf = XMALLOC(LTC_FILE_READ_BUFSIZE)) == NULL) {
|
||||
return CRYPT_MEM;
|
||||
}
|
||||
|
||||
if ((err = xcbc_init(&xcbc, cipher, key, keylen)) != CRYPT_OK) {
|
||||
goto LBL_ERR;
|
||||
}
|
||||
|
||||
in = fopen(filename, "rb");
|
||||
if (in == NULL) {
|
||||
err = CRYPT_FILE_NOTFOUND;
|
||||
goto LBL_ERR;
|
||||
}
|
||||
|
||||
do {
|
||||
x = fread(buf, 1, LTC_FILE_READ_BUFSIZE, in);
|
||||
if ((err = xcbc_process(&xcbc, buf, (unsigned long)x)) != CRYPT_OK) {
|
||||
fclose(in);
|
||||
goto LBL_CLEANBUF;
|
||||
}
|
||||
} while (x == LTC_FILE_READ_BUFSIZE);
|
||||
|
||||
if (fclose(in) != 0) {
|
||||
err = CRYPT_ERROR;
|
||||
goto LBL_CLEANBUF;
|
||||
}
|
||||
|
||||
err = xcbc_done(&xcbc, out, outlen);
|
||||
|
||||
LBL_CLEANBUF:
|
||||
zeromem(buf, LTC_FILE_READ_BUFSIZE);
|
||||
LBL_ERR:
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(&xcbc, sizeof(xcbc_state));
|
||||
#endif
|
||||
XFREE(buf);
|
||||
return err;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
106
thirdparty/libtomcrypt/mac/xcbc/xcbc_init.c
vendored
Normal file
106
thirdparty/libtomcrypt/mac/xcbc/xcbc_init.c
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file xcbc_init.c
|
||||
XCBC Support, start an XCBC state
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/** Initialize XCBC-MAC state
|
||||
@param xcbc [out] XCBC state to initialize
|
||||
@param cipher Index of cipher to use
|
||||
@param key [in] Secret key
|
||||
@param keylen Length of secret key in octets
|
||||
Return CRYPT_OK on success
|
||||
*/
|
||||
int xcbc_init(xcbc_state *xcbc, int cipher, const unsigned char *key, unsigned long keylen)
|
||||
{
|
||||
int x, y, err;
|
||||
symmetric_key *skey;
|
||||
unsigned long k1;
|
||||
|
||||
LTC_ARGCHK(xcbc != NULL);
|
||||
LTC_ARGCHK(key != NULL);
|
||||
|
||||
/* schedule the key */
|
||||
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef LTC_FAST
|
||||
if (cipher_descriptor[cipher].block_length % sizeof(LTC_FAST_TYPE)) {
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
#endif
|
||||
|
||||
skey = NULL;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/* setup K1 */
|
||||
err = cipher_descriptor[cipher].setup(xcbc->K[0], k1, 0, &xcbc->key);
|
||||
|
||||
/* setup struct */
|
||||
zeromem(xcbc->IV, cipher_descriptor[cipher].block_length);
|
||||
xcbc->blocksize = cipher_descriptor[cipher].block_length;
|
||||
xcbc->cipher = cipher;
|
||||
xcbc->buflen = 0;
|
||||
done:
|
||||
cipher_descriptor[cipher].done(skey);
|
||||
if (skey != NULL) {
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(skey, sizeof(*skey));
|
||||
#endif
|
||||
XFREE(skey);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
||||
|
69
thirdparty/libtomcrypt/mac/xcbc/xcbc_memory.c
vendored
Normal file
69
thirdparty/libtomcrypt/mac/xcbc/xcbc_memory.c
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file xcbc_process.c
|
||||
XCBC Support, XCBC-MAC a block of memory
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/** XCBC-MAC a block of memory
|
||||
@param cipher Index of cipher to use
|
||||
@param key [in] Secret key
|
||||
@param keylen Length of key in octets
|
||||
@param in [in] Message to MAC
|
||||
@param inlen Length of input in octets
|
||||
@param out [out] Destination for the MAC tag
|
||||
@param outlen [in/out] Output size and final tag size
|
||||
Return CRYPT_OK on success.
|
||||
*/
|
||||
int xcbc_memory(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
const unsigned char *in, unsigned long inlen,
|
||||
unsigned char *out, unsigned long *outlen)
|
||||
{
|
||||
xcbc_state *xcbc;
|
||||
int err;
|
||||
|
||||
/* is the cipher valid? */
|
||||
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Use accelerator if found */
|
||||
if (cipher_descriptor[cipher].xcbc_memory != NULL) {
|
||||
return cipher_descriptor[cipher].xcbc_memory(key, keylen, in, inlen, out, outlen);
|
||||
}
|
||||
|
||||
xcbc = XCALLOC(1, sizeof(*xcbc));
|
||||
if (xcbc == NULL) {
|
||||
return CRYPT_MEM;
|
||||
}
|
||||
|
||||
if ((err = xcbc_init(xcbc, cipher, key, keylen)) != CRYPT_OK) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((err = xcbc_process(xcbc, in, inlen)) != CRYPT_OK) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
err = xcbc_done(xcbc, out, outlen);
|
||||
done:
|
||||
XFREE(xcbc);
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
88
thirdparty/libtomcrypt/mac/xcbc/xcbc_memory_multi.c
vendored
Normal file
88
thirdparty/libtomcrypt/mac/xcbc/xcbc_memory_multi.c
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
/**
|
||||
@file xcbc_memory_multi.c
|
||||
XCBC support, process multiple blocks of memory, Tom St Denis
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/**
|
||||
XCBC 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 XCBC
|
||||
@param inlen The length of the data to send through XCBC (octets)
|
||||
@param ... tuples of (data,len) pairs to XCBC, terminated with a (NULL,x) (x=don't care)
|
||||
@return CRYPT_OK if successful
|
||||
*/
|
||||
int xcbc_memory_multi(int cipher,
|
||||
const unsigned char *key, unsigned long keylen,
|
||||
unsigned char *out, unsigned long *outlen,
|
||||
const unsigned char *in, unsigned long inlen, ...)
|
||||
{
|
||||
int err;
|
||||
xcbc_state *xcbc;
|
||||
va_list args;
|
||||
const unsigned char *curptr;
|
||||
unsigned long curlen;
|
||||
|
||||
LTC_ARGCHK(key != NULL);
|
||||
LTC_ARGCHK(in != NULL);
|
||||
LTC_ARGCHK(out != NULL);
|
||||
LTC_ARGCHK(outlen != NULL);
|
||||
|
||||
/* allocate ram for xcbc state */
|
||||
xcbc = XMALLOC(sizeof(xcbc_state));
|
||||
if (xcbc == NULL) {
|
||||
return CRYPT_MEM;
|
||||
}
|
||||
|
||||
/* xcbc process the message */
|
||||
if ((err = xcbc_init(xcbc, cipher, key, keylen)) != CRYPT_OK) {
|
||||
goto LBL_ERR;
|
||||
}
|
||||
va_start(args, inlen);
|
||||
curptr = in;
|
||||
curlen = inlen;
|
||||
for (;;) {
|
||||
/* process buf */
|
||||
if ((err = xcbc_process(xcbc, curptr, curlen)) != CRYPT_OK) {
|
||||
goto LBL_ERR;
|
||||
}
|
||||
/* step to next */
|
||||
curptr = va_arg(args, const unsigned char*);
|
||||
if (curptr == NULL) {
|
||||
break;
|
||||
}
|
||||
curlen = va_arg(args, unsigned long);
|
||||
}
|
||||
if ((err = xcbc_done(xcbc, out, outlen)) != CRYPT_OK) {
|
||||
goto LBL_ERR;
|
||||
}
|
||||
LBL_ERR:
|
||||
#ifdef LTC_CLEAN_STACK
|
||||
zeromem(xcbc, sizeof(xcbc_state));
|
||||
#endif
|
||||
XFREE(xcbc);
|
||||
va_end(args);
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
73
thirdparty/libtomcrypt/mac/xcbc/xcbc_process.c
vendored
Normal file
73
thirdparty/libtomcrypt/mac/xcbc/xcbc_process.c
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file xcbc_process.c
|
||||
XCBC Support, process blocks with XCBC
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/** Process data through XCBC-MAC
|
||||
@param xcbc The XCBC-MAC state
|
||||
@param in Input data to process
|
||||
@param inlen Length of input in octets
|
||||
Return CRYPT_OK on success
|
||||
*/
|
||||
int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen)
|
||||
{
|
||||
int err;
|
||||
#ifdef LTC_FAST
|
||||
int x;
|
||||
#endif
|
||||
|
||||
LTC_ARGCHK(xcbc != NULL);
|
||||
LTC_ARGCHK(in != NULL);
|
||||
|
||||
/* check structure */
|
||||
if ((err = cipher_is_valid(xcbc->cipher)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
if ((xcbc->blocksize > cipher_descriptor[xcbc->cipher].block_length) || (xcbc->blocksize < 0) ||
|
||||
(xcbc->buflen > xcbc->blocksize) || (xcbc->buflen < 0)) {
|
||||
return CRYPT_INVALID_ARG;
|
||||
}
|
||||
|
||||
#ifdef LTC_FAST
|
||||
if (xcbc->buflen == 0) {
|
||||
while (inlen > (unsigned long)xcbc->blocksize) {
|
||||
for (x = 0; x < xcbc->blocksize; x += sizeof(LTC_FAST_TYPE)) {
|
||||
*(LTC_FAST_TYPE_PTR_CAST(&(xcbc->IV[x]))) ^= *(LTC_FAST_TYPE_PTR_CAST(&(in[x])));
|
||||
}
|
||||
cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
|
||||
in += xcbc->blocksize;
|
||||
inlen -= xcbc->blocksize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while (inlen) {
|
||||
if (xcbc->buflen == xcbc->blocksize) {
|
||||
cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
|
||||
xcbc->buflen = 0;
|
||||
}
|
||||
xcbc->IV[xcbc->buflen++] ^= *in++;
|
||||
--inlen;
|
||||
}
|
||||
return CRYPT_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
||||
|
126
thirdparty/libtomcrypt/mac/xcbc/xcbc_test.c
vendored
Normal file
126
thirdparty/libtomcrypt/mac/xcbc/xcbc_test.c
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
|
||||
*
|
||||
* LibTomCrypt is a library that provides various cryptographic
|
||||
* algorithms in a highly modular and flexible manner.
|
||||
*
|
||||
* The library is free for all purposes without any express
|
||||
* guarantee it works.
|
||||
*/
|
||||
#include "tomcrypt.h"
|
||||
|
||||
/**
|
||||
@file xcbc_test.c
|
||||
XCBC Support, Test XCBC-MAC mode
|
||||
*/
|
||||
|
||||
#ifdef LTC_XCBC
|
||||
|
||||
/** Test XCBC-MAC mode
|
||||
Return CRYPT_OK on succes
|
||||
*/
|
||||
int xcbc_test(void)
|
||||
{
|
||||
#ifdef LTC_NO_TEST
|
||||
return CRYPT_NOP;
|
||||
#else
|
||||
static const struct {
|
||||
int msglen;
|
||||
unsigned char K[16], M[34], T[16];
|
||||
} tests[] = {
|
||||
{
|
||||
0,
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
|
||||
{ 0 },
|
||||
|
||||
{ 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
|
||||
0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29 }
|
||||
},
|
||||
|
||||
{
|
||||
3,
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
|
||||
{ 0x00, 0x01, 0x02 },
|
||||
|
||||
{ 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
|
||||
0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f }
|
||||
},
|
||||
|
||||
{
|
||||
16,
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
|
||||
{ 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
|
||||
0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 }
|
||||
},
|
||||
|
||||
{
|
||||
32,
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
|
||||
|
||||
{ 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
|
||||
0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4 }
|
||||
},
|
||||
|
||||
{
|
||||
34,
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
|
||||
|
||||
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21 },
|
||||
|
||||
{ 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
|
||||
0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8 },
|
||||
},
|
||||
|
||||
|
||||
|
||||
};
|
||||
unsigned char T[16];
|
||||
unsigned long taglen;
|
||||
int err, x, idx;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
|
||||
taglen = 16;
|
||||
if ((err = xcbc_memory(idx, tests[x].K, 16, tests[x].M, tests[x].msglen, T, &taglen)) != CRYPT_OK) {
|
||||
return err;
|
||||
}
|
||||
if (compare_testvector(T, taglen, tests[x].T, 16, "XCBC", x)) {
|
||||
return CRYPT_FAIL_TESTVECTOR;
|
||||
}
|
||||
}
|
||||
|
||||
return CRYPT_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* ref: HEAD -> master, tag: v1.18.2 */
|
||||
/* git commit: 7e7eb695d581782f04b24dc444cbfde86af59853 */
|
||||
/* commit time: 2018-07-01 22:49:01 +0200 */
|
||||
|
Reference in New Issue
Block a user