@@ -147,8 +147,6 @@ int main(void)
147
147
148
148
atecc608a_print_serial_number ();
149
149
atecc608a_print_config_zone ();
150
- ASSERT_SUCCESS_PSA (atecc608a_generate_key (atecc608a_key_slot_device , pubkey , pubkey_size ));
151
- atcab_printbin_label ("pubKey generated: " , pubkey , ATCA_PUB_KEY_SIZE );
152
150
153
151
ASSERT_SUCCESS_PSA (atecc608a_hash_sha256 (hash_input1 ,
154
152
sizeof (hash_input1 ) - 1 ,
@@ -167,6 +165,21 @@ int main(void)
167
165
/* Verify that the device has a locked config before doing anything */
168
166
ASSERT_SUCCESS_PSA (atecc608a_check_config_locked ());
169
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 */
170
183
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_export (
171
184
atecc608a_key_slot_device , pubkey , sizeof (pubkey ),
172
185
& pubkey_len ));
@@ -177,13 +190,16 @@ int main(void)
177
190
key_type , alg , PSA_KEY_USAGE_VERIFY , pubkey ,
178
191
pubkey_len ));
179
192
193
+ /* Test that signing using the generated private key and verifying using
194
+ * the exported public key works */
180
195
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_asym -> p_sign (
181
196
atecc608a_key_slot_device , alg , hash , sizeof (hash ),
182
197
signature , sizeof (signature ), & signature_length ));
183
198
184
199
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_asym -> p_verify (
185
200
atecc608a_public_key_slot , alg , hash , sizeof (hash ),
186
201
signature , signature_length ));
202
+
187
203
/*
188
204
* Import the secure element's public key into a volatile key slot.
189
205
*/
0 commit comments