@@ -105,6 +105,18 @@ psa_status_t atecc608a_print_serial_number()
105
105
return status ;
106
106
}
107
107
108
+ psa_status_t atecc608a_print_config_zone ()
109
+ {
110
+ uint8_t config_buffer [ATCA_ECC_CONFIG_SIZE ] = {0 };
111
+ psa_status_t status = PSA_ERROR_GENERIC_ERROR ;
112
+ ASSERT_SUCCESS_PSA (atecc608a_init ());
113
+ ASSERT_SUCCESS (atcab_read_config_zone (config_buffer ));
114
+ atcab_printbin_label ("Config zone: " , config_buffer , ATCA_ECC_CONFIG_SIZE );
115
+ exit :
116
+ atecc608a_deinit ();
117
+ return status ;
118
+ }
119
+
108
120
int main (void )
109
121
{
110
122
enum {
@@ -131,8 +143,12 @@ int main(void)
131
143
static uint8_t pubkey [pubkey_size ];
132
144
size_t pubkey_len = 0 ;
133
145
psa_key_slot_number_t atecc608a_key_slot_device = 0 ;
146
+ psa_key_slot_number_t atecc608a_public_key_slot = 9 ;
134
147
135
148
atecc608a_print_serial_number ();
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 );
136
152
137
153
ASSERT_SUCCESS_PSA (atecc608a_hash_sha256 (hash_input1 ,
138
154
sizeof (hash_input1 ) - 1 ,
@@ -147,17 +163,27 @@ int main(void)
147
163
ASSERT_SUCCESS_PSA (psa_crypto_init ());
148
164
149
165
atecc608a_print_locked_zones ();
166
+
150
167
/* Verify that the device has a locked config before doing anything */
151
168
ASSERT_SUCCESS_PSA (atecc608a_check_config_locked ());
152
169
153
170
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_export (
154
171
atecc608a_key_slot_device , pubkey , sizeof (pubkey ),
155
172
& pubkey_len ));
156
173
174
+ ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_key_management -> p_import (
175
+ atecc608a_public_key_slot ,
176
+ atecc608a_drv_info .lifetime ,
177
+ key_type , alg , PSA_KEY_USAGE_VERIFY , pubkey ,
178
+ pubkey_len ));
179
+
157
180
ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_asym -> p_sign (
158
181
atecc608a_key_slot_device , alg , hash , sizeof (hash ),
159
182
signature , sizeof (signature ), & signature_length ));
160
183
184
+ ASSERT_SUCCESS_PSA (atecc608a_drv_info .p_asym -> p_verify (
185
+ atecc608a_public_key_slot , alg , hash , sizeof (hash ),
186
+ signature , signature_length ));
161
187
/*
162
188
* Import the secure element's public key into a volatile key slot.
163
189
*/
0 commit comments