Moved the STM32 functions to their own .c file. Added GPL header. Finished testing on STM32 CubeMX with F4 and F7 and StdPeriLib with F4.

This commit is contained in:
David Garske
2018-02-05 12:57:06 -08:00
parent a4a5f4f27a
commit 0be1c10fcd
7 changed files with 62 additions and 16 deletions

View File

@@ -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

View File

@@ -50,7 +50,6 @@
#if defined(STM32_HASH)
/* Supports CubeMX HAL or Standard Peripheral Library */
#include <wolfssl/wolfcrypt/port/st/stm32_hash.h>
#define HAVE_MD5_CUST_API
int wc_InitMd5_ex(wc_Md5* md5, void* heap, int devId)

View File

@@ -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 <config.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/port/st/stm32.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/error-crypt.h>
@@ -17,6 +39,7 @@
#include <wolfcrypt/src/misc.c>
#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_ */

View File

@@ -95,7 +95,6 @@
#elif defined(STM32_HASH)
/* Supports CubeMX HAL or Standard Peripheral Library */
#include <wolfssl/wolfcrypt/port/st/stm32_hash.h>
int wc_InitSha_ex(wc_Sha* sha, void* heap, int devId)
{
if (sha == NULL) {

View File

@@ -374,7 +374,6 @@ static int InitSha256(wc_Sha256* sha256)
#elif defined(STM32_HASH_SHA2)
/* Supports CubeMX HAL or Standard Peripheral Library */
#include <wolfssl/wolfcrypt/port/st/stm32_hash.h>
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 <wolfssl/wolfcrypt/port/st/stm32_hash.h>
int wc_InitSha224_ex(wc_Sha224* sha224, void* heap, int devId)
{

View File

@@ -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

View File

@@ -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_ */