diff --git a/src/include.am b/src/include.am index 1dcf24a2b..f65331b4c 100644 --- a/src/include.am +++ b/src/include.am @@ -74,7 +74,8 @@ endif src_libwolfssl_la_SOURCES += \ wolfcrypt/src/logging.c \ wolfcrypt/src/wc_port.c \ - wolfcrypt/src/error.c + wolfcrypt/src/error.c\ + wolfcrypt/src/port/ti/ti-hash.c if BUILD_MEMORY src_libwolfssl_la_SOURCES += wolfcrypt/src/memory.c @@ -191,8 +192,6 @@ if BUILD_PKCS7 src_libwolfssl_la_SOURCES += wolfcrypt/src/pkcs7.c endif -src_libwolfssl_la_SOURCES += wolfcrypt/src/port/ti/ti-hash.c - # ssl files src_libwolfssl_la_SOURCES += \ src/internal.c \ diff --git a/wolfcrypt/src/md5.c b/wolfcrypt/src/md5.c index 6c2e45d9f..64c2ff15a 100644 --- a/wolfcrypt/src/md5.c +++ b/wolfcrypt/src/md5.c @@ -180,12 +180,6 @@ #endif /* WOLFSSL_HAVE_MIN */ -#ifdef TI_HASH_TEST -void wc_InitMd5_ti(Md5* md5) ; -void wc_Md5Update_ti(Md5* md5, const byte* data, word32 len) ; -void wc_Md5Final_ti(Md5* md5, byte* hash) ; -#endif - void wc_InitMd5(Md5* md5) { md5->digest[0] = 0x67452301L; @@ -196,10 +190,6 @@ void wc_InitMd5(Md5* md5) md5->buffLen = 0; md5->loLen = 0; md5->hiLen = 0; - -#ifdef TI_HASH_TEST - wc_InitMd5_ti(md5) ; -#endif } #ifndef FREESCALE_MMCAU @@ -328,10 +318,6 @@ void wc_Md5Update(Md5* md5, const byte* data, word32 len) md5->buffLen = 0; } } -#ifdef TI_HASH_TEST - wc_Md5Update_ti(md5, data, len) ; -#endif - } @@ -376,10 +362,6 @@ void wc_Md5Final(Md5* md5, byte* hash) XMEMCPY(hash, md5->digest, MD5_DIGEST_SIZE); wc_InitMd5(md5); /* reset state */ - -#ifdef TI_HASH_TEST - wc_Md5Final_ti(md5, hash) ; -#endif } #endif /* STM32F2_HASH */ @@ -410,17 +392,10 @@ int wc_Md5Hash(const byte* data, word32 len, byte* hash) return 0; } -#if defined(WOLFSSL_TI_HASH)||defined(TI_HASH_TEST) -#include "wolfssl/wolfcrypt/port/ti/ti-hash.h" -#endif void wc_Md5GetHash(Md5* md5, byte* hash) { -#if defined(WOLFSSL_TI_HASH) || defined(TI_HASH_TEST) - wc_Md5GetHash_ti(md5, hash) ; -#else Md5 save = *md5 ; wc_Md5Final(md5, hash) ; *md5 = save ; -#endif } #endif /* NO_MD5 */ diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index be2106cbd..d1b2dc572 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -452,20 +452,13 @@ int wc_ShaHash(const byte* data, word32 len, byte* hash) } -#ifdef WOLFSSL_TI_HASH -#include "wolfssl/wolfcrypt/port/ti/ti-hash.h" -#endif int wc_ShaGetHash(Sha* sha, byte* hash) { -#if defined(WOLFSS_TI_HASH) - wc_ShaGetHash_TI(sha, hash) ; -#else int ret ; Sha save = *sha ; ret = wc_ShaFinal(sha, hash) ; *sha = save ; return ret ; -#endif } #endif /* HAVE_FIPS */ diff --git a/wolfcrypt/src/sha256.c b/wolfcrypt/src/sha256.c index 90f99a35b..93e94666d 100644 --- a/wolfcrypt/src/sha256.c +++ b/wolfcrypt/src/sha256.c @@ -576,20 +576,13 @@ int wc_Sha256Hash(const byte* data, word32 len, byte* hash) return ret; } -#ifdef WOLFSSL_TI_HASH -#include "wolfssl/wolfcrypt/port/ti/ti-hash.h" -#endif int wc_Sha256GetHash(Sha256* sha256, byte* hash) { -#if defined(WOLFSS_TI_HASH) - return wc_Sha256GetHash_TI(sha256, hash) ; -#else int ret ; Sha256 save = *sha256 ; ret = wc_Sha256Final(sha256, hash) ; *sha256 = save ; return ret ; -#endif } #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2) diff --git a/wolfssl/wolfcrypt/port/ti/ti-ccm.h b/wolfssl/wolfcrypt/port/ti/ti-ccm.h new file mode 100644 index 000000000..f0fb24799 --- /dev/null +++ b/wolfssl/wolfcrypt/port/ti/ti-ccm.h @@ -0,0 +1,40 @@ +/* port/ti/ti_ccm.c + * + * Copyright (C) 2006-2015 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 +#endif + +#include + +#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH) + +bool wolfSSL_TI_CCMInit(void) ; + +#ifndef SINGLE_THREADED +void wolfSSL_TI_lockCCM() ; +void wolfSSL_TI_unlockCCM() ; +#else +#define wolfSSL_TI_lockCCM() +#define wolfSSL_TI_unlockCCM() +#endif + +#endif diff --git a/wolfssl/wolfcrypt/port/ti/ti-hash.h b/wolfssl/wolfcrypt/port/ti/ti-hash.h new file mode 100644 index 000000000..505ccc498 --- /dev/null +++ b/wolfssl/wolfcrypt/port/ti/ti-hash.h @@ -0,0 +1,64 @@ +/* port/ti/ti-hash.h + * + * Copyright (C) 2006-2015 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 + */ + +#ifndef WOLF_CRYPT_TI_HASH_H +#define WOLF_CRYPT_TI_HASH_H + +#include + +#ifndef WOLFSSL_TI_INITBUFF +#define WOLFSSL_TI_INITBUFF 64 +#endif + +#define WOLFSSL_MAX_HASH_SIZE 64 + +typedef struct { + byte *msg ; + word32 used ; + word32 len ; + byte hash[WOLFSSL_MAX_HASH_SIZE] ; +} wolfssl_TI_Hash ; + + +#ifndef TI_HASH_TEST +#if !defined(NO_MD5) +typedef wolfssl_TI_Hash Md5 ; + +#endif +#if !defined(NO_SHA) +typedef wolfssl_TI_Hash Sha ; +#endif +#if !defined(NO_SHA256) +typedef wolfssl_TI_Hash Sha256 ; +#endif + +#if defined(HAVE_SHA224) +typedef wolfssl_TI_Hash Sha224 ; +#define SHA224_DIGEST_SIZE 28 + +WOLFSSL_API int wc_InitSha224(Sha224* sha224) ; +WOLFSSL_API int wc_Sha224Update(Sha224* sha224, const byte* data, word32 len) ; +WOLFSSL_API int wc_Sha224Final(Sha224* sha224, byte* hash) ; +WOLFSSL_API int wc_Sha224Hash(const byte* data, word32 len, byte*hash) ; + +#endif +#endif +#endif /* WOLF_CRYPT_TI_HASH_H */