-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathwh_demo_client_all.c
More file actions
205 lines (177 loc) · 4.65 KB
/
wh_demo_client_all.c
File metadata and controls
205 lines (177 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
#include "wh_demo_client_wctest.h"
#include "wh_demo_client_wcbench.h"
#include "wh_demo_client_nvm.h"
#ifdef WOLFHSM_CFG_ENABLE_AUTHENTICATION
#include "wh_demo_client_auth.h"
#include "wolfhsm/wh_error.h"
#endif /* WOLFHSM_CFG_ENABLE_AUTHENTICATION */
#include "wh_demo_client_keystore.h"
#include "wh_demo_client_crypto.h"
#include "wh_demo_client_secboot.h"
#include "wh_demo_client_keywrap.h"
#include "wh_demo_client_all.h"
int wh_DemoClient_All(whClientContext* clientContext)
{
int rc = 0;
#ifdef WOLFHSM_CFG_ENABLE_AUTHENTICATION
whUserId userId = WH_USER_ID_INVALID;
/* Auth demos */
rc = wh_DemoClient_Auth(clientContext);
if (rc != 0) {
return rc;
}
/* Log in as an admin user for the rest of the tests */
if (wh_Client_AuthLogin(clientContext, WH_AUTH_METHOD_PIN, "admin", "1234",
4, &rc, &userId) != 0) {
return -1;
}
if (rc != WH_ERROR_OK && rc != WH_AUTH_NOT_ENABLED) {
return rc;
}
#endif /* WOLFHSM_CFG_ENABLE_AUTHENTICATION */
/* wolfCrypt test and benchmark */
#ifdef WH_DEMO_WCTEST
rc = wh_DemoClient_wcTest(clientContext);
if (rc != 0) {
return rc;
}
#endif
#ifdef WH_DEMO_WCBENCH
rc = wh_DemoClient_wcBench(clientContext);
if (rc != 0) {
return rc;
}
#endif
/* NVM demos */
rc = wh_DemoClient_Nvm(clientContext);
if (rc != 0) {
return rc;
}
/* Keystore demos */
rc = wh_DemoClient_KeystoreBasic(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_KeystoreCommitKey(clientContext);
if (rc != 0) {
return rc;
}
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_AES)
rc = wh_DemoClient_KeystoreAes(clientContext);
if (rc != 0) {
return rc;
}
#endif
#ifdef WOLFHSM_CFG_KEYWRAP
rc = wh_DemoClient_KeyWrap(clientContext);
if (rc != 0) {
return rc;
}
#endif /* WOLFHSM_CFG_KEYWRAP */
/**Crypto demos */
#if !defined(WOLFHSM_CFG_NO_CRYPTO) && !defined(NO_RSA)
rc = wh_DemoClient_CryptoRsa(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoRsaImport(clientContext);
if (rc != 0) {
return rc;
}
#endif /* !NO_RSA */
#ifdef HAVE_CURVE25519
rc = wh_DemoClient_CryptoCurve25519(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoCurve25519Import(clientContext);
if (rc != 0) {
return rc;
}
#endif /* HAVE_CURVE25519 */
#ifdef HAVE_ECC
rc = wh_DemoClient_CryptoEcc(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoEccImport(clientContext);
if (rc != 0) {
return rc;
}
#endif /* HAVE_ECC */
#if !defined(NO_AES) && defined(HAVE_AES_CBC)
rc = wh_DemoClient_CryptoAesCbc(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoAesCbcImport(clientContext);
if (rc != 0) {
return rc;
}
#endif /* !NO_AES && HAVE_AES_CBC */
#if !defined(NO_AES) && defined(HAVE_AESGCM)
rc = wh_DemoClient_CryptoAesGcm(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoAesGcmImport(clientContext);
if (rc != 0) {
return rc;
}
#endif /* !NO_AES && HAVE_AESGCM */
#ifdef HAVE_HKDF
rc = wh_DemoClient_CryptoHkdfExport(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoHkdfCache(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoHkdfCacheInputKey(clientContext);
if (rc != 0) {
return rc;
}
#endif /* HAVE_HKDF */
#if defined(HAVE_CMAC_KDF) && defined(WOLFSSL_CMAC)
rc = wh_DemoClient_CryptoCmacKdfExport(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoCmacKdfCache(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoCmacKdfCacheInputs(clientContext);
if (rc != 0) {
return rc;
}
#endif /* HAVE_CMAC_KDF && WOLFSSL_CMAC */
#if defined(WOLFSSL_CMAC)
rc = wh_DemoClient_CryptoCmac(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoCmacImport(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_CryptoCmacOneshotImport(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_SecBoot_Provision(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_SecBoot_Boot(clientContext);
if (rc != 0) {
return rc;
}
rc = wh_DemoClient_SecBoot_Zeroize(clientContext);
if (rc != 0) {
return rc;
}
#endif /* WOLFSSL_CMAC */
return rc;
}