diff --git a/wolfcrypt/src/include.am b/wolfcrypt/src/include.am index 3e0b5abb8..315388e12 100644 --- a/wolfcrypt/src/include.am +++ b/wolfcrypt/src/include.am @@ -60,7 +60,8 @@ EXTRA_DIST += wolfcrypt/src/port/ti/ti-aes.c \ wolfcrypt/src/port/caam/caam_driver.c \ wolfcrypt/src/port/caam/caam_init.c \ wolfcrypt/src/port/caam/caam_sha.c \ - wolfcrypt/src/port/caam/caam_doc.pdf + wolfcrypt/src/port/caam/caam_doc.pdf \ + wolfcrypt/src/port/st/stm32.c if BUILD_CAVIUM src_libwolfssl_la_SOURCES += wolfcrypt/src/port/cavium/cavium_nitrox.c diff --git a/wolfcrypt/src/md5.c b/wolfcrypt/src/md5.c index 5754fa983..e8314b213 100644 --- a/wolfcrypt/src/md5.c +++ b/wolfcrypt/src/md5.c @@ -50,7 +50,6 @@ #if defined(STM32_HASH) /* Supports CubeMX HAL or Standard Peripheral Library */ - #include #define HAVE_MD5_CUST_API int wc_InitMd5_ex(wc_Md5* md5, void* heap, int devId) diff --git a/wolfssl/wolfcrypt/port/st/stm32_hash.h b/wolfcrypt/src/port/st/stm32.c similarity index 83% rename from wolfssl/wolfcrypt/port/st/stm32_hash.h rename to wolfcrypt/src/port/st/stm32.c index 7796e9163..6ce216bd5 100644 --- a/wolfssl/wolfcrypt/port/st/stm32_hash.h +++ b/wolfcrypt/src/port/st/stm32.c @@ -1,11 +1,33 @@ -#ifndef _WOLFPORT_STM32_HASH_H_ -#define _WOLFPORT_STM32_HASH_H_ - -#ifdef STM32_HASH +/* stm32.c + * + * Copyright (C) 2006-2017 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * 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-1335, USA + */ /* Generic STM32 Hashing Function */ /* Supports CubeMX HAL or Standard Peripheral Library */ +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + #include #include #include @@ -17,6 +39,7 @@ #include #endif +#ifdef STM32_HASH /* User can override STM32_HASH_CLOCK_ENABLE and STM32_HASH_CLOCK_DISABLE */ #ifndef STM32_HASH_CLOCK_ENABLE @@ -123,13 +146,14 @@ static inline int wc_Stm32_Hash_WaitDone(void) return 0; } -static inline void wc_Stm32_Hash_Init(STM32_HASH_Context* stmCtx) + +void wc_Stm32_Hash_Init(STM32_HASH_Context* stmCtx) { /* clear context */ XMEMSET(stmCtx, 0, sizeof(STM32_HASH_Context)); } -static int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo, +int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo, const byte* data, int len) { int ret = 0; @@ -185,7 +209,7 @@ static int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo, return ret; } -static inline int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, +int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, byte* hash, int digestSize) { int ret = 0; @@ -225,5 +249,3 @@ static inline int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, } #endif /* STM32_HASH */ - -#endif /* _WOLFPORT_STM32_HASH_H_ */ diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index 9f9364284..3a4a97376 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -95,7 +95,6 @@ #elif defined(STM32_HASH) /* Supports CubeMX HAL or Standard Peripheral Library */ - #include int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId) { if (sha == NULL) { diff --git a/wolfcrypt/src/sha256.c b/wolfcrypt/src/sha256.c index 68d80d166..f260f366c 100644 --- a/wolfcrypt/src/sha256.c +++ b/wolfcrypt/src/sha256.c @@ -374,7 +374,6 @@ static int InitSha256(wc_Sha256* sha256) #elif defined(STM32_HASH_SHA2) /* Supports CubeMX HAL or Standard Peripheral Library */ - #include int wc_InitSha256_ex(wc_Sha256* sha256, void* heap, int devId) { @@ -2476,7 +2475,6 @@ SHA256_NOINLINE static int Transform_Sha256_AVX2_RORX_Len(wc_Sha256* sha256, #ifdef STM32_HASH_SHA2 /* Supports CubeMX HAL or Standard Peripheral Library */ - #include int wc_InitSha224_ex(wc_Sha224* sha224, void* heap, int devId) { diff --git a/wolfssl/wolfcrypt/include.am b/wolfssl/wolfcrypt/include.am index e768b749c..565f69f4d 100644 --- a/wolfssl/wolfcrypt/include.am +++ b/wolfssl/wolfcrypt/include.am @@ -75,8 +75,7 @@ noinst_HEADERS+= \ wolfssl/wolfcrypt/port/caam/caam_driver.h \ wolfssl/wolfcrypt/port/caam/wolfcaam.h \ wolfssl/wolfcrypt/port/caam/wolfcaam_sha.h \ - wolfssl/wolfcrypt/port/st/stm32.h \ - wolfssl/wolfcrypt/port/st/stm32_hash.h + wolfssl/wolfcrypt/port/st/stm32.h if BUILD_ASYNCCRYPT nobase_include_HEADERS+= wolfssl/wolfcrypt/async.h diff --git a/wolfssl/wolfcrypt/port/st/stm32.h b/wolfssl/wolfcrypt/port/st/stm32.h index 1f011820a..2c82b4760 100644 --- a/wolfssl/wolfcrypt/port/st/stm32.h +++ b/wolfssl/wolfcrypt/port/st/stm32.h @@ -1,3 +1,24 @@ +/* stm32.h + * + * Copyright (C) 2006-2017 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * 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-1335, USA + */ + #ifndef _WOLFPORT_STM32_H_ #define _WOLFPORT_STM32_H_ @@ -50,6 +71,13 @@ typedef struct { } STM32_HASH_Context; +/* API's */ +void wc_Stm32_Hash_Init(STM32_HASH_Context* stmCtx); +int wc_Stm32_Hash_Update(STM32_HASH_Context* stmCtx, word32 algo, + const byte* data, int len); +int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo, + byte* hash, int digestSize); + #endif /* STM32_HASH */ #endif /* _WOLFPORT_STM32_H_ */