Skip to content

Commit 11c9035

Browse files
misc fixes and correct name for test file
1 parent b42a8b6 commit 11c9035

8 files changed

Lines changed: 80 additions & 62 deletions

File tree

wolfcrypt/src/port/autosar/cryif.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* cryif.c
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*
@@ -47,7 +47,13 @@ void CryIf_Init(const CryIf_ConfigType* in)
4747

4848
void CryIf_GetVersionInfo(Std_VersionInfoType* ver)
4949
{
50-
(void)ver;
50+
if (ver != NULL) {
51+
ver->vendorID = 0; /* no vendor or module ID */
52+
ver->moduleID = 0;
53+
ver->sw_major_version = 5;
54+
ver->sw_minor_version = 6;
55+
ver->sw_patch_version = 6;
56+
}
5157
}
5258

5359

wolfcrypt/src/port/autosar/crypto.c

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* crypto.c
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*
@@ -101,38 +101,44 @@ static int GetKey(Crypto_JobType* job, uint32 eId, uint8 **key, uint32 *keySz)
101101
}
102102

103103
// @TODO sanity checks on setup... uint8 redirectionConfig;
104-
if (eId == job->jobRedirectionInfoRef->inputKeyElementId) {
105-
if (job->jobRedirectionInfoRef->inputKeyId >= MAX_KEYSTORE) {
106-
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
107-
ret = -1;
108-
}
109-
else {
110-
i = job->jobRedirectionInfoRef->inputKeyId;
111-
*key = keyStore[i].key;
112-
*keySz = keyStore[i].keyLen;
113-
}
114-
}
115-
if (eId == job->jobRedirectionInfoRef->secondaryInputKeyElementId) {
116-
if (job->jobRedirectionInfoRef->secondaryInputKeyId >= MAX_KEYSTORE) {
117-
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
118-
ret = -1;
119-
}
120-
else {
121-
i = job->jobRedirectionInfoRef->secondaryInputKeyId;
122-
*key = keyStore[i].key;
123-
*keySz = keyStore[i].keyLen;
124-
}
125-
}
126-
if (eId == job->jobRedirectionInfoRef->tertiaryInputKeyElementId) {
127-
if (job->jobRedirectionInfoRef->tertiaryInputKeyId >= MAX_KEYSTORE) {
128-
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
104+
switch (eid) {
105+
case job->jobRedirectionInfoRef->inputKeyElementId:
106+
if (job->jobRedirectionInfoRef->inputKeyId >= MAX_KEYSTORE) {
107+
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
108+
ret = -1;
109+
}
110+
else {
111+
i = job->jobRedirectionInfoRef->inputKeyId;
112+
*key = keyStore[i].key;
113+
*keySz = keyStore[i].keyLen;
114+
}
115+
break;
116+
case job->jobRedirectionInfoRef->secondaryInputKeyElementId:
117+
if (job->jobRedirectionInfoRef->secondaryInputKeyId >= MAX_KEYSTORE) {
118+
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
119+
ret = -1;
120+
}
121+
else {
122+
i = job->jobRedirectionInfoRef->secondaryInputKeyId;
123+
*key = keyStore[i].key;
124+
*keySz = keyStore[i].keyLen;
125+
}
126+
break;
127+
case job->jobRedirectionInfoRef->tertiaryInputKeyElementId:
128+
if (job->jobRedirectionInfoRef->tertiaryInputKeyId >= MAX_KEYSTORE) {
129+
WOLFSSL_MSG("Bogus input key ID redirection (too large)");
130+
ret = -1;
131+
}
132+
else {
133+
i = job->jobRedirectionInfoRef->tertiaryInputKeyId;
134+
*key = keyStore[i].key;
135+
*keySz = keyStore[i].keyLen;
136+
}
137+
break;
138+
default:
139+
WOLFSSL_MSG("Unknown key element ID");
129140
ret = -1;
130-
}
131-
else {
132-
i = job->jobRedirectionInfoRef->tertiaryInputKeyId;
133-
*key = keyStore[i].key;
134-
*keySz = keyStore[i].keyLen;
135-
}
141+
break;
136142
}
137143
#else
138144
/* find first key of key element type */
@@ -180,8 +186,15 @@ static Aes* NewAesStruct(Crypto_JobType* job)
180186

181187
for (i = 0; i < MAX_JOBS; i++) {
182188
if (activeJobs[i].inUse == 0) {
189+
int ret;
190+
183191
activeJobs[i].inUse = 1;
184192
activeJobs[i].jobId = job->jobId;
193+
ret = wc_AesInit(&activeJobs[i].aes, NULL, INVALID_DEVID);
194+
if (ret != 0) {
195+
WOLFSSL_MSG("Error initializing AES structure");
196+
return NULL;
197+
}
185198
return &activeJobs[i].aes;
186199
}
187200
}
@@ -252,7 +265,7 @@ Std_ReturnType wolfSSL_Crypto_CBC(Crypto_JobType* job)
252265
WOLFSSL_MSG("Crypto error setting up AES key");
253266
return E_NOT_OK;
254267
}
255-
/* ForceZero(key, keySz); Do not keep raw key in memory */
268+
ForceZero(key, keySz);
256269
}
257270

258271
if ((job->jobPrimitiveInputOutput.mode & CRYPTO_OPERATIONMODE_UPDATE)

wolfcrypt/src/port/autosar/csm.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* csm.c
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*
@@ -156,18 +156,16 @@ void Csm_Init(const Csm_ConfigType* config)
156156
}
157157

158158

159-
/* not yet implemented */
159+
/* getter function for CSM version info */
160160
void Csm_GetVersionInfo(Std_VersionInfoType* version)
161161
{
162-
(void)version;
163-
164-
/*
165-
version->vendorID = ; //uint16
166-
version->moduleID = ; //uint16
167-
version->sw_major_version = ; //uint8
168-
version->sw_minor_version = ; //uint8
169-
version->sw_patch_version = ; //uint8
170-
*/
162+
if (version != NULL) {
163+
version->vendorID = 0; /* no vendor or module ID */
164+
version->moduleID = 0;
165+
version->sw_major_version = 5;
166+
version->sw_minor_version = 6;
167+
version->sw_patch_version = 6;
168+
}
171169
}
172170

173171

wolfcrypt/src/port/autosar/include.am

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ EXTRA_DIST += wolfcrypt/src/port/autosar/csm.c \
33
wolfcrypt/src/port/autosar/crypto.c \
44
wolfcrypt/src/port/autosar/cryif.c \
55
wolfcrypt/src/port/autosar/README.md \
6-
wolfcrypt/src/port/autosar/example.c
6+
wolfcrypt/src/port/autosar/test.c
77

88
if BUILD_AUTOSAR
99
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/autosar/csm.c
1010
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/autosar/crypto.c
1111
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/autosar/cryif.c
1212

1313
if BUILD_TESTS
14-
check_PROGRAMS += wolfcrypt/src/port/autosar/example.test
15-
noinst_PROGRAMS += wolfcrypt/src/port/autosar/example.test
14+
check_PROGRAMS += wolfcrypt/src/port/autosar/test.test
15+
noinst_PROGRAMS += wolfcrypt/src/port/autosar/test.test
1616

17-
wolfcrypt_src_port_autosar_example_test_SOURCES = \
18-
wolfcrypt/src/port/autosar/example.c
19-
wolfcrypt_src_port_autosar_example_test_LDADD = \
17+
wolfcrypt_src_port_autosar_test_test_SOURCES = \
18+
wolfcrypt/src/port/autosar/test.c
19+
wolfcrypt_src_port_autosar_test_test_LDADD = \
2020
src/libwolfssl.la $(LIB_STATIC_ADD)
21-
wolfcrypt_src_port_autosar_example_test_DEPENDENCIES = src/libwolfssl.la
21+
wolfcrypt_src_port_autosar_test_test_DEPENDENCIES = src/libwolfssl.la
2222
endif
2323
endif
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* example.c
1+
/* test.c
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*
@@ -46,8 +46,8 @@ static int singleshot_test(void)
4646
0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,
4747
0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb
4848
};
49-
const uint8 key[] = "0123456789abcdef "; /* align */
50-
const uint8 iv[] = "1234567890abcdef "; /* align */
49+
const uint8 key[] = "0123456789abcdef ";
50+
const uint8 iv[] = "1234567890abcdef ";
5151

5252
XMEMSET(cipher, 0, BLOCK_SIZE);
5353
XMEMSET(plain, 0, BLOCK_SIZE);

wolfssl/wolfcrypt/port/autosar/CryIf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* CryIf.h
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

wolfssl/wolfcrypt/port/autosar/Crypto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Crypto.h
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*

wolfssl/wolfcrypt/port/autosar/Csm.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* csm.h
22
*
3-
* Copyright (C) 2006-2019 wolfSSL Inc.
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
44
*
55
* This file is part of wolfSSL.
66
*
@@ -83,7 +83,7 @@ typedef enum Crypto_ServiceInfoType {
8383
CRYPTO_DECRYPT = 0x04,
8484
CRYPTO_RANDOMGENERATE = 0x0B,
8585

86-
#if 0
86+
#ifdef CSM_UNSUPPORTED_ALGS
8787
/* not yet supported */
8888
CRYPTO_HASH = 0x00,
8989
CRYPTO_MACGENERATE = 0x01,
@@ -107,7 +107,8 @@ typedef enum Crypto_ServiceInfoType {
107107
typedef enum Crypto_AlgorithmModeType {
108108
CRYPTO_ALGOMODE_NOT_SET = 0x00,
109109
CRYPTO_ALGOMODE_CBC = 0x02,
110-
#if 0
110+
111+
#ifdef CSM_UNSUPPORTED_ALGS
111112
/* not yet supported */
112113
CRYPTO_ALGOMODE_ECB = 0x01,
113114
CRYPTO_ALGOMODE_CFB = 0x03,

0 commit comments

Comments
 (0)