forked from wolfSSL/wolfssl
Merge branch 'master' into blake2
This commit is contained in:
@@ -23,7 +23,7 @@ RESULT=$?
|
|||||||
|
|
||||||
# make sure full config is ok
|
# make sure full config is ok
|
||||||
echo -e "\n\nTesting full config as well...\n\n"
|
echo -e "\n\nTesting full config as well...\n\n"
|
||||||
./configure --enable-opensslExtra --enable-fastmath --enable-dtls --enable-aesgcm --enable-aesccm --enable-hc128 --enable-sniffer --enable-psk --enable-rabbit;
|
./configure --enable-opensslExtra --enable-fastmath --enable-dtls --enable-aesgcm --enable-aesccm --enable-hc128 --enable-sniffer --enable-psk --enable-rabbit --enable-camellia;
|
||||||
RESULT=$?
|
RESULT=$?
|
||||||
[ $RESULT -ne 0 ] && echo -e "\n\nFull config ./configure failed" && exit 1
|
[ $RESULT -ne 0 ] && echo -e "\n\nFull config ./configure failed" && exit 1
|
||||||
|
|
||||||
|
16
configure.ac
16
configure.ac
@@ -365,6 +365,21 @@ fi
|
|||||||
AM_CONDITIONAL([BUILD_AESNI], [test "x$ENABLED_AESNI" = "xyes"])
|
AM_CONDITIONAL([BUILD_AESNI], [test "x$ENABLED_AESNI" = "xyes"])
|
||||||
|
|
||||||
|
|
||||||
|
# Camellia
|
||||||
|
AC_ARG_ENABLE([camellia],
|
||||||
|
[ --enable-camellia Enable CyaSSL Camellia support (default: disabled)],
|
||||||
|
[ ENABLED_CAMELLIA=$enableval ],
|
||||||
|
[ ENABLED_CAMELLIA=no ]
|
||||||
|
)
|
||||||
|
|
||||||
|
if test "$ENABLED_CAMELLIA" = "yes"
|
||||||
|
then
|
||||||
|
AM_CFLAGS="$AM_CFLAGS -DHAVE_CAMELLIA"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AM_CONDITIONAL([BUILD_CAMELLIA], [test "x$ENABLED_CAMELLIA" = "xyes"])
|
||||||
|
|
||||||
|
|
||||||
# MD2
|
# MD2
|
||||||
AC_ARG_ENABLE([md2],
|
AC_ARG_ENABLE([md2],
|
||||||
[ --enable-md2 Enable CyaSSL MD2 support (default: disabled)],
|
[ --enable-md2 Enable CyaSSL MD2 support (default: disabled)],
|
||||||
@@ -834,6 +849,7 @@ echo " * sniffer: $ENABLED_SNIFFER"
|
|||||||
echo " * AES-NI: $ENABLED_AESNI"
|
echo " * AES-NI: $ENABLED_AESNI"
|
||||||
echo " * AES-GCM: $ENABLED_AESGCM"
|
echo " * AES-GCM: $ENABLED_AESGCM"
|
||||||
echo " * AES-CCM: $ENABLED_AESCCM"
|
echo " * AES-CCM: $ENABLED_AESCCM"
|
||||||
|
echo " * Camellia: $ENABLED_CAMELLIA"
|
||||||
echo " * RIPEMD: $ENABLED_RIPEMD"
|
echo " * RIPEMD: $ENABLED_RIPEMD"
|
||||||
echo " * SHA-512: $ENABLED_SHA512"
|
echo " * SHA-512: $ENABLED_SHA512"
|
||||||
echo " * keygen: $ENABLED_KEYGEN"
|
echo " * keygen: $ENABLED_KEYGEN"
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include <cyassl/ctaocrypt/hc128.h>
|
#include <cyassl/ctaocrypt/hc128.h>
|
||||||
#include <cyassl/ctaocrypt/rabbit.h>
|
#include <cyassl/ctaocrypt/rabbit.h>
|
||||||
#include <cyassl/ctaocrypt/aes.h>
|
#include <cyassl/ctaocrypt/aes.h>
|
||||||
|
#include <cyassl/ctaocrypt/camellia.h>
|
||||||
#include <cyassl/ctaocrypt/md5.h>
|
#include <cyassl/ctaocrypt/md5.h>
|
||||||
#include <cyassl/ctaocrypt/sha.h>
|
#include <cyassl/ctaocrypt/sha.h>
|
||||||
#include <cyassl/ctaocrypt/sha256.h>
|
#include <cyassl/ctaocrypt/sha256.h>
|
||||||
@@ -61,6 +62,7 @@ void bench_rabbit(void);
|
|||||||
void bench_aes(int);
|
void bench_aes(int);
|
||||||
void bench_aesgcm(void);
|
void bench_aesgcm(void);
|
||||||
void bench_aesccm(void);
|
void bench_aesccm(void);
|
||||||
|
void bench_camellia(void);
|
||||||
|
|
||||||
void bench_md5(void);
|
void bench_md5(void);
|
||||||
void bench_sha(void);
|
void bench_sha(void);
|
||||||
@@ -94,6 +96,9 @@ int main(int argc, char** argv)
|
|||||||
#ifdef HAVE_AESCCM
|
#ifdef HAVE_AESCCM
|
||||||
bench_aesccm();
|
bench_aesccm();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_CAMELLIA
|
||||||
|
bench_camellia();
|
||||||
|
#endif
|
||||||
#ifndef NO_RC4
|
#ifndef NO_RC4
|
||||||
bench_arc4();
|
bench_arc4();
|
||||||
#endif
|
#endif
|
||||||
@@ -245,6 +250,28 @@ void bench_aesccm(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_CAMELLIA
|
||||||
|
void bench_camellia(void)
|
||||||
|
{
|
||||||
|
Camellia cam;
|
||||||
|
double start, total, persec;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
CamelliaSetKey(&cam, key, 16, iv);
|
||||||
|
start = current_time();
|
||||||
|
|
||||||
|
for(i = 0; i < megs; i++)
|
||||||
|
CamelliaCbcEncrypt(&cam, plain, cipher, sizeof(plain));
|
||||||
|
|
||||||
|
total = current_time() - start;
|
||||||
|
|
||||||
|
persec = 1 / total * megs;
|
||||||
|
printf("Camellia %d megs took %5.3f seconds, %6.2f MB/s\n", megs, total,
|
||||||
|
persec);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_DES3
|
#ifndef NO_DES3
|
||||||
void bench_des(void)
|
void bench_des(void)
|
||||||
{
|
{
|
||||||
|
1568
ctaocrypt/src/camellia.c
Normal file
1568
ctaocrypt/src/camellia.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -40,6 +40,7 @@
|
|||||||
#include <cyassl/ctaocrypt/rsa.h>
|
#include <cyassl/ctaocrypt/rsa.h>
|
||||||
#include <cyassl/ctaocrypt/des3.h>
|
#include <cyassl/ctaocrypt/des3.h>
|
||||||
#include <cyassl/ctaocrypt/aes.h>
|
#include <cyassl/ctaocrypt/aes.h>
|
||||||
|
#include <cyassl/ctaocrypt/camellia.h>
|
||||||
#include <cyassl/ctaocrypt/hmac.h>
|
#include <cyassl/ctaocrypt/hmac.h>
|
||||||
#include <cyassl/ctaocrypt/dh.h>
|
#include <cyassl/ctaocrypt/dh.h>
|
||||||
#include <cyassl/ctaocrypt/dsa.h>
|
#include <cyassl/ctaocrypt/dsa.h>
|
||||||
@@ -113,6 +114,7 @@ int des3_test(void);
|
|||||||
int aes_test(void);
|
int aes_test(void);
|
||||||
int aesgcm_test(void);
|
int aesgcm_test(void);
|
||||||
int aesccm_test(void);
|
int aesccm_test(void);
|
||||||
|
int camellia_test(void);
|
||||||
int rsa_test(void);
|
int rsa_test(void);
|
||||||
int dh_test(void);
|
int dh_test(void);
|
||||||
int dsa_test(void);
|
int dsa_test(void);
|
||||||
@@ -302,6 +304,13 @@ void ctaocrypt_test(void* args)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_CAMELLIA
|
||||||
|
if ( (ret = camellia_test()) )
|
||||||
|
err_sys("CAMELLIA test failed!\n", ret);
|
||||||
|
else
|
||||||
|
printf( "CAMELLIA test passed!\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( (ret = random_test()) )
|
if ( (ret = random_test()) )
|
||||||
err_sys("RANDOM test failed!\n", ret);
|
err_sys("RANDOM test failed!\n", ret);
|
||||||
else
|
else
|
||||||
@@ -1679,6 +1688,209 @@ int aesccm_test(void)
|
|||||||
#endif /* NO_AES */
|
#endif /* NO_AES */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_CAMELLIA
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CAM_ECB_ENC, CAM_ECB_DEC, CAM_CBC_ENC, CAM_CBC_DEC
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int type;
|
||||||
|
const byte* plaintext;
|
||||||
|
const byte* iv;
|
||||||
|
const byte* ciphertext;
|
||||||
|
const byte* key;
|
||||||
|
word32 keySz;
|
||||||
|
int errorCode;
|
||||||
|
} test_vector_t;
|
||||||
|
|
||||||
|
int camellia_test(void)
|
||||||
|
{
|
||||||
|
/* Camellia ECB Test Plaintext */
|
||||||
|
const byte pte[] =
|
||||||
|
{
|
||||||
|
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||||
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Camellia ECB Test Initialization Vector */
|
||||||
|
const byte ive[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
|
/* Test 1: Camellia ECB 128-bit key */
|
||||||
|
const byte k1[] =
|
||||||
|
{
|
||||||
|
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||||
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
|
||||||
|
};
|
||||||
|
const byte c1[] =
|
||||||
|
{
|
||||||
|
0x67, 0x67, 0x31, 0x38, 0x54, 0x96, 0x69, 0x73,
|
||||||
|
0x08, 0x57, 0x06, 0x56, 0x48, 0xea, 0xbe, 0x43
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test 2: Camellia ECB 192-bit key */
|
||||||
|
const byte k2[] =
|
||||||
|
{
|
||||||
|
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||||
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||||
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77
|
||||||
|
};
|
||||||
|
const byte c2[] =
|
||||||
|
{
|
||||||
|
0xb4, 0x99, 0x34, 0x01, 0xb3, 0xe9, 0x96, 0xf8,
|
||||||
|
0x4e, 0xe5, 0xce, 0xe7, 0xd7, 0x9b, 0x09, 0xb9
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test 3: Camellia ECB 256-bit key */
|
||||||
|
const byte k3[] =
|
||||||
|
{
|
||||||
|
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
|
||||||
|
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
||||||
|
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
||||||
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
|
||||||
|
};
|
||||||
|
const byte c3[] =
|
||||||
|
{
|
||||||
|
0x9a, 0xcc, 0x23, 0x7d, 0xff, 0x16, 0xd7, 0x6c,
|
||||||
|
0x20, 0xef, 0x7c, 0x91, 0x9e, 0x3a, 0x75, 0x09
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Camellia CBC Test Plaintext */
|
||||||
|
const byte ptc[] =
|
||||||
|
{
|
||||||
|
0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
|
||||||
|
0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Camellia CBC Test Initialization Vector */
|
||||||
|
const byte ivc[] =
|
||||||
|
{
|
||||||
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||||
|
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test 4: Camellia-CBC 128-bit key */
|
||||||
|
const byte k4[] =
|
||||||
|
{
|
||||||
|
0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
|
||||||
|
0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
|
||||||
|
};
|
||||||
|
const byte c4[] =
|
||||||
|
{
|
||||||
|
0x16, 0x07, 0xCF, 0x49, 0x4B, 0x36, 0xBB, 0xF0,
|
||||||
|
0x0D, 0xAE, 0xB0, 0xB5, 0x03, 0xC8, 0x31, 0xAB
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test 5: Camellia-CBC 192-bit key */
|
||||||
|
const byte k5[] =
|
||||||
|
{
|
||||||
|
0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52,
|
||||||
|
0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5,
|
||||||
|
0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B
|
||||||
|
};
|
||||||
|
const byte c5[] =
|
||||||
|
{
|
||||||
|
0x2A, 0x48, 0x30, 0xAB, 0x5A, 0xC4, 0xA1, 0xA2,
|
||||||
|
0x40, 0x59, 0x55, 0xFD, 0x21, 0x95, 0xCF, 0x93
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Test 6: CBC 256-bit key */
|
||||||
|
const byte k6[] =
|
||||||
|
{
|
||||||
|
0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE,
|
||||||
|
0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81,
|
||||||
|
0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7,
|
||||||
|
0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4
|
||||||
|
};
|
||||||
|
const byte c6[] =
|
||||||
|
{
|
||||||
|
0xE6, 0xCF, 0xA3, 0x5F, 0xC0, 0x2B, 0x13, 0x4A,
|
||||||
|
0x4D, 0x2C, 0x0B, 0x67, 0x37, 0xAC, 0x3E, 0xDA
|
||||||
|
};
|
||||||
|
|
||||||
|
byte out[CAMELLIA_BLOCK_SIZE];
|
||||||
|
Camellia cam;
|
||||||
|
int i, testsSz;
|
||||||
|
const test_vector_t testVectors[] =
|
||||||
|
{
|
||||||
|
{CAM_ECB_ENC, pte, ive, c1, k1, sizeof(k1), -114},
|
||||||
|
{CAM_ECB_ENC, pte, ive, c2, k2, sizeof(k2), -115},
|
||||||
|
{CAM_ECB_ENC, pte, ive, c3, k3, sizeof(k3), -116},
|
||||||
|
{CAM_ECB_DEC, pte, ive, c1, k1, sizeof(k1), -117},
|
||||||
|
{CAM_ECB_DEC, pte, ive, c2, k2, sizeof(k2), -118},
|
||||||
|
{CAM_ECB_DEC, pte, ive, c3, k3, sizeof(k3), -119},
|
||||||
|
{CAM_CBC_ENC, ptc, ivc, c4, k4, sizeof(k4), -120},
|
||||||
|
{CAM_CBC_ENC, ptc, ivc, c5, k5, sizeof(k5), -121},
|
||||||
|
{CAM_CBC_ENC, ptc, ivc, c6, k6, sizeof(k6), -122},
|
||||||
|
{CAM_CBC_DEC, ptc, ivc, c4, k4, sizeof(k4), -123},
|
||||||
|
{CAM_CBC_DEC, ptc, ivc, c5, k5, sizeof(k5), -124},
|
||||||
|
{CAM_CBC_DEC, ptc, ivc, c6, k6, sizeof(k6), -125}
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((sizeof(pte) != CAMELLIA_BLOCK_SIZE) ||
|
||||||
|
(sizeof(ptc) != CAMELLIA_BLOCK_SIZE))
|
||||||
|
return -113;
|
||||||
|
|
||||||
|
testsSz = sizeof(testVectors)/sizeof(test_vector_t);
|
||||||
|
for (i = 0; i < testsSz; i++) {
|
||||||
|
CamelliaSetKey(&cam, testVectors[i].key, testVectors[i].keySz,
|
||||||
|
testVectors[i].iv);
|
||||||
|
|
||||||
|
switch (testVectors[i].type) {
|
||||||
|
case CAM_ECB_ENC:
|
||||||
|
CamelliaEncryptDirect(&cam, out, testVectors[i].plaintext);
|
||||||
|
if (memcmp(out, testVectors[i].ciphertext, CAMELLIA_BLOCK_SIZE))
|
||||||
|
return testVectors[i].errorCode;
|
||||||
|
break;
|
||||||
|
case CAM_ECB_DEC:
|
||||||
|
CamelliaDecryptDirect(&cam, out, testVectors[i].ciphertext);
|
||||||
|
if (memcmp(out, testVectors[i].plaintext, CAMELLIA_BLOCK_SIZE))
|
||||||
|
return testVectors[i].errorCode;
|
||||||
|
break;
|
||||||
|
case CAM_CBC_ENC:
|
||||||
|
CamelliaCbcEncrypt(&cam, out, testVectors[i].plaintext,
|
||||||
|
CAMELLIA_BLOCK_SIZE);
|
||||||
|
if (memcmp(out, testVectors[i].ciphertext, CAMELLIA_BLOCK_SIZE))
|
||||||
|
return testVectors[i].errorCode;
|
||||||
|
break;
|
||||||
|
case CAM_CBC_DEC:
|
||||||
|
CamelliaCbcDecrypt(&cam, out, testVectors[i].ciphertext,
|
||||||
|
CAMELLIA_BLOCK_SIZE);
|
||||||
|
if (memcmp(out, testVectors[i].plaintext, CAMELLIA_BLOCK_SIZE))
|
||||||
|
return testVectors[i].errorCode;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Setting the IV and checking it was actually set. */
|
||||||
|
CamelliaSetIV(&cam, ivc);
|
||||||
|
if (XMEMCMP(cam.reg, ivc, CAMELLIA_BLOCK_SIZE))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Setting the IV to NULL should leave the IV unchanged */
|
||||||
|
if (CamelliaSetIV(&cam, NULL) != 0 ||
|
||||||
|
XMEMCMP(cam.reg, ivc, CAMELLIA_BLOCK_SIZE))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* First parameter should never be null */
|
||||||
|
if (CamelliaSetIV(NULL, NULL) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* First parameter should never be null, check it fails */
|
||||||
|
if (CamelliaSetKey(NULL, k1, sizeof(k1), NULL) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Key should have a size of 16, 24, or 32 */
|
||||||
|
if (CamelliaSetKey(&cam, k1, 0, NULL) == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_CAMELLIA */
|
||||||
|
|
||||||
|
|
||||||
int random_test(void)
|
int random_test(void)
|
||||||
{
|
{
|
||||||
RNG rng;
|
RNG rng;
|
||||||
|
96
cyassl/ctaocrypt/camellia.h
Normal file
96
cyassl/ctaocrypt/camellia.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/* camellia.h ver 1.2.0
|
||||||
|
*
|
||||||
|
* Copyright (c) 2006,2007
|
||||||
|
* NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer as
|
||||||
|
* the first lines of this file unmodified.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* camellia.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2013 Sawtooth Consulting Ltd.
|
||||||
|
*
|
||||||
|
* This file is part of CyaSSL.
|
||||||
|
*
|
||||||
|
* CyaSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* CyaSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CAMELLIA
|
||||||
|
|
||||||
|
#ifndef CTAO_CRYPT_CAMELLIA_H
|
||||||
|
#define CTAO_CRYPT_CAMELLIA_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <cyassl/ctaocrypt/types.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CAMELLIA_BLOCK_SIZE = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CAMELLIA_TABLE_BYTE_LEN 272
|
||||||
|
#define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / sizeof(word32))
|
||||||
|
|
||||||
|
typedef word32 KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
|
||||||
|
|
||||||
|
typedef struct Camellia {
|
||||||
|
word32 keySz;
|
||||||
|
KEY_TABLE_TYPE key;
|
||||||
|
word32 reg[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||||
|
word32 tmp[CAMELLIA_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
|
||||||
|
} Camellia;
|
||||||
|
|
||||||
|
|
||||||
|
CYASSL_API int CamelliaSetKey(Camellia* cam,
|
||||||
|
const byte* key, word32 len, const byte* iv);
|
||||||
|
CYASSL_API int CamelliaSetIV(Camellia* cam, const byte* iv);
|
||||||
|
CYASSL_API void CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in);
|
||||||
|
CYASSL_API void CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in);
|
||||||
|
CYASSL_API void CamelliaCbcEncrypt(Camellia* cam,
|
||||||
|
byte* out, const byte* in, word32 sz);
|
||||||
|
CYASSL_API void CamelliaCbcDecrypt(Camellia* cam,
|
||||||
|
byte* out, const byte* in, word32 sz);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CTAO_CRYPT_AES_H */
|
||||||
|
#endif /* HAVE_CAMELLIA */
|
||||||
|
|
@@ -6,6 +6,7 @@ nobase_include_HEADERS+= \
|
|||||||
cyassl/ctaocrypt/arc4.h \
|
cyassl/ctaocrypt/arc4.h \
|
||||||
cyassl/ctaocrypt/asn.h \
|
cyassl/ctaocrypt/asn.h \
|
||||||
cyassl/ctaocrypt/asn_public.h \
|
cyassl/ctaocrypt/asn_public.h \
|
||||||
|
cyassl/ctaocrypt/camellia.h \
|
||||||
cyassl/ctaocrypt/coding.h \
|
cyassl/ctaocrypt/coding.h \
|
||||||
cyassl/ctaocrypt/des3.h \
|
cyassl/ctaocrypt/des3.h \
|
||||||
cyassl/ctaocrypt/dh.h \
|
cyassl/ctaocrypt/dh.h \
|
||||||
|
@@ -39,6 +39,10 @@ if BUILD_AESNI
|
|||||||
src_libcyassl_la_SOURCES += ctaocrypt/src/aes_asm.s
|
src_libcyassl_la_SOURCES += ctaocrypt/src/aes_asm.s
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if BUILD_CAMELLIA
|
||||||
|
src_libcyassl_la_SOURCES += ctaocrypt/src/camellia.c
|
||||||
|
endif
|
||||||
|
|
||||||
if BUILD_MD2
|
if BUILD_MD2
|
||||||
src_libcyassl_la_SOURCES += ctaocrypt/src/md2.c
|
src_libcyassl_la_SOURCES += ctaocrypt/src/md2.c
|
||||||
endif
|
endif
|
||||||
|
Reference in New Issue
Block a user