new changes

This commit is contained in:
kaleb-himes
2014-12-29 10:27:03 -07:00
parent db383fbbac
commit edf53a1ed0
80 changed files with 7421 additions and 4826 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
ctaocrypt/src/src/
*.swp
*.lo
*.la
@ -36,6 +37,8 @@ fips_test.c
fips
ctaocrypt/benchmark/benchmark
ctaocrypt/test/testctaocrypt
wolfcrypt/benchmark/benchmark
wolfcrypt/test/testwolfcrypt
examples/client/client
examples/echoclient/echoclient
examples/echoserver/echoserver

View File

@ -60,8 +60,12 @@ EXTRA_DIST+= README.md
EXTRA_DIST+= LICENSING
#-------------------------------------#
include wolfssl/include.am
if BUILD_FIPS
include cyassl/include.am
else
include wolfssl/include.am
endif
#-------------------------------------#
include certs/include.am
include certs/1024/include.am
@ -72,14 +76,23 @@ include swig/include.am
include src/include.am
include support/include.am
#-------------------------------------#
include wolfcrypt/benchmark/include.am
if BUILD_FIPS
include ctaocrypt/benchmark/include.am
else
include wolfcrypt/benchmark/include.am
endif
#-------------------------------------#
include wolfcrypt/src/include.am
if BUILD_FIPS
include ctaocrypt/src/include.am
else
include wolfcrypt/src/include.am
endif
#-------------------------------------#
include wolfcrypt/test/include.am
if BUILD_FIPS
include ctaocrypt/test/include.am
else
include wolfcrypt/test/include.am
endif
#-------------------------------------#
include examples/client/include.am
include examples/server/include.am

View File

@ -1472,7 +1472,7 @@ AC_ARG_ENABLE([smallstack],
if test "x$ENABLED_SMALL_STACK" = "xyes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_SMALL_STACK"
AM_CFLAGS="$AM_CFLAGS -DCYASSL_SMALL_STACK"
fi

179
ctaocrypt/src/arc4.c Normal file
View File

@ -0,0 +1,179 @@
/* arc4.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#ifndef NO_RC4
#include <cyassl/ctaocrypt/arc4.h>
#ifdef HAVE_CAVIUM
static void Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length);
static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
word32 length);
#endif
void Arc4SetKey(Arc4* arc4, const byte* key, word32 length)
{
word32 i;
word32 keyIndex = 0, stateIndex = 0;
#ifdef HAVE_CAVIUM
if (arc4->magic == CYASSL_ARC4_CAVIUM_MAGIC)
return Arc4CaviumSetKey(arc4, key, length);
#endif
arc4->x = 1;
arc4->y = 0;
for (i = 0; i < ARC4_STATE_SIZE; i++)
arc4->state[i] = (byte)i;
for (i = 0; i < ARC4_STATE_SIZE; i++) {
word32 a = arc4->state[i];
stateIndex += key[keyIndex] + a;
stateIndex &= 0xFF;
arc4->state[i] = arc4->state[stateIndex];
arc4->state[stateIndex] = (byte)a;
if (++keyIndex >= length)
keyIndex = 0;
}
}
static INLINE byte MakeByte(word32* x, word32* y, byte* s)
{
word32 a = s[*x], b;
*y = (*y+a) & 0xff;
b = s[*y];
s[*x] = (byte)b;
s[*y] = (byte)a;
*x = (*x+1) & 0xff;
return s[(a+b) & 0xff];
}
void Arc4Process(Arc4* arc4, byte* out, const byte* in, word32 length)
{
word32 x;
word32 y;
#ifdef HAVE_CAVIUM
if (arc4->magic == CYASSL_ARC4_CAVIUM_MAGIC)
return Arc4CaviumProcess(arc4, out, in, length);
#endif
x = arc4->x;
y = arc4->y;
while(length--)
*out++ = *in++ ^ MakeByte(&x, &y, arc4->state);
arc4->x = (byte)x;
arc4->y = (byte)y;
}
#ifdef HAVE_CAVIUM
#include <cyassl/ctaocrypt/logging.h>
#include "cavium_common.h"
/* Initiliaze Arc4 for use with Nitrox device */
int Arc4InitCavium(Arc4* arc4, int devId)
{
if (arc4 == NULL)
return -1;
if (CspAllocContext(CONTEXT_SSL, &arc4->contextHandle, devId) != 0)
return -1;
arc4->devId = devId;
arc4->magic = CYASSL_ARC4_CAVIUM_MAGIC;
return 0;
}
/* Free Arc4 from use with Nitrox device */
void Arc4FreeCavium(Arc4* arc4)
{
if (arc4 == NULL)
return;
if (arc4->magic != CYASSL_ARC4_CAVIUM_MAGIC)
return;
CspFreeContext(CONTEXT_SSL, arc4->contextHandle, arc4->devId);
arc4->magic = 0;
}
static void Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length)
{
word32 requestId;
if (CspInitializeRc4(CAVIUM_BLOCKING, arc4->contextHandle, length,
(byte*)key, &requestId, arc4->devId) != 0) {
CYASSL_MSG("Bad Cavium Arc4 Init");
}
}
static void Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
word32 length)
{
cyassl_word offset = 0;
word32 requestId;
while (length > CYASSL_MAX_16BIT) {
word16 slen = (word16)CYASSL_MAX_16BIT;
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
slen, (byte*)in + offset, out + offset, &requestId,
arc4->devId) != 0) {
CYASSL_MSG("Bad Cavium Arc4 Encrypt");
}
length -= CYASSL_MAX_16BIT;
offset += CYASSL_MAX_16BIT;
}
if (length) {
word16 slen = (word16)length;
if (CspEncryptRc4(CAVIUM_BLOCKING, arc4->contextHandle,CAVIUM_UPDATE,
slen, (byte*)in + offset, out + offset, &requestId,
arc4->devId) != 0) {
CYASSL_MSG("Bad Cavium Arc4 Encrypt");
}
}
}
#endif /* HAVE_CAVIUM */
#endif /* NO_ARC4 */

1621
ctaocrypt/src/camellia.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,140 +20,140 @@
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#ifdef CYASSL_MD2
#include <cyassl/ctaocrypt/md2.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h>
#else
#include <ctaocrypt/src/misc.c>
#endif
void InitMd2(Md2* md2)
{
XMEMSET(md2->X, 0, MD2_X_SIZE);
XMEMSET(md2->C, 0, MD2_BLOCK_SIZE);
XMEMSET(md2->buffer, 0, MD2_BLOCK_SIZE);
md2->count = 0;
}
void Md2Update(Md2* md2, const byte* data, word32 len)
{
static const byte S[256] =
{
41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,
76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,
138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,
245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,
148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,
39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,
181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,
150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,
112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,
96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,
234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,
129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,
8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,
203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,
166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,
31, 26, 219, 153, 141, 51, 159, 17, 131, 20
};
while (len) {
word32 L = (MD2_PAD_SIZE - md2->count) < len ?
(MD2_PAD_SIZE - md2->count) : len;
XMEMCPY(md2->buffer + md2->count, data, L);
md2->count += L;
data += L;
len -= L;
if (md2->count == MD2_PAD_SIZE) {
int i;
byte t;
md2->count = 0;
XMEMCPY(md2->X + MD2_PAD_SIZE, md2->buffer, MD2_PAD_SIZE);
t = md2->C[15];
for(i = 0; i < MD2_PAD_SIZE; i++) {
md2->X[32 + i] = md2->X[MD2_PAD_SIZE + i] ^ md2->X[i];
t = md2->C[i] ^= S[md2->buffer[i] ^ t];
}
t=0;
for(i = 0; i < 18; i++) {
int j;
for(j = 0; j < MD2_X_SIZE; j += 8) {
t = md2->X[j+0] ^= S[t];
t = md2->X[j+1] ^= S[t];
t = md2->X[j+2] ^= S[t];
t = md2->X[j+3] ^= S[t];
t = md2->X[j+4] ^= S[t];
t = md2->X[j+5] ^= S[t];
t = md2->X[j+6] ^= S[t];
t = md2->X[j+7] ^= S[t];
}
t = (t + i) & 0xFF;
}
}
}
}
void Md2Final(Md2* md2, byte* hash)
{
byte padding[MD2_BLOCK_SIZE];
word32 padLen = MD2_PAD_SIZE - md2->count;
word32 i;
for (i = 0; i < padLen; i++)
padding[i] = (byte)padLen;
Md2Update(md2, padding, padLen);
Md2Update(md2, md2->C, MD2_BLOCK_SIZE);
XMEMCPY(hash, md2->X, MD2_DIGEST_SIZE);
InitMd2(md2);
}
int Md2Hash(const byte* data, word32 len, byte* hash)
{
#ifdef CYASSL_SMALL_STACK
Md2* md2;
#else
Md2 md2[1];
#endif
#ifdef CYASSL_SMALL_STACK
md2 = (Md2*)XMALLOC(sizeof(Md2), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (md2 == NULL)
return MEMORY_E;
#endif
InitMd2(md2);
Md2Update(md2, data, len);
Md2Final(md2, hash);
#ifdef CYASSL_SMALL_STACK
XFREE(md2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return 0;
}
#endif /* CYASSL_MD2 */
//#ifdef HAVE_CONFIG_H
// #include <config.h>
//#endif
//
//#include <cyassl/ctaocrypt/settings.h>
//
//#ifdef CYASSL_MD2
//
//#include <cyassl/ctaocrypt/md2.h>
//#include <cyassl/ctaocrypt/error-crypt.h>
//
//#ifdef NO_INLINE
// #include <cyassl/ctaocrypt/misc.h>
//#else
// #include <ctaocrypt/src/misc.c>
//#endif
//
//
//void InitMd2(Md2* md2)
//{
// XMEMSET(md2->X, 0, MD2_X_SIZE);
// XMEMSET(md2->C, 0, MD2_BLOCK_SIZE);
// XMEMSET(md2->buffer, 0, MD2_BLOCK_SIZE);
// md2->count = 0;
//}
//
//
//void Md2Update(Md2* md2, const byte* data, word32 len)
//{
// static const byte S[256] =
// {
// 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
// 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,
// 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,
// 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,
// 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,
// 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,
// 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,
// 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,
// 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,
// 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,
// 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
// 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,
// 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,
// 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,
// 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,
// 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,
// 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,
// 31, 26, 219, 153, 141, 51, 159, 17, 131, 20
// };
//
// while (len) {
// word32 L = (MD2_PAD_SIZE - md2->count) < len ?
// (MD2_PAD_SIZE - md2->count) : len;
// XMEMCPY(md2->buffer + md2->count, data, L);
// md2->count += L;
// data += L;
// len -= L;
//
// if (md2->count == MD2_PAD_SIZE) {
// int i;
// byte t;
//
// md2->count = 0;
// XMEMCPY(md2->X + MD2_PAD_SIZE, md2->buffer, MD2_PAD_SIZE);
// t = md2->C[15];
//
// for(i = 0; i < MD2_PAD_SIZE; i++) {
// md2->X[32 + i] = md2->X[MD2_PAD_SIZE + i] ^ md2->X[i];
// t = md2->C[i] ^= S[md2->buffer[i] ^ t];
// }
//
// t=0;
// for(i = 0; i < 18; i++) {
// int j;
// for(j = 0; j < MD2_X_SIZE; j += 8) {
// t = md2->X[j+0] ^= S[t];
// t = md2->X[j+1] ^= S[t];
// t = md2->X[j+2] ^= S[t];
// t = md2->X[j+3] ^= S[t];
// t = md2->X[j+4] ^= S[t];
// t = md2->X[j+5] ^= S[t];
// t = md2->X[j+6] ^= S[t];
// t = md2->X[j+7] ^= S[t];
// }
// t = (t + i) & 0xFF;
// }
// }
// }
//}
//
//
//void Md2Final(Md2* md2, byte* hash)
//{
// byte padding[MD2_BLOCK_SIZE];
// word32 padLen = MD2_PAD_SIZE - md2->count;
// word32 i;
//
// for (i = 0; i < padLen; i++)
// padding[i] = (byte)padLen;
//
// Md2Update(md2, padding, padLen);
// Md2Update(md2, md2->C, MD2_BLOCK_SIZE);
//
// XMEMCPY(hash, md2->X, MD2_DIGEST_SIZE);
//
// InitMd2(md2);
//}
//
//
//int Md2Hash(const byte* data, word32 len, byte* hash)
//{
//#ifdef CYASSL_SMALL_STACK
// Md2* md2;
//#else
// Md2 md2[1];
//#endif
//
//#ifdef CYASSL_SMALL_STACK
// md2 = (Md2*)XMALLOC(sizeof(Md2), NULL, DYNAMIC_TYPE_TMP_BUFFER);
// if (md2 == NULL)
// return MEMORY_E;
//#endif
//
// InitMd2(md2);
// Md2Update(md2, data, len);
// Md2Final(md2, hash);
//
//#ifdef CYASSL_SMALL_STACK
// XFREE(md2, NULL, DYNAMIC_TYPE_TMP_BUFFER);
//#endif
//
// return 0;
//}
//
//
//#endif /* CYASSL_MD2 */

View File

@ -19,201 +19,201 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#ifndef NO_MD4
#include <cyassl/ctaocrypt/md4.h>
#ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h>
#else
#include <ctaocrypt/src/misc.c>
#endif
#ifndef min
static INLINE word32 min(word32 a, word32 b)
{
return a > b ? b : a;
}
#endif /* min */
void InitMd4(Md4* md4)
{
md4->digest[0] = 0x67452301L;
md4->digest[1] = 0xefcdab89L;
md4->digest[2] = 0x98badcfeL;
md4->digest[3] = 0x10325476L;
md4->buffLen = 0;
md4->loLen = 0;
md4->hiLen = 0;
}
static void Transform(Md4* md4)
{
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
/* Copy context->state[] to working vars */
word32 A = md4->digest[0];
word32 B = md4->digest[1];
word32 C = md4->digest[2];
word32 D = md4->digest[3];
#define function(a,b,c,d,k,s) a=rotlFixed(a+F(b,c,d)+md4->buffer[k],s);
function(A,B,C,D, 0, 3);
function(D,A,B,C, 1, 7);
function(C,D,A,B, 2,11);
function(B,C,D,A, 3,19);
function(A,B,C,D, 4, 3);
function(D,A,B,C, 5, 7);
function(C,D,A,B, 6,11);
function(B,C,D,A, 7,19);
function(A,B,C,D, 8, 3);
function(D,A,B,C, 9, 7);
function(C,D,A,B,10,11);
function(B,C,D,A,11,19);
function(A,B,C,D,12, 3);
function(D,A,B,C,13, 7);
function(C,D,A,B,14,11);
function(B,C,D,A,15,19);
#undef function
#define function(a,b,c,d,k,s) \
a=rotlFixed(a+G(b,c,d)+md4->buffer[k]+0x5a827999,s);
function(A,B,C,D, 0, 3);
function(D,A,B,C, 4, 5);
function(C,D,A,B, 8, 9);
function(B,C,D,A,12,13);
function(A,B,C,D, 1, 3);
function(D,A,B,C, 5, 5);
function(C,D,A,B, 9, 9);
function(B,C,D,A,13,13);
function(A,B,C,D, 2, 3);
function(D,A,B,C, 6, 5);
function(C,D,A,B,10, 9);
function(B,C,D,A,14,13);
function(A,B,C,D, 3, 3);
function(D,A,B,C, 7, 5);
function(C,D,A,B,11, 9);
function(B,C,D,A,15,13);
#undef function
#define function(a,b,c,d,k,s) \
a=rotlFixed(a+H(b,c,d)+md4->buffer[k]+0x6ed9eba1,s);
function(A,B,C,D, 0, 3);
function(D,A,B,C, 8, 9);
function(C,D,A,B, 4,11);
function(B,C,D,A,12,15);
function(A,B,C,D, 2, 3);
function(D,A,B,C,10, 9);
function(C,D,A,B, 6,11);
function(B,C,D,A,14,15);
function(A,B,C,D, 1, 3);
function(D,A,B,C, 9, 9);
function(C,D,A,B, 5,11);
function(B,C,D,A,13,15);
function(A,B,C,D, 3, 3);
function(D,A,B,C,11, 9);
function(C,D,A,B, 7,11);
function(B,C,D,A,15,15);
/* Add the working vars back into digest state[] */
md4->digest[0] += A;
md4->digest[1] += B;
md4->digest[2] += C;
md4->digest[3] += D;
}
static INLINE void AddLength(Md4* md4, word32 len)
{
word32 tmp = md4->loLen;
if ( (md4->loLen += len) < tmp)
md4->hiLen++; /* carry low to high */
}
void Md4Update(Md4* md4, const byte* data, word32 len)
{
/* do block size increments */
byte* local = (byte*)md4->buffer;
while (len) {
word32 add = min(len, MD4_BLOCK_SIZE - md4->buffLen);
XMEMCPY(&local[md4->buffLen], data, add);
md4->buffLen += add;
data += add;
len -= add;
if (md4->buffLen == MD4_BLOCK_SIZE) {
#ifdef BIG_ENDIAN_ORDER
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
#endif
Transform(md4);
AddLength(md4, MD4_BLOCK_SIZE);
md4->buffLen = 0;
}
}
}
void Md4Final(Md4* md4, byte* hash)
{
byte* local = (byte*)md4->buffer;
AddLength(md4, md4->buffLen); /* before adding pads */
local[md4->buffLen++] = 0x80; /* add 1 */
/* pad with zeros */
if (md4->buffLen > MD4_PAD_SIZE) {
XMEMSET(&local[md4->buffLen], 0, MD4_BLOCK_SIZE - md4->buffLen);
md4->buffLen += MD4_BLOCK_SIZE - md4->buffLen;
#ifdef BIG_ENDIAN_ORDER
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
#endif
Transform(md4);
md4->buffLen = 0;
}
XMEMSET(&local[md4->buffLen], 0, MD4_PAD_SIZE - md4->buffLen);
/* put lengths in bits */
md4->hiLen = (md4->loLen >> (8*sizeof(md4->loLen) - 3)) +
(md4->hiLen << 3);
md4->loLen = md4->loLen << 3;
/* store lengths */
#ifdef BIG_ENDIAN_ORDER
ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
#endif
/* ! length ordering dependent on digest endian type ! */
XMEMCPY(&local[MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
XMEMCPY(&local[MD4_PAD_SIZE + sizeof(word32)], &md4->hiLen, sizeof(word32));
Transform(md4);
#ifdef BIG_ENDIAN_ORDER
ByteReverseWords(md4->digest, md4->digest, MD4_DIGEST_SIZE);
#endif
XMEMCPY(hash, md4->digest, MD4_DIGEST_SIZE);
InitMd4(md4); /* reset state */
}
#endif /* NO_MD4 */
//#ifdef HAVE_CONFIG_H
// #include <config.h>
//#endif
//
//#include <cyassl/ctaocrypt/settings.h>
//
//#ifndef NO_MD4
//
//#include <cyassl/ctaocrypt/md4.h>
//#ifdef NO_INLINE
// #include <cyassl/ctaocrypt/misc.h>
//#else
// #include <ctaocrypt/src/misc.c>
//#endif
//
//
//#ifndef min
//
// static INLINE word32 min(word32 a, word32 b)
// {
// return a > b ? b : a;
// }
//
//#endif /* min */
//
//
//void InitMd4(Md4* md4)
//{
// md4->digest[0] = 0x67452301L;
// md4->digest[1] = 0xefcdab89L;
// md4->digest[2] = 0x98badcfeL;
// md4->digest[3] = 0x10325476L;
//
// md4->buffLen = 0;
// md4->loLen = 0;
// md4->hiLen = 0;
//}
//
//
//static void Transform(Md4* md4)
//{
//#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
//#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
//#define H(x, y, z) ((x) ^ (y) ^ (z))
//
// /* Copy context->state[] to working vars */
// word32 A = md4->digest[0];
// word32 B = md4->digest[1];
// word32 C = md4->digest[2];
// word32 D = md4->digest[3];
//
//#define function(a,b,c,d,k,s) a=rotlFixed(a+F(b,c,d)+md4->buffer[k],s);
// function(A,B,C,D, 0, 3);
// function(D,A,B,C, 1, 7);
// function(C,D,A,B, 2,11);
// function(B,C,D,A, 3,19);
// function(A,B,C,D, 4, 3);
// function(D,A,B,C, 5, 7);
// function(C,D,A,B, 6,11);
// function(B,C,D,A, 7,19);
// function(A,B,C,D, 8, 3);
// function(D,A,B,C, 9, 7);
// function(C,D,A,B,10,11);
// function(B,C,D,A,11,19);
// function(A,B,C,D,12, 3);
// function(D,A,B,C,13, 7);
// function(C,D,A,B,14,11);
// function(B,C,D,A,15,19);
//
//#undef function
//#define function(a,b,c,d,k,s) \
// a=rotlFixed(a+G(b,c,d)+md4->buffer[k]+0x5a827999,s);
//
// function(A,B,C,D, 0, 3);
// function(D,A,B,C, 4, 5);
// function(C,D,A,B, 8, 9);
// function(B,C,D,A,12,13);
// function(A,B,C,D, 1, 3);
// function(D,A,B,C, 5, 5);
// function(C,D,A,B, 9, 9);
// function(B,C,D,A,13,13);
// function(A,B,C,D, 2, 3);
// function(D,A,B,C, 6, 5);
// function(C,D,A,B,10, 9);
// function(B,C,D,A,14,13);
// function(A,B,C,D, 3, 3);
// function(D,A,B,C, 7, 5);
// function(C,D,A,B,11, 9);
// function(B,C,D,A,15,13);
//
//#undef function
//#define function(a,b,c,d,k,s) \
// a=rotlFixed(a+H(b,c,d)+md4->buffer[k]+0x6ed9eba1,s);
//
// function(A,B,C,D, 0, 3);
// function(D,A,B,C, 8, 9);
// function(C,D,A,B, 4,11);
// function(B,C,D,A,12,15);
// function(A,B,C,D, 2, 3);
// function(D,A,B,C,10, 9);
// function(C,D,A,B, 6,11);
// function(B,C,D,A,14,15);
// function(A,B,C,D, 1, 3);
// function(D,A,B,C, 9, 9);
// function(C,D,A,B, 5,11);
// function(B,C,D,A,13,15);
// function(A,B,C,D, 3, 3);
// function(D,A,B,C,11, 9);
// function(C,D,A,B, 7,11);
// function(B,C,D,A,15,15);
//
// /* Add the working vars back into digest state[] */
// md4->digest[0] += A;
// md4->digest[1] += B;
// md4->digest[2] += C;
// md4->digest[3] += D;
//}
//
//
//static INLINE void AddLength(Md4* md4, word32 len)
//{
// word32 tmp = md4->loLen;
// if ( (md4->loLen += len) < tmp)
// md4->hiLen++; /* carry low to high */
//}
//
//
//void Md4Update(Md4* md4, const byte* data, word32 len)
//{
// /* do block size increments */
// byte* local = (byte*)md4->buffer;
//
// while (len) {
// word32 add = min(len, MD4_BLOCK_SIZE - md4->buffLen);
// XMEMCPY(&local[md4->buffLen], data, add);
//
// md4->buffLen += add;
// data += add;
// len -= add;
//
// if (md4->buffLen == MD4_BLOCK_SIZE) {
// #ifdef BIG_ENDIAN_ORDER
// ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
// #endif
// Transform(md4);
// AddLength(md4, MD4_BLOCK_SIZE);
// md4->buffLen = 0;
// }
// }
//}
//
//
//void Md4Final(Md4* md4, byte* hash)
//{
// byte* local = (byte*)md4->buffer;
//
// AddLength(md4, md4->buffLen); /* before adding pads */
//
// local[md4->buffLen++] = 0x80; /* add 1 */
//
// /* pad with zeros */
// if (md4->buffLen > MD4_PAD_SIZE) {
// XMEMSET(&local[md4->buffLen], 0, MD4_BLOCK_SIZE - md4->buffLen);
// md4->buffLen += MD4_BLOCK_SIZE - md4->buffLen;
//
// #ifdef BIG_ENDIAN_ORDER
// ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
// #endif
// Transform(md4);
// md4->buffLen = 0;
// }
// XMEMSET(&local[md4->buffLen], 0, MD4_PAD_SIZE - md4->buffLen);
//
// /* put lengths in bits */
// md4->hiLen = (md4->loLen >> (8*sizeof(md4->loLen) - 3)) +
// (md4->hiLen << 3);
// md4->loLen = md4->loLen << 3;
//
// /* store lengths */
// #ifdef BIG_ENDIAN_ORDER
// ByteReverseWords(md4->buffer, md4->buffer, MD4_BLOCK_SIZE);
// #endif
// /* ! length ordering dependent on digest endian type ! */
// XMEMCPY(&local[MD4_PAD_SIZE], &md4->loLen, sizeof(word32));
// XMEMCPY(&local[MD4_PAD_SIZE + sizeof(word32)], &md4->hiLen, sizeof(word32));
//
// Transform(md4);
// #ifdef BIG_ENDIAN_ORDER
// ByteReverseWords(md4->digest, md4->digest, MD4_DIGEST_SIZE);
// #endif
// XMEMCPY(hash, md4->digest, MD4_DIGEST_SIZE);
//
// InitMd4(md4); /* reset state */
//}
//
//
//#endif /* NO_MD4 */
//

View File

@ -20,372 +20,372 @@
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#if !defined(NO_MD5)
#ifdef CYASSL_PIC32MZ_HASH
#define InitMd5 InitMd5_sw
#define Md5Update Md5Update_sw
#define Md5Final Md5Final_sw
#endif
#include <cyassl/ctaocrypt/md5.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h>
#else
#include <ctaocrypt/src/misc.c>
#endif
#ifdef FREESCALE_MMCAU
#include "cau_api.h"
#define XTRANSFORM(S,B) cau_md5_hash_n((B), 1, (unsigned char*)(S)->digest)
#else
#define XTRANSFORM(S,B) Transform((S))
#endif
#ifdef STM32F2_HASH
/*
* STM32F2 hardware MD5 support through the STM32F2 standard peripheral
* library. Documentation located in STM32F2xx Standard Peripheral Library
* document (See note in README).
*/
#include "stm32f2xx.h"
void InitMd5(Md5* md5)
{
/* STM32F2 struct notes:
* md5->buffer = first 4 bytes used to hold partial block if needed
* md5->buffLen = num bytes currently stored in md5->buffer
* md5->loLen = num bytes that have been written to STM32 FIFO
*/
XMEMSET(md5->buffer, 0, MD5_REG_SIZE);
md5->buffLen = 0;
md5->loLen = 0;
/* initialize HASH peripheral */
HASH_DeInit();
/* configure algo used, algo mode, datatype */
HASH->CR &= ~ (HASH_CR_ALGO | HASH_CR_DATATYPE | HASH_CR_MODE);
HASH->CR |= (HASH_AlgoSelection_MD5 | HASH_AlgoMode_HASH
| HASH_DataType_8b);
/* reset HASH processor */
HASH->CR |= HASH_CR_INIT;
}
void Md5Update(Md5* md5, const byte* data, word32 len)
{
word32 i = 0;
word32 fill = 0;
word32 diff = 0;
/* if saved partial block is available */
if (md5->buffLen > 0) {
fill = 4 - md5->buffLen;
/* if enough data to fill, fill and push to FIFO */
if (fill <= len) {
XMEMCPY((byte*)md5->buffer + md5->buffLen, data, fill);
HASH_DataIn(*(uint32_t*)md5->buffer);
data += fill;
len -= fill;
md5->loLen += 4;
md5->buffLen = 0;
} else {
/* append partial to existing stored block */
XMEMCPY((byte*)md5->buffer + md5->buffLen, data, len);
md5->buffLen += len;
return;
}
}
/* write input block in the IN FIFO */
for (i = 0; i < len; i += 4)
{
diff = len - i;
if (diff < 4) {
/* store incomplete last block, not yet in FIFO */
XMEMSET(md5->buffer, 0, MD5_REG_SIZE);
XMEMCPY((byte*)md5->buffer, data, diff);
md5->buffLen = diff;
} else {
HASH_DataIn(*(uint32_t*)data);
data+=4;
}
}
/* keep track of total data length thus far */
md5->loLen += (len - md5->buffLen);
}
void Md5Final(Md5* md5, byte* hash)
{
__IO uint16_t nbvalidbitsdata = 0;
/* finish reading any trailing bytes into FIFO */
if (md5->buffLen > 0) {
HASH_DataIn(*(uint32_t*)md5->buffer);
md5->loLen += md5->buffLen;
}
/* calculate number of valid bits in last word of input data */
nbvalidbitsdata = 8 * (md5->loLen % MD5_REG_SIZE);
/* configure number of valid bits in last word of the data */
HASH_SetLastWordValidBitsNbr(nbvalidbitsdata);
/* start HASH processor */
HASH_StartDigest();
/* wait until Busy flag == RESET */
while (HASH_GetFlagStatus(HASH_FLAG_BUSY) != RESET) {}
/* read message digest */
md5->digest[0] = HASH->HR[0];
md5->digest[1] = HASH->HR[1];
md5->digest[2] = HASH->HR[2];
md5->digest[3] = HASH->HR[3];
ByteReverseWords(md5->digest, md5->digest, MD5_DIGEST_SIZE);
XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE);
InitMd5(md5); /* reset state */
}
#else /* CTaoCrypt software implementation */
#ifndef min
static INLINE word32 min(word32 a, word32 b)
{
return a > b ? b : a;
}
#endif /* min */
void InitMd5(Md5* md5)
{
md5->digest[0] = 0x67452301L;
md5->digest[1] = 0xefcdab89L;
md5->digest[2] = 0x98badcfeL;
md5->digest[3] = 0x10325476L;
md5->buffLen = 0;
md5->loLen = 0;
md5->hiLen = 0;
}
#ifndef FREESCALE_MMCAU
static void Transform(Md5* md5)
{
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s) \
w = rotlFixed(w + f(x, y, z) + data, s) + x
/* Copy context->state[] to working vars */
word32 a = md5->digest[0];
word32 b = md5->digest[1];
word32 c = md5->digest[2];
word32 d = md5->digest[3];
MD5STEP(F1, a, b, c, d, md5->buffer[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, md5->buffer[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, md5->buffer[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, md5->buffer[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, md5->buffer[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, md5->buffer[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, md5->buffer[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, md5->buffer[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, md5->buffer[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, md5->buffer[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, md5->buffer[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, md5->buffer[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, md5->buffer[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, md5->buffer[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, md5->buffer[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, md5->buffer[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, md5->buffer[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, md5->buffer[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, md5->buffer[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, md5->buffer[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, md5->buffer[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, md5->buffer[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, md5->buffer[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, md5->buffer[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, md5->buffer[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, md5->buffer[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, md5->buffer[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, md5->buffer[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, md5->buffer[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, md5->buffer[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, md5->buffer[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, md5->buffer[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, md5->buffer[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, md5->buffer[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, md5->buffer[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, md5->buffer[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, md5->buffer[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, md5->buffer[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, md5->buffer[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, md5->buffer[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, md5->buffer[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, md5->buffer[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, md5->buffer[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, md5->buffer[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, md5->buffer[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, md5->buffer[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, md5->buffer[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, md5->buffer[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, md5->buffer[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, md5->buffer[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, md5->buffer[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, md5->buffer[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, md5->buffer[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, md5->buffer[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, md5->buffer[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, md5->buffer[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, md5->buffer[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, md5->buffer[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, md5->buffer[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, md5->buffer[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, md5->buffer[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, md5->buffer[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, md5->buffer[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, md5->buffer[9] + 0xeb86d391, 21);
/* Add the working vars back into digest state[] */
md5->digest[0] += a;
md5->digest[1] += b;
md5->digest[2] += c;
md5->digest[3] += d;
}
#endif /* FREESCALE_MMCAU */
static INLINE void AddLength(Md5* md5, word32 len)
{
word32 tmp = md5->loLen;
if ( (md5->loLen += len) < tmp)
md5->hiLen++; /* carry low to high */
}
void Md5Update(Md5* md5, const byte* data, word32 len)
{
/* do block size increments */
byte* local = (byte*)md5->buffer;
while (len) {
word32 add = min(len, MD5_BLOCK_SIZE - md5->buffLen);
XMEMCPY(&local[md5->buffLen], data, add);
md5->buffLen += add;
data += add;
len -= add;
if (md5->buffLen == MD5_BLOCK_SIZE) {
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
#endif
XTRANSFORM(md5, local);
AddLength(md5, MD5_BLOCK_SIZE);
md5->buffLen = 0;
}
}
}
void Md5Final(Md5* md5, byte* hash)
{
byte* local = (byte*)md5->buffer;
AddLength(md5, md5->buffLen); /* before adding pads */
local[md5->buffLen++] = 0x80; /* add 1 */
/* pad with zeros */
if (md5->buffLen > MD5_PAD_SIZE) {
XMEMSET(&local[md5->buffLen], 0, MD5_BLOCK_SIZE - md5->buffLen);
md5->buffLen += MD5_BLOCK_SIZE - md5->buffLen;
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
#endif
XTRANSFORM(md5, local);
md5->buffLen = 0;
}
XMEMSET(&local[md5->buffLen], 0, MD5_PAD_SIZE - md5->buffLen);
/* put lengths in bits */
md5->hiLen = (md5->loLen >> (8*sizeof(md5->loLen) - 3)) +
(md5->hiLen << 3);
md5->loLen = md5->loLen << 3;
/* store lengths */
#if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
#endif
/* ! length ordering dependent on digest endian type ! */
XMEMCPY(&local[MD5_PAD_SIZE], &md5->loLen, sizeof(word32));
XMEMCPY(&local[MD5_PAD_SIZE + sizeof(word32)], &md5->hiLen, sizeof(word32));
XTRANSFORM(md5, local);
#ifdef BIG_ENDIAN_ORDER
ByteReverseWords(md5->digest, md5->digest, MD5_DIGEST_SIZE);
#endif
XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE);
InitMd5(md5); /* reset state */
}
#endif /* STM32F2_HASH */
int Md5Hash(const byte* data, word32 len, byte* hash)
{
#ifdef CYASSL_SMALL_STACK
Md5* md5;
#else
Md5 md5[1];
#endif
#ifdef CYASSL_SMALL_STACK
md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (md5 == NULL)
return MEMORY_E;
#endif
InitMd5(md5);
Md5Update(md5, data, len);
Md5Final(md5, hash);
#ifdef CYASSL_SMALL_STACK
XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif
return 0;
}
#endif /* NO_MD5 */
//#ifdef HAVE_CONFIG_H
// #include <config.h>
//#endif
//
//#include <cyassl/ctaocrypt/settings.h>
//
//#if !defined(NO_MD5)
//
//#ifdef CYASSL_PIC32MZ_HASH
//#define InitMd5 InitMd5_sw
//#define Md5Update Md5Update_sw
//#define Md5Final Md5Final_sw
//#endif
//
//#include <cyassl/ctaocrypt/md5.h>
//#include <cyassl/ctaocrypt/error-crypt.h>
//
//#ifdef NO_INLINE
// #include <cyassl/ctaocrypt/misc.h>
//#else
// #include <ctaocrypt/src/misc.c>
//#endif
//
//#ifdef FREESCALE_MMCAU
// #include "cau_api.h"
// #define XTRANSFORM(S,B) cau_md5_hash_n((B), 1, (unsigned char*)(S)->digest)
//#else
// #define XTRANSFORM(S,B) Transform((S))
//#endif
//
//
//#ifdef STM32F2_HASH
// /*
// * STM32F2 hardware MD5 support through the STM32F2 standard peripheral
// * library. Documentation located in STM32F2xx Standard Peripheral Library
// * document (See note in README).
// */
// #include "stm32f2xx.h"
//
// void InitMd5(Md5* md5)
// {
// /* STM32F2 struct notes:
// * md5->buffer = first 4 bytes used to hold partial block if needed
// * md5->buffLen = num bytes currently stored in md5->buffer
// * md5->loLen = num bytes that have been written to STM32 FIFO
// */
// XMEMSET(md5->buffer, 0, MD5_REG_SIZE);
//
// md5->buffLen = 0;
// md5->loLen = 0;
//
// /* initialize HASH peripheral */
// HASH_DeInit();
//
// /* configure algo used, algo mode, datatype */
// HASH->CR &= ~ (HASH_CR_ALGO | HASH_CR_DATATYPE | HASH_CR_MODE);
// HASH->CR |= (HASH_AlgoSelection_MD5 | HASH_AlgoMode_HASH
// | HASH_DataType_8b);
//
// /* reset HASH processor */
// HASH->CR |= HASH_CR_INIT;
// }
//
// void Md5Update(Md5* md5, const byte* data, word32 len)
// {
// word32 i = 0;
// word32 fill = 0;
// word32 diff = 0;
//
// /* if saved partial block is available */
// if (md5->buffLen > 0) {
// fill = 4 - md5->buffLen;
//
// /* if enough data to fill, fill and push to FIFO */
// if (fill <= len) {
// XMEMCPY((byte*)md5->buffer + md5->buffLen, data, fill);
// HASH_DataIn(*(uint32_t*)md5->buffer);
//
// data += fill;
// len -= fill;
// md5->loLen += 4;
// md5->buffLen = 0;
// } else {
// /* append partial to existing stored block */
// XMEMCPY((byte*)md5->buffer + md5->buffLen, data, len);
// md5->buffLen += len;
// return;
// }
// }
//
// /* write input block in the IN FIFO */
// for (i = 0; i < len; i += 4)
// {
// diff = len - i;
// if (diff < 4) {
// /* store incomplete last block, not yet in FIFO */
// XMEMSET(md5->buffer, 0, MD5_REG_SIZE);
// XMEMCPY((byte*)md5->buffer, data, diff);
// md5->buffLen = diff;
// } else {
// HASH_DataIn(*(uint32_t*)data);
// data+=4;
// }
// }
//
// /* keep track of total data length thus far */
// md5->loLen += (len - md5->buffLen);
// }
//
// void Md5Final(Md5* md5, byte* hash)
// {
// __IO uint16_t nbvalidbitsdata = 0;
//
// /* finish reading any trailing bytes into FIFO */
// if (md5->buffLen > 0) {
// HASH_DataIn(*(uint32_t*)md5->buffer);
// md5->loLen += md5->buffLen;
// }
//
// /* calculate number of valid bits in last word of input data */
// nbvalidbitsdata = 8 * (md5->loLen % MD5_REG_SIZE);
//
// /* configure number of valid bits in last word of the data */
// HASH_SetLastWordValidBitsNbr(nbvalidbitsdata);
//
// /* start HASH processor */
// HASH_StartDigest();
//
// /* wait until Busy flag == RESET */
// while (HASH_GetFlagStatus(HASH_FLAG_BUSY) != RESET) {}
//
// /* read message digest */
// md5->digest[0] = HASH->HR[0];
// md5->digest[1] = HASH->HR[1];
// md5->digest[2] = HASH->HR[2];
// md5->digest[3] = HASH->HR[3];
//
// ByteReverseWords(md5->digest, md5->digest, MD5_DIGEST_SIZE);
//
// XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE);
//
// InitMd5(md5); /* reset state */
// }
//
//#else /* CTaoCrypt software implementation */
//
//#ifndef min
//
// static INLINE word32 min(word32 a, word32 b)
// {
// return a > b ? b : a;
// }
//
//#endif /* min */
//
//
//void InitMd5(Md5* md5)
//{
// md5->digest[0] = 0x67452301L;
// md5->digest[1] = 0xefcdab89L;
// md5->digest[2] = 0x98badcfeL;
// md5->digest[3] = 0x10325476L;
//
// md5->buffLen = 0;
// md5->loLen = 0;
// md5->hiLen = 0;
//}
//
//#ifndef FREESCALE_MMCAU
//
//static void Transform(Md5* md5)
//{
//#define F1(x, y, z) (z ^ (x & (y ^ z)))
//#define F2(x, y, z) F1(z, x, y)
//#define F3(x, y, z) (x ^ y ^ z)
//#define F4(x, y, z) (y ^ (x | ~z))
//
//#define MD5STEP(f, w, x, y, z, data, s) \
// w = rotlFixed(w + f(x, y, z) + data, s) + x
//
// /* Copy context->state[] to working vars */
// word32 a = md5->digest[0];
// word32 b = md5->digest[1];
// word32 c = md5->digest[2];
// word32 d = md5->digest[3];
//
// MD5STEP(F1, a, b, c, d, md5->buffer[0] + 0xd76aa478, 7);
// MD5STEP(F1, d, a, b, c, md5->buffer[1] + 0xe8c7b756, 12);
// MD5STEP(F1, c, d, a, b, md5->buffer[2] + 0x242070db, 17);
// MD5STEP(F1, b, c, d, a, md5->buffer[3] + 0xc1bdceee, 22);
// MD5STEP(F1, a, b, c, d, md5->buffer[4] + 0xf57c0faf, 7);
// MD5STEP(F1, d, a, b, c, md5->buffer[5] + 0x4787c62a, 12);
// MD5STEP(F1, c, d, a, b, md5->buffer[6] + 0xa8304613, 17);
// MD5STEP(F1, b, c, d, a, md5->buffer[7] + 0xfd469501, 22);
// MD5STEP(F1, a, b, c, d, md5->buffer[8] + 0x698098d8, 7);
// MD5STEP(F1, d, a, b, c, md5->buffer[9] + 0x8b44f7af, 12);
// MD5STEP(F1, c, d, a, b, md5->buffer[10] + 0xffff5bb1, 17);
// MD5STEP(F1, b, c, d, a, md5->buffer[11] + 0x895cd7be, 22);
// MD5STEP(F1, a, b, c, d, md5->buffer[12] + 0x6b901122, 7);
// MD5STEP(F1, d, a, b, c, md5->buffer[13] + 0xfd987193, 12);
// MD5STEP(F1, c, d, a, b, md5->buffer[14] + 0xa679438e, 17);
// MD5STEP(F1, b, c, d, a, md5->buffer[15] + 0x49b40821, 22);
//
// MD5STEP(F2, a, b, c, d, md5->buffer[1] + 0xf61e2562, 5);
// MD5STEP(F2, d, a, b, c, md5->buffer[6] + 0xc040b340, 9);
// MD5STEP(F2, c, d, a, b, md5->buffer[11] + 0x265e5a51, 14);
// MD5STEP(F2, b, c, d, a, md5->buffer[0] + 0xe9b6c7aa, 20);
// MD5STEP(F2, a, b, c, d, md5->buffer[5] + 0xd62f105d, 5);
// MD5STEP(F2, d, a, b, c, md5->buffer[10] + 0x02441453, 9);
// MD5STEP(F2, c, d, a, b, md5->buffer[15] + 0xd8a1e681, 14);
// MD5STEP(F2, b, c, d, a, md5->buffer[4] + 0xe7d3fbc8, 20);
// MD5STEP(F2, a, b, c, d, md5->buffer[9] + 0x21e1cde6, 5);
// MD5STEP(F2, d, a, b, c, md5->buffer[14] + 0xc33707d6, 9);
// MD5STEP(F2, c, d, a, b, md5->buffer[3] + 0xf4d50d87, 14);
// MD5STEP(F2, b, c, d, a, md5->buffer[8] + 0x455a14ed, 20);
// MD5STEP(F2, a, b, c, d, md5->buffer[13] + 0xa9e3e905, 5);
// MD5STEP(F2, d, a, b, c, md5->buffer[2] + 0xfcefa3f8, 9);
// MD5STEP(F2, c, d, a, b, md5->buffer[7] + 0x676f02d9, 14);
// MD5STEP(F2, b, c, d, a, md5->buffer[12] + 0x8d2a4c8a, 20);
//
// MD5STEP(F3, a, b, c, d, md5->buffer[5] + 0xfffa3942, 4);
// MD5STEP(F3, d, a, b, c, md5->buffer[8] + 0x8771f681, 11);
// MD5STEP(F3, c, d, a, b, md5->buffer[11] + 0x6d9d6122, 16);
// MD5STEP(F3, b, c, d, a, md5->buffer[14] + 0xfde5380c, 23);
// MD5STEP(F3, a, b, c, d, md5->buffer[1] + 0xa4beea44, 4);
// MD5STEP(F3, d, a, b, c, md5->buffer[4] + 0x4bdecfa9, 11);
// MD5STEP(F3, c, d, a, b, md5->buffer[7] + 0xf6bb4b60, 16);
// MD5STEP(F3, b, c, d, a, md5->buffer[10] + 0xbebfbc70, 23);
// MD5STEP(F3, a, b, c, d, md5->buffer[13] + 0x289b7ec6, 4);
// MD5STEP(F3, d, a, b, c, md5->buffer[0] + 0xeaa127fa, 11);
// MD5STEP(F3, c, d, a, b, md5->buffer[3] + 0xd4ef3085, 16);
// MD5STEP(F3, b, c, d, a, md5->buffer[6] + 0x04881d05, 23);
// MD5STEP(F3, a, b, c, d, md5->buffer[9] + 0xd9d4d039, 4);
// MD5STEP(F3, d, a, b, c, md5->buffer[12] + 0xe6db99e5, 11);
// MD5STEP(F3, c, d, a, b, md5->buffer[15] + 0x1fa27cf8, 16);
// MD5STEP(F3, b, c, d, a, md5->buffer[2] + 0xc4ac5665, 23);
//
// MD5STEP(F4, a, b, c, d, md5->buffer[0] + 0xf4292244, 6);
// MD5STEP(F4, d, a, b, c, md5->buffer[7] + 0x432aff97, 10);
// MD5STEP(F4, c, d, a, b, md5->buffer[14] + 0xab9423a7, 15);
// MD5STEP(F4, b, c, d, a, md5->buffer[5] + 0xfc93a039, 21);
// MD5STEP(F4, a, b, c, d, md5->buffer[12] + 0x655b59c3, 6);
// MD5STEP(F4, d, a, b, c, md5->buffer[3] + 0x8f0ccc92, 10);
// MD5STEP(F4, c, d, a, b, md5->buffer[10] + 0xffeff47d, 15);
// MD5STEP(F4, b, c, d, a, md5->buffer[1] + 0x85845dd1, 21);
// MD5STEP(F4, a, b, c, d, md5->buffer[8] + 0x6fa87e4f, 6);
// MD5STEP(F4, d, a, b, c, md5->buffer[15] + 0xfe2ce6e0, 10);
// MD5STEP(F4, c, d, a, b, md5->buffer[6] + 0xa3014314, 15);
// MD5STEP(F4, b, c, d, a, md5->buffer[13] + 0x4e0811a1, 21);
// MD5STEP(F4, a, b, c, d, md5->buffer[4] + 0xf7537e82, 6);
// MD5STEP(F4, d, a, b, c, md5->buffer[11] + 0xbd3af235, 10);
// MD5STEP(F4, c, d, a, b, md5->buffer[2] + 0x2ad7d2bb, 15);
// MD5STEP(F4, b, c, d, a, md5->buffer[9] + 0xeb86d391, 21);
//
// /* Add the working vars back into digest state[] */
// md5->digest[0] += a;
// md5->digest[1] += b;
// md5->digest[2] += c;
// md5->digest[3] += d;
//}
//
//#endif /* FREESCALE_MMCAU */
//
//
//static INLINE void AddLength(Md5* md5, word32 len)
//{
// word32 tmp = md5->loLen;
// if ( (md5->loLen += len) < tmp)
// md5->hiLen++; /* carry low to high */
//}
//
//
//void Md5Update(Md5* md5, const byte* data, word32 len)
//{
// /* do block size increments */
// byte* local = (byte*)md5->buffer;
//
// while (len) {
// word32 add = min(len, MD5_BLOCK_SIZE - md5->buffLen);
// XMEMCPY(&local[md5->buffLen], data, add);
//
// md5->buffLen += add;
// data += add;
// len -= add;
//
// if (md5->buffLen == MD5_BLOCK_SIZE) {
// #if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
// ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
// #endif
// XTRANSFORM(md5, local);
// AddLength(md5, MD5_BLOCK_SIZE);
// md5->buffLen = 0;
// }
// }
//}
//
//
//void Md5Final(Md5* md5, byte* hash)
//{
// byte* local = (byte*)md5->buffer;
//
// AddLength(md5, md5->buffLen); /* before adding pads */
//
// local[md5->buffLen++] = 0x80; /* add 1 */
//
// /* pad with zeros */
// if (md5->buffLen > MD5_PAD_SIZE) {
// XMEMSET(&local[md5->buffLen], 0, MD5_BLOCK_SIZE - md5->buffLen);
// md5->buffLen += MD5_BLOCK_SIZE - md5->buffLen;
//
// #if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
// ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
// #endif
// XTRANSFORM(md5, local);
// md5->buffLen = 0;
// }
// XMEMSET(&local[md5->buffLen], 0, MD5_PAD_SIZE - md5->buffLen);
//
// /* put lengths in bits */
// md5->hiLen = (md5->loLen >> (8*sizeof(md5->loLen) - 3)) +
// (md5->hiLen << 3);
// md5->loLen = md5->loLen << 3;
//
// /* store lengths */
// #if defined(BIG_ENDIAN_ORDER) && !defined(FREESCALE_MMCAU)
// ByteReverseWords(md5->buffer, md5->buffer, MD5_BLOCK_SIZE);
// #endif
// /* ! length ordering dependent on digest endian type ! */
// XMEMCPY(&local[MD5_PAD_SIZE], &md5->loLen, sizeof(word32));
// XMEMCPY(&local[MD5_PAD_SIZE + sizeof(word32)], &md5->hiLen, sizeof(word32));
//
// XTRANSFORM(md5, local);
// #ifdef BIG_ENDIAN_ORDER
// ByteReverseWords(md5->digest, md5->digest, MD5_DIGEST_SIZE);
// #endif
// XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE);
//
// InitMd5(md5); /* reset state */
//}
//
//#endif /* STM32F2_HASH */
//
//
//int Md5Hash(const byte* data, word32 len, byte* hash)
//{
//#ifdef CYASSL_SMALL_STACK
// Md5* md5;
//#else
// Md5 md5[1];
//#endif
//
//#ifdef CYASSL_SMALL_STACK
// md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
// if (md5 == NULL)
// return MEMORY_E;
//#endif
//
// InitMd5(md5);
// Md5Update(md5, data, len);
// Md5Final(md5, hash);
//
//#ifdef CYASSL_SMALL_STACK
// XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
//#endif
//
// return 0;
//}
//
//#endif /* NO_MD5 */

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,7 @@
/* Begin PBXFileReference section */
52397C5C17E0E63200517C9A /* port.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = port.c; path = ctaocrypt/src/port.c; sourceTree = SOURCE_ROOT; };
52B1344D16F3C9E800C07B32 /* libcyassl-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libcyassl-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; };
52B1344D16F3C9E800C07B32 /* libwolfssl-ios.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libwolfssl-ios.a"; sourceTree = BUILT_PRODUCTS_DIR; };
52B1347B16F3CCC400C07B32 /* tls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tls.c; path = src/tls.c; sourceTree = SOURCE_ROOT; };
52B1347C16F3CCC400C07B32 /* ssl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ssl.c; path = src/ssl.c; sourceTree = SOURCE_ROOT; };
52B1347D16F3CCC400C07B32 /* ocsp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ocsp.c; path = src/ocsp.c; sourceTree = SOURCE_ROOT; };
@ -115,7 +115,7 @@
52B1344E16F3C9E800C07B32 /* Products */ = {
isa = PBXGroup;
children = (
52B1344D16F3C9E800C07B32 /* libcyassl-ios.a */,
52B1344D16F3C9E800C07B32 /* libwolfssl-ios.a */,
);
name = Products;
sourceTree = "<group>";
@ -195,7 +195,7 @@
);
name = "cyassl-ios";
productName = "cyassl-ios";
productReference = 52B1344D16F3C9E800C07B32 /* libcyassl-ios.a */;
productReference = 52B1344D16F3C9E800C07B32 /* libwolfssl-ios.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */

View File

@ -98,7 +98,7 @@
43CB530D116E9FD5000A264B /* iphone-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "iphone-Info.plist"; sourceTree = "<group>"; };
43D565640F1EC9A600550C88 /* hc128.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; name = hc128.c; path = ctaocrypt/src/hc128.c; sourceTree = "<group>"; };
43D565660F1EC9CC00550C88 /* rabbit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; name = rabbit.c; path = ctaocrypt/src/rabbit.c; sourceTree = "<group>"; };
D2AAC046055464E500DB518D /* libcyassl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcyassl.a; sourceTree = BUILT_PRODUCTS_DIR; };
D2AAC046055464E500DB518D /* libwolfssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libwolfssl.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -135,7 +135,7 @@
1AB674ADFE9D54B511CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
D2AAC046055464E500DB518D /* libcyassl.a */,
D2AAC046055464E500DB518D /* libwolfssl.a */,
);
name = Products;
sourceTree = "<group>";
@ -220,7 +220,7 @@
);
name = cyassl;
productName = cyassl;
productReference = D2AAC046055464E500DB518D /* libcyassl.a */;
productReference = D2AAC046055464E500DB518D /* libwolfssl.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */

View File

@ -24,4 +24,15 @@
#include <wolfssl/wolfcrypt/arc4.h>
/* for arc4 reverse compatibility */
#ifndef NO_RC4
#include <wolfssl/wolfcrypt/arc4.h>
#define CYASSL_ARC4_CAVIUM_MAGIC WOLFSSL_ARC4_CAVIUM_MAGIC
#define Arc4Process wc_Arc4Process
#define Arc4SetKey wc_Arc4SetKey
#define Arc4InitCavium wc_Arc4InitCavium
#define Arc4FreeCavium wc_Arc4FreeCavium
#endif
#endif /* CTAO_CRYPT_ARC4_H */

View File

@ -25,34 +25,13 @@
#ifndef CTAOCRYPT_BLAKE2_H
#define CTAOCRYPT_BLAKE2_H
#include <cyassl/ctaocrypt/blake2-int.h>
#include <wolfssl/wolfcrypt/blake2.h>
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes, variable digest size up to 512 bits (64 bytes) */
enum {
BLAKE2B_ID = 7, /* hash type unique */
BLAKE2B_256 = 32 /* 256 bit type, SSL default */
};
/* BLAKE2b digest */
typedef struct Blake2b {
blake2b_state S[1]; /* our state */
word32 digestSz; /* digest size used on init */
} Blake2b;
CYASSL_API int InitBlake2b(Blake2b*, word32);
CYASSL_API int Blake2bUpdate(Blake2b*, const byte*, word32);
CYASSL_API int Blake2bFinal(Blake2b*, byte*, word32);
#ifdef __cplusplus
}
/* for blake2 reverse compatibility */
#ifdef HAVE_BLAKE2
#define InitBlake2b wc_InitBlake2b
#define Blake2bUpdate wc_Blake2bUpdate
#define Blake2bFinal wc_Blake2bFinal
#endif
#endif /* CTAOCRYPT_BLAKE2_H */

View File

@ -24,4 +24,15 @@
#include <wolfssl/wolfcrypt/camellia.h>
/* for blake2 reverse compatibility */
#ifdef HAVE_CAMELLIA
#define CamelliaSetKey wc_CamelliaSetKey
#define CamelliaSetIV wc_CamelliaSetIV
#define CamelliaEncryptDirect wc_CamelliaEncryptDirect
#define CamelliaDecryptDirect wc_CamelliaDecryptDirect
#define CamelliaCbcEncrypt wc_CamelliaCbcEncrypt
#define CamelliaCbcDecrypt wc_CamelliaCbcDecrypt
#endif
#endif /* CTAO_CRYPT_CAMELLIA_H */

View File

@ -22,34 +22,12 @@
#ifndef CTAO_CRYPT_CHACHA_H
#define CTAO_CRYPT_CHACHA_H
#include "types.h"
#include <wolfssl/wolfcrypt/chacha.h>
#ifdef __cplusplus
extern "C" {
#endif
/* for chacha reverse compatibility */
#define Chacha_Process wc_Chacha_Process
#define Chacha_SetKey wc_Chacha_SetKey
#define Chacha_SetIV wc_Chacha_SetIV
enum {
CHACHA_ENC_TYPE = 7 /* cipher unique type */
};
typedef struct ChaCha {
word32 X[16]; /* state of cipher */
} ChaCha;
CYASSL_API int Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain,
word32 msglen);
CYASSL_API int Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz);
/**
* IV(nonce) changes with each record
* counter is for what value the block counter should start ... usually 0
*/
CYASSL_API int Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif
#endif /* CTAO_CRYPT_CHACHA_H */

View File

@ -25,27 +25,32 @@
#ifndef CTAO_CRYPT_COMPRESS_H
#define CTAO_CRYPT_COMPRESS_H
#include <wolfssl/wolfcrypt/compress.h>
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#define COMPRESS_FIXED 1
CYASSL_API int Compress(byte*, word32, const byte*, word32, word32);
CYASSL_API int DeCompress(byte*, word32, const byte*, word32);
#ifdef __cplusplus
} /* extern "C" */
#endif
/* reverse compatibility */
#define Compress wc_Compress
#define DeCompress wc_DeCompress
//#include <cyassl/ctaocrypt/types.h>
//
//
//#ifdef __cplusplus
// extern "C" {
//#endif
//
//
//#define COMPRESS_FIXED 1
//
//
//CYASSL_API int Compress(byte*, word32, const byte*, word32, word32);
//CYASSL_API int DeCompress(byte*, word32, const byte*, word32);
//
//
//#ifdef __cplusplus
// } /* extern "C" */
//#endif
//
//
#endif /* CTAO_CRYPT_COMPRESS_H */
#endif /* HAVE_LIBZ */

View File

@ -25,41 +25,52 @@
#ifndef CTAO_CRYPT_DH_H
#define CTAO_CRYPT_DH_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/integer.h>
#include <cyassl/ctaocrypt/random.h>
#include <wolfssl/wolfcrypt/dh.h>
#ifdef __cplusplus
extern "C" {
#endif
/* for dh reverse compatibility */
#define InitDhKey wc_InitDhKey
#define FreeDhKey wc_FreeDhKey
#define DhGenerateKeyPair wc_DhGenerateKeyPair
#define DhAgree wc_DhAgree
#define DhKeyDecode wc_DhKeyDecode
#define DhSetKey wc_DhSetKey
#define DhParamsLoad wc_DhParamsLoad
/* Diffie-Hellman Key */
typedef struct DhKey {
mp_int p, g; /* group parameters */
} DhKey;
CYASSL_API void InitDhKey(DhKey* key);
CYASSL_API void FreeDhKey(DhKey* key);
CYASSL_API int DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv,
word32* privSz, byte* pub, word32* pubSz);
CYASSL_API int DhAgree(DhKey* key, byte* agree, word32* agreeSz,
const byte* priv, word32 privSz, const byte* otherPub,
word32 pubSz);
CYASSL_API int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
word32);
CYASSL_API int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
word32 gSz);
CYASSL_API int DhParamsLoad(const byte* input, word32 inSz, byte* p,
word32* pInOutSz, byte* g, word32* gInOutSz);
#ifdef __cplusplus
} /* extern "C" */
#endif
//#include <cyassl/ctaocrypt/types.h>
//#include <cyassl/ctaocrypt/integer.h>
//#include <cyassl/ctaocrypt/random.h>
//
//#ifdef __cplusplus
// extern "C" {
//#endif
//
//
///* Diffie-Hellman Key */
//typedef struct DhKey {
// mp_int p, g; /* group parameters */
//} DhKey;
//
//
//CYASSL_API void InitDhKey(DhKey* key);
//CYASSL_API void FreeDhKey(DhKey* key);
//
//CYASSL_API int DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv,
// word32* privSz, byte* pub, word32* pubSz);
//CYASSL_API int DhAgree(DhKey* key, byte* agree, word32* agreeSz,
// const byte* priv, word32 privSz, const byte* otherPub,
// word32 pubSz);
//
//CYASSL_API int DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
// word32);
//CYASSL_API int DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
// word32 gSz);
//CYASSL_API int DhParamsLoad(const byte* input, word32 inSz, byte* p,
// word32* pInOutSz, byte* g, word32* gInOutSz);
//
//
//#ifdef __cplusplus
// } /* extern "C" */
//#endif
#endif /* CTAO_CRYPT_DH_H */

View File

@ -25,43 +25,8 @@
#ifndef CTAO_CRYPT_DSA_H
#define CTAO_CRYPT_DSA_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/integer.h>
#include <cyassl/ctaocrypt/random.h>
#include <wolfssl/wolfcrypt/dsa.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
DSA_PUBLIC = 0,
DSA_PRIVATE = 1
};
/* DSA */
typedef struct DsaKey {
mp_int p, q, g, y, x;
int type; /* public or private */
} DsaKey;
CYASSL_API void InitDsaKey(DsaKey* key);
CYASSL_API void FreeDsaKey(DsaKey* key);
CYASSL_API int DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng);
CYASSL_API int DsaVerify(const byte* digest, const byte* sig, DsaKey* key,
int* answer);
CYASSL_API int DsaPublicKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
word32);
CYASSL_API int DsaPrivateKeyDecode(const byte* input, word32* inOutIdx, DsaKey*,
word32);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* WOLF_CRYPT_DSA_H */
#endif /* CTAO_CRYPT_DSA_H */
#endif /* NO_DSA */

View File

@ -25,6 +25,39 @@
#define CTAO_CRYPT_ECC_H
#include <wolfssl/wolfcrypt/ecc.h>
/* for ecc reverse compatibility */
#ifdef HAVE_ECC
#define ecc_make_key wc_ecc_make_key
#define ecc_shared_secret wc_ecc_shared_secret
#define ecc_sign_hash wc_ecc_sign_hash
#define ecc_verify_hash wc_ecc_verify_hash
#define ecc_init wc_ecc_init
#define ecc_free wc_ecc_free
#define ecc_fp_free wc_ecc_fp_free
#define ecc_export_x963 wc_ecc_export_x963
#define ecc_size wc_ecc_size
#define ecc_sig_size wc_ecc_sig_size
#define ecc_export_x963_ex wc_ecc_export_x963_ex
#define ecc_import_x963 wc_ecc_import_x963
#define ecc_import_private_key wc_ecc_import_private_key
#define ecc_rs_to_sig wc_ecc_rs_to_sig
#define ecc_import_raw wc_ecc_import_raw
#define ecc_export_private_only wc_ecc_export_private_only
#ifdef HAVE_ECC_ENCRYPT
/* ecc encrypt */
#define ecc_ctx_new wc_ecc_ctx_new
#define ecc_ctx_free wc_ecc_ctx_free
#define ecc_ctx_reset wc_ecc_ctx_reset
#define ecc_ctx_get_own_salt wc_ecc_ctx_get_own_salt
#define ecc_ctx_set_peer_salt wc_ecc_ctx_set_peer_salt
#define ecc_ctx_set_info wc_ecc_ctx_set_info
#define ecc_encrypt wc_ecc_encrypt
#define ecc_decrypt wc_ecc_decrypt
#endif /* HAVE_ECC_ENCRYPT */
#endif
//
//#include <cyassl/ctaocrypt/types.h>
//#include <cyassl/ctaocrypt/integer.h>

View File

@ -23,6 +23,10 @@
#ifndef CTAO_CRYPT_ERROR_H
#define CTAO_CRYPT_ERROR_H
/* for name change and fips compatibility @wc_fips */
#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/error-crypt.h>
#else
#include <cyassl/ctaocrypt/types.h>
@ -150,7 +154,7 @@ CYASSL_API const char* CTaoCryptGetErrorString(int error);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* HAVE_FIPS */
#endif /* CTAO_CRYPT_ERROR_H */

View File

@ -25,36 +25,15 @@
#ifndef CTAO_CRYPT_HC128_H
#define CTAO_CRYPT_HC128_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/hc128.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
HC128_ENC_TYPE = 6 /* cipher unique type */
};
/* HC-128 stream cipher */
typedef struct HC128 {
word32 T[1024]; /* P[i] = T[i]; Q[i] = T[1024 + i ]; */
word32 X[16];
word32 Y[16];
word32 counter1024; /* counter1024 = i mod 1024 at the ith step */
word32 key[8];
word32 iv[8];
} HC128;
CYASSL_API int Hc128_Process(HC128*, byte*, const byte*, word32);
CYASSL_API int Hc128_SetKey(HC128*, const byte* key, const byte* iv);
#ifdef __cplusplus
} /* extern "C" */
/* for hc128 reverse compatibility */
#ifdef HAVE_HC128
#define Hc128_Process wc_Hc128_Process
#define Hc128_SetKey wc_Hc128_SetKey
#endif
#endif /* CTAO_CRYPT_HC128_H */
#endif /* HAVE_HC128 */

View File

@ -25,46 +25,50 @@
#ifndef CYASSL_LOGGING_H
#define CYASSL_LOGGING_H
#ifdef __cplusplus
extern "C" {
#endif
enum CYA_Log_Levels {
ERROR_LOG = 0,
INFO_LOG,
ENTER_LOG,
LEAVE_LOG,
OTHER_LOG
};
typedef void (*CyaSSL_Logging_cb)(const int logLevel,
const char *const logMessage);
CYASSL_API int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb log_function);
#ifdef DEBUG_CYASSL
void CYASSL_ENTER(const char* msg);
void CYASSL_LEAVE(const char* msg, int ret);
void CYASSL_ERROR(int);
void CYASSL_MSG(const char* msg);
#else /* DEBUG_CYASSL */
#define CYASSL_ENTER(m)
#define CYASSL_LEAVE(m, r)
#define CYASSL_ERROR(e)
#define CYASSL_MSG(m)
#endif /* DEBUG_CYASSL */
#ifdef __cplusplus
}
#endif
/* for fips compatibility @wc_fips */
#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/logging.h>
#else
#ifdef __cplusplus
extern "C" {
#endif
enum CYA_Log_Levels {
ERROR_LOG = 0,
INFO_LOG,
ENTER_LOG,
LEAVE_LOG,
OTHER_LOG
};
typedef void (*CyaSSL_Logging_cb)(const int logLevel,
const char *const logMessage);
CYASSL_API int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb log_function);
#ifdef DEBUG_CYASSL
void CYASSL_ENTER(const char* msg);
void CYASSL_LEAVE(const char* msg, int ret);
void CYASSL_ERROR(int);
void CYASSL_MSG(const char* msg);
#else /* DEBUG_CYASSL */
#define CYASSL_ENTER(m)
#define CYASSL_LEAVE(m, r)
#define CYASSL_ERROR(e)
#define CYASSL_MSG(m)
#endif /* DEBUG_CYASSL */
#ifdef __cplusplus
}
#endif
#endif /* HAVE_FIPS*/
#endif /* CYASSL_MEMORY_H */

View File

@ -20,46 +20,53 @@
*/
/* check for old macro */
#if !defined(CYASSL_MD2) && defined(WOLFSSL_MD2)
#define CYASSL_MD2
#endif
#ifdef CYASSL_MD2
#ifndef CTAO_CRYPT_MD2_H
#define CTAO_CRYPT_MD2_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/md2.h>
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes */
enum {
MD2 = 6, /* hash type unique */
MD2_BLOCK_SIZE = 16,
MD2_DIGEST_SIZE = 16,
MD2_PAD_SIZE = 16,
MD2_X_SIZE = 48
};
/* Md2 digest */
typedef struct Md2 {
word32 count; /* bytes % PAD_SIZE */
byte X[MD2_X_SIZE];
byte C[MD2_BLOCK_SIZE];
byte buffer[MD2_BLOCK_SIZE];
} Md2;
CYASSL_API void InitMd2(Md2*);
CYASSL_API void Md2Update(Md2*, const byte*, word32);
CYASSL_API void Md2Final(Md2*, byte*);
CYASSL_API int Md2Hash(const byte*, word32, byte*);
#ifdef __cplusplus
} /* extern "C" */
#endif
//#include <cyassl/ctaocrypt/types.h>
//
//#ifdef __cplusplus
// extern "C" {
//#endif
//
//
///* in bytes */
//enum {
// MD2 = 6, /* hash type unique */
// MD2_BLOCK_SIZE = 16,
// MD2_DIGEST_SIZE = 16,
// MD2_PAD_SIZE = 16,
// MD2_X_SIZE = 48
//};
//
//
///* Md2 digest */
//typedef struct Md2 {
// word32 count; /* bytes % PAD_SIZE */
// byte X[MD2_X_SIZE];
// byte C[MD2_BLOCK_SIZE];
// byte buffer[MD2_BLOCK_SIZE];
//} Md2;
//
//
//CYASSL_API void InitMd2(Md2*);
//CYASSL_API void Md2Update(Md2*, const byte*, word32);
//CYASSL_API void Md2Final(Md2*, byte*);
//CYASSL_API int Md2Hash(const byte*, word32, byte*);
//
//
//#ifdef __cplusplus
// } /* extern "C" */
//#endif
#endif /* CTAO_CRYPT_MD2_H */
#endif /* CYASSL_MD2 */

View File

@ -25,39 +25,41 @@
#ifndef CTAO_CRYPT_MD4_H
#define CTAO_CRYPT_MD4_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/md4.h>
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes */
enum {
MD4_BLOCK_SIZE = 64,
MD4_DIGEST_SIZE = 16,
MD4_PAD_SIZE = 56
};
/* MD4 digest */
typedef struct Md4 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 digest[MD4_DIGEST_SIZE / sizeof(word32)];
word32 buffer[MD4_BLOCK_SIZE / sizeof(word32)];
} Md4;
CYASSL_API void InitMd4(Md4*);
CYASSL_API void Md4Update(Md4*, const byte*, word32);
CYASSL_API void Md4Final(Md4*, byte*);
#ifdef __cplusplus
} /* extern "C" */
#endif
//#include <cyassl/ctaocrypt/types.h>
//
//#ifdef __cplusplus
// extern "C" {
//#endif
//
//
///* in bytes */
//enum {
// MD4_BLOCK_SIZE = 64,
// MD4_DIGEST_SIZE = 16,
// MD4_PAD_SIZE = 56
//};
//
//
///* MD4 digest */
//typedef struct Md4 {
// word32 buffLen; /* in bytes */
// word32 loLen; /* length in bytes */
// word32 hiLen; /* length in bytes */
// word32 digest[MD4_DIGEST_SIZE / sizeof(word32)];
// word32 buffer[MD4_BLOCK_SIZE / sizeof(word32)];
//} Md4;
//
//
//CYASSL_API void InitMd4(Md4*);
//CYASSL_API void Md4Update(Md4*, const byte*, word32);
//CYASSL_API void Md4Final(Md4*, byte*);
//
//
//#ifdef __cplusplus
// } /* extern "C" */
//#endif
#endif /* CTAO_CRYPT_MD4_H */

View File

@ -24,51 +24,54 @@
#ifndef CTAO_CRYPT_MD5_H
#define CTAO_CRYPT_MD5_H
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <wolfssl/wolfcrypt/md5.h>
/* in bytes */
enum {
#ifdef STM32F2_HASH
MD5_REG_SIZE = 4, /* STM32 register size, bytes */
#endif
MD5 = 0, /* hash type unique */
MD5_BLOCK_SIZE = 64,
MD5_DIGEST_SIZE = 16,
MD5_PAD_SIZE = 56
};
#ifdef CYASSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif
/* MD5 digest */
typedef struct Md5 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)];
#ifndef CYASSL_PIC32MZ_HASH
word32 digest[MD5_DIGEST_SIZE / sizeof(word32)];
#else
word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
pic32mz_desc desc ; /* Crypt Engine descripter */
#endif
} Md5;
CYASSL_API void InitMd5(Md5*);
CYASSL_API void Md5Update(Md5*, const byte*, word32);
CYASSL_API void Md5Final(Md5*, byte*);
CYASSL_API int Md5Hash(const byte*, word32, byte*);
#ifdef __cplusplus
} /* extern "C" */
#endif
//#include <cyassl/ctaocrypt/types.h>
//
//#ifdef __cplusplus
// extern "C" {
//#endif
//
//
///* in bytes */
//enum {
//#ifdef STM32F2_HASH
// MD5_REG_SIZE = 4, /* STM32 register size, bytes */
//#endif
// MD5 = 0, /* hash type unique */
// MD5_BLOCK_SIZE = 64,
// MD5_DIGEST_SIZE = 16,
// MD5_PAD_SIZE = 56
//};
//
//#ifdef CYASSL_PIC32MZ_HASH
//#include "port/pic32/pic32mz-crypt.h"
//#endif
//
///* MD5 digest */
//typedef struct Md5 {
// word32 buffLen; /* in bytes */
// word32 loLen; /* length in bytes */
// word32 hiLen; /* length in bytes */
// word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)];
// #ifndef CYASSL_PIC32MZ_HASH
// word32 digest[MD5_DIGEST_SIZE / sizeof(word32)];
// #else
// word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
// pic32mz_desc desc ; /* Crypt Engine descripter */
// #endif
//} Md5;
//
//CYASSL_API void InitMd5(Md5*);
//CYASSL_API void Md5Update(Md5*, const byte*, word32);
//CYASSL_API void Md5Final(Md5*, byte*);
//CYASSL_API int Md5Hash(const byte*, word32, byte*);
//
//
//#ifdef __cplusplus
// } /* extern "C" */
//#endif
#endif /* CTAO_CRYPT_MD5_H */
#endif /* NO_MD5 */

View File

@ -26,7 +26,11 @@
#define CYASSL_MEMORY_H
#include <stdlib.h>
/* for fips compatibility @wc_fips */
#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/memory.h>
#else
#ifdef __cplusplus
extern "C" {
@ -53,4 +57,6 @@ CYASSL_API void* CyaSSL_Realloc(void *ptr, size_t size);
}
#endif
#endif /* HAVE_FIPS */
#endif /* CYASSL_MEMORY_H */

View File

@ -25,97 +25,19 @@
#ifndef CTAO_CRYPT_PKCS7_H
#define CTAO_CRYPT_PKCS7_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/asn.h>
#include <cyassl/ctaocrypt/asn_public.h>
#include <cyassl/ctaocrypt/random.h>
#include <cyassl/ctaocrypt/des3.h>
#include <wolfssl/wolfcrypt/pkcs7.h>
#ifdef __cplusplus
extern "C" {
#endif
/* PKCS#7 content types, ref RFC 2315 (Section 14) */
enum PKCS7_TYPES {
PKCS7_MSG = 650, /* 1.2.840.113549.1.7 */
DATA = 651, /* 1.2.840.113549.1.7.1 */
SIGNED_DATA = 652, /* 1.2.840.113549.1.7.2 */
ENVELOPED_DATA = 653, /* 1.2.840.113549.1.7.3 */
SIGNED_AND_ENVELOPED_DATA = 654, /* 1.2.840.113549.1.7.4 */
DIGESTED_DATA = 655, /* 1.2.840.113549.1.7.5 */
ENCRYPTED_DATA = 656 /* 1.2.840.113549.1.7.6 */
};
enum Pkcs7_Misc {
PKCS7_NONCE_SZ = 16,
MAX_ENCRYPTED_KEY_SZ = 512, /* max enc. key size, RSA <= 4096 */
MAX_CONTENT_KEY_LEN = DES3_KEYLEN, /* highest current cipher is 3DES */
MAX_RECIP_SZ = MAX_VERSION_SZ +
MAX_SEQ_SZ + ASN_NAME_MAX + MAX_SN_SZ +
MAX_SEQ_SZ + MAX_ALGO_SZ + 1 + MAX_ENCRYPTED_KEY_SZ
};
typedef struct PKCS7Attrib {
byte* oid;
word32 oidSz;
byte* value;
word32 valueSz;
} PKCS7Attrib;
typedef struct PKCS7 {
byte* content; /* inner content, not owner */
word32 contentSz; /* content size */
int contentOID; /* PKCS#7 content type OID sum */
RNG* rng;
int hashOID;
int encryptOID; /* key encryption algorithm OID */
byte* singleCert; /* recipient cert, DER, not owner */
word32 singleCertSz; /* size of recipient cert buffer, bytes */
byte issuerHash[SHA_SIZE]; /* hash of all alt Names */
byte* issuer; /* issuer name of singleCert */
word32 issuerSz; /* length of issuer name */
byte issuerSn[MAX_SN_SZ]; /* singleCert's serial number */
word32 issuerSnSz; /* length of serial number */
byte publicKey[512];
word32 publicKeySz;
byte* privateKey; /* private key, DER, not owner */
word32 privateKeySz; /* size of private key buffer, bytes */
PKCS7Attrib* signedAttribs;
word32 signedAttribsSz;
} PKCS7;
CYASSL_LOCAL int SetContentType(int pkcs7TypeOID, byte* output);
CYASSL_LOCAL int GetContentType(const byte* input, word32* inOutIdx,
word32* oid, word32 maxIdx);
CYASSL_LOCAL int CreateRecipientInfo(const byte* cert, word32 certSz,
int keyEncAlgo, int blockKeySz,
RNG* rng, byte* contentKeyPlain,
byte* contentKeyEnc,
int* keyEncSz, byte* out, word32 outSz);
CYASSL_API int PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz);
CYASSL_API void PKCS7_Free(PKCS7* pkcs7);
CYASSL_API int PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz);
CYASSL_API int PKCS7_EncodeSignedData(PKCS7* pkcs7,
byte* output, word32 outputSz);
CYASSL_API int PKCS7_VerifySignedData(PKCS7* pkcs7,
byte* pkiMsg, word32 pkiMsgSz);
CYASSL_API int PKCS7_EncodeEnvelopedData(PKCS7* pkcs7,
byte* output, word32 outputSz);
CYASSL_API int PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
word32 pkiMsgSz, byte* output,
word32 outputSz);
#ifdef __cplusplus
} /* extern "C" */
#endif
/* for pkcs7 reverse compatibility */
#define SetContentType wc_SetContentType
#define GetContentType wc_GetContentType
#define CreateRecipientInfo wc_CreateRecipientInfo
#define PKCS7_InitWithCert wc_PKCS7_InitWithCert
#define PKCS7_Free wc_PKCS7_Free
#define PKCS7_EncodeData wc_PKCS7_EncodeData
#define PKCS7_EncodeSignedData wc_PKCS7_EncodeSignedData
#define PKCS7_VerifySignedData wc_PKCS7_VerifySignedData
#define PKCS7_EncodeEnvelopedData wc_PKCS7_EncodeEnvelopedData
#define PKCS7_DecodeEnvelopedData wc_PKCS7_DecodeEnvelopedData
#endif /* CTAO_CRYPT_PKCS7_H */

View File

@ -25,57 +25,7 @@
#ifndef CTAO_CRYPT_POLY1305_H
#define CTAO_CRYPT_POLY1305_H
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/* auto detect between 32bit / 64bit */
#define HAS_SIZEOF_INT128_64BIT (defined(__SIZEOF_INT128__) && defined(__LP64__))
#define HAS_MSVC_64BIT (defined(_MSC_VER) && defined(_M_X64))
#define HAS_GCC_4_4_64BIT (defined(__GNUC__) && defined(__LP64__) && \
((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))))
#if (HAS_SIZEOF_INT128_64BIT || HAS_MSVC_64BIT || HAS_GCC_4_4_64BIT)
#define POLY130564
#else
#define POLY130532
#endif
enum {
POLY1305 = 7,
POLY1305_BLOCK_SIZE = 16,
POLY1305_DIGEST_SIZE = 16,
POLY1305_PAD_SIZE = 56
};
/* Poly1305 state */
typedef struct Poly1305 {
#if defined(POLY130564)
word64 r[3];
word64 h[3];
word64 pad[2];
#else
word32 r[5];
word32 h[5];
word32 pad[4];
#endif
size_t leftover;
unsigned char buffer[POLY1305_BLOCK_SIZE];
unsigned char final;
} Poly1305;
/* does init */
CYASSL_API int Poly1305SetKey(Poly1305* poly1305, const byte* key, word32 kySz);
CYASSL_API int Poly1305Update(Poly1305* poly1305, const byte*, word32);
CYASSL_API int Poly1305Final(Poly1305* poly1305, byte* tag);
#ifdef __cplusplus
} /* extern "C" */
#endif
#include <wolfssl/wolfcrypt/poly1305.h>
#endif /* CTAO_CRYPT_POLY1305_H */

View File

@ -25,41 +25,15 @@
#ifndef CTAO_CRYPT_RABBIT_H
#define CTAO_CRYPT_RABBIT_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/rabbit.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
RABBIT_ENC_TYPE = 5 /* cipher unique type */
};
/* Rabbit Context */
typedef struct RabbitCtx {
word32 x[8];
word32 c[8];
word32 carry;
} RabbitCtx;
/* Rabbit stream cipher */
typedef struct Rabbit {
RabbitCtx masterCtx;
RabbitCtx workCtx;
} Rabbit;
CYASSL_API int RabbitProcess(Rabbit*, byte*, const byte*, word32);
CYASSL_API int RabbitSetKey(Rabbit*, const byte* key, const byte* iv);
#ifdef __cplusplus
} /* extern "C" */
/* for rabbit reverse compatibility */
#ifndef NO_RABBIT
#define RabbitProcess wc_RabbitProcess
#define RabbitSetKey wc_RabbitSetKey
#endif
#endif /* CTAO_CRYPT_RABBIT_H */
#endif /* NO_RABBIT */

View File

@ -27,5 +27,14 @@
#include <wolfssl/wolfcrypt/ripemd.h>
/* for ripemd reverse compatibility */
#ifdef WOLFSSL_RIPEMD
#define CYASSL_RIPEMD /* @TODO */
#define InitRipeMd wc_InitRipeMd
#define RipeMdUpdate wc_RipeMdUpdate
#define RipeMdFinal wc_RipeMdFinal
#endif
#endif /* CTAO_CRYPT_RIPEMD_H */
#endif /* CYASSL_RIPEMD */

View File

@ -100,7 +100,6 @@
/* #define CYASSL_PICOTCP_DEMO */
#include <cyassl/ctaocrypt/visibility.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifdef IPHONE
#define SIZEOF_LONG_LONG 8

View File

@ -88,7 +88,6 @@
#define WOLFSSL_MAX_ERROR_SZ CYASSL_MAX_ERROR_SZ
/* src/ssl.c */
#ifdef CYASSL_SSL_H
#define CYASSL_CRL WOLFSSL_CRL
#define CYASSL_SSLV3 WOLFSSL_SSLV3
#define CYASSL_TLSV1 WOLFSSL_TLSV1
@ -121,7 +120,6 @@
#define CyaSSL_CertManagerDisableOCSP wolfSSL_CertManagerDisableOCSP
#define CyaSSL_get_current_cipher_suite wolfSSL_get_current_cipher_suite
#define CyaSSL_CTX_load_verify_locations wolfSSL_CTX_load_verify_locations
#endif /* CYASSL_SSL_H */
/* io.c */
#define CYASSL_CBIO_ERR_ISR WOLFSSL_CBIO_ERR_ISR
@ -156,9 +154,12 @@
#define CyaSSL_ERR_reason_error_string wolfSSL_ERR_reason_error_string
/* fips defines */
#define WOLFSSL_LEAVE CYASSL_LEAVE
#define WOLFSSL_ERROR CYASSL_ERROR
#define WOLFSSL_GENERAL_ALIGNMENT CYASSL_GENERAL_ALIGNMENT
//defined in logging
//#define WOLFSSL_LEAVE CYASSL_LEAVE
//#define WOLFSSL_ERROR CYASSL_ERROR
//defined in settings.h
//#define WOLFSSL_GENERAL_ALIGNMENT CYASSL_GENERAL_ALIGNMENT
#define wolfcrypt_test ctaocrypt_test
@ -329,10 +330,11 @@
#define CyaSSL_dtls_get_current_timeout wolfSSL_dtls_get_current_timeout
/* Memory Abstraction Layer */
#define CyaSSL_Free wolfSSL_Free
#define CyaSSL_Malloc wolfSSL_Malloc
#define CyaSSL_Realloc wolfSSL_Realloc
#define CyaSSL_SetAllocators wolfSSL_SetAllocators
//#define CyaSSL_Free wolfSSL_Free
//#define CyaSSL_Malloc wolfSSL_Malloc
//#define CyaSSL_Realloc wolfSSL_Realloc
//#define CyaSSL_SetAllocators wolfSSL_SetAllocators
/* moved to wolfssl/wolfcrypt/memory.h */
/* Certificate Manager */
#define CyaSSL_CertManagerNew wolfSSL_CertManagerNew
@ -390,125 +392,15 @@
#undef WOLFSSL_API
#define WOLFSSL_API CYASSL_API
#define WOLFSSL_ENTER(x) CYASSL_ENTER(x) /* @TODO*/
#define WOLFSSL_BIT_SIZE CYASSL_BIT_SIZE /* @TODO*/
/* wrapper around macros until they are changed in cyassl code
* needs investigation in regards to macros in fips */
#define WOLFSSL_MAX_16BIT CYASSL_MAX_16BIT
#define WOLFSSL_MSG(x) CYASSL_MSG(x)
#define NO_WOLFSSL_ALLOC_ALIGN NO_CYASSL_ALLOC_ALIGN /* @TODO*/
/* for arc4 reverse compatibility */
#ifndef NO_RC4
#include <wolfssl/wolfcrypt/arc4.h>
#define CYASSL_ARC4_CAVIUM_MAGIC WOLFSSL_ARC4_CAVIUM_MAGIC
#define Arc4Process wc_Arc4Process
#define Arc4SetKey wc_Arc4SetKey
#define Arc4InitCavium wc_Arc4InitCavium
#define Arc4FreeCavium wc_Arc4FreeCavium
#endif
/* for chacha reverse compatibility */
#ifdef HAVE_CHACHA
#define ChachaProcess wc_ChachaProcess
#define ChachaSetKey wc_ChachaSetKey
#define Chacha_SetIV wc_Chacha_SetIV
#endif
/* for DH reverse compatibility */
#ifndef NO_DH
#define InitDhKey wc_InitDhKey
#define FreeDhKey wc_FreeDhKey
#define DhGenerateKeyPair wc_DhGenerateKeyPair
#endif
/* for DSA reverse compatibility */
#ifndef NO_DSA
#define InitDsaKey wc_InitDsaKey
#define FreeDsaKey wc_FreeDsaKey
#define DsaSign wc_DsaSign
#define DsaVerify wc_DsaVerify
#define DsaPublicKeyDecode wc_DsaPublicKeyDecode
#define DsaPrivateKeyDecode wc_DsaPrivateKeyDecode
#endif
/* for hc128 reverse compatibility */
#ifdef HAVE_HC128
#define Hc128_Process wc_Hc128_Process
#define Hc128_SetKey wc_Hc128_SetKey
#endif
/* for md2 reverse compatibility */
#define CYASSL_MD2 WOLFSSL_MD2 /* @TODO */
//#ifdef WOLFSSL_MD2
#define InitMd2 wc_InitMd2
#define Md2Update wc_Md2Update
#define Md2Final wc_Md2Final
#define Md2Hash wc_Md2Hash
//#endif
/* for md4 reverse compatibility */
#ifndef NO_MD4
#define InitMd4 wc_InitMd4
#define Md4Update wc_Md4Update
#define Md4Final wc_Md4Final
#endif
/* for md5 reverse compatibility */
#ifndef NO_MD5
#define InitMd5 wc_InitMd5
#define Md5Update wc_Md5Update
#define Md5Final wc_Md5Final
#define Md5Hash wc_Md5Hash
#endif
/* for poly1305 reverse compatibility */
#ifdef HAVE_POLY1305
#define Poly1305SetKey wc_Poly1305SetKey
#define Poly1305Update wc_Poly1305Update
#define Poly1305Final wc_Poly1305Final
#endif
/* for rabbit reverse compatibility */
#ifndef NO_RABBIT
#define RabbitProcess wc_RabbitProcess
#define RabbitSetKey wc_RabbitSetKey
#endif
/* for ripemd reverse compatibility */
#ifdef WOLFSSL_RIPEMD
#define CYASSL_RIPEMD /* @TODO */
#define InitRipeMd wc_InitRipeMd
#define RipeMdUpdate wc_RipeMdUpdate
#define RipeMdFinal wc_RipeMdFinal
#endif
/* for pkcs7 reverse compatibility */
#ifdef HAVE_PKCS7
#define SetContentType wc_SetContentType
#define GetContentType wc_GetContentType
#define CreateRecipientInfo wc_CreateRecipientInfo
#define PKCS7_InitWithCert wc_PKCS7_InitWithCert
#define PKCS7_Free wc_PKCS7_Free
#define PKCS7_EncodeData wc_PKCS7_EncodeData
#define PKCS7_EncodeSignedData wc_PKCS7_EncodeSignedData
#define PKCS7_VerifySignedData wc_PKCS7_VerifySignedData
#define PKCS7_EncodeEnvelopedData wc_PKCS7_EncodeEnvelopedData
#define PKCS7_DecodeEnvelopedData wc_PKCS7_DecodeEnvelopedData
#endif
/* for pwdbased reverse compatibility */
#ifndef NO_PWDBASED
@ -518,65 +410,6 @@
#endif
/* for blake2 reverse compatibility */
#ifdef HAVE_BLAKE2
#define InitBlake2b wc_InitBlake2b
#define Blake2bUpdate wc_Blake2bUpdate
#define Blake2bFinal wc_Blake2bFinal
#endif
/* for blake2 reverse compatibility */
#ifdef HAVE_CAMELLIA
#define CamelliaSetKey wc_CamelliaSetKey
#define CamelliaSetIV wc_CamelliaSetIV
#define CamelliaEncryptDirect wc_CamelliaEncryptDirect
#define CamelliaDecryptDirect wc_CamelliaDecryptDirect
#define CamelliaCbcEncrypt wc_CamelliaCbcEncrypt
#define CamelliaCbcDecrypt wc_CamelliaCbcDecrypt
#endif
/* for chacha reverse compatibility */
#ifdef HAVE_CHACHA
#define Chacha_Process wc_Chacha_Process
#define Chacha_SetKey wc_Chacha_SetKey
#define Chacha_SetIV wc_Chacha_SetIV
#endif
/* for ecc reverse compatibility */
#ifdef HAVE_ECC
#define ecc_make_key wc_ecc_make_key
#define ecc_shared_secret wc_ecc_shared_secret
#define ecc_sign_hash wc_ecc_sign_hash
#define ecc_verify_hash wc_ecc_verify_hash
#define ecc_init wc_ecc_init
#define ecc_free wc_ecc_free
#define ecc_fp_free wc_ecc_fp_free
#define ecc_export_x963 wc_ecc_export_x963
#define ecc_export_x963_ex wc_ecc_export_x963_ex
#define ecc_import_x963 wc_ecc_import_x963
#define ecc_import_private_key wc_ecc_import_private_key
#define ecc_rs_to_sig wc_ecc_rs_to_sig
#define ecc_import_raw wc_ecc_import_raw
#define ecc_export_private_only wc_ecc_export_private_only
#define ecc_size wc_ecc_size
#define ecc_sig_size wc_ecc_sig_size
#ifdef HAVE_ECC_ENCRYPT
/* ecc encrypt */
//ecEncCtx* wc_ecc_ctx_new(int flags, RNG* rng);
//void wc_ecc_ctx_free(ecEncCtx*);
//int wc_ecc_ctx_reset(ecEncCtx*, RNG*); /* reset for use again w/o alloc/free */
//const byte* wc_ecc_ctx_get_own_salt(ecEncCtx*);
//int wc_ecc_ctx_set_peer_salt(ecEncCtx*, const byte* salt);
//int wc_ecc_ctx_set_info(ecEncCtx*, const byte* info, int sz);
//int wc_ecc_encrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
//int wc_ecc_decrypt(ecc_key* privKey, ecc_key* pubKey, const byte* msg,
#endif /* HAVE_ECC_ENCRYPT */
#endif
/* examples/client/client.h */
#define CYASSL_THREAD WOLFSSL_THREAD
@ -584,6 +417,11 @@
#define LIBCYASSL_VERSION_STRING LIBWOLFSSL_VERSION_STRING
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -1,3 +1,4 @@
#include <wolfssl/test.h>
/* server.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.

View File

@ -7,8 +7,8 @@ check_PROGRAMS += mcapi/test
noinst_PROGRAMS += mcapi/test
mcapi_test_SOURCES = mcapi/crypto.c \
mcapi/mcapi_test.c
mcapi_test_LDADD = src/libcyassl.la
mcapi_test_DEPENDENCIES = src/libcyassl.la
mcapi_test_LDADD = src/libwolfssl.la
mcapi_test_DEPENDENCIES = src/libwolfssl.la
endif
noinst_HEADERS += mcapi/crypto.h

View File

@ -66,10 +66,10 @@ mkdir -p $RPM_BUILD_ROOT/
%{_docdir}/cyassl/example/echoclient.c
%{_docdir}/cyassl/example/client.c
%{_docdir}/cyassl/README.txt
%{_libdir}/libcyassl.la
%{_libdir}/libcyassl.so
%{_libdir}/libcyassl.so.5
%{_libdir}/libcyassl.so.5.0.5
%{_libdir}/libwolfssl.la
%{_libdir}/libwolfssl.so
%{_libdir}/libwolfssl.so.5
%{_libdir}/libwolfssl.so.5.0.5
%files devel
%defattr(-,root,root,-)

View File

@ -71,13 +71,15 @@ src_libwolfssl_la_SOURCES += \
endif
if BUILD_MEMORY
src_libwolfssl_la_SOURCES += ctaocrypt/src/memory.c \
wolfcrypt/src/memory.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/memory.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/memory.c
endif
endif
if BUILD_DH
src_libwolfssl_la_SOURCES += ctaocrypt/src/dh.c \
wolfcrypt/src/dh.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/dh.c
endif
if BUILD_ASN
@ -97,8 +99,7 @@ endif
endif
if BUILD_POLY1305
src_libwolfssl_la_SOURCES += ctaocrypt/src/poly1305.c \
wolfcrypt/src/poly1305.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/poly1305.c
endif
if BUILD_RC4
@ -106,23 +107,28 @@ src_libwolfssl_la_SOURCES += wolfcrypt/src/arc4.c
endif
if BUILD_MD4
src_libwolfssl_la_SOURCES += ctaocrypt/src/md4.c \
wolfcrypt/src/md4.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/md4.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/md4.c
endif
endif
if BUILD_MD5
src_libwolfssl_la_SOURCES += ctaocrypt/src/md5.c \
wolfcrypt/src/md5.c
src_libwolfssl_la_SOURCES += ctaocrypt/src/md5.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/md5.c
endif
if BUILD_PWDBASED
src_libwolfssl_la_SOURCES += ctaocrypt/src/pwdbased.c \
wolfcrypt/src/pwdbased.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/pwdbased.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/pwdbased.c
endif
endif
if BUILD_DSA
src_libwolfssl_la_SOURCES += ctaocrypt/src/dsa.c \
wolfcrypt/src/dsa.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/dsa.c
endif
if BUILD_AESNI
@ -130,18 +136,19 @@ src_libwolfssl_la_SOURCES += ctaocrypt/src/aes_asm.s
endif
if BUILD_CAMELLIA
src_libwolfssl_la_SOURCES += ctaocrypt/src/camellia.c \
wolfcrypt/src/camellia.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/camellia.c
endif
if BUILD_MD2
src_libwolfssl_la_SOURCES += ctaocrypt/src/md2.c \
wolfcrypt/src/md2.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/md2.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/md2.c
endif
endif
if BUILD_RIPEMD
src_libwolfssl_la_SOURCES += ctaocrypt/src/ripemd.c \
wolfcrypt/src/ripemd.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/ripemd.c
endif
if BUILD_BLAKE2
@ -149,33 +156,40 @@ src_libwolfssl_la_SOURCES += wolfcrypt/src/blake2b.c
endif
if BUILD_HC128
src_libwolfssl_la_SOURCES += ctaocrypt/src/hc128.c \
ctaocrypt/src/hc128.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/hc128.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/hc128.c
endif
endif
if BUILD_RABBIT
src_libwolfssl_la_SOURCES += ctaocrypt/src/rabbit.c \
wolfcrypt/src/rabbit.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/rabbit.c
endif
if BUILD_CHACHA
src_libwolfssl_la_SOURCES += ctaocrypt/src/chacha.c \
wolfcrypt/src/chacha.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/chacha.c
endif
if !BUILD_INLINE
src_libwolfssl_la_SOURCES += ctaocrypt/src/misc.c \
wolfcrypt/src/misc.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/misc.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/misc.c
endif
endif
if BUILD_FASTMATH
src_libwolfssl_la_SOURCES += ctaocrypt/src/tfm.c \
wolfcrypt/src/tfm.c
src_libwolfssl_la_SOURCES += ctaocrypt/src/tfm.c
src_libwolfssl_la_SOURCES += wolfcrypt/src/tfm.c
endif
if BUILD_SLOWMATH
src_libwolfssl_la_SOURCES += ctaocrypt/src/integer.c \
wolfcrypt/src/integer.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/integer.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/integer.c
endif
endif
if BUILD_ECC
@ -183,13 +197,19 @@ src_libwolfssl_la_SOURCES += wolfcrypt/src/ecc.c
endif
if BUILD_LIBZ
src_libwolfssl_la_SOURCES += ctaocrypt/src/compress.c \
wolfcrypt/src/compress.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/compress.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/compress.c
endif
endif
if BUILD_PKCS7
src_libwolfssl_la_SOURCES += ctaocrypt/src/pkcs7.c \
wolfcrypt/src/pkcs7.c
if BUILD_FIPS
src_libwolfssl_la_SOURCES += ctaocrypt/src/pkcs7.c
else
src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs7.c
endif
endif

View File

@ -20,7 +20,7 @@
*/
/* Name change compatibility layer */
#include <cyassl/ssl.h>
//#include <cyassl/ssl.h>
#ifdef HAVE_CONFIG_H
@ -587,8 +587,8 @@ void FreeCiphers(WOLFSSL* ssl)
#ifdef BUILD_AES
#ifdef HAVE_CAVIUM
if (ssl->devId != NO_CAVIUM_DEVICE) {
AesFreeCavium(ssl->encrypt.aes);
AesFreeCavium(ssl->decrypt.aes);
wc_AesFreeCavium(ssl->encrypt.aes);
wc_AesFreeCavium(ssl->decrypt.aes);
}
#endif
XFREE(ssl->encrypt.aes, ssl->heap, DYNAMIC_TYPE_CIPHER);
@ -5662,7 +5662,7 @@ static INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input, word16 sz)
#ifdef BUILD_AES
case wolfssl_aes:
return AesCbcEncrypt(ssl->encrypt.aes, out, input, sz);
return wc_AesCbcEncrypt(ssl->encrypt.aes, out, input, sz);
#endif
#ifdef BUILD_AESGCM
@ -5697,7 +5697,7 @@ static INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input, word16 sz)
ssl->keys.aead_enc_imp_IV, AEAD_IMP_IV_SZ);
XMEMCPY(nonce + AEAD_IMP_IV_SZ,
ssl->keys.aead_exp_IV, AEAD_EXP_IV_SZ);
gcmRet = AesGcmEncrypt(ssl->encrypt.aes,
gcmRet = wc_AesGcmEncrypt(ssl->encrypt.aes,
out + AEAD_EXP_IV_SZ, input + AEAD_EXP_IV_SZ,
sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
nonce, AEAD_NONCE_SZ,
@ -5743,7 +5743,7 @@ static INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input, word16 sz)
ssl->keys.aead_enc_imp_IV, AEAD_IMP_IV_SZ);
XMEMCPY(nonce + AEAD_IMP_IV_SZ,
ssl->keys.aead_exp_IV, AEAD_EXP_IV_SZ);
AesCcmEncrypt(ssl->encrypt.aes,
wc_AesCcmEncrypt(ssl->encrypt.aes,
out + AEAD_EXP_IV_SZ, input + AEAD_EXP_IV_SZ,
sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
nonce, AEAD_NONCE_SZ,
@ -5821,7 +5821,7 @@ static INLINE int Decrypt(WOLFSSL* ssl, byte* plain, const byte* input,
#ifdef BUILD_AES
case wolfssl_aes:
return AesCbcDecrypt(ssl->decrypt.aes, plain, input, sz);
return wc_AesCbcDecrypt(ssl->decrypt.aes, plain, input, sz);
#endif
#ifdef BUILD_AESGCM
@ -5848,7 +5848,7 @@ static INLINE int Decrypt(WOLFSSL* ssl, byte* plain, const byte* input,
additional + AEAD_LEN_OFFSET);
XMEMCPY(nonce, ssl->keys.aead_dec_imp_IV, AEAD_IMP_IV_SZ);
XMEMCPY(nonce + AEAD_IMP_IV_SZ, input, AEAD_EXP_IV_SZ);
if (AesGcmDecrypt(ssl->decrypt.aes,
if (wc_AesGcmDecrypt(ssl->decrypt.aes,
plain + AEAD_EXP_IV_SZ,
input + AEAD_EXP_IV_SZ,
sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,
@ -5889,7 +5889,7 @@ static INLINE int Decrypt(WOLFSSL* ssl, byte* plain, const byte* input,
additional + AEAD_LEN_OFFSET);
XMEMCPY(nonce, ssl->keys.aead_dec_imp_IV, AEAD_IMP_IV_SZ);
XMEMCPY(nonce + AEAD_IMP_IV_SZ, input, AEAD_EXP_IV_SZ);
if (AesCcmDecrypt(ssl->decrypt.aes,
if (wc_AesCcmDecrypt(ssl->decrypt.aes,
plain + AEAD_EXP_IV_SZ,
input + AEAD_EXP_IV_SZ,
sz - AEAD_EXP_IV_SZ - ssl->specs.aead_mac_size,

View File

@ -5,8 +5,8 @@
if BUILD_SNIFFTEST
noinst_PROGRAMS += sslSniffer/sslSnifferTest/snifftest
sslSniffer_sslSnifferTest_snifftest_SOURCES = sslSniffer/sslSnifferTest/snifftest.c
sslSniffer_sslSnifferTest_snifftest_LDADD = src/libcyassl.la -lpcap
sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES = src/libcyassl.la
sslSniffer_sslSnifferTest_snifftest_LDADD = src/libwolfssl.la -lpcap
sslSniffer_sslSnifferTest_snifftest_DEPENDENCIES = src/libwolfssl.la
endif
EXTRA_DIST += sslSniffer/sslSniffer.vcproj
EXTRA_DIST += sslSniffer/sslSniffer.vcxproj

View File

@ -14,8 +14,8 @@ tests_unit_test_SOURCES = \
examples/client/client.c \
examples/server/server.c
tests_unit_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS)
tests_unit_test_LDADD = src/libcyassl.la
tests_unit_test_DEPENDENCIES = src/libcyassl.la
tests_unit_test_LDADD = src/libwolfssl.la
tests_unit_test_DEPENDENCIES = src/libwolfssl.la
endif
EXTRA_DIST += tests/unit.h
EXTRA_DIST += tests/test.conf \

View File

@ -1,4 +1,8 @@
/* unit.c unit tests driver */
/* Name change compatibility layer */
#include <cyassl/ssl.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

View File

@ -7,15 +7,15 @@ if BUILD_EXAMPLES
check_PROGRAMS += testsuite/testsuite.test
noinst_PROGRAMS += testsuite/testsuite.test
testsuite_testsuite_test_SOURCES = \
ctaocrypt/test/test.c \
wolfcrypt/test/test.c \
examples/client/client.c \
examples/echoclient/echoclient.c \
examples/echoserver/echoserver.c \
examples/server/server.c \
testsuite/testsuite.c
testsuite_testsuite_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS)
testsuite_testsuite_test_LDADD = src/libcyassl.la
testsuite_testsuite_test_DEPENDENCIES = src/libcyassl.la
testsuite_testsuite_test_LDADD = src/libwolfssl.la
testsuite_testsuite_test_DEPENDENCIES = src/libwolfssl.la
endif
EXTRA_DIST += testsuite/testsuite.sln
EXTRA_DIST += testsuite/testsuite-ntru.vcproj

View File

@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../;../NTRU/include"
PreprocessorDefinitions="NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;HAVE_NTRU;NO_PSK;WIN32"
PreprocessorDefinitions="NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;HAVE_NTRU;NO_PSK;WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -118,7 +118,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../;../NTRU/include"
PreprocessorDefinitions="NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;HAVE_NTRU;NO_PSK;WIN32"
PreprocessorDefinitions="NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;HAVE_NTRU;NO_PSK;WIN32"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@ -193,7 +193,7 @@
>
</File>
<File
RelativePath="..\ctaocrypt\test\test.c"
RelativePath="..\wolfcrypt\test\test.c"
>
</File>
<File

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL.
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -23,15 +23,15 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <cyassl/test.h>
#include "ctaocrypt/test/test.h"
#include <wolfssl/test.h>
#include "wolfcrypt/test/test.h"
#ifndef SINGLE_THREADED
#include <cyassl/openssl/ssl.h>
#include <cyassl/ctaocrypt/sha256.h>
#include <wolfssl/openssl/ssl.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include "examples/echoclient/echoclient.h"
#include "examples/echoserver/echoserver.h"
@ -88,12 +88,12 @@ int testsuite_test(int argc, char** argv)
server_args.argc = argc;
server_args.argv = argv;
CyaSSL_Init();
#if defined(DEBUG_CYASSL) && !defined(HAVE_VALGRIND)
CyaSSL_Debugging_ON();
wolfSSL_Init();
#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
wolfSSL_Debugging_ON();
#endif
#if !defined(CYASSL_TIRTOS)
#if !defined(WOLFSSL_TIRTOS)
if (CurrentDir("testsuite") || CurrentDir("_build"))
ChangeDirBack(1);
else if (CurrentDir("Debug") || CurrentDir("Release"))
@ -103,18 +103,18 @@ int testsuite_test(int argc, char** argv)
/* Debug or Release */
#endif
#ifdef CYASSL_TIRTOS
#ifdef WOLFSSL_TIRTOS
fdOpenSession(Task_self());
#endif
server_args.signal = &ready;
InitTcpReady(&ready);
/* CTaoCrypt test */
ctaocrypt_test(&server_args);
/* wc_ test */
wolfcrypt_test(&server_args);
if (server_args.return_code != 0) return server_args.return_code;
/* Simple CyaSSL client server test */
/* Simple wolfSSL client server test */
simple_test(&server_args);
if (server_args.return_code != 0) return server_args.return_code;
@ -148,7 +148,7 @@ int testsuite_test(int argc, char** argv)
echoclient_test(&echo_args);
if (echo_args.return_code != 0) return echo_args.return_code;
#ifdef CYASSL_DTLS
#ifdef WOLFSSL_DTLS
wait_tcp_ready(&server_args);
#endif
/* send quit to echoserver */
@ -165,7 +165,7 @@ int testsuite_test(int argc, char** argv)
{
char ciphers[1024];
XMEMSET(ciphers, 0, sizeof(ciphers));
CyaSSL_get_ciphers(ciphers, sizeof(ciphers)-1);
wolfSSL_get_ciphers(ciphers, sizeof(ciphers)-1);
printf("ciphers = %s\n", ciphers);
}
@ -180,10 +180,10 @@ int testsuite_test(int argc, char** argv)
return EXIT_FAILURE;
}
CyaSSL_Cleanup();
wolfSSL_Cleanup();
FreeTcpReady(&ready);
#ifdef CYASSL_TIRTOS
#ifdef WOLFSSL_TIRTOS
fdCloseSession(Task_self());
#endif
@ -237,8 +237,8 @@ void simple_test(func_args* args)
cliArgs.return_code = 0;
strcpy(svrArgs.argv[0], "SimpleServer");
#if !defined(USE_WINDOWS_API) && !defined(CYASSL_SNIFFER) && \
!defined(CYASSL_TIRTOS)
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_SNIFFER) && \
!defined(WOLFSSL_TIRTOS)
strcpy(svrArgs.argv[svrArgs.argc++], "-p");
strcpy(svrArgs.argv[svrArgs.argc++], "0");
#endif
@ -296,7 +296,7 @@ void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_create(thread, 0, fun, args);
return;
#elif defined(CYASSL_TIRTOS)
#elif defined(WOLFSSL_TIRTOS)
/* Initialize the defaults and set the parameters. */
Task_Params taskParams;
Task_Params_init(&taskParams);
@ -317,7 +317,7 @@ void join_thread(THREAD_TYPE thread)
{
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
pthread_join(thread, 0);
#elif defined(CYASSL_TIRTOS)
#elif defined(WOLFSSL_TIRTOS)
while(1) {
if (Task_getMode(thread) == Task_Mode_TERMINATED) {
Task_sleep(5);
@ -420,7 +420,7 @@ int main(int argc, char** argv)
/* Relative to Workspace, Build/Products */
/* Debug or Release */
ctaocrypt_test(&server_args);
wolfcrypt_test(&server_args);
if (server_args.return_code != 0) return server_args.return_code;
printf("\nAll tests passed!\n");

View File

@ -42,7 +42,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../"
PreprocessorDefinitions="NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;NO_PSK"
PreprocessorDefinitions="NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -117,7 +117,7 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../"
PreprocessorDefinitions="NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;NO_PSK"
PreprocessorDefinitions="NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
@ -191,7 +191,7 @@
>
</File>
<File
RelativePath="..\ctaocrypt\test\test.c"
RelativePath="..\wolfcrypt\test\test.c"
>
</File>
<File

View File

@ -85,7 +85,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -104,7 +104,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
@ -123,7 +123,7 @@
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader />
@ -144,7 +144,7 @@
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NO_MAIN_DRIVER;CYASSL_RIPEMD;CYASSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NO_MAIN_DRIVER;WOLFSSL_RIPEMD;WOLFSSL_SHA512;OPENSSL_EXTRA;NO_PSK;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
@ -165,11 +165,11 @@
<ClCompile Include="..\examples\echoclient\echoclient.c" />
<ClCompile Include="..\examples\echoserver\echoserver.c" />
<ClCompile Include="..\examples\server\server.c" />
<ClCompile Include="..\ctaocrypt\test\test.c" />
<ClCompile Include="..\wolfcrypt\test\test.c" />
<ClCompile Include="testsuite.c" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\cyassl.vcxproj">
<ProjectReference Include="..\wolfssl.vcxproj">
<Project>{73973223-5ee8-41ca-8e88-1d60e89a237b}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>

View File

@ -19,18 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* CTaoCrypt benchmark */
/* wolfCrypt benchmark */
/* wolfssl_cyassl compatibility layer */
#include <cyassl/ssl.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <string.h>
@ -41,6 +37,7 @@
#include <stdio.h>
#endif
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/des3.h>
#include <wolfssl/wolfcrypt/arc4.h>
#include <wolfssl/wolfcrypt/hc128.h>
@ -68,18 +65,18 @@
#include "ntru_crypto.h"
#endif
#if defined(CYASSL_MDK_ARM)
extern FILE * CyaSSL_fopen(const char *fname, const char *mode) ;
#define fopen CyaSSL_fopen
#if defined(WOLFSSL_MDK_ARM)
extern FILE * wolfSSL_fopen(const char *fname, const char *mode) ;
#define fopen wolfSSL_fopen
#endif
#if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048)
/* include test cert and key buffers for use with NO_FILESYSTEM */
#if defined(CYASSL_MDK_ARM)
#if defined(WOLFSSL_MDK_ARM)
#include "cert_data.h" /* use certs_test.c for initial data,
so other commands can share the data. */
#else
#include <cyassl/certs_test.h>
#include <wolfssl/certs_test.h>
#endif
#endif
@ -152,8 +149,8 @@ static int OpenNitroxDevice(int dma_mode,int dev_id)
#endif
#if defined(DEBUG_CYASSL) && !defined(HAVE_VALGRIND)
CYASSL_API int CyaSSL_Debugging_ON();
#if defined(DEBUG_WOLfSSL) && !defined(HAVE_VALGRIND)
WOLFSSL_API int wolfSSL_Debugging_ON();
#endif
/* so embedded projects can pull in tests on their own */
@ -169,8 +166,8 @@ int benchmark_test(void *args)
{
#endif
#if defined(DEBUG_CYASSL) && !defined(HAVE_VALGRIND)
CyaSSL_Debugging_ON();
#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND)
wolfSSL_Debugging_ON();
#endif
#ifdef HAVE_CAVIUM
@ -188,7 +185,7 @@ int benchmark_test(void *args)
bench_aesgcm();
#endif
#ifdef CYASSL_AES_COUNTER
#ifdef WOLFSSL_AES_COUNTER
bench_aesctr();
#endif
@ -228,13 +225,13 @@ int benchmark_test(void *args)
#ifndef NO_SHA256
bench_sha256();
#endif
#ifdef CYASSL_SHA384
#ifdef WOLFSSL_SHA384
bench_sha384();
#endif
#ifdef CYASSL_SHA512
#ifdef WOLFSSL_SHA512
bench_sha512();
#endif
#ifdef CYASSL_RIPEMD
#ifdef WOLFSSL_RIPEMD
bench_ripemd();
#endif
#ifdef HAVE_BLAKE2
@ -255,7 +252,7 @@ int benchmark_test(void *args)
bench_dh();
#endif
#if defined(CYASSL_KEY_GEN) && !defined(NO_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
bench_rsaKeyGen();
#endif
@ -335,13 +332,13 @@ void bench_aes(int show)
int ret;
#ifdef HAVE_CAVIUM
if (AesInitCavium(&enc, CAVIUM_DEV_ID) != 0) {
if (wc_AesInitCavium(&enc, CAVIUM_DEV_ID) != 0) {
printf("aes init cavium failed\n");
return;
}
#endif
ret = AesSetKey(&enc, key, 16, iv, AES_ENCRYPTION);
ret = wc_AesSetKey(&enc, key, 16, iv, AES_ENCRYPTION);
if (ret != 0) {
printf("AesSetKey failed, ret = %d\n", ret);
return;
@ -349,7 +346,7 @@ void bench_aes(int show)
start = current_time(1);
for(i = 0; i < numBlocks; i++)
AesCbcEncrypt(&enc, plain, cipher, sizeof(plain));
wc_AesCbcEncrypt(&enc, plain, cipher, sizeof(plain));
total = current_time(0) - start;
@ -363,7 +360,7 @@ void bench_aes(int show)
printf("AES %d %s took %5.3f seconds, %7.3f MB/s\n", numBlocks,
blockType, total, persec);
#ifdef HAVE_CAVIUM
AesFreeCavium(&enc);
wc_AesFreeCavium(&enc);
#endif
}
#endif
@ -382,11 +379,11 @@ void bench_aesgcm(void)
double start, total, persec;
int i;
AesGcmSetKey(&enc, key, 16);
wc_AesGcmSetKey(&enc, key, 16);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
AesGcmEncrypt(&enc, cipher, plain, sizeof(plain), iv, 12,
wc_AesGcmEncrypt(&enc, cipher, plain, sizeof(plain), iv, 12,
tag, 16, additional, 13);
total = current_time(0) - start;
@ -402,18 +399,18 @@ void bench_aesgcm(void)
}
#endif
#ifdef CYASSL_AES_COUNTER
#ifdef WOLFSSL_AES_COUNTER
void bench_aesctr(void)
{
Aes enc;
double start, total, persec;
int i;
AesSetKeyDirect(&enc, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
wc_AesSetKeyDirect(&enc, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
AesCtrEncrypt(&enc, plain, cipher, sizeof(plain));
wc_AesCtrEncrypt(&enc, plain, cipher, sizeof(plain));
total = current_time(0) - start;
@ -437,11 +434,11 @@ void bench_aesccm(void)
double start, total, persec;
int i;
AesCcmSetKey(&enc, key, 16);
wc_AesCcmSetKey(&enc, key, 16);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
AesCcmEncrypt(&enc, cipher, plain, sizeof(plain), iv, 12,
wc_AesCcmEncrypt(&enc, cipher, plain, sizeof(plain), iv, 12,
tag, 16, additional, 13);
total = current_time(0) - start;
@ -468,7 +465,7 @@ void bench_poly1305()
int ret;
ret = Poly1305SetKey(&enc, key, 32);
ret = wc_Poly1305SetKey(&enc, key, 32);
if (ret != 0) {
printf("Poly1305SetKey failed, ret = %d\n", ret);
return;
@ -476,9 +473,9 @@ void bench_poly1305()
start = current_time(1);
for(i = 0; i < numBlocks; i++)
Poly1305Update(&enc, plain, sizeof(plain));
wc_Poly1305Update(&enc, plain, sizeof(plain));
Poly1305Final(&enc, mac);
wc_Poly1305Final(&enc, mac);
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -500,7 +497,7 @@ void bench_camellia(void)
double start, total, persec;
int i, ret;
ret = CamelliaSetKey(&cam, key, 16, iv);
ret = wc_CamelliaSetKey(&cam, key, 16, iv);
if (ret != 0) {
printf("CamelliaSetKey failed, ret = %d\n", ret);
return;
@ -508,7 +505,7 @@ void bench_camellia(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++)
CamelliaCbcEncrypt(&cam, plain, cipher, sizeof(plain));
wc_CamelliaCbcEncrypt(&cam, plain, cipher, sizeof(plain));
total = current_time(0) - start;
@ -532,10 +529,10 @@ void bench_des(void)
int i, ret;
#ifdef HAVE_CAVIUM
if (Des3_InitCavium(&enc, CAVIUM_DEV_ID) != 0)
if (wc_Des3_InitCavium(&enc, CAVIUM_DEV_ID) != 0)
printf("des3 init cavium failed\n");
#endif
ret = Des3_SetKey(&enc, key, iv, DES_ENCRYPTION);
ret = wc_Des3_SetKey(&enc, key, iv, DES_ENCRYPTION);
if (ret != 0) {
printf("Des3_SetKey failed, ret = %d\n", ret);
return;
@ -543,7 +540,7 @@ void bench_des(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++)
Des3_CbcEncrypt(&enc, plain, cipher, sizeof(plain));
wc_Des3_CbcEncrypt(&enc, plain, cipher, sizeof(plain));
total = current_time(0) - start;
@ -556,7 +553,7 @@ void bench_des(void)
printf("3DES %d %s took %5.3f seconds, %7.3f MB/s\n", numBlocks,
blockType, total, persec);
#ifdef HAVE_CAVIUM
Des3_FreeCavium(&enc);
wc_Des3_FreeCavium(&enc);
#endif
}
#endif
@ -603,11 +600,11 @@ void bench_hc128(void)
double start, total, persec;
int i;
Hc128_SetKey(&enc, key, iv);
wc_Hc128_SetKey(&enc, key, iv);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
Hc128_Process(&enc, cipher, plain, sizeof(plain));
wc_Hc128_Process(&enc, cipher, plain, sizeof(plain));
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -629,11 +626,11 @@ void bench_rabbit(void)
double start, total, persec;
int i;
RabbitSetKey(&enc, key, iv);
wc_RabbitSetKey(&enc, key, iv);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
RabbitProcess(&enc, cipher, plain, sizeof(plain));
wc_RabbitProcess(&enc, cipher, plain, sizeof(plain));
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -655,12 +652,12 @@ void bench_chacha(void)
double start, total, persec;
int i;
Chacha_SetKey(&enc, key, 16);
wc_Chacha_SetKey(&enc, key, 16);
start = current_time(1);
for (i = 0; i < numBlocks; i++) {
Chacha_SetIV(&enc, iv, 0);
Chacha_Process(&enc, cipher, plain, sizeof(plain));
wc_Chacha_SetIV(&enc, iv, 0);
wc_Chacha_Process(&enc, cipher, plain, sizeof(plain));
}
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -683,13 +680,13 @@ void bench_md5(void)
double start, total, persec;
int i;
InitMd5(&hash);
wc_InitMd5(&hash);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
Md5Update(&hash, plain, sizeof(plain));
wc_Md5Update(&hash, plain, sizeof(plain));
Md5Final(&hash, digest);
wc_Md5Final(&hash, digest);
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -712,7 +709,7 @@ void bench_sha(void)
double start, total, persec;
int i, ret;
ret = InitSha(&hash);
ret = wc_InitSha(&hash);
if (ret != 0) {
printf("InitSha failed, ret = %d\n", ret);
return;
@ -720,9 +717,9 @@ void bench_sha(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++)
ShaUpdate(&hash, plain, sizeof(plain));
wc_ShaUpdate(&hash, plain, sizeof(plain));
ShaFinal(&hash, digest);
wc_ShaFinal(&hash, digest);
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -745,7 +742,7 @@ void bench_sha256(void)
double start, total, persec;
int i, ret;
ret = InitSha256(&hash);
ret = wc_InitSha256(&hash);
if (ret != 0) {
printf("InitSha256 failed, ret = %d\n", ret);
return;
@ -753,14 +750,14 @@ void bench_sha256(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++) {
ret = Sha256Update(&hash, plain, sizeof(plain));
ret = wc_Sha256Update(&hash, plain, sizeof(plain));
if (ret != 0) {
printf("Sha256Update failed, ret = %d\n", ret);
return;
}
}
ret = Sha256Final(&hash, digest);
ret = wc_Sha256Final(&hash, digest);
if (ret != 0) {
printf("Sha256Final failed, ret = %d\n", ret);
return;
@ -778,7 +775,7 @@ void bench_sha256(void)
}
#endif
#ifdef CYASSL_SHA384
#ifdef WOLFSSL_SHA384
void bench_sha384(void)
{
Sha384 hash;
@ -786,7 +783,7 @@ void bench_sha384(void)
double start, total, persec;
int i, ret;
ret = InitSha384(&hash);
ret = wc_InitSha384(&hash);
if (ret != 0) {
printf("InitSha384 failed, ret = %d\n", ret);
return;
@ -794,14 +791,14 @@ void bench_sha384(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++) {
ret = Sha384Update(&hash, plain, sizeof(plain));
ret = wc_Sha384Update(&hash, plain, sizeof(plain));
if (ret != 0) {
printf("Sha384Update failed, ret = %d\n", ret);
return;
}
}
ret = Sha384Final(&hash, digest);
ret = wc_Sha384Final(&hash, digest);
if (ret != 0) {
printf("Sha384Final failed, ret = %d\n", ret);
return;
@ -819,7 +816,7 @@ void bench_sha384(void)
}
#endif
#ifdef CYASSL_SHA512
#ifdef WOLFSSL_SHA512
void bench_sha512(void)
{
Sha512 hash;
@ -827,7 +824,7 @@ void bench_sha512(void)
double start, total, persec;
int i, ret;
ret = InitSha512(&hash);
ret = wc_InitSha512(&hash);
if (ret != 0) {
printf("InitSha512 failed, ret = %d\n", ret);
return;
@ -835,14 +832,14 @@ void bench_sha512(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++) {
ret = Sha512Update(&hash, plain, sizeof(plain));
ret = wc_Sha512Update(&hash, plain, sizeof(plain));
if (ret != 0) {
printf("Sha512Update failed, ret = %d\n", ret);
return;
}
}
ret = Sha512Final(&hash, digest);
ret = wc_Sha512Final(&hash, digest);
if (ret != 0) {
printf("Sha512Final failed, ret = %d\n", ret);
return;
@ -860,7 +857,7 @@ void bench_sha512(void)
}
#endif
#ifdef CYASSL_RIPEMD
#ifdef WOLFSSL_RIPEMD
void bench_ripemd(void)
{
RipeMd hash;
@ -868,13 +865,13 @@ void bench_ripemd(void)
double start, total, persec;
int i;
InitRipeMd(&hash);
wc_InitRipeMd(&hash);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
RipeMdUpdate(&hash, plain, sizeof(plain));
wc_RipeMdUpdate(&hash, plain, sizeof(plain));
RipeMdFinal(&hash, digest);
wc_RipeMdFinal(&hash, digest);
total = current_time(0) - start;
persec = 1 / total * numBlocks;
@ -897,7 +894,7 @@ void bench_blake2(void)
double start, total, persec;
int i, ret;
ret = InitBlake2b(&b2b, 64);
ret = wc_InitBlake2b(&b2b, 64);
if (ret != 0) {
printf("InitBlake2b failed, ret = %d\n", ret);
return;
@ -905,14 +902,14 @@ void bench_blake2(void)
start = current_time(1);
for(i = 0; i < numBlocks; i++) {
ret = Blake2bUpdate(&b2b, plain, sizeof(plain));
ret = wc_Blake2bUpdate(&b2b, plain, sizeof(plain));
if (ret != 0) {
printf("Blake2bUpdate failed, ret = %d\n", ret);
return;
}
}
ret = Blake2bFinal(&b2b, digest, 64);
ret = wc_Blake2bFinal(&b2b, digest, 64);
if (ret != 0) {
printf("Blake2bFinal failed, ret = %d\n", ret);
return;
@ -932,7 +929,7 @@ void bench_blake2(void)
#if !defined(NO_RSA) || !defined(NO_DH) \
|| defined(CYASSL_KEYGEN) || defined(HAVE_ECC)
|| defined(WOLFSSL_KEYGEN) || defined(HAVE_ECC)
static RNG rng;
#endif
@ -940,7 +937,7 @@ static RNG rng;
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
#if defined(CYASSL_MDK_SHELL)
#if defined(WOLFSSL_MDK_SHELL)
static char *certRSAname = "certs/rsa2048.der";
/* set by shell command */
static void set_Bench_RSA_File(char * cert) { certRSAname = cert ; }
@ -988,25 +985,25 @@ void bench_rsa(void)
#ifdef HAVE_CAVIUM
if (RsaInitCavium(&rsaKey, CAVIUM_DEV_ID) != 0)
if (wc_RsaInitCavium(&rsaKey, CAVIUM_DEV_ID) != 0)
printf("RSA init cavium failed\n");
#endif
ret = InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret < 0) {
printf("InitRNG failed\n");
return;
}
ret = InitRsaKey(&rsaKey, 0);
ret = wc_InitRsaKey(&rsaKey, 0);
if (ret < 0) {
printf("InitRsaKey failed\n");
return;
}
ret = RsaPrivateKeyDecode(tmp, &idx, &rsaKey, (word32)bytes);
ret = wc_RsaPrivateKeyDecode(tmp, &idx, &rsaKey, (word32)bytes);
start = current_time(1);
for (i = 0; i < ntimes; i++)
ret = RsaPublicEncrypt(message,len,enc,sizeof(enc), &rsaKey, &rng);
ret = wc_RsaPublicEncrypt(message,len,enc,sizeof(enc), &rsaKey, &rng);
total = current_time(0) - start;
each = total / ntimes; /* per second */
@ -1024,7 +1021,7 @@ void bench_rsa(void)
for (i = 0; i < ntimes; i++) {
byte out[512]; /* for up to 4096 bit */
RsaPrivateDecrypt(enc, (word32)ret, out, sizeof(out), &rsaKey);
wc_RsaPrivateDecrypt(enc, (word32)ret, out, sizeof(out), &rsaKey);
}
total = current_time(0) - start;
@ -1034,9 +1031,9 @@ void bench_rsa(void)
printf("RSA %d decryption took %6.3f milliseconds, avg over %d"
" iterations\n", rsaKeySz, milliEach, ntimes);
FreeRsaKey(&rsaKey);
wc_FreeRsaKey(&rsaKey);
#ifdef HAVE_CAVIUM
RsaFreeCavium(&rsaKey);
wc_RsaFreeCavium(&rsaKey);
#endif
}
#endif
@ -1046,7 +1043,7 @@ void bench_rsa(void)
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
#if defined(CYASSL_MDK_SHELL)
#if defined(WOLFSSL_MDK_SHELL)
static char *certDHname = "certs/dh2048.der";
/* set by shell command */
void set_Bench_DH_File(char * cert) { certDHname = cert ; }
@ -1093,7 +1090,7 @@ void bench_dh(void)
return;
}
ret = InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret < 0) {
printf("InitRNG failed\n");
return;
@ -1102,8 +1099,8 @@ void bench_dh(void)
#endif /* USE_CERT_BUFFERS */
InitDhKey(&dhKey);
bytes = DhKeyDecode(tmp, &idx, &dhKey, (word32)bytes);
wc_InitDhKey(&dhKey);
bytes = wc_DhKeyDecode(tmp, &idx, &dhKey, (word32)bytes);
if (bytes != 0) {
printf("dhekydecode failed, can't benchmark\n");
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
@ -1115,7 +1112,7 @@ void bench_dh(void)
start = current_time(1);
for (i = 0; i < ntimes; i++)
DhGenerateKeyPair(&dhKey, &rng, priv, &privSz, pub, &pubSz);
wc_DhGenerateKeyPair(&dhKey, &rng, priv, &privSz, pub, &pubSz);
total = current_time(0) - start;
each = total / ntimes; /* per second */
@ -1124,11 +1121,11 @@ void bench_dh(void)
printf("DH %d key generation %6.3f milliseconds, avg over %d"
" iterations\n", dhKeySz, milliEach, ntimes);
DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
wc_DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
start = current_time(1);
for (i = 0; i < ntimes; i++)
DhAgree(&dhKey, agree, &agreeSz, priv, privSz, pub2, pubSz2);
wc_DhAgree(&dhKey, agree, &agreeSz, priv, privSz, pub2, pubSz2);
total = current_time(0) - start;
each = total / ntimes; /* per second */
@ -1140,11 +1137,11 @@ void bench_dh(void)
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
fclose(file);
#endif
FreeDhKey(&dhKey);
wc_FreeDhKey(&dhKey);
}
#endif
#if defined(CYASSL_KEY_GEN) && !defined(NO_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
void bench_rsaKeyGen(void)
{
RsaKey genKey;
@ -1155,9 +1152,9 @@ void bench_rsaKeyGen(void)
start = current_time(1);
for(i = 0; i < genTimes; i++) {
InitRsaKey(&genKey, 0);
MakeRsaKey(&genKey, 1024, 65537, &rng);
FreeRsaKey(&genKey);
wc_InitRsaKey(&genKey, 0);
wc_MakeRsaKey(&genKey, 1024, 65537, &rng);
wc_FreeRsaKey(&genKey);
}
total = current_time(0) - start;
@ -1171,9 +1168,9 @@ void bench_rsaKeyGen(void)
start = current_time(1);
for(i = 0; i < genTimes; i++) {
InitRsaKey(&genKey, 0);
MakeRsaKey(&genKey, 2048, 65537, &rng);
FreeRsaKey(&genKey);
wc_InitRsaKey(&genKey, 0);
wc_MakeRsaKey(&genKey, 2048, 65537, &rng);
wc_FreeRsaKey(&genKey);
}
total = current_time(0) - start;
@ -1182,7 +1179,7 @@ void bench_rsaKeyGen(void)
printf("RSA 2048 key generation %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, genTimes);
}
#endif /* CYASSL_KEY_GEN */
#endif /* WOLFSSL_KEY_GEN */
#ifdef HAVE_NTRU
byte GetEntropy(ENTROPY_CMD cmd, byte* out);
@ -1385,7 +1382,7 @@ void bench_eccKeyGen(void)
double start, total, each, milliEach;
int i, ret;
ret = InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret < 0) {
printf("InitRNG failed\n");
return;
@ -1394,8 +1391,8 @@ void bench_eccKeyGen(void)
start = current_time(1);
for(i = 0; i < genTimes; i++) {
ecc_make_key(&rng, 32, &genKey);
ecc_free(&genKey);
wc_ecc_make_key(&rng, 32, &genKey);
wc_ecc_free(&genKey);
}
total = current_time(0) - start;
@ -1417,21 +1414,21 @@ void bench_eccKeyAgree(void)
byte digest[32];
word32 x = 0;
ecc_init(&genKey);
ecc_init(&genKey2);
wc_ecc_init(&genKey);
wc_ecc_init(&genKey2);
ret = InitRng(&rng);
ret = wc_InitRng(&rng);
if (ret < 0) {
printf("InitRNG failed\n");
return;
}
ret = ecc_make_key(&rng, 32, &genKey);
ret = wc_ecc_make_key(&rng, 32, &genKey);
if (ret != 0) {
printf("ecc_make_key failed\n");
return;
}
ret = ecc_make_key(&rng, 32, &genKey2);
ret = wc_ecc_make_key(&rng, 32, &genKey2);
if (ret != 0) {
printf("ecc_make_key failed\n");
return;
@ -1442,7 +1439,7 @@ void bench_eccKeyAgree(void)
for(i = 0; i < agreeTimes; i++) {
x = sizeof(shared);
ret = ecc_shared_secret(&genKey, &genKey2, shared, &x);
ret = wc_ecc_shared_secret(&genKey, &genKey2, shared, &x);
if (ret != 0) {
printf("ecc_shared_secret failed\n");
return;
@ -1464,7 +1461,7 @@ void bench_eccKeyAgree(void)
for(i = 0; i < agreeTimes; i++) {
x = sizeof(sig);
ret = ecc_sign_hash(digest, sizeof(digest), sig, &x, &rng, &genKey);
ret = wc_ecc_sign_hash(digest, sizeof(digest), sig, &x, &rng, &genKey);
if (ret != 0) {
printf("ecc_sign_hash failed\n");
return;
@ -1481,7 +1478,7 @@ void bench_eccKeyAgree(void)
for(i = 0; i < agreeTimes; i++) {
int verify = 0;
ret = ecc_verify_hash(sig, x, digest, sizeof(digest), &verify, &genKey);
ret = wc_ecc_verify_hash(sig, x, digest, sizeof(digest), &verify, &genKey);
if (ret != 0) {
printf("ecc_verify_hash failed\n");
return;
@ -1494,8 +1491,8 @@ void bench_eccKeyAgree(void)
printf("EC-DSA verify time %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, agreeTimes);
ecc_free(&genKey2);
ecc_free(&genKey);
wc_ecc_free(&genKey2);
wc_ecc_free(&genKey);
}
#endif /* HAVE_ECC */

View File

@ -181,7 +181,6 @@ void wc_AesFreeCavium(Aes* aes)
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
int wc_AesSetKey_fips(Aes* aes, const byte* key, word32 len,
const byte* iv, int dir)
{
@ -233,17 +232,6 @@ void wc_AesFreeCavium(Aes* aes)
return AesGcmDecrypt_fips(aes, out, in, sz, iv, ivSz,
authTag, authTagSz, authIn, authInSz);
}
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define AesSetKey AesSetKey_fips
#define AesSetIV AesSetIV_fips
#define AesCbcEncrypt AesCbcEncrypt_fips
#define AesCbcDecrypt AesCbcDecrypt_fips
#define AesGcmSetKey AesGcmSetKey_fips
#define AesGcmEncrypt AesGcmEncrypt_fips
#define AesGcmDecrypt AesGcmDecrypt_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */

169
wolfcrypt/src/compress.c Normal file
View File

@ -0,0 +1,169 @@
/* compress.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
wc_*
* wolfSSL 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.
*
* wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#ifdef HAVE_LIBZ
#include <wolfssl/wolfcrypt/compress.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
#else
#include <wolfcrypt/src/misc.c>
#endif
#include <zlib.h>
/* alloc user allocs to work with zlib */
static void* myAlloc(void* opaque, unsigned int item, unsigned int size)
{
(void)opaque;
return XMALLOC(item * size, opaque, DYNAMIC_TYPE_LIBZ);
}
static void myFree(void* opaque, void* memory)
{
(void)opaque;
XFREE(memory, opaque, DYNAMIC_TYPE_LIBZ);
}
#ifdef HAVE_MCAPI
#define DEFLATE_DEFAULT_WINDOWBITS 11
#define DEFLATE_DEFAULT_MEMLEVEL 1
#else
#define DEFLATE_DEFAULT_WINDOWBITS 15
#define DEFLATE_DEFAULT_MEMLEVEL 8
#endif
int wc_Compress(byte* out, word32 outSz, const byte* in, word32 inSz, word32 flags)
/*
* out - pointer to destination buffer
* outSz - size of destination buffer
* in - pointer to source buffer to compress
* inSz - size of source to compress
* flags - flags to control how compress operates
*
* return:
* negative - error code
* positive - bytes stored in out buffer
*
* Note, the output buffer still needs to be larger than the input buffer.
* The right chunk of data won't compress at all, and the lookup table will
* add to the size of the output. The libz code says the compressed
* buffer should be srcSz + 0.1% + 12.
*/
{
z_stream stream;
int result = 0;
stream.next_in = (Bytef*)in;
stream.avail_in = (uInt)inSz;
#ifdef MAXSEG_64K
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != inSz) return COMPRESS_INIT_E;
#endif
stream.next_out = out;
stream.avail_out = (uInt)outSz;
if ((uLong)stream.avail_out != outSz) return COMPRESS_INIT_E;
stream.zalloc = (alloc_func)myAlloc;
stream.zfree = (free_func)myFree;
stream.opaque = (voidpf)0;
if (deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
DEFLATE_DEFAULT_WINDOWBITS, DEFLATE_DEFAULT_MEMLEVEL,
flags ? Z_FIXED : Z_DEFAULT_STRATEGY) != Z_OK)
return COMPRESS_INIT_E;
if (deflate(&stream, Z_FINISH) != Z_STREAM_END) {
deflateEnd(&stream);
return COMPRESS_E;
}
result = (int)stream.total_out;
if (deflateEnd(&stream) != Z_OK)
result = COMPRESS_E;
return result;
}
int wc_DeCompress(byte* out, word32 outSz, const byte* in, word32 inSz)
/*
* out - pointer to destination buffer
* outSz - size of destination buffer
* in - pointer to source buffer to compress
* inSz - size of source to compress
* flags - flags to control how compress operates
*
* return:
* negative - error code
* positive - bytes stored in out buffer
*/
{
z_stream stream;
int result = 0;
stream.next_in = (Bytef*)in;
stream.avail_in = (uInt)inSz;
/* Check for source > 64K on 16-bit machine: */
if ((uLong)stream.avail_in != inSz) return DECOMPRESS_INIT_E;
stream.next_out = out;
stream.avail_out = (uInt)outSz;
if ((uLong)stream.avail_out != outSz) return DECOMPRESS_INIT_E;
stream.zalloc = (alloc_func)myAlloc;
stream.zfree = (free_func)myFree;
stream.opaque = (voidpf)0;
if (inflateInit2(&stream, DEFLATE_DEFAULT_WINDOWBITS) != Z_OK)
return DECOMPRESS_INIT_E;
if (inflate(&stream, Z_FINISH) != Z_STREAM_END) {
inflateEnd(&stream);
return DECOMPRESS_E;
}
result = (int)stream.total_out;
if (inflateEnd(&stream) != Z_OK)
result = DECOMPRESS_E;
return result;
}
#endif /* HAVE_LIBZ */

View File

@ -23,12 +23,12 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifndef NO_DH
#include <cyassl/ctaocrypt/dh.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/dh.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifndef USER_MATH_LIB
#include <math.h>
@ -139,7 +139,7 @@ int wc_DhGenerateKeyPair(DhKey* key, RNG* rng, byte* priv, word32* privSz,
return (ret != 0) ? ret : GeneratePublic(key, priv, *privSz, pub, pubSz);
}
int DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz, const byte* priv,
word32 privSz, const byte* otherPub, word32 pubSz)
{
int ret = 0;

View File

@ -23,19 +23,19 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
/* submitted by eof */
#include <cyassl/ctaocrypt/logging.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef __cplusplus
extern "C" {
#endif
CYASSL_API int CyaSSL_Debugging_ON(void);
CYASSL_API void CyaSSL_Debugging_OFF(void);
WOLFSSL_API int wolfSSL_Debugging_ON(void);
WOLFSSL_API void wolfSSL_Debugging_OFF(void);
#ifdef __cplusplus
}
#endif
@ -44,13 +44,13 @@
#ifdef DEBUG_CYASSL
/* Set these to default values initially. */
static CyaSSL_Logging_cb log_function = 0;
static wolfSSL_Logging_cb log_function = 0;
static int loggingEnabled = 0;
#endif /* DEBUG_CYASSL */
int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb f)
int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
{
#ifdef DEBUG_CYASSL
int res = 0;
@ -68,7 +68,7 @@ int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb f)
}
int CyaSSL_Debugging_ON(void)
int wolfSSL_Debugging_ON(void)
{
#ifdef DEBUG_CYASSL
loggingEnabled = 1;
@ -79,7 +79,7 @@ int CyaSSL_Debugging_ON(void)
}
void CyaSSL_Debugging_OFF(void)
void wolfSSL_Debugging_OFF(void)
{
#ifdef DEBUG_CYASSL
loggingEnabled = 0;
@ -123,40 +123,40 @@ static void cyassl_log(const int logLevel, const char *const logMessage)
}
void CYASSL_MSG(const char* msg)
void WOLFSSL_MSG(const char* msg)
{
if (loggingEnabled)
cyassl_log(INFO_LOG , msg);
}
void CYASSL_ENTER(const char* msg)
void WOLFSSL_ENTER(const char* msg)
{
if (loggingEnabled) {
char buffer[80];
sprintf(buffer, "CyaSSL Entering %s", msg);
sprintf(buffer, "wolfSSL Entering %s", msg);
cyassl_log(ENTER_LOG , buffer);
}
}
void CYASSL_LEAVE(const char* msg, int ret)
void WOLFSSL_LEAVE(const char* msg, int ret)
{
if (loggingEnabled) {
char buffer[80];
sprintf(buffer, "CyaSSL Leaving %s, return %d", msg, ret);
sprintf(buffer, "wolfSSL Leaving %s, return %d", msg, ret);
cyassl_log(LEAVE_LOG , buffer);
}
}
void CYASSL_ERROR(int error)
void WOLFSSL_ERROR(int error)
{
if (loggingEnabled) {
char buffer[80];
sprintf(buffer, "CyaSSL error occured, error = %d", error);
sprintf(buffer, "wolfSSL error occured, error = %d", error);
cyassl_log(ERROR_LOG , buffer);
}
}
#endif /* DEBUG_CYASSL */
#endif /* DEBUG_WOLFSSL */

View File

@ -26,8 +26,7 @@
#include <wolfssl/wolfcrypt/settings.h>
//#ifdef WOLFSSL_MD2
//@TODO
#ifdef WOLFSSL_MD2
#include <wolfssl/wolfcrypt/md2.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
@ -157,5 +156,5 @@ int wc_Md2Hash(const byte* data, word32 len, byte* hash)
}
//@TODO
//#endif /* WOLFSSL_MD2 */
#endif /* WOLFSSL_MD2 */

View File

@ -23,15 +23,15 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifndef NO_MD4
#include <cyassl/ctaocrypt/md4.h>
#include <wolfssl/wolfcrypt/md4.h>
#ifdef NO_INLINE
#include <cyassl/ctaocrypt/misc.h>
#include <wolfssl/wolfcrypt/misc.h>
#else
#include <ctaocrypt/src/misc.c>
#include <wolfcrypt/src/misc.c>
#endif

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -25,8 +25,15 @@
#include <wolfssl/wolfcrypt/settings.h>
//#ifdef USE_WOLFSSL_MEMORY
//@TODO
/* check old macros @wc_fips */
#if defined(USE_CYASSL_MEMORY) && !defined(USE_WOLFSSL_MEMORY)
#define USE_WOLFSSL_MEMORY
#endif
#if defined(CYASSL_MALLOC_CHECK) && !defined(WOLFSSL_MALLOC_CHECK)
#define WOLFSSL_MALLOC_CHECK
#endif
#ifdef USE_WOLFSSL_MEMORY
#include <wolfssl/wolfcrypt/memory.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
@ -102,7 +109,7 @@ void* wolfSSL_Realloc(void *ptr, size_t size)
return res;
}
//#endif /* USE_WOLFSSL_MEMORY */
#endif /* USE_WOLFSSL_MEMORY */
#ifdef HAVE_IO_POOL

View File

@ -23,13 +23,13 @@
#include <config.h>
#endif
#include <cyassl/ctaocrypt/settings.h>
#include <wolfssl/wolfcrypt/settings.h>
#ifdef HAVE_PKCS7
#include <cyassl/ctaocrypt/pkcs7.h>
#include <cyassl/ctaocrypt/error-crypt.h>
#include <cyassl/ctaocrypt/logging.h>
#include <wolfssl/wolfcrypt/pkcs7.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#include <wolfssl/wolfcrypt/logging.h>
#ifndef min
static INLINE word32 min(word32 a, word32 b)
@ -41,7 +41,7 @@
/* placed ASN.1 contentType OID into *output, return idx on success,
* 0 upon failure */
WOLFSSL_LOCAL int wc_setContentType(int pkcs7TypeOID, byte* output)
WOLFSSL_LOCAL int wc_SetContentType(int pkcs7TypeOID, byte* output)
{
/* PKCS#7 content types, RFC 2315, section 14 */
static const byte pkcs7[] = { 0x2A, 0x86, 0x48, 0x86, 0xF7,
@ -147,7 +147,7 @@ int wc_GetContentType(const byte* input, word32* inOutIdx, word32* oid,
/* init PKCS7 struct with recipient cert, decode into DecodedCert */
int wc_PKS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz)
int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz)
{
int ret = 0;
@ -789,7 +789,7 @@ int wc_PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz)
cert = &pkiMsg[idx];
certSz += (certIdx - idx);
}
wc_PKS7_InitWithCert(pkcs7, cert, certSz);
wc_PKCS7_InitWithCert(pkcs7, cert, certSz);
}
idx += length;
}
@ -1222,7 +1222,7 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz)
};
/* outer content type */
outerContentTypeSz = wc_setContentType(ENVELOPED_DATA, outerContentType);
outerContentTypeSz = wc_SetContentType(ENVELOPED_DATA, outerContentType);
/* version, defined as 0 in RFC 2315 */
verSz = SetMyVersion(0, ver, 0);
@ -1279,7 +1279,7 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz)
}
/* EncryptedContentInfo */
contentTypeSz = wc_setContentType(pkcs7->contentOID, contentType);
contentTypeSz = wc_SetContentType(pkcs7->contentOID, contentType);
if (contentTypeSz == 0) {
#ifdef WOLFSSL_SMALL_STACK
XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER);

View File

@ -183,7 +183,7 @@ int wc_RsaFlattenPublicKey(RsaKey* key, byte* a, word32* aSz, byte* b,
}
int wc_ RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
int wc_RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, RNG* rng)
{
return RsaSSL_Sign_fips(in, inLen, out, outLen, key, rng);

View File

@ -0,0 +1,88 @@
/* sha.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#if !defined(NO_SHA)
#ifdef HAVE_FIPS
/* set NO_WRAPPERS before headers, use direct internal f()s not wrappers */
#define FIPS_NO_WRAPPERS
#endif
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/logging.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef NO_INLINE
#include <wolfssl/wolfcrypt/misc.h>
#else
#include <wolfcrypt/src/misc.c>
#endif
int wc_InitSha(Sha* sha)
{
return InitSha(sha);
}
int wc_ShaUpdate(Sha* sha, const byte* data, word32 len)
{
return ShaUpdate(sha, data, len);
}
int wc_ShaFinal(Sha* sha, byte* hash)
{
return ShaFinal(sha, hash);
}
int wc_ShaHash(const byte* data, word32 len, byte* hash)
{
return ShaHash(data, len, hash);
}
/* fips wrapper calls, user can call direct */
#ifdef HAVE_FIPS
int wc_InitSha_fips(Sha* sha)
{
return InitSha_fips(sha);
}
int wc_ShaUpdate_fips(Sha* sha, const byte* data, word32 len)
{
return ShaUpdate_fips(sha, data, len);
}
int wc_ShaFinal_fips(Sha* sha, byte* out)
{
return ShaFinal_fips(sha,out);
}
#endif /* HAVE_FIPS */
#endif /* NO_SHA */

View File

@ -0,0 +1,58 @@
/* sha256.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL 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.
*
* wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* code submitted by raphael.huck@efixo.com */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/sha256.h>
#if !defined(NO_SHA256)
int wc_InitSha256(Sha256* sha)
{
return InitSha256(sha);
}
int wc_Sha256Update(Sha256* sha, const byte* data, word32 len)
{
return Sha256Update(sha, data, len);
}
int wc_Sha256Final(Sha256* sha, byte* out)
{
return Sha256Final(sha, out);
}
int wc_Sha256Hash(const byte* data, word32 len, byte* out)
{
return Sha256Hash(data, len, out);
}
#endif

90
wolfcrypt/src/sha512.c Normal file
View File

@ -0,0 +1,90 @@
/* sha512.c
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* wolfSSL 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.
*
* wolfSSL 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/sha512.h>
#ifdef WOLFSSL_SHA512
#ifdef __cplusplus
extern "C" {
#endif
int wc_InitSha512(Sha512* sha)
{
return InitSha512(sha);
}
int wc_Sha512Update(Sha512* sha, const byte* data, word32 len)
{
return Sha512Update(sha, data, len);
}
int wc_Sha512Final(Sha512* sha, byte* out)
{
return Sha512Final(sha, out);
}
int wc_Sha512Hash(const byte* data, word32 len, byte* out)
{
return Sha512Hash(data, len, out);
}
#if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM)
int wc_InitSha384(Sha384* sha)
{
return InitSha384(sha);
}
int wc_Sha384Update(Sha384* sha, const byte* data, word32 len)
{
return Sha384Update(sha, data, len);
}
int wc_Sha384Final(Sha384* sha, byte* out)
{
return Sha384Final(sha, out);
}
int wc_Sha384Hash(const byte* data, word32 len, byte* out)
{
return Sha384Hash(data, len, out);
}
#endif /* WOLFSSL_SHA384 */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* WOLFSSL_SHA512 */

View File

@ -1,11 +0,0 @@
# vim:ft=automake
# All paths should be given relative to the root
noinst_PROGRAMS+= wolfcrypt/test/testwolfcrypt
wolfcrypt_test_testwolfcrypt_SOURCES = wolfcrypt/test/test.c
wolfcrypt_test_testwolfcrypt_LDADD = src/libcyassl.la
wolfcrypt_test_testwolfcrypt_DEPENDENCIES = src/libcyassl.la
noinst_HEADERS += wolfcrypt/test/test.h
EXTRA_DIST += wolfcrypt/test/test.sln
EXTRA_DIST += wolfcrypt/test/test.vcproj
DISTCLEANFILES+= wolfcrypt/test/.libs/testwolfcrypt

File diff suppressed because it is too large Load Diff

View File

@ -106,16 +106,16 @@
word32 sz, const byte* iv, word32 ivSz,
const byte* authTag, word32 authTagSz,
const byte* authIn, word32 authInSz);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define AesSetKey AesSetKey_fips
#define AesSetIV AesSetIV_fips
#define AesCbcEncrypt AesCbcEncrypt_fips
#define AesCbcDecrypt AesCbcDecrypt_fips
#define AesGcmSetKey AesGcmSetKey_fips
#define AesGcmEncrypt AesGcmEncrypt_fips
#define AesGcmDecrypt AesGcmDecrypt_fips
#endif /* FIPS_NO_WRAPPERS */
// #ifndef FIPS_NO_WRAPPERS
// /* if not impl or fips.c impl wrapper force fips calls if fips build */
// #define AesSetKey AesSetKey_fips
// #define AesSetIV AesSetIV_fips
// #define AesCbcEncrypt AesCbcEncrypt_fips
// #define AesCbcDecrypt AesCbcDecrypt_fips
// #define AesGcmSetKey AesGcmSetKey_fips
// #define AesGcmEncrypt AesGcmEncrypt_fips
// #define AesGcmDecrypt AesGcmDecrypt_fips
// #endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -21,18 +21,18 @@
#ifndef NO_ASN
#ifndef CTAO_CRYPT_ASN_H
#define CTAO_CRYPT_ASN_H
#ifndef WOLF_CRYPT_ASN_H
#define WOLF_CRYPT_ASN_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/rsa.h>
#include <cyassl/ctaocrypt/dh.h>
#include <cyassl/ctaocrypt/dsa.h>
#include <cyassl/ctaocrypt/sha.h>
#include <cyassl/ctaocrypt/md5.h>
#include <cyassl/ctaocrypt/asn_public.h> /* public interface */
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/rsa.h>
#include <wolfssl/wolfcrypt/dh.h>
#include <wolfssl/wolfcrypt/dsa.h>
#include <wolfssl/wolfcrypt/sha.h>
#include <wolfssl/wolfcrypt/md5.h>
#include <wolfssl/wolfcrypt/asn_public.h> /* public interface */
#ifdef HAVE_ECC
#include <cyassl/ctaocrypt/ecc.h>
#include <wolfssl/wolfcrypt/ecc.h>
#endif
#ifdef __cplusplus

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -22,11 +22,11 @@
#ifdef HAVE_LIBZ
#ifndef CTAO_CRYPT_COMPRESS_H
#define CTAO_CRYPT_COMPRESS_H
#ifndef WOLF_CRYPT_COMPRESS_H
#define WOLF_CRYPT_COMPRESS_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
@ -37,8 +37,8 @@
#define COMPRESS_FIXED 1
CYASSL_API int Compress(byte*, word32, const byte*, word32, word32);
CYASSL_API int DeCompress(byte*, word32, const byte*, word32);
WOLFSSL_API int wc_Compress(byte*, word32, const byte*, word32, word32);
WOLFSSL_API int wc_DeCompress(byte*, word32, const byte*, word32);
#ifdef __cplusplus
@ -46,7 +46,7 @@ CYASSL_API int DeCompress(byte*, word32, const byte*, word32);
#endif
#endif /* CTAO_CRYPT_COMPRESS_H */
#endif /* WOLF_CRYPT_COMPRESS_H */
#endif /* HAVE_LIBZ */

View File

@ -29,6 +29,14 @@
#include <wolfssl/wolfcrypt/integer.h>
#include <wolfssl/wolfcrypt/random.h>
/* for DSA reverse compatibility */
#define InitDsaKey wc_InitDsaKey
#define FreeDsaKey wc_FreeDsaKey
#define DsaSign wc_DsaSign
#define DsaVerify wc_DsaVerify
#define DsaPublicKeyDecode wc_DsaPublicKeyDecode
#define DsaPrivateKeyDecode wc_DsaPrivateKeyDecode
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -23,8 +23,11 @@
#ifndef WOLF_CRYPT_ERROR_H
#define WOLF_CRYPT_ERROR_H
/* compatibility and fips @wc_fips */
#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/types.h>
#define CTaoCryptErrorString wc_CryptErrorString
#define CTaoCryptGetErrorString wc_CryptGetErrorString
#ifdef __cplusplus
extern "C" {
@ -150,7 +153,11 @@ WOLFSSL_API const char* wc_GetErrorString(int error);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_ERROR_H */
#else
#include <cyassl/ctaocrypt/error-crypt.h>
#define wc_ErrorString CTaoCryptErrorString
#define wc_GetErrorString CTaoCryptGetErrorString
#endif /* HAVE_FIPS */
#endif /* WOLF_CRYPT_ERROR_H */

View File

@ -27,9 +27,6 @@
/* for fips */
#include <cyassl/ctaocrypt/hmac.h>
#if defined(WOLFSSL_SHA512) && !defined(CYASSL_SHA512)
#define CYASSL_SHA512
#endif
#ifdef HAVE_CAVIUM

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -22,49 +22,67 @@
/* submitted by eof */
#ifndef CYASSL_LOGGING_H
#define CYASSL_LOGGING_H
#ifndef WOLFSSL_LOGGING_H
#define WOLFSSL_LOGGING_H
/* for reverse compatibility @wc_fips */
#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/types.h>
#define CYASSL_LEAVE WOLFSSL_LEAVE
#define CYASSL_ERROR WOLFSSL_ERROR
#define CYASSL_ENTER WOLFSSL_ENTER
#define CYASSL_MSG WOLFSSL_MSG
#ifdef __cplusplus
extern "C" {
/* check old macros possibly declared */
#if defined(CYASSL_DEBUG) && !defined(DEBUG_WOLFSSL)
#define DEBUG_WOLFSSL
#endif
#ifdef __cplusplus
extern "C" {
#endif
enum CYA_Log_Levels {
ERROR_LOG = 0,
INFO_LOG,
ENTER_LOG,
LEAVE_LOG,
OTHER_LOG
};
typedef void (*wolfSSL_Logging_cb)(const int logLevel,
const char *const logMessage);
WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
#ifdef DEBUG_WOLFSSL
void WOLFSSL_ENTER(const char* msg);
void WOLFSSL_LEAVE(const char* msg, int ret);
void WOLFSSL_ERROR(int);
void WOLFSSL_MSG(const char* msg);
#else /* DEBUG_WOLFSSL */
#define WOLFSSL_ENTER(m)
#define WOLFSSL_LEAVE(m, r)
#define WOLFSSL_ERROR(e)
#define WOLFSSL_MSG(m)
#endif /* DEBUG_WOLFSSL */
#ifdef __cplusplus
}
#endif
#else /* if using fips use old logging file */
#include <cyassl/ctaocrypt/logging.h>
#define WOLFSSL_LEAVE CYASSL_LEAVE
#define WOLFSSL_ERROR CYASSL_ERROR
#define WOLFSSL_ENTER CYASSL_ENTER
#define WOLFSSL_MSG CYASSL_MSG
#endif
#endif /* WOLFSSL_MEMORY_H */
enum CYA_Log_Levels {
ERROR_LOG = 0,
INFO_LOG,
ENTER_LOG,
LEAVE_LOG,
OTHER_LOG
};
typedef void (*CyaSSL_Logging_cb)(const int logLevel,
const char *const logMessage);
CYASSL_API int CyaSSL_SetLoggingCb(CyaSSL_Logging_cb log_function);
#ifdef DEBUG_CYASSL
void CYASSL_ENTER(const char* msg);
void CYASSL_LEAVE(const char* msg, int ret);
void CYASSL_ERROR(int);
void CYASSL_MSG(const char* msg);
#else /* DEBUG_CYASSL */
#define CYASSL_ENTER(m)
#define CYASSL_LEAVE(m, r)
#define CYASSL_ERROR(e)
#define CYASSL_MSG(m)
#endif /* DEBUG_CYASSL */
#ifdef __cplusplus
}
#endif
#endif /* CYASSL_MEMORY_H */

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -19,15 +19,29 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* check for old macro */
#if defined(CYASSL_MD2) && !defined(WOLFSSL_MD2)
#define WOLFSSL_MD2
#endif
//#ifdef WOLFSSL_MD2
//@TODO
#ifdef WOLFSSL_MD2
#ifndef WOLF_CRYPT_MD2_H
#define WOLF_CRYPT_MD2_H
#include <wolfssl/wolfcrypt/types.h>
/* for md2 reverse compatibility */
#ifdef WOLFSSL_MD2
#define InitMd2 wc_InitMd2
#define Md2Update wc_Md2Update
#define Md2Final wc_Md2Final
#define Md2Hash wc_Md2Hash
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -62,6 +76,6 @@ WOLFSSL_API int wc_Md2Hash(const byte*, word32, byte*);
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_MD2_H */
//@TODO
//#endif /* CYASSL_MD2 */
#endif /* WOLF_CRYPT_MD2_H */
#endif /* WOLFSSL_MD2 */

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -22,10 +22,17 @@
#ifndef NO_MD4
#ifndef CTAO_CRYPT_MD4_H
#define CTAO_CRYPT_MD4_H
#ifndef WOLF_CRYPT_MD4_H
#define WOLF_CRYPT_MD4_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
/* for md4 reverse compatibility */
#ifndef NO_MD4
#define InitMd4 wc_InitMd4
#define Md4Update wc_Md4Update
#define Md4Final wc_Md4Final
#endif
#ifdef __cplusplus
extern "C" {
@ -50,16 +57,16 @@ typedef struct Md4 {
} Md4;
CYASSL_API void InitMd4(Md4*);
CYASSL_API void Md4Update(Md4*, const byte*, word32);
CYASSL_API void Md4Final(Md4*, byte*);
WOLFSSL_API void wc_InitMd4(Md4*);
WOLFSSL_API void wc_Md4Update(Md4*, const byte*, word32);
WOLFSSL_API void wc_Md4Final(Md4*, byte*);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_MD4_H */
#endif /* WOLF_CRYPT_MD4_H */
#endif /* NO_MD4 */

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -26,41 +26,47 @@
#include <wolfssl/wolfcrypt/types.h>
#include <cyassl/ctaocrypt/md5.h>
/* for md5 reverse compatibility */
#ifndef NO_MD5
#define InitMd5 wc_InitMd5
#define Md5Update wc_Md5Update
#define Md5Final wc_Md5Final
#define Md5Hash wc_Md5Hash
#endif
#ifdef __cplusplus
extern "C" {
#endif
///* in bytes */
//enum {
//#ifdef STM32F2_HASH
// MD5_REG_SIZE = 4, /* STM32 register size, bytes */
//#endif
// MD5 = 0, /* hash type unique */
// MD5_BLOCK_SIZE = 64,
// MD5_DIGEST_SIZE = 16,
// MD5_PAD_SIZE = 56
//};
//
//#ifdef CYASSL_PIC32MZ_HASH
//#include "port/pic32/pic32mz-crypt.h"
//#endif
//
///* MD5 digest */
//typedef struct Md5 {
// word32 buffLen; /* in bytes */
// word32 loLen; /* length in bytes */
// word32 hiLen; /* length in bytes */
// word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)];
// #ifndef CYASSL_PIC32MZ_HASH
// word32 digest[MD5_DIGEST_SIZE / sizeof(word32)];
// #else
// word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
// pic32mz_desc desc ; /* Crypt Engine descripter */
// #endif
//} Md5;
/* in bytes */
enum {
#ifdef STM32F2_HASH
MD5_REG_SIZE = 4, /* STM32 register size, bytes */
#endif
MD5 = 0, /* hash type unique */
MD5_BLOCK_SIZE = 64,
MD5_DIGEST_SIZE = 16,
MD5_PAD_SIZE = 56
};
#ifdef CYASSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif
/* MD5 digest */
typedef struct Md5 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 buffer[MD5_BLOCK_SIZE / sizeof(word32)];
#ifndef CYASSL_PIC32MZ_HASH
word32 digest[MD5_DIGEST_SIZE / sizeof(word32)];
#else
word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
pic32mz_desc desc ; /* Crypt Engine descripter */
#endif
} Md5;
WOLFSSL_API void wc_InitMd5(Md5*);
WOLFSSL_API void wc_Md5Update(Md5*, const byte*, word32);
@ -72,5 +78,5 @@ WOLFSSL_API int wc_Md5Hash(const byte*, word32, byte*);
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_MD5_H */
#endif /* WOLF_CRYPT_MD5_H */
#endif /* NO_MD5 */

View File

@ -27,29 +27,47 @@
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/* compatibility and fips @wc_fips */
#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/types.h>
#define CyaSSL_Malloc_cb wolfSSL_Malloc_cb
#define CyaSSL_Free_cb wolfSSL_Free_cb
#define CyaSSL_Realloc_cb wolfSSL_Realloc_cb
#define CyaSSL_SetAllocators wolfSSL_SetAllocators
/* Public in case user app wants to use XMALLOC/XFREE */
#define CyaSSL_Malloc wolfSSL_Malloc
#define CyaSSL_Free wolfSSL_Free
#define CyaSSL_Realloc wolfSSL_Realloc
typedef void *(*wolfSSL_Malloc_cb)(size_t size);
typedef void (*wolfSSL_Free_cb)(void *ptr);
typedef void *(*wolfSSL_Realloc_cb)(void *ptr, size_t size);
/* Public set function */
WOLFSSL_API int wolfSSL_SetAllocators(wolfSSL_Malloc_cb malloc_function,
wolfSSL_Free_cb free_function,
wolfSSL_Realloc_cb realloc_function);
/* Public in case user app wants to use XMALLOC/XFREE */
WOLFSSL_API void* wolfSSL_Malloc(size_t size);
WOLFSSL_API void wolfSSL_Free(void *ptr);
WOLFSSL_API void* wolfSSL_Realloc(void *ptr, size_t size);
#ifdef __cplusplus
}
typedef void *(*wolfSSL_Malloc_cb)(size_t size);
typedef void (*wolfSSL_Free_cb)(void *ptr);
typedef void *(*wolfSSL_Realloc_cb)(void *ptr, size_t size);
/* Public set function */
WOLFSSL_API int wolfSSL_SetAllocators(wolfSSL_Malloc_cb malloc_function,
wolfSSL_Free_cb free_function,
wolfSSL_Realloc_cb realloc_function);
/* Public in case user app wants to use XMALLOC/XFREE */
WOLFSSL_API void* wolfSSL_Malloc(size_t size);
WOLFSSL_API void wolfSSL_Free(void *ptr);
WOLFSSL_API void* wolfSSL_Realloc(void *ptr, size_t size);
#else
#include <cyassl/ctaocrypt/memory.h>
/* when using fips map wolfSSL to CyaSSL*/
#define wolfSSL_Malloc_cb CyaSSL_Malloc_cb
#define wolfSSL_Free_cb CyaSSL_Free_cb
#define wolfSSL_Realloc_cb CyaSSL_Realloc_cb
#define wolfSSL_SetAllocators CyaSSL_SetAllocators
/* Public in case user app wants to use XMALLOC/XFREE */
#define wolfSSL_Malloc CyaSSL_Malloc
#define wolfSSL_Free CyaSSL_Free
#define wolfSSL_Realloc CyaSSL_Realloc
#endif
#endif /* WOLFSSL_MEMORY_H */

View File

@ -2,15 +2,15 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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
* wolfSSL 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.
*
@ -22,14 +22,14 @@
#ifdef HAVE_PKCS7
#ifndef CTAO_CRYPT_PKCS7_H
#define CTAO_CRYPT_PKCS7_H
#ifndef WOLF_CRYPT_PKCS7_H
#define WOLF_CRYPT_PKCS7_H
#include <cyassl/ctaocrypt/types.h>
#include <cyassl/ctaocrypt/asn.h>
#include <cyassl/ctaocrypt/asn_public.h>
#include <cyassl/ctaocrypt/random.h>
#include <cyassl/ctaocrypt/des3.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/asn.h>
#include <wolfssl/wolfcrypt/asn_public.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/wolfcrypt/des3.h>
#ifdef __cplusplus
extern "C" {
@ -91,25 +91,25 @@ typedef struct PKCS7 {
} PKCS7;
CYASSL_LOCAL int SetContentType(int pkcs7TypeOID, byte* output);
CYASSL_LOCAL int GetContentType(const byte* input, word32* inOutIdx,
WOLFSSL_LOCAL int wc_SetContentType(int pkcs7TypeOID, byte* output);
WOLFSSL_LOCAL int wc_GetContentType(const byte* input, word32* inOutIdx,
word32* oid, word32 maxIdx);
CYASSL_LOCAL int CreateRecipientInfo(const byte* cert, word32 certSz,
WOLFSSL_LOCAL int wc_CreateRecipientInfo(const byte* cert, word32 certSz,
int keyEncAlgo, int blockKeySz,
RNG* rng, byte* contentKeyPlain,
byte* contentKeyEnc,
int* keyEncSz, byte* out, word32 outSz);
CYASSL_API int PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz);
CYASSL_API void PKCS7_Free(PKCS7* pkcs7);
CYASSL_API int PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz);
CYASSL_API int PKCS7_EncodeSignedData(PKCS7* pkcs7,
WOLFSSL_API int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz);
WOLFSSL_API void wc_PKCS7_Free(PKCS7* pkcs7);
WOLFSSL_API int wc_PKCS7_EncodeData(PKCS7* pkcs7, byte* output, word32 outputSz);
WOLFSSL_API int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7,
byte* output, word32 outputSz);
CYASSL_API int PKCS7_VerifySignedData(PKCS7* pkcs7,
WOLFSSL_API int wc_PKCS7_VerifySignedData(PKCS7* pkcs7,
byte* pkiMsg, word32 pkiMsgSz);
CYASSL_API int PKCS7_EncodeEnvelopedData(PKCS7* pkcs7,
WOLFSSL_API int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7,
byte* output, word32 outputSz);
CYASSL_API int PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
word32 pkiMsgSz, byte* output,
word32 outputSz);
@ -117,7 +117,7 @@ CYASSL_API int PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_PKCS7_H */
#endif /* WOLF_CRYPT_PKCS7_H */
#endif /* HAVE_PKCS7 */

View File

@ -27,6 +27,11 @@
#include <wolfssl/wolfcrypt/types.h>
/* for poly1305 reverse compatibility */
#define Poly1305SetKey wc_Poly1305SetKey
#define Poly1305Update wc_Poly1305Update
#define Poly1305Final wc_Poly1305Final
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -25,16 +25,6 @@
#include <wolfssl/wolfcrypt/types.h>
#if defined(HAVE_HASHDRBG) || defined(NO_RC4)
#ifdef NO_SHA256
#error "Hash DRBG requires SHA-256."
#endif /* NO_SHA256 */
#include <cyassl/ctaocrypt/sha256.h>
#else /* HAVE_HASHDRBG || NO_RC4 */
#include <cyassl/ctaocrypt/arc4.h>
#endif /* HAVE_HASHDRBG || NO_RC4 */
/* for fips */
#include <cyassl/ctaocrypt/random.h>

View File

@ -27,11 +27,6 @@
/* for fips */
#include <cyassl/ctaocrypt/rsa.h>
//#include <cyassl/ctaocrypt/types.h>
//#include <cyassl/ctaocrypt/integer.h>
//#include <cyassl/ctaocrypt/random.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -75,41 +70,27 @@ WOLFSSL_API int wc_RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*,
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
WOLFSSL_API int InitRsaKey_fips(RsaKey* key, void*);
WOLFSSL_API int FreeRsaKey_fips(RsaKey* key);
WOLFSSL_API int wc_InitRsaKey_fips(RsaKey* key, void*);
WOLFSSL_API int wc_FreeRsaKey_fips(RsaKey* key);
WOLFSSL_API int RsaPublicEncrypt_fips(const byte* in,word32 inLen,byte* out,
WOLFSSL_API int wc_RsaPublicEncrypt_fips(const byte* in,word32 inLen,byte* out,
word32 outLen, RsaKey* key, RNG* rng);
WOLFSSL_API int RsaPrivateDecryptInline_fips(byte* in, word32 inLen,
WOLFSSL_API int wc_RsaPrivateDecryptInline_fips(byte* in, word32 inLen,
byte** out, RsaKey* key);
WOLFSSL_API int RsaPrivateDecrypt_fips(const byte* in, word32 inLen,
WOLFSSL_API int wc_RsaPrivateDecrypt_fips(const byte* in, word32 inLen,
byte* out,word32 outLen,RsaKey* key);
WOLFSSL_API int RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
WOLFSSL_API int wc_RsaSSL_Sign_fips(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, RNG* rng);
WOLFSSL_API int RsaSSL_VerifyInline_fips(byte* in, word32 inLen, byte** out,
WOLFSSL_API int wc_RsaSSL_VerifyInline_fips(byte* in, word32 inLen, byte** out,
RsaKey* key);
WOLFSSL_API int RsaSSL_Verify_fips(const byte* in, word32 inLen, byte* out,
WOLFSSL_API int wc_RsaSSL_Verify_fips(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key);
WOLFSSL_API int RsaEncryptSize_fips(RsaKey* key);
WOLFSSL_API int wc_RsaEncryptSize_fips(RsaKey* key);
WOLFSSL_API int RsaPrivateKeyDecode_fips(const byte* input, word32* inOutIdx,
WOLFSSL_API int wc_RsaPrivateKeyDecode_fips(const byte* input, word32* inOutIdx,
RsaKey*, word32);
WOLFSSL_API int RsaPublicKeyDecode_fips(const byte* input, word32* inOutIdx,
WOLFSSL_API int wc_RsaPublicKeyDecode_fips(const byte* input, word32* inOutIdx,
RsaKey*, word32);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitRsaKey InitRsaKey_fips
#define FreeRsaKey FreeRsaKey_fips
#define RsaPublicEncrypt RsaPublicEncrypt_fips
#define RsaPrivateDecryptInline RsaPrivateDecryptInline_fips
#define RsaPrivateDecrypt RsaPrivateDecrypt_fips
#define RsaSSL_Sign RsaSSL_Sign_fips
#define RsaSSL_VerifyInline RsaSSL_VerifyInline_fips
#define RsaSSL_Verify RsaSSL_Verify_fips
#define RsaEncryptSize RsaEncryptSize_fips
/* no implicit KeyDecodes since in asn.c (not rsa.c) */
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */

View File

@ -26,7 +26,716 @@
#ifndef WOLF_CRYPT_SETTINGS_H
#define WOLF_CRYPT_SETTINGS_H
#ifdef __cplusplus
extern "C" {
#endif
/* Uncomment next line if using IPHONE */
/* #define IPHONE */
/* Uncomment next line if using ThreadX */
/* #define THREADX */
/* Uncomment next line if using Micrium ucOS */
/* #define MICRIUM */
/* Uncomment next line if using Mbed */
/* #define MBED */
/* Uncomment next line if using Microchip PIC32 ethernet starter kit */
/* #define MICROCHIP_PIC32 */
/* Uncomment next line if using Microchip TCP/IP stack, version 5 */
/* #define MICROCHIP_TCPIP_V5 */
/* Uncomment next line if using Microchip TCP/IP stack, version 6 or later */
/* #define MICROCHIP_TCPIP */
/* Uncomment next line if using PIC32MZ Crypto Engine */
/* #define WOLFSSL_MICROCHIP_PIC32MZ */
/* Uncomment next line if using FreeRTOS */
/* #define FREERTOS */
/* Uncomment next line if using FreeRTOS Windows Simulator */
/* #define FREERTOS_WINSIM */
/* Uncomment next line if using RTIP */
/* #define EBSNET */
/* Uncomment next line if using lwip */
/* #define WOLFSSL_LWIP */
/* Uncomment next line if building wolfSSL for a game console */
/* #define WOLFSSL_GAME_BUILD */
/* Uncomment next line if building wolfSSL for LSR */
/* #define WOLFSSL_LSR */
/* Uncomment next line if building wolfSSL for Freescale MQX/RTCS/MFS */
/* #define FREESCALE_MQX */
/* Uncomment next line if using STM32F2 */
/* #define WOLFSSL_STM32F2 */
/* Uncomment next line if using Comverge settings */
/* #define COMVERGE */
/* Uncomment next line if using QL SEP settings */
/* #define WOLFSSL_QL */
/* Uncomment next line if building for EROAD */
/* #define WOLFSSL_EROAD */
/* Uncomment next line if building for IAR EWARM */
/* #define WOLFSSL_IAR_ARM */
/* Uncomment next line if using TI-RTOS settings */
/* #define WOLFSSL_TIRTOS */
/* Uncomment next line if building with PicoTCP */
/* #define WOLFSSL_PICOTCP */
/* Uncomment next line if building for PicoTCP demo bundle */
/* #define WOLFSSL_PICOTCP_DEMO */
#include <wolfssl/wolfcrypt/visibility.h>
#include <cyassl/ctaocrypt/settings.h>
#ifdef IPHONE
#define SIZEOF_LONG_LONG 8
#endif
#ifdef WOLFSSL_USER_SETTINGS
#include <user_settings.h>
#endif
#ifdef COMVERGE
#define THREADX
#define HAVE_NETX
#define WOLFSSL_USER_IO
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define NO_SHA512
#define NO_DH
#define NO_DSA
#define NO_HC128
#define NO_RSA
#define NO_SESSION_CACHE
#define HAVE_ECC
#endif
#ifdef THREADX
#define SIZEOF_LONG_LONG 8
#endif
#ifdef HAVE_NETX
#include "nx_api.h"
#endif
#if defined(HAVE_LWIP_NATIVE) /* using LwIP native TCP socket */
#define WOLFSSL_LWIP
#define NO_WRITEV
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#endif
#if defined(WOLFSSL_IAR_ARM)
#define NO_MAIN_DRIVER
#define SINGLE_THREADED
#define USE_CERT_BUFFERS_1024
#define BENCH_EMBEDDED
#define NO_FILESYSTEM
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define BENCH_EMBEDDED
#endif
#ifdef MICROCHIP_PIC32
/* #define WOLFSSL_MICROCHIP_PIC32MZ */
#define SIZEOF_LONG_LONG 8
#define SINGLE_THREADED
#define WOLFSSL_USER_IO
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#endif
#ifdef WOLFSSL_MICROCHIP_PIC32MZ
#define WOLFSSL_PIC32MZ_CE
#define WOLFSSL_PIC32MZ_CRYPT
#define HAVE_AES_ENGINE
#define WOLFSSL_PIC32MZ_RNG
/* #define WOLFSSL_PIC32MZ_HASH */
#define WOLFSSL_AES_COUNTER
#define HAVE_AESGCM
#define NO_BIG_INT
#endif
#ifdef MICROCHIP_TCPIP_V5
/* include timer functions */
#include "TCPIP Stack/TCPIP.h"
#endif
#ifdef MICROCHIP_TCPIP
/* include timer, NTP functions */
#ifdef MICROCHIP_MPLAB_HARMONY
#include "tcpip/tcpip.h"
#else
#include "system/system_services.h"
#include "tcpip/sntp.h"
#endif
#endif
#ifdef MBED
#define WOLFSSL_USER_IO
#define NO_FILESYSTEM
#define NO_CERT
#define USE_CERT_BUFFERS_1024
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_SHA512
#define NO_DH
#define NO_DSA
#define NO_HC128
#define HAVE_ECC
#define NO_SESSION_CACHE
#define WOLFSSL_CMSIS_RTOS
#endif
#ifdef WOLFSSL_EROAD
#define FREESCALE_MQX
#define FREESCALE_MMCAU
#define SINGLE_THREADED
#define NO_STDIO_FILESYSTEM
#define WOLFSSL_LEANPSK
#define HAVE_NULL_CIPHER
#define NO_OLD_TLS
#define NO_ASN
#define NO_BIG_INT
#define NO_RSA
#define NO_DSA
#define NO_DH
#define NO_CERTS
#define NO_PWDBASED
#define NO_DES3
#define NO_MD4
#define NO_RC4
#define NO_MD5
#define NO_SESSION_CACHE
#define NO_MAIN_DRIVER
#endif
#ifdef WOLFSSL_PICOTCP
#define errno pico_err
#include "pico_defines.h"
#include "pico_stack.h"
#include "pico_constants.h"
#define CUSTOM_RAND_GENERATE pico_rand
#endif
#ifdef WOLFSSL_PICOTCP_DEMO
#define WOLFSSL_STM32
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define XMALLOC(s, h, type) PICO_ZALLOC((s))
#define XFREE(p, h, type) PICO_FREE((p))
#define SINGLE_THREADED
#define NO_WRITEV
#define WOLFSSL_USER_IO
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#endif
#ifdef FREERTOS_WINSIM
#define FREERTOS
#define USE_WINDOWS_API
#endif
/* Micrium will use Visual Studio for compilation but not the Win32 API */
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
&& !defined(EBSNET) && !defined(WOLFSSL_EROAD)
#define USE_WINDOWS_API
#endif
#if defined(WOLFSSL_LEANPSK) && !defined(XMALLOC_USER)
#include <stdlib.h>
#define XMALLOC(s, h, type) malloc((s))
#define XFREE(p, h, type) free((p))
#define XREALLOC(p, n, h, t) realloc((p), (n))
#endif
#if defined(XMALLOC_USER) && defined(SSN_BUILDING_LIBYASSL)
#undef XMALLOC
#define XMALLOC yaXMALLOC
#undef XFREE
#define XFREE yaXFREE
#undef XREALLOC
#define XREALLOC yaXREALLOC
#endif
#ifdef FREERTOS
#ifndef NO_WRITEV
#define NO_WRITEV
#endif
#ifndef NO_SHA512
#define NO_SHA512
#endif
#ifndef NO_DH
#define NO_DH
#endif
#ifndef NO_DSA
#define NO_DSA
#endif
#ifndef NO_HC128
#define NO_HC128
#endif
#ifndef SINGLE_THREADED
#include "FreeRTOS.h"
#include "semphr.h"
#endif
#endif
#ifdef WOLFSSL_TIRTOS
#define SIZEOF_LONG_LONG 8
#define NO_WRITEV
#define NO_WOLFSSL_DIR
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define NO_DEV_RANDOM
#define NO_FILESYSTEM
#define USE_CERT_BUFFERS_2048
#define NO_ERROR_STRINGS
#define USER_TIME
#ifdef __IAR_SYSTEMS_ICC__
#pragma diag_suppress=Pa089
#elif !defined(__GNUC__)
/* Suppress the sslpro warning */
#pragma diag_suppress=11
#endif
#include <ti/ndk/nettools/mytime/mytime.h>
#endif
#ifdef EBSNET
#include "rtip.h"
/* #define DEBUG_WOLFSSL */
#define NO_WOLFSSL_DIR /* tbd */
#if (POLLOS)
#define SINGLE_THREADED
#endif
#if (RTPLATFORM)
#if (!RTP_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
#else
#if (!KS_LITTLE_ENDIAN)
#define BIG_ENDIAN_ORDER
#endif
#endif
#if (WINMSP3)
#undef SIZEOF_LONG
#define SIZEOF_LONG_LONG 8
#else
#sslpro: settings.h - please implement SIZEOF_LONG and SIZEOF_LONG_LONG
#endif
#define XMALLOC(s, h, type) ((void *)rtp_malloc((s), SSL_PRO_MALLOC))
#define XFREE(p, h, type) (rtp_free(p))
#define XREALLOC(p, n, h, t) realloc((p), (n))
#endif /* EBSNET */
#ifdef WOLFSSL_GAME_BUILD
#define SIZEOF_LONG_LONG 8
#if defined(__PPU) || defined(__XENON)
#define BIG_ENDIAN_ORDER
#endif
#endif
#ifdef WOLFSSL_LSR
#define HAVE_WEBSERVER
#define SIZEOF_LONG_LONG 8
#define WOLFSSL_LOW_MEMORY
#define NO_WRITEV
#define NO_SHA512
#define NO_DH
#define NO_DSA
#define NO_HC128
#define NO_DEV_RANDOM
#define NO_WOLFSSL_DIR
#define NO_RABBIT
#ifndef NO_FILESYSTEM
#define LSR_FS
#include "inc/hw_types.h"
#include "fs.h"
#endif
#define WOLFSSL_LWIP
#include <errno.h> /* for tcp errno */
#define WOLFSSL_SAFERTOS
#if defined(__IAR_SYSTEMS_ICC__)
/* enum uses enum */
#pragma diag_suppress=Pa089
#endif
#endif
#ifdef WOLFSSL_SAFERTOS
#ifndef SINGLE_THREADED
#include "SafeRTOS/semphr.h"
#endif
#include "SafeRTOS/heap.h"
#define XMALLOC(s, h, type) pvPortMalloc((s))
#define XFREE(p, h, type) vPortFree((p))
#define XREALLOC(p, n, h, t) pvPortRealloc((p), (n))
#endif
#ifdef WOLFSSL_LOW_MEMORY
#undef RSA_LOW_MEM
#define RSA_LOW_MEM
#undef WOLFSSL_SMALL_STACK
#define WOLFSSL_SMALL_STACK
#undef TFM_TIMING_RESISTANT
#define TFM_TIMING_RESISTANT
#endif
#ifdef FREESCALE_MQX
#define SIZEOF_LONG_LONG 8
#define NO_WRITEV
#define NO_DEV_RANDOM
#define NO_RABBIT
#define NO_WOLFSSL_DIR
#define USE_FAST_MATH
#define TFM_TIMING_RESISTANT
#define FREESCALE_K70_RNGA
/* #define FREESCALE_K53_RNGB */
#include "mqx.h"
#ifndef NO_FILESYSTEM
#include "mfs.h"
#include "fio.h"
#endif
#ifndef SINGLE_THREADED
#include "mutex.h"
#endif
#define XMALLOC(s, h, t) (void *)_mem_alloc_system((s))
#define XFREE(p, h, t) {void* xp = (p); if ((xp)) _mem_free((xp));}
/* Note: MQX has no realloc, using fastmath above */
#endif
#ifdef WOLFSSL_STM32F2
#define SIZEOF_LONG_LONG 8
#define NO_DEV_RANDOM
#define NO_WOLFSSL_DIR
#define NO_RABBIT
#define STM32F2_RNG
#define STM32F2_CRYPTO
#define KEIL_INTRINSICS
#endif
#ifdef MICRIUM
#include "stdlib.h"
#include "net_cfg.h"
#include "ssl_cfg.h"
#include "net_secure_os.h"
#define WOLFSSL_TYPES
typedef CPU_INT08U byte;
typedef CPU_INT16U word16;
typedef CPU_INT32U word32;
#if (NET_SECURE_MGR_CFG_WORD_SIZE == CPU_WORD_SIZE_32)
#define SIZEOF_LONG 4
#undef SIZEOF_LONG_LONG
#else
#undef SIZEOF_LONG
#define SIZEOF_LONG_LONG 8
#endif
#define STRING_USER
#define XSTRLEN(pstr) ((CPU_SIZE_T)Str_Len((CPU_CHAR *)(pstr)))
#define XSTRNCPY(pstr_dest, pstr_src, len_max) \
((CPU_CHAR *)Str_Copy_N((CPU_CHAR *)(pstr_dest), \
(CPU_CHAR *)(pstr_src), (CPU_SIZE_T)(len_max)))
#define XSTRNCMP(pstr_1, pstr_2, len_max) \
((CPU_INT16S)Str_Cmp_N((CPU_CHAR *)(pstr_1), \
(CPU_CHAR *)(pstr_2), (CPU_SIZE_T)(len_max)))
#define XSTRSTR(pstr, pstr_srch) \
((CPU_CHAR *)Str_Str((CPU_CHAR *)(pstr), \
(CPU_CHAR *)(pstr_srch)))
#define XMEMSET(pmem, data_val, size) \
((void)Mem_Set((void *)(pmem), (CPU_INT08U) (data_val), \
(CPU_SIZE_T)(size)))
#define XMEMCPY(pdest, psrc, size) ((void)Mem_Copy((void *)(pdest), \
(void *)(psrc), (CPU_SIZE_T)(size)))
#define XMEMCMP(pmem_1, pmem_2, size) \
(((CPU_BOOLEAN)Mem_Cmp((void *)(pmem_1), (void *)(pmem_2), \
(CPU_SIZE_T)(size))) ? DEF_NO : DEF_YES)
#define XMEMMOVE XMEMCPY
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
#define MICRIUM_MALLOC
#define XMALLOC(s, h, type) ((void *)NetSecure_BlkGet((CPU_INT08U)(type), \
(CPU_SIZE_T)(s), (void *)0))
#define XFREE(p, h, type) (NetSecure_BlkFree((CPU_INT08U)(type), \
(p), (void *)0))
#define XREALLOC(p, n, h, t) realloc((p), (n))
#endif
#if (NET_SECURE_MGR_CFG_FS_EN == DEF_ENABLED)
#undef NO_FILESYSTEM
#else
#define NO_FILESYSTEM
#endif
#if (SSL_CFG_TRACE_LEVEL == WOLFSSL_TRACE_LEVEL_DBG)
#define DEBUG_WOLFSSL
#else
#undef DEBUG_WOLFSSL
#endif
#if (SSL_CFG_OPENSSL_EN == DEF_ENABLED)
#define OPENSSL_EXTRA
#else
#undef OPENSSL_EXTRA
#endif
#if (SSL_CFG_MULTI_THREAD_EN == DEF_ENABLED)
#undef SINGLE_THREADED
#else
#define SINGLE_THREADED
#endif
#if (SSL_CFG_DH_EN == DEF_ENABLED)
#undef NO_DH
#else
#define NO_DH
#endif
#if (SSL_CFG_DSA_EN == DEF_ENABLED)
#undef NO_DSA
#else
#define NO_DSA
#endif
#if (SSL_CFG_PSK_EN == DEF_ENABLED)
#undef NO_PSK
#else
#define NO_PSK
#endif
#if (SSL_CFG_3DES_EN == DEF_ENABLED)
#undef NO_DES
#else
#define NO_DES
#endif
#if (SSL_CFG_AES_EN == DEF_ENABLED)
#undef NO_AES
#else
#define NO_AES
#endif
#if (SSL_CFG_RC4_EN == DEF_ENABLED)
#undef NO_RC4
#else
#define NO_RC4
#endif
#if (SSL_CFG_RABBIT_EN == DEF_ENABLED)
#undef NO_RABBIT
#else
#define NO_RABBIT
#endif
#if (SSL_CFG_HC128_EN == DEF_ENABLED)
#undef NO_HC128
#else
#define NO_HC128
#endif
#if (CPU_CFG_ENDIAN_TYPE == CPU_ENDIAN_TYPE_BIG)
#define BIG_ENDIAN_ORDER
#else
#undef BIG_ENDIAN_ORDER
#define LITTLE_ENDIAN_ORDER
#endif
#if (SSL_CFG_MD4_EN == DEF_ENABLED)
#undef NO_MD4
#else
#define NO_MD4
#endif
#if (SSL_CFG_WRITEV_EN == DEF_ENABLED)
#undef NO_WRITEV
#else
#define NO_WRITEV
#endif
#if (SSL_CFG_USER_RNG_SEED_EN == DEF_ENABLED)
#define NO_DEV_RANDOM
#else
#undef NO_DEV_RANDOM
#endif
#if (SSL_CFG_USER_IO_EN == DEF_ENABLED)
#define WOLFSSL_USER_IO
#else
#undef WOLFSSL_USER_IO
#endif
#if (SSL_CFG_DYNAMIC_BUFFERS_EN == DEF_ENABLED)
#undef LARGE_STATIC_BUFFERS
#undef STATIC_CHUNKS_ONLY
#else
#define LARGE_STATIC_BUFFERS
#define STATIC_CHUNKS_ONLY
#endif
#if (SSL_CFG_DER_LOAD_EN == DEF_ENABLED)
#define WOLFSSL_DER_LOAD
#else
#undef WOLFSSL_DER_LOAD
#endif
#if (SSL_CFG_DTLS_EN == DEF_ENABLED)
#define WOLFSSL_DTLS
#else
#undef WOLFSSL_DTLS
#endif
#if (SSL_CFG_CALLBACKS_EN == DEF_ENABLED)
#define WOLFSSL_CALLBACKS
#else
#undef WOLFSSL_CALLBACKS
#endif
#if (SSL_CFG_FAST_MATH_EN == DEF_ENABLED)
#define USE_FAST_MATH
#else
#undef USE_FAST_MATH
#endif
#if (SSL_CFG_TFM_TIMING_RESISTANT_EN == DEF_ENABLED)
#define TFM_TIMING_RESISTANT
#else
#undef TFM_TIMING_RESISTANT
#endif
#endif /* MICRIUM */
#ifdef WOLFSSL_QL
#ifndef WOLFSSL_SEP
#define WOLFSSL_SEP
#endif
#ifndef OPENSSL_EXTRA
#define OPENSSL_EXTRA
#endif
#ifndef SESSION_CERTS
#define SESSION_CERTS
#endif
#ifndef HAVE_AESCCM
#define HAVE_AESCCM
#endif
#ifndef ATOMIC_USER
#define ATOMIC_USER
#endif
#ifndef WOLFSSL_DER_LOAD
#define WOLFSSL_DER_LOAD
#endif
#ifndef KEEP_PEER_CERT
#define KEEP_PEER_CERT
#endif
#ifndef HAVE_ECC
#define HAVE_ECC
#endif
#ifndef SESSION_INDEX
#define SESSION_INDEX
#endif
#endif /* WOLFSSL_QL */
#if !defined(XMALLOC_USER) && !defined(MICRIUM_MALLOC) && \
!defined(WOLFSSL_LEANPSK) && !defined(NO_CYASSL_MEMORY)
#define USE_WOLFSSL_MEMORY
#endif
#if defined(OPENSSL_EXTRA) && !defined(NO_CERTS)
#undef KEEP_PEER_CERT
#define KEEP_PEER_CERT
#endif
/* stream ciphers except arc4 need 32bit alignment, intel ok without */
#ifndef XSTREAM_ALIGNMENT
#if defined(__x86_64__) || defined(__ia64__) || defined(__i386__)
#define NO_XSTREAM_ALIGNMENT
#else
#define XSTREAM_ALIGNMENT
#endif
#endif
/* FreeScale MMCAU hardware crypto has 4 byte alignment */
#ifdef FREESCALE_MMCAU
#define WOLFSSL_MMCAU_ALIGNMENT 4
#endif
/* if using hardware crypto and have alignment requirements, specify the
requirement here. The record header of SSL/TLS will prvent easy alignment.
This hint tries to help as much as possible. */
#ifndef WOLFSSL_GENERAL_ALIGNMENT
#ifdef WOLFSSL_AESNI
#define WOLFSSL_GENERAL_ALIGNMENT 16
#elif defined(XSTREAM_ALIGNMENT)
#define WOLFSSL_GENERAL_ALIGNMENT 4
#elif defined(FREESCALE_MMCAU)
#define WOLFSSL_GENERAL_ALIGNMENT CYASSL_MMCAU_ALIGNMENT
#else
#define WOLFSSL_GENERAL_ALIGNMENT 0
#endif
#endif
#ifdef HAVE_CRL
/* not widely supported yet */
#undef NO_SKID
#define NO_SKID
#endif
#ifdef __INTEL_COMPILER
#pragma warning(disable:2259) /* explicit casts to smaller sizes, disable */
#endif
/* Place any other flags or defines here */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -22,62 +22,35 @@
#ifndef NO_SHA
#ifndef CTAO_CRYPT_SHA_H
#define CTAO_CRYPT_SHA_H
#ifndef WOLF_CRYPT_SHA_H
#define WOLF_CRYPT_SHA_H
#include <cyassl/ctaocrypt/types.h>
#include <wolfssl/wolfcrypt/types.h>
/* for fips */
#include <cyassl/ctaocrypt/sha.h>
#ifdef __cplusplus
extern "C" {
#endif
/* in bytes */
enum {
#ifdef STM32F2_HASH
SHA_REG_SIZE = 4, /* STM32 register size, bytes */
#endif
SHA = 1, /* hash type unique */
SHA_BLOCK_SIZE = 64,
SHA_DIGEST_SIZE = 20,
SHA_PAD_SIZE = 56
};
#ifdef CYASSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif
/* Sha digest */
typedef struct Sha {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 buffer[SHA_BLOCK_SIZE / sizeof(word32)];
#ifndef CYASSL_PIC32MZ_HASH
word32 digest[SHA_DIGEST_SIZE / sizeof(word32)];
#else
word32 digest[PIC32_HASH_SIZE / sizeof(word32)];
pic32mz_desc desc; /* Crypt Engine descripter */
#endif
} Sha;
CYASSL_API int InitSha(Sha*);
CYASSL_API int ShaUpdate(Sha*, const byte*, word32);
CYASSL_API int ShaFinal(Sha*, byte*);
CYASSL_API int ShaHash(const byte*, word32, byte*);
WOLFSSL_API int wc_InitSha(Sha*);
WOLFSSL_API int wc_ShaUpdate(Sha*, const byte*, word32);
WOLFSSL_API int wc_ShaFinal(Sha*, byte*);
WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha_fips(Sha*);
CYASSL_API int ShaUpdate_fips(Sha*, const byte*, word32);
CYASSL_API int ShaFinal_fips(Sha*, byte*);
WOLFSSL_API int wc_InitSha_fips(Sha*);
WOLFSSL_API int wc_ShaUpdate_fips(Sha*, const byte*, word32);
WOLFSSL_API int wc_ShaFinal_fips(Sha*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha InitSha_fips
#define ShaUpdate ShaUpdate_fips
#define ShaFinal ShaFinal_fips
#define wc_InitSha wc_InitSha_fips
#define wc_ShaUpdate wc_ShaUpdate_fips
#define wc_ShaFinal wc_ShaFinal_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */

View File

@ -1,15 +1,13 @@
/* sha256.h
*
* Copyright (C) 2006-2014 wolfSSL Inc.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* This file is part of CyaSSL.
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -25,67 +23,35 @@
#ifndef NO_SHA256
#ifndef CTAO_CRYPT_SHA256_H
#define CTAO_CRYPT_SHA256_H
#ifndef WOLF_CRYPT_SHA256_H
#define WOLF_CRYPT_SHA256_H
#include <cyassl/ctaocrypt/types.h>
/* for fips */
#include <cyassl/ctaocrypt/sha256.h>
//#ifndef HAVE_FIPS
#include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CYASSL_PIC32MZ_HASH
#include "port/pic32/pic32mz-crypt.h"
#endif
/* in bytes */
enum {
SHA256 = 2, /* hash type unique */
SHA256_BLOCK_SIZE = 64,
SHA256_DIGEST_SIZE = 32,
SHA256_PAD_SIZE = 56
};
/* Sha256 digest */
typedef struct Sha256 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)];
word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)];
#ifdef CYASSL_PIC32MZ_HASH
pic32mz_desc desc ; /* Crypt Engine descripter */
#endif
} Sha256;
CYASSL_API int InitSha256(Sha256*);
CYASSL_API int Sha256Update(Sha256*, const byte*, word32);
CYASSL_API int Sha256Final(Sha256*, byte*);
CYASSL_API int Sha256Hash(const byte*, word32, byte*);
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha256_fips(Sha256*);
CYASSL_API int Sha256Update_fips(Sha256*, const byte*, word32);
CYASSL_API int Sha256Final_fips(Sha256*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha256 InitSha256_fips
#define Sha256Update Sha256Update_fips
#define Sha256Final Sha256Final_fips
#endif /* FIPS_NO_WRAPPERS */
#endif /* HAVE_FIPS */
WOLFSSL_API int wc_InitSha256(Sha256*);
WOLFSSL_API int wc_Sha256Update(Sha256*, const byte*, word32);
WOLFSSL_API int wc_Sha256Final(Sha256*, byte*);
WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*);
#ifdef __cplusplus
} /* extern "C" */
#endif
//#else
//#define wc_InitSha256 wc_InitSha256Sha256*);
//#define int wc_Sha256Update(Swc_Sha256Updateha256*, const byte*, word32);
//#define int wc_Sha256Final(wc_Sha256FinalSha256*, byte*);
//#define int wc_Sha256Hash(wc_Sha256Hashconst byte*, word32, byte*);
//
//#endif /* HAVE_FIPS */
#endif /* CTAO_CRYPT_SHA256_H */
#endif /* WOLF_CRYPT_SHA256_H */
#endif /* NO_SHA256 */

View File

@ -2,14 +2,14 @@
*
* Copyright (C) 2006-2014 wolfSSL Inc.
*
* This file is part of CyaSSL.
* This file is part of wolfSSL. (formerly known as CyaSSL)
*
* CyaSSL is free software; you can redistribute it and/or modify
* wolfSSL 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,
* wolfSSL 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.
@ -19,76 +19,54 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* check for old macro */
#if defined(CYASSL_SHA512) && !defined(WOLFSSL_SHA512)
#define WOLFSSL_SHA512
#endif
#if defined(CYASSL_SHA384) && !defined(WOLFSSL_SHA384)
#define WOLFSSL_SHA384
#endif
#ifdef CYASSL_SHA512
#ifdef WOLFSSL_SHA512
#ifndef CTAO_CRYPT_SHA512_H
#define CTAO_CRYPT_SHA512_H
#ifndef WOLF_CRYPT_SHA512_H
#define WOLF_CRYPT_SHA512_H
#include <wolfssl/wolfcrypt/types.h>
/* since using old code turn on old macros @wc_fips */
#if !defined(CYASSL_SHA512)
#define CYASSL_SHA512
#endif
#if !defined(CYASSL_SHA384) && defined(WOLFSSL_SHA384)
#define CYASSL_SHA384
#endif
/* for fips */
#include <cyassl/ctaocrypt/sha512.h>
#include <cyassl/ctaocrypt/types.h>
#ifdef __cplusplus
extern "C" {
#endif
WOLFSSL_API int wc_InitSha512(Sha512*);
WOLFSSL_API int wc_Sha512Update(Sha512*, const byte*, word32);
WOLFSSL_API int wc_Sha512Final(Sha512*, byte*);
WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*);
/* in bytes */
enum {
SHA512 = 4, /* hash type unique */
SHA512_BLOCK_SIZE = 128,
SHA512_DIGEST_SIZE = 64,
SHA512_PAD_SIZE = 112
};
#if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM)
/* Sha512 digest */
typedef struct Sha512 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)];
word64 buffer[SHA512_BLOCK_SIZE / sizeof(word64)];
} Sha512;
CYASSL_API int InitSha512(Sha512*);
CYASSL_API int Sha512Update(Sha512*, const byte*, word32);
CYASSL_API int Sha512Final(Sha512*, byte*);
CYASSL_API int Sha512Hash(const byte*, word32, byte*);
#if defined(CYASSL_SHA384) || defined(HAVE_AESGCM)
/* in bytes */
enum {
SHA384 = 5, /* hash type unique */
SHA384_BLOCK_SIZE = 128,
SHA384_DIGEST_SIZE = 48,
SHA384_PAD_SIZE = 112
};
/* Sha384 digest */
typedef struct Sha384 {
word32 buffLen; /* in bytes */
word32 loLen; /* length in bytes */
word32 hiLen; /* length in bytes */
word64 digest[SHA512_DIGEST_SIZE / sizeof(word64)]; /* for transform 512 */
word64 buffer[SHA384_BLOCK_SIZE / sizeof(word64)];
} Sha384;
CYASSL_API int InitSha384(Sha384*);
CYASSL_API int Sha384Update(Sha384*, const byte*, word32);
CYASSL_API int Sha384Final(Sha384*, byte*);
CYASSL_API int Sha384Hash(const byte*, word32, byte*);
WOLFSSL_API int wc_InitSha384(Sha384*);
WOLFSSL_API int wc_Sha384Update(Sha384*, const byte*, word32);
WOLFSSL_API int wc_Sha384Final(Sha384*, byte*);
WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);
#ifdef HAVE_FIPS
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha512_fips(Sha512*);
CYASSL_API int Sha512Update_fips(Sha512*, const byte*, word32);
CYASSL_API int Sha512Final_fips(Sha512*, byte*);
WOLFSSL_API int wc_InitSha512_fips(Sha512*);
WOLFSSL_API int wc_Sha512Update_fips(Sha512*, const byte*, word32);
WOLFSSL_API int wc_Sha512Final_fips(Sha512*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha512 InitSha512_fips
@ -97,9 +75,9 @@ CYASSL_API int Sha384Hash(const byte*, word32, byte*);
#endif /* FIPS_NO_WRAPPERS */
/* fips wrapper calls, user can call direct */
CYASSL_API int InitSha384_fips(Sha384*);
CYASSL_API int Sha384Update_fips(Sha384*, const byte*, word32);
CYASSL_API int Sha384Final_fips(Sha384*, byte*);
WOLFSSL_API int wc_InitSha384_fips(Sha384*);
WOLFSSL_API int wc_Sha384Update_fips(Sha384*, const byte*, word32);
WOLFSSL_API int wc_Sha384Final_fips(Sha384*, byte*);
#ifndef FIPS_NO_WRAPPERS
/* if not impl or fips.c impl wrapper force fips calls if fips build */
#define InitSha384 InitSha384_fips
@ -110,11 +88,11 @@ CYASSL_API int Sha384Hash(const byte*, word32, byte*);
#endif /* HAVE_FIPS */
#endif /* CYASSL_SHA384 */
#endif /* WOLFSSL_SHA384 */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* CTAO_CRYPT_SHA512_H */
#endif /* CYASSL_SHA512 */
#endif /* WOLF_CRYPT_SHA512_H */
#endif /* WOLFSSL_SHA512 */

File diff suppressed because it is too large Load Diff