forked from wolfSSL/wolfssl
aes.c cleaned. ti-has.c, ti-aes.c, ti-des3.c are included in each respective algorithm source file.
This commit is contained in:
@@ -174,6 +174,11 @@ void wc_AesFreeCavium(Aes* aes)
|
||||
}
|
||||
#endif
|
||||
#else /* HAVE_FIPS */
|
||||
|
||||
#ifdef WOLFSSL_TI_CRYPT
|
||||
#include <wolfcrypt/src/port/ti/ti-aes.c>
|
||||
#else
|
||||
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
#ifdef NO_INLINE
|
||||
@@ -230,10 +235,6 @@ void wc_AesFreeCavium(Aes* aes)
|
||||
word32 length);
|
||||
static int wc_AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
|
||||
word32 length);
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
|
||||
/* defined in port/ti_aes.c */
|
||||
|
||||
#else
|
||||
/* using CTaoCrypt software AES implementation */
|
||||
#define NEED_AES_TABLES
|
||||
@@ -1509,11 +1510,6 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
||||
{
|
||||
return wc_AesSetKey(aes, userKey, keylen, iv, dir);
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
|
||||
/* defined in port/ti_md5.c */
|
||||
|
||||
#else
|
||||
static int wc_AesSetKeyLocal(Aes* aes, const byte* userKey, word32 keylen,
|
||||
const byte* iv, int dir)
|
||||
@@ -1784,10 +1780,6 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
#elif defined(WOLFSSL_PIC32MZ_CRYPT)
|
||||
#error "PIC32MZ doesn't yet support AES direct"
|
||||
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
|
||||
/* defined in port/ti_aes.c */
|
||||
|
||||
#else
|
||||
/* Allow direct access to one block encrypt */
|
||||
void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in)
|
||||
@@ -2322,10 +2314,6 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
|
||||
/* defined in port/ti_aes.c */
|
||||
|
||||
#else
|
||||
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
|
||||
{
|
||||
@@ -2606,10 +2594,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
|
||||
#elif defined(FREESCALE_MMCAU)
|
||||
#error "Freescale mmCAU doesn't currently support AES-CTR mode"
|
||||
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
/* defined in port/ti/ti_aes.c */
|
||||
|
||||
|
||||
#else
|
||||
/* Increment AES counter */
|
||||
static INLINE void IncrementAesCounter(byte* inOutCtr)
|
||||
@@ -2691,7 +2676,7 @@ enum {
|
||||
CTR_SZ = 4
|
||||
};
|
||||
|
||||
#if !defined(WOLFSSL_TI_CRYPT)
|
||||
|
||||
static INLINE void InitGcmCounter(byte* inOutCtr)
|
||||
{
|
||||
inOutCtr[AES_BLOCK_SIZE - 4] = 0;
|
||||
@@ -2796,10 +2781,6 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
|
||||
if (ret == 0) {
|
||||
#ifdef FREESCALE_MMCAU
|
||||
cau_aes_encrypt(iv, rk, aes->rounds, aes->H);
|
||||
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
/* defined in port/ti/ti_aes.c */
|
||||
|
||||
#else
|
||||
wc_AesEncrypt(aes, iv, aes->H);
|
||||
#endif
|
||||
@@ -3313,7 +3294,8 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz,
|
||||
}
|
||||
|
||||
#endif /* end GCM_WORD32 */
|
||||
|
||||
|
||||
|
||||
int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
@@ -3468,7 +3450,8 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
|
||||
{
|
||||
@@ -3500,7 +3483,6 @@ WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_TI_CRYPT)
|
||||
void wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
|
||||
{
|
||||
byte nonce[AES_BLOCK_SIZE];
|
||||
@@ -3781,7 +3763,6 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* WOLFCRYPT_TI_CRYPT */
|
||||
|
||||
#endif /* HAVE_AESCCM */
|
||||
|
||||
@@ -3909,6 +3890,8 @@ static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in,
|
||||
|
||||
#endif /* HAVE_CAVIUM */
|
||||
|
||||
#endif /* WOLFSSL_TI_CRYPT */
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#endif /* NO_AES */
|
||||
|
@@ -129,6 +129,11 @@ void wc_Des3_FreeCavium(Des3* des3)
|
||||
|
||||
#endif /* HAVE_CAVIUM */
|
||||
#else /* build without fips */
|
||||
|
||||
#if defined(WOLFSSL_TI_CRYPT)
|
||||
#include <wolfcrypt/src/port/ti/ti-des3.c>
|
||||
#else
|
||||
|
||||
#include <wolfssl/wolfcrypt/error-crypt.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
|
||||
@@ -943,9 +948,6 @@ int wc_Des3_SetIV(Des3* des, const byte* iv);
|
||||
PIC32_DECRYPTION, PIC32_ALGO_TDES, PIC32_CRYPTOALGO_TCBC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_TI_CRYPT)
|
||||
/* defined in port/ti/ti-des3.c */
|
||||
|
||||
#else /* CTaoCrypt software implementation */
|
||||
|
||||
@@ -1671,5 +1673,6 @@ static int wc_Des3_CaviumCbcDecrypt(Des3* des3, byte* out, const byte* in,
|
||||
}
|
||||
|
||||
#endif /* HAVE_CAVIUM */
|
||||
#endif /* WOLFSSL_TI_CRYPT */
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* NO_DES3 */
|
||||
|
@@ -26,7 +26,12 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if !defined(NO_MD5) && !defined(WOLFSSL_TI_HASH)
|
||||
#if !defined(NO_MD5)
|
||||
|
||||
#if defined(WOLFSSL_TI_HASH)
|
||||
#define WOLFSSL_TI_MD5
|
||||
#include <wolfcrypt/src/port/ti/ti-hash.c>
|
||||
#else
|
||||
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
#define wc_InitMd5 wc_InitMd5_sw
|
||||
@@ -164,10 +169,6 @@
|
||||
wc_InitMd5(md5); /* reset state */
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_IT_HASH)
|
||||
|
||||
/* defined in port/ti_hash.c */
|
||||
|
||||
#else /* CTaoCrypt software implementation */
|
||||
|
||||
#ifndef WOLFSSL_HAVE_MIN
|
||||
@@ -392,4 +393,6 @@ int wc_Md5Hash(const byte* data, word32 len, byte* hash)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_TI_HASH */
|
||||
|
||||
#endif /* NO_MD5 */
|
||||
|
@@ -144,7 +144,7 @@ static int hashHash(const byte* data, word32 len, byte* hash, word32 algo, word3
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(NO_MD5)
|
||||
#if !defined(NO_MD5) && defined(WOLFSSL_TI_MD5)
|
||||
WOLFSSL_API void wc_InitMd5(Md5* md5)
|
||||
{
|
||||
if (md5 == NULL)
|
||||
@@ -175,7 +175,7 @@ WOLFSSL_API int wc_Md5Hash(const byte*data, word32 len, byte*hash)
|
||||
|
||||
#endif /* NO_MD5 */
|
||||
|
||||
#if !defined(NO_SHA)
|
||||
#if !defined(NO_SHA) && defined(WOLFSSL_TI_SHA)
|
||||
WOLFSSL_API int wc_InitSha(Sha* sha)
|
||||
{
|
||||
if (sha == NULL)
|
||||
@@ -206,7 +206,7 @@ WOLFSSL_API int wc_ShaHash(const byte*data, word32 len, byte*hash)
|
||||
|
||||
#endif /* NO_SHA */
|
||||
|
||||
#if defined(HAVE_SHA224)
|
||||
#if defined(HAVE_SHA224) && defined(WOLFSSL_TI_SHA224)
|
||||
WOLFSSL_API int wc_InitSha224(Sha224* sha224)
|
||||
{
|
||||
if (sha224 == NULL)
|
||||
@@ -237,7 +237,7 @@ WOLFSSL_API int wc_Sha224Hash(const byte* data, word32 len, byte*hash)
|
||||
|
||||
#endif /* HAVE_SHA224 */
|
||||
|
||||
#if !defined(NO_SHA256)
|
||||
#if !defined(NO_SHA256) && defined(WOLFSSL_TI_SHA256)
|
||||
WOLFSSL_API int wc_InitSha256(Sha256* sha256)
|
||||
{
|
||||
if (sha256 == NULL)
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
|
||||
#if !defined(NO_SHA) && !defined(WOLFSSL_TI_HASH)
|
||||
#if !defined(NO_SHA)
|
||||
|
||||
#include <wolfssl/wolfcrypt/sha.h>
|
||||
#include <wolfssl/wolfcrypt/logging.h>
|
||||
@@ -64,6 +64,11 @@
|
||||
|
||||
#else /* else build without fips */
|
||||
|
||||
#if defined(WOLFSSL_TI_HASH)
|
||||
#define WOLFSSL_TI_SHA
|
||||
#include <wolfcrypt/src/port/ti/ti-hash.c>
|
||||
#else
|
||||
|
||||
#ifdef WOLFSSL_PIC32MZ_HASH
|
||||
#define wc_InitSha wc_InitSha_sw
|
||||
#define wc_ShaUpdate wc_ShaUpdate_sw
|
||||
@@ -196,10 +201,6 @@ int wc_ShaFinal(Sha* sha, byte* hash)
|
||||
return wc_InitSha(sha); /* reset state */
|
||||
}
|
||||
|
||||
#elif defined(WOLFSSL_TI_HASH)
|
||||
|
||||
/* defined in port/ti/ti_hash.c */
|
||||
|
||||
#else /* wc_ software implementation */
|
||||
|
||||
#ifndef WOLFSSL_HAVE_MIN
|
||||
@@ -453,5 +454,6 @@ int wc_ShaHash(const byte* data, word32 len, byte* hash)
|
||||
}
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
#endif /* WOLFSSL_TI_HASH */
|
||||
#endif /* NO_SHA */
|
||||
|
||||
|
@@ -56,8 +56,13 @@ int wc_Sha256Hash(const byte* data, word32 len, byte* out)
|
||||
|
||||
#else /* else build without fips */
|
||||
|
||||
#if !defined(NO_SHA256) && !defined(WOLFSSL_TI_HASH)
|
||||
/* defined in port/ti/ti_hash.c */
|
||||
#if !defined(NO_SHA256) && defined(WOLFSSL_TI_HASH)
|
||||
#define WOLFSSL_TI_SHA256
|
||||
#ifdef HAVE_SHA224
|
||||
#define WOLFSSL_TI_SHA224
|
||||
#endif
|
||||
#include <wolfcrypt/src/port/ti/ti-hash.c>
|
||||
#else
|
||||
|
||||
#if !defined (ALIGN32)
|
||||
#if defined (__GNUC__)
|
||||
@@ -1757,9 +1762,9 @@ static int Transform_AVX2(Sha256* sha256)
|
||||
|
||||
#endif /* HAVE_INTEL_AVX2 */
|
||||
|
||||
#endif /* WOLFSSL_TI_HAHS */
|
||||
|
||||
#endif /* HAVE_FIPS */
|
||||
|
||||
#endif /* WOLFSSL_TI_HAHS */
|
||||
|
||||
#endif /* NO_SHA256 */
|
||||
|
||||
|
@@ -649,4 +649,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
|
||||
#endif /* USE_WINDOWS_API */
|
||||
|
||||
#endif /* SINGLE_THREADED */
|
||||
|
||||
|
||||
#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
|
||||
#include <wolfcrypt/src/port/ti/ti-ccm.c> /* initialize and Mutex for TI Crypt Engine */
|
||||
#endif
|
||||
|
@@ -88,6 +88,8 @@
|
||||
#include <wolfssl/wolfcrypt/ripemd.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssl/wolfcrypt/hash.h>
|
||||
|
||||
#ifdef WOLFSSL_CALLBACKS
|
||||
#include <wolfssl/callbacks.h>
|
||||
#include <signal.h>
|
||||
|
35
wolfssl/wolfcrypt/hash.h
Normal file
35
wolfssl/wolfcrypt/hash.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/* 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_HASH_H
|
||||
#define WOLF_CRYPT_HASH_H
|
||||
|
||||
#ifndef NO_MD5
|
||||
WOLFSSL_API void wc_Md5GetHash(Md5*, byte*);
|
||||
#endif
|
||||
#ifndef NO_SHA
|
||||
WOLFSSL_API int wc_ShaGetHash(Sha*, byte*);
|
||||
#endif
|
||||
#ifndef NO_SHA256
|
||||
WOLFSSL_API int wc_Sha256GetHash(Sha256*, byte*);
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -52,11 +52,6 @@ enum {
|
||||
#include "port/pic32/pic32mz-crypt.h"
|
||||
#endif
|
||||
|
||||
#ifdef TI_HASH_TEST
|
||||
#include "wolfssl/wolfcrypt/port/ti/ti-hash.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef WOLFSSL_TI_HASH
|
||||
|
||||
/* MD5 digest */
|
||||
@@ -81,7 +76,6 @@ WOLFSSL_API void wc_InitMd5(Md5*);
|
||||
WOLFSSL_API void wc_Md5Update(Md5*, const byte*, word32);
|
||||
WOLFSSL_API void wc_Md5Final(Md5*, byte*);
|
||||
WOLFSSL_API int wc_Md5Hash(const byte*, word32, byte*);
|
||||
WOLFSSL_API void wc_Md5GetHash(Md5*, byte*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@@ -77,7 +77,6 @@ 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*);
|
||||
WOLFSSL_API int wc_ShaGetHash(Sha*, byte*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@@ -75,7 +75,6 @@ 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*);
|
||||
WOLFSSL_API int wc_Sha256GetHash(Sha256*, byte*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
Reference in New Issue
Block a user