@@ -148,13 +148,6 @@ int main(void)
148
148
atecc608a_print_serial_number ();
149
149
atecc608a_print_config_zone ();
150
150
151
- ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_generate (
152
- atecc608a_key_slot_device , keypair_type ,
153
- PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY ,
154
- key_bits , NULL , 0 , pubkey , pubkey_size , & pubkey_len ));
155
-
156
- atcab_printbin_label ("pubKey generated: " , pubkey , pubkey_len );
157
-
158
151
ASSERT_SUCCESS_PSA (atecc608a_hash_sha256 (hash_input1 ,
159
152
sizeof (hash_input1 ) - 1 ,
160
153
sha256_expected_hash1 ,
@@ -172,6 +165,21 @@ int main(void)
172
165
/* Verify that the device has a locked config before doing anything */
173
166
ASSERT_SUCCESS_PSA (atecc608a_check_config_locked ());
174
167
168
+ /* Test that a public key received during a private key generation
169
+ * can be imported */
170
+ ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_generate (
171
+ atecc608a_key_slot_device , keypair_type ,
172
+ PSA_KEY_USAGE_SIGN | PSA_KEY_USAGE_VERIFY ,
173
+ key_bits , NULL , 0 , pubkey , pubkey_size , & pubkey_len ));
174
+
175
+ ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_import (
176
+ atecc608a_public_key_slot ,
177
+ atecc608a_drv_info .lifetime ,
178
+ key_type , alg , PSA_KEY_USAGE_VERIFY , pubkey ,
179
+ pubkey_len ));
180
+
181
+ /* Test that a public key that is exported from a private key - can be
182
+ * imported */
175
183
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_export (
176
184
atecc608a_key_slot_device , pubkey , sizeof (pubkey ),
177
185
& pubkey_len ));
@@ -182,13 +190,16 @@ int main(void)
182
190
key_type , alg , PSA_KEY_USAGE_VERIFY , pubkey ,
183
191
pubkey_len ));
184
192
193
+ /* Test that signing using the generated private key and verifying using
194
+ * the exported public key works */
185
195
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_asym -> p_sign (
186
196
atecc608a_key_slot_device , alg , hash , sizeof (hash ),
187
197
signature , sizeof (signature ), & signature_length ));
188
198
189
199
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_asym -> p_verify (
190
200
atecc608a_public_key_slot , alg , hash , sizeof (hash ),
191
201
signature , signature_length ));
202
+
192
203
/*
193
204
* Import the secure element's public key into a volatile key slot.
194
205
*/
0 commit comments