forked from wolfSSL/wolfssl
Fix SE050 Port
The SE050 port won't compile in the latest wolfSSL. This patch: * Updates the documentation * Fixes a missing `#ifdef` that breaks the build * Changes the use of `mp_int` to `MATH_INT_T` * Fixes compiler error with `ecc.c` * Adds a tiny bit of extra debugging info
This commit is contained in:
@ -2732,7 +2732,7 @@ AC_ARG_WITH([se050],
|
|||||||
[
|
[
|
||||||
AC_MSG_CHECKING([for SE050])
|
AC_MSG_CHECKING([for SE050])
|
||||||
|
|
||||||
LIBS="$LIBS -lSSS_APIs"
|
LIBS="$LIBS -lSSS_APIs -lex_common"
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <fsl_sss_api.h>]], [[ sss_mac_init(0);]])],[ libse050_linked=yes ],[ libse050_linked=no ])
|
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <fsl_sss_api.h>]], [[ sss_mac_init(0);]])],[ libse050_linked=yes ],[ libse050_linked=no ])
|
||||||
|
|
||||||
if test "x$libse050_linked" = "xno" ; then
|
if test "x$libse050_linked" = "xno" ; then
|
||||||
|
@ -9225,6 +9225,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
|
|||||||
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
|
#elif defined(WOLFSSL_XILINX_CRYPT_VERSAL)
|
||||||
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2];
|
byte sigRS[ECC_MAX_CRYPTO_HW_SIZE * 2];
|
||||||
byte hashcopy[ECC_MAX_CRYPTO_HW_SIZE] = {0};
|
byte hashcopy[ECC_MAX_CRYPTO_HW_SIZE] = {0};
|
||||||
|
#elif defined(WOLFSSL_SE050)
|
||||||
#else
|
#else
|
||||||
int curveLoaded = 0;
|
int curveLoaded = 0;
|
||||||
DECLARE_CURVE_SPECS(ECC_CURVE_FIELD_COUNT);
|
DECLARE_CURVE_SPECS(ECC_CURVE_FIELD_COUNT);
|
||||||
|
@ -34,21 +34,24 @@ Raspberry Pi, [here](https://www.nxp.com/docs/en/application-note/AN12570.pdf).
|
|||||||
|
|
||||||
Summarizing the build steps for Raspberry Pi:
|
Summarizing the build steps for Raspberry Pi:
|
||||||
|
|
||||||
|
In `raspi-config` go to "Interface Options" and enable I2C.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
$ sudo apt update
|
||||||
|
$ sudo apt install cmake libssl-dev cmake-curses-gui git
|
||||||
$ cd ~
|
$ cd ~
|
||||||
$ mkdir se_mw
|
$ mkdir se_mw
|
||||||
$ unzip SE-PLUG-TRUST-MW.zip -d se_mw
|
$ unzip SE-PLUG-TRUST-MW.zip -d se_mw
|
||||||
$ cd se_mw/simw-top/scripts
|
$ cd se_mw/se05x_mw_v04.05.01/simw-top/scripts
|
||||||
$ python create_cmake_projects.py rpi
|
$ python create_cmake_projects.py rpi
|
||||||
$ cd ~/se_mw/simw-top_build/raspbian_native_se050_t1oi2c
|
$ cd ~/se_mw/se05x_mw_v04.05.01/simw-top_build/raspbian_native_se050_t1oi2c
|
||||||
$ ccmake .
|
$ ccmake .
|
||||||
# Make sure the following are set:
|
# Make sure the following are set:
|
||||||
# `Host OS` to `Raspbian`
|
# `PTMW_Host` to `Raspbian`
|
||||||
# `Host Crypto` to `None` (see HostCrypto section below)
|
# `PTMW_HostCrypto` to `User` (see HostCrypto section below)
|
||||||
# `SMCOM` to `T1oI2C`
|
# `SMCOM` to `T1oI2C`
|
||||||
$ c # to configure
|
$ c # to configure
|
||||||
$ g # to generate
|
$ g # to generate, this will exit upon completion
|
||||||
$ q
|
|
||||||
$ cmake --build .
|
$ cmake --build .
|
||||||
$ sudo make install
|
$ sudo make install
|
||||||
```
|
```
|
||||||
@ -56,7 +59,7 @@ $ sudo make install
|
|||||||
This will also compile several demo apps which can be run if wanted, ie:
|
This will also compile several demo apps which can be run if wanted, ie:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cd ~/se_mw/simw-top_build/raspbian_native_se050_t1oi2c/bin
|
$ cd ~/se_mw/se05x_mw_v04.05.01/simw-top_build/raspbian_native_se050_t1oi2c/bin
|
||||||
$ ./ex_ecc # (or, ./se05x_GetInfo, etc)
|
$ ./ex_ecc # (or, ./se05x_GetInfo, etc)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2332,6 +2332,7 @@ void se050_ecc_free_key(struct ecc_key* key)
|
|||||||
if (status == kStatus_SSS_Success) {
|
if (status == kStatus_SSS_Success) {
|
||||||
status = sss_key_object_get_handle(&keyObject, key->keyId);
|
status = sss_key_object_get_handle(&keyObject, key->keyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == kStatus_SSS_Success) {
|
if (status == kStatus_SSS_Success) {
|
||||||
sss_key_object_free(&keyObject);
|
sss_key_object_free(&keyObject);
|
||||||
key->keyId = 0;
|
key->keyId = 0;
|
||||||
@ -2532,8 +2533,8 @@ int se050_ecc_create_key(struct ecc_key* key, int curve_id, int keySize)
|
|||||||
wolfSSL_CryptHwMutexUnLock();
|
wolfSSL_CryptHwMutexUnLock();
|
||||||
|
|
||||||
#ifdef SE050_DEBUG
|
#ifdef SE050_DEBUG
|
||||||
printf("se050_ecc_create_key: key %p, ret %d, keyId %d\n",
|
printf("se050_ecc_create_key: key %p, ret %d, status %d, keyId %d\n",
|
||||||
key, ret, key->keyId);
|
key, ret, status, key->keyId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -2688,7 +2689,8 @@ int se050_ecc_shared_secret(ecc_key* private_key, ecc_key* public_key,
|
|||||||
wolfSSL_CryptHwMutexUnLock();
|
wolfSSL_CryptHwMutexUnLock();
|
||||||
|
|
||||||
#ifdef SE050_DEBUG
|
#ifdef SE050_DEBUG
|
||||||
printf("se050_ecc_shared_secret: ret %d, outlen %d\n", ret, *outlen);
|
printf("se050_ecc_shared_secret: ret %d, status %d, outlen %d\n", ret,
|
||||||
|
status, *outlen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -155,13 +155,14 @@ WOLFSSL_LOCAL void se050_aes_free(struct Aes* aes);
|
|||||||
struct WC_RNG;
|
struct WC_RNG;
|
||||||
struct ecc_key;
|
struct ecc_key;
|
||||||
|
|
||||||
|
#ifdef HAVE_ECC
|
||||||
WOLFSSL_LOCAL int se050_ecc_use_key_id(struct ecc_key* key, word32 keyId);
|
WOLFSSL_LOCAL int se050_ecc_use_key_id(struct ecc_key* key, word32 keyId);
|
||||||
WOLFSSL_LOCAL int se050_ecc_get_key_id(struct ecc_key* key, word32* keyId);
|
WOLFSSL_LOCAL int se050_ecc_get_key_id(struct ecc_key* key, word32* keyId);
|
||||||
WOLFSSL_LOCAL int se050_ecc_sign_hash_ex(const byte* in, word32 inLen,
|
WOLFSSL_LOCAL int se050_ecc_sign_hash_ex(const byte* in, word32 inLen,
|
||||||
mp_int* r, mp_int* s, byte* out, word32 *outLen, struct ecc_key* key);
|
MATH_INT_T* r, MATH_INT_T* s, byte* out, word32 *outLen, struct ecc_key* key);
|
||||||
|
|
||||||
WOLFSSL_LOCAL int se050_ecc_verify_hash_ex(const byte* hash, word32 hashlen,
|
WOLFSSL_LOCAL int se050_ecc_verify_hash_ex(const byte* hash, word32 hashlen,
|
||||||
mp_int* r, mp_int* s, struct ecc_key* key, int* res);
|
MATH_INT_T* r, MATH_INT_T* s, struct ecc_key* key, int* res);
|
||||||
|
|
||||||
WOLFSSL_LOCAL int se050_ecc_create_key(struct ecc_key* key, int curve_id,
|
WOLFSSL_LOCAL int se050_ecc_create_key(struct ecc_key* key, int curve_id,
|
||||||
int keySize);
|
int keySize);
|
||||||
|
Reference in New Issue
Block a user