misc fixes and correct name for test file

This commit is contained in:
JacobBarthelmeh
2024-03-05 18:31:42 +07:00
parent b42a8b6c5d
commit 11c9035a62
8 changed files with 80 additions and 62 deletions

View File

@ -1,6 +1,6 @@
/* cryif.c
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
@ -47,7 +47,13 @@ void CryIf_Init(const CryIf_ConfigType* in)
void CryIf_GetVersionInfo(Std_VersionInfoType* ver)
{
(void)ver;
if (ver != NULL) {
ver->vendorID = 0; /* no vendor or module ID */
ver->moduleID = 0;
ver->sw_major_version = 5;
ver->sw_minor_version = 6;
ver->sw_patch_version = 6;
}
}

View File

@ -1,6 +1,6 @@
/* crypto.c
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
@ -101,38 +101,44 @@ static int GetKey(Crypto_JobType* job, uint32 eId, uint8 **key, uint32 *keySz)
}
// @TODO sanity checks on setup... uint8 redirectionConfig;
if (eId == job->jobRedirectionInfoRef->inputKeyElementId) {
if (job->jobRedirectionInfoRef->inputKeyId >= MAX_KEYSTORE) {
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
switch (eid) {
case job->jobRedirectionInfoRef->inputKeyElementId:
if (job->jobRedirectionInfoRef->inputKeyId >= MAX_KEYSTORE) {
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
ret = -1;
}
else {
i = job->jobRedirectionInfoRef->inputKeyId;
*key = keyStore[i].key;
*keySz = keyStore[i].keyLen;
}
break;
case job->jobRedirectionInfoRef->secondaryInputKeyElementId:
if (job->jobRedirectionInfoRef->secondaryInputKeyId >= MAX_KEYSTORE) {
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
ret = -1;
}
else {
i = job->jobRedirectionInfoRef->secondaryInputKeyId;
*key = keyStore[i].key;
*keySz = keyStore[i].keyLen;
}
break;
case job->jobRedirectionInfoRef->tertiaryInputKeyElementId:
if (job->jobRedirectionInfoRef->tertiaryInputKeyId >= MAX_KEYSTORE) {
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
ret = -1;
}
else {
i = job->jobRedirectionInfoRef->tertiaryInputKeyId;
*key = keyStore[i].key;
*keySz = keyStore[i].keyLen;
}
break;
default:
WOLFSSL_MSG("Unknown key element ID");
ret = -1;
}
else {
i = job->jobRedirectionInfoRef->inputKeyId;
*key = keyStore[i].key;
*keySz = keyStore[i].keyLen;
}
}
if (eId == job->jobRedirectionInfoRef->secondaryInputKeyElementId) {
if (job->jobRedirectionInfoRef->secondaryInputKeyId >= MAX_KEYSTORE) {
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
ret = -1;
}
else {
i = job->jobRedirectionInfoRef->secondaryInputKeyId;
*key = keyStore[i].key;
*keySz = keyStore[i].keyLen;
}
}
if (eId == job->jobRedirectionInfoRef->tertiaryInputKeyElementId) {
if (job->jobRedirectionInfoRef->tertiaryInputKeyId >= MAX_KEYSTORE) {
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
ret = -1;
}
else {
i = job->jobRedirectionInfoRef->tertiaryInputKeyId;
*key = keyStore[i].key;
*keySz = keyStore[i].keyLen;
}
break;
}
#else
/* find first key of key element type */
@ -180,8 +186,15 @@ static Aes* NewAesStruct(Crypto_JobType* job)
for (i = 0; i < MAX_JOBS; i++) {
if (activeJobs[i].inUse == 0) {
int ret;
activeJobs[i].inUse = 1;
activeJobs[i].jobId = job->jobId;
ret = wc_AesInit(&activeJobs[i].aes, NULL, INVALID_DEVID);
if (ret != 0) {
WOLFSSL_MSG("Error initializing AES structure");
return NULL;
}
return &activeJobs[i].aes;
}
}
@ -252,7 +265,7 @@ Std_ReturnType wolfSSL_Crypto_CBC(Crypto_JobType* job)
WOLFSSL_MSG("Crypto error setting up AES key");
return E_NOT_OK;
}
/* ForceZero(key, keySz); Do not keep raw key in memory */
ForceZero(key, keySz);
}
if ((job->jobPrimitiveInputOutput.mode & CRYPTO_OPERATIONMODE_UPDATE)

View File

@ -1,6 +1,6 @@
/* csm.c
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
@ -156,18 +156,16 @@ void Csm_Init(const Csm_ConfigType* config)
}
/* not yet implemented */
/* getter function for CSM version info */
void Csm_GetVersionInfo(Std_VersionInfoType* version)
{
(void)version;
/*
version->vendorID = ; //uint16
version->moduleID = ; //uint16
version->sw_major_version = ; //uint8
version->sw_minor_version = ; //uint8
version->sw_patch_version = ; //uint8
*/
if (version != NULL) {
version->vendorID = 0; /* no vendor or module ID */
version->moduleID = 0;
version->sw_major_version = 5;
version->sw_minor_version = 6;
version->sw_patch_version = 6;
}
}

View File

@ -3,7 +3,7 @@ EXTRA_DIST += wolfcrypt/src/port/autosar/csm.c \
wolfcrypt/src/port/autosar/crypto.c \
wolfcrypt/src/port/autosar/cryif.c \
wolfcrypt/src/port/autosar/README.md \
wolfcrypt/src/port/autosar/example.c
wolfcrypt/src/port/autosar/test.c
if BUILD_AUTOSAR
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/autosar/csm.c
@ -11,13 +11,13 @@ src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/autosar/crypto.c
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/autosar/cryif.c
if BUILD_TESTS
check_PROGRAMS += wolfcrypt/src/port/autosar/example.test
noinst_PROGRAMS += wolfcrypt/src/port/autosar/example.test
check_PROGRAMS += wolfcrypt/src/port/autosar/test.test
noinst_PROGRAMS += wolfcrypt/src/port/autosar/test.test
wolfcrypt_src_port_autosar_example_test_SOURCES = \
wolfcrypt/src/port/autosar/example.c
wolfcrypt_src_port_autosar_example_test_LDADD = \
wolfcrypt_src_port_autosar_test_test_SOURCES = \
wolfcrypt/src/port/autosar/test.c
wolfcrypt_src_port_autosar_test_test_LDADD = \
src/libwolfssl.la $(LIB_STATIC_ADD)
wolfcrypt_src_port_autosar_example_test_DEPENDENCIES = src/libwolfssl.la
wolfcrypt_src_port_autosar_test_test_DEPENDENCIES = src/libwolfssl.la
endif
endif

View File

@ -1,6 +1,6 @@
/* example.c
/* test.c
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
@ -46,8 +46,8 @@ static int singleshot_test(void)
0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,
0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb
};
const uint8 key[] = "0123456789abcdef "; /* align */
const uint8 iv[] = "1234567890abcdef "; /* align */
const uint8 key[] = "0123456789abcdef ";
const uint8 iv[] = "1234567890abcdef ";
XMEMSET(cipher, 0, BLOCK_SIZE);
XMEMSET(plain, 0, BLOCK_SIZE);

View File

@ -1,6 +1,6 @@
/* CryIf.h
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*

View File

@ -1,6 +1,6 @@
/* Crypto.h
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*

View File

@ -1,6 +1,6 @@
/* csm.h
*
* Copyright (C) 2006-2019 wolfSSL Inc.
* Copyright (C) 2006-2024 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
@ -83,7 +83,7 @@ typedef enum Crypto_ServiceInfoType {
CRYPTO_DECRYPT = 0x04,
CRYPTO_RANDOMGENERATE = 0x0B,
#if 0
#ifdef CSM_UNSUPPORTED_ALGS
/* not yet supported */
CRYPTO_HASH = 0x00,
CRYPTO_MACGENERATE = 0x01,
@ -107,7 +107,8 @@ typedef enum Crypto_ServiceInfoType {
typedef enum Crypto_AlgorithmModeType {
CRYPTO_ALGOMODE_NOT_SET = 0x00,
CRYPTO_ALGOMODE_CBC = 0x02,
#if 0
#ifdef CSM_UNSUPPORTED_ALGS
/* not yet supported */
CRYPTO_ALGOMODE_ECB = 0x01,
CRYPTO_ALGOMODE_CFB = 0x03,