|
14 | 14 | #include "sw/device/lib/runtime/log.h" |
15 | 15 | #include "sw/device/lib/testing/profile.h" |
16 | 16 | #include "sw/device/lib/testing/test_framework/check.h" |
| 17 | +#include "sw/device/tests/crypto/lib/crypto_test_lib.h" |
17 | 18 |
|
18 | 19 | #define MODULE_ID MAKE_MODULE_ID('a', 'g', 't') |
19 | 20 |
|
@@ -123,13 +124,17 @@ static status_t stream_gcm(otcrypto_aes_gcm_context_t *ctx, |
123 | 124 |
|
124 | 125 | status_t aes_gcm_testutils_encrypt(const aes_gcm_test_t *test, bool streaming, |
125 | 126 | uint32_t *cycles) { |
| 127 | + // Determine the security level. |
| 128 | + otcrypto_key_security_level_t sec_level; |
| 129 | + TRY(determine_security_level(&sec_level)); |
| 130 | + |
126 | 131 | // Construct the blinded key configuration. |
127 | 132 | otcrypto_key_config_t config = { |
128 | 133 | .version = kOtcryptoLibVersion1, |
129 | 134 | .key_mode = kOtcryptoKeyModeAesGcm, |
130 | 135 | .key_length = test->key_len * sizeof(uint32_t), |
131 | 136 | .hw_backed = kHardenedBoolFalse, |
132 | | - .security_level = kOtcryptoKeySecurityLevelHigh, |
| 137 | + .security_level = sec_level, |
133 | 138 | }; |
134 | 139 |
|
135 | 140 | // Construct blinded key from the key and testing mask. |
@@ -220,13 +225,17 @@ status_t aes_gcm_testutils_encrypt(const aes_gcm_test_t *test, bool streaming, |
220 | 225 | status_t aes_gcm_testutils_decrypt(const aes_gcm_test_t *test, |
221 | 226 | hardened_bool_t *tag_valid, bool streaming, |
222 | 227 | uint32_t *cycles) { |
| 228 | + // Determine the security level. |
| 229 | + otcrypto_key_security_level_t sec_level; |
| 230 | + TRY(determine_security_level(&sec_level)); |
| 231 | + |
223 | 232 | // Construct the blinded key configuration. |
224 | 233 | otcrypto_key_config_t config = { |
225 | 234 | .version = kOtcryptoLibVersion1, |
226 | 235 | .key_mode = kOtcryptoKeyModeAesGcm, |
227 | 236 | .key_length = test->key_len * sizeof(uint32_t), |
228 | 237 | .hw_backed = kHardenedBoolFalse, |
229 | | - .security_level = kOtcryptoKeySecurityLevelHigh, |
| 238 | + .security_level = sec_level, |
230 | 239 | }; |
231 | 240 |
|
232 | 241 | // Construct blinded key from the key and testing mask. |
|
0 commit comments