53
53
#define ASSERT_SUCCESS (expression ) ASSERT_STATUS(expression, ATCA_SUCCESS, \
54
54
atecc608a_to_psa_error(ASSERT_result))
55
55
56
+ /** Does the same as the macro above, but without the error translation and for
57
+ * the PSA return code - PSA_SUCCESS.*/
58
+ #define ASSERT_SUCCESS_PSA (expression ) ASSERT_STATUS(expression, PSA_SUCCESS, \
59
+ ASSERT_result)
60
+
56
61
ATCAIfaceCfg atca_iface_config = {
57
62
.iface_type = ATCA_I2C_IFACE ,
58
63
.devtype = ATECC608A ,
@@ -115,6 +120,16 @@ psa_status_t atecc608a_to_psa_error(ATCA_STATUS ret)
115
120
}
116
121
}
117
122
123
+ psa_status_t atecc608a_init ()
124
+ {
125
+ return atecc608a_to_psa_error (atcab_init (& atca_iface_config ));
126
+ }
127
+
128
+ psa_status_t atecc608a_deinit ()
129
+ {
130
+ return atecc608a_to_psa_error (atcab_release ());
131
+ }
132
+
118
133
static psa_status_t atecc608a_export_public_key (psa_key_slot_number_t key ,
119
134
uint8_t * p_data , size_t data_size ,
120
135
size_t * p_data_length )
@@ -128,9 +143,9 @@ static psa_status_t atecc608a_export_public_key(psa_key_slot_number_t key,
128
143
return PSA_ERROR_BUFFER_TOO_SMALL ;
129
144
}
130
145
131
- ATCAB_INIT ( );
146
+ ASSERT_SUCCESS_PSA ( atecc608a_init () );
132
147
133
- /* atcab_get_pubkey returns concatenated x and y values, and the desired
148
+ /* atcab_get_pubkey returns concatenated x and y values, and the desired
134
149
format is 0x04 + x + y. We start at &p_data[1] and add a 0x04 at p_data[0]. */
135
150
ASSERT_SUCCESS (atcab_get_pubkey (slot , & p_data [1 ]));
136
151
@@ -143,7 +158,7 @@ static psa_status_t atecc608a_export_public_key(psa_key_slot_number_t key,
143
158
#endif
144
159
145
160
exit :
146
- ATCAB_DEINIT ();
161
+ atecc608a_deinit ();
147
162
return status ;
148
163
}
149
164
@@ -175,12 +190,12 @@ static psa_status_t atecc608a_asymmetric_sign(psa_key_slot_number_t key_slot,
175
190
return PSA_ERROR_BUFFER_TOO_SMALL ;
176
191
}
177
192
178
- ATCAB_INIT ( );
193
+ ASSERT_SUCCESS_PSA ( atecc608a_init () );
179
194
180
195
/* Signature will be returned here. Format is R and S integers in
181
196
* big-endian format. 64 bytes for P256 curve. */
182
197
ASSERT_SUCCESS (atcab_sign (key_id , p_hash , p_signature ));
183
-
198
+
184
199
* p_signature_length = ATCA_SIG_SIZE ;
185
200
186
201
#ifdef DEBUG_PRINT
@@ -189,7 +204,7 @@ static psa_status_t atecc608a_asymmetric_sign(psa_key_slot_number_t key_slot,
189
204
#endif
190
205
191
206
exit :
192
- ATCAB_DEINIT ();
207
+ atecc608a_deinit ();
193
208
return status ;
194
209
}
195
210
@@ -214,7 +229,7 @@ static psa_drv_se_key_management_t atecc608a_key_management =
214
229
};
215
230
216
231
psa_drv_se_info_t atecc608a_drv_info =
217
- {
232
+ {
218
233
.lifetime = PSA_ATECC608A_LIFETIME ,
219
234
.p_key_management = & atecc608a_key_management ,
220
235
.p_mac = 0 ,
0 commit comments