@@ -91,7 +91,7 @@ ble_sm_alg_xor_128(const uint8_t *p, const uint8_t *q, uint8_t *r)
91
91
}
92
92
93
93
int
94
- ble_sm_alg_encrypt (const uint8_t * key , const uint8_t * plaintext ,
94
+ na_ble_sm_alg_encrypt (const uint8_t * key , const uint8_t * plaintext ,
95
95
uint8_t * enc_data )
96
96
{
97
97
uint8_t tmp [16 ];
@@ -135,7 +135,7 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext,
135
135
}
136
136
137
137
int
138
- ble_sm_alg_s1 (const uint8_t * k , const uint8_t * r1 , const uint8_t * r2 ,
138
+ na_ble_sm_alg_s1 (const uint8_t * k , const uint8_t * r1 , const uint8_t * r2 ,
139
139
uint8_t * out )
140
140
{
141
141
int rc ;
@@ -152,12 +152,12 @@ ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2,
152
152
memcpy (out + 8 , r1 , 8 );
153
153
154
154
/* s1(k, r1 , r2) = e(k, r') */
155
- rc = ble_sm_alg_encrypt (k , out , out );
155
+ rc = na_ble_sm_alg_encrypt (k , out , out );
156
156
if (rc != 0 ) {
157
157
return rc ;
158
158
}
159
159
160
- BLE_HS_LOG (DEBUG , "ble_sm_alg_s1 ()\n k=" );
160
+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_s1 ()\n k=" );
161
161
ble_hs_log_flat_buf (k , 16 );
162
162
BLE_HS_LOG (DEBUG , "\n r1=" );
163
163
ble_hs_log_flat_buf (r1 , 16 );
@@ -171,7 +171,7 @@ ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2,
171
171
}
172
172
173
173
int
174
- ble_sm_alg_c1 (const uint8_t * k , const uint8_t * r ,
174
+ na_ble_sm_alg_c1 (const uint8_t * k , const uint8_t * r ,
175
175
const uint8_t * preq , const uint8_t * pres ,
176
176
uint8_t iat , uint8_t rat ,
177
177
const uint8_t * ia , const uint8_t * ra ,
@@ -180,7 +180,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
180
180
uint8_t p1 [16 ], p2 [16 ];
181
181
int rc ;
182
182
183
- BLE_HS_LOG (DEBUG , "ble_sm_alg_c1 ()\n k=" );
183
+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_c1 ()\n k=" );
184
184
ble_hs_log_flat_buf (k , 16 );
185
185
BLE_HS_LOG (DEBUG , "\n r=" );
186
186
ble_hs_log_flat_buf (r , 16 );
@@ -208,7 +208,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
208
208
/* Using out_enc_data as temporary output buffer */
209
209
ble_sm_alg_xor_128 (r , p1 , out_enc_data );
210
210
211
- rc = ble_sm_alg_encrypt (k , out_enc_data , out_enc_data );
211
+ rc = na_ble_sm_alg_encrypt (k , out_enc_data , out_enc_data );
212
212
if (rc != 0 ) {
213
213
rc = BLE_HS_EUNKNOWN ;
214
214
goto done ;
@@ -224,7 +224,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
224
224
225
225
ble_sm_alg_xor_128 (out_enc_data , p2 , out_enc_data );
226
226
227
- rc = ble_sm_alg_encrypt (k , out_enc_data , out_enc_data );
227
+ rc = na_ble_sm_alg_encrypt (k , out_enc_data , out_enc_data );
228
228
if (rc != 0 ) {
229
229
rc = BLE_HS_EUNKNOWN ;
230
230
goto done ;
@@ -251,7 +251,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
251
251
252
252
#if MYNEWT_VAL (BLE_CRYPTO_STACK_MBEDTLS )
253
253
int
254
- ble_sm_alg_aes_cmac (const uint8_t * key , const uint8_t * in , size_t len ,
254
+ na_ble_sm_alg_aes_cmac (const uint8_t * key , const uint8_t * in , size_t len ,
255
255
uint8_t * out )
256
256
{
257
257
int rc = BLE_HS_EUNKNOWN ;
@@ -289,7 +289,7 @@ ble_sm_alg_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len,
289
289
290
290
#else
291
291
int
292
- ble_sm_alg_aes_cmac (const uint8_t * key , const uint8_t * in , size_t len ,
292
+ na_ble_sm_alg_aes_cmac (const uint8_t * key , const uint8_t * in , size_t len ,
293
293
uint8_t * out )
294
294
{
295
295
struct tc_aes_key_sched_struct sched ;
@@ -322,14 +322,14 @@ ble_sm_alg_log_buf(const char *name, const uint8_t *buf, int len)
322
322
}
323
323
324
324
int
325
- ble_sm_alg_f4 (const uint8_t * u , const uint8_t * v , const uint8_t * x ,
325
+ na_ble_sm_alg_f4 (const uint8_t * u , const uint8_t * v , const uint8_t * x ,
326
326
uint8_t z , uint8_t * out_enc_data )
327
327
{
328
328
uint8_t xs [16 ];
329
329
uint8_t m [65 ];
330
330
int rc ;
331
331
332
- BLE_HS_LOG (DEBUG , "ble_sm_alg_f4 ()\n u=" );
332
+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_f4 ()\n u=" );
333
333
ble_hs_log_flat_buf (u , 32 );
334
334
BLE_HS_LOG (DEBUG , "\n v=" );
335
335
ble_hs_log_flat_buf (v , 32 );
@@ -344,15 +344,15 @@ ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x,
344
344
* Core Spec 4.2 Vol 3 Part H 2.2.5
345
345
*
346
346
* note:
347
- * ble_sm_alg_aes_cmac uses BE data; ble_sm_alg_f4 accepts LE so we swap.
347
+ * na_ble_sm_alg_aes_cmac uses BE data; na_ble_sm_alg_f4 accepts LE so we swap.
348
348
*/
349
349
swap_buf (m , u , 32 );
350
350
swap_buf (m + 32 , v , 32 );
351
351
m [64 ] = z ;
352
352
353
353
swap_buf (xs , x , 16 );
354
354
355
- rc = ble_sm_alg_aes_cmac (xs , m , sizeof (m ), out_enc_data );
355
+ rc = na_ble_sm_alg_aes_cmac (xs , m , sizeof (m ), out_enc_data );
356
356
if (rc != 0 ) {
357
357
return BLE_HS_EUNKNOWN ;
358
358
}
@@ -367,7 +367,7 @@ ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x,
367
367
}
368
368
369
369
int
370
- ble_sm_alg_f5 (const uint8_t * w , const uint8_t * n1 , const uint8_t * n2 ,
370
+ na_ble_sm_alg_f5 (const uint8_t * w , const uint8_t * n1 , const uint8_t * n2 ,
371
371
uint8_t a1t , const uint8_t * a1 , uint8_t a2t , const uint8_t * a2 ,
372
372
uint8_t * mackey , uint8_t * ltk )
373
373
{
@@ -389,14 +389,14 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
389
389
uint8_t t [16 ];
390
390
int rc ;
391
391
392
- BLE_HS_LOG (DEBUG , "ble_sm_alg_f5 ()\n" );
392
+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_f5 ()\n" );
393
393
ble_sm_alg_log_buf ("w" , w , 32 );
394
394
ble_sm_alg_log_buf ("n1" , n1 , 16 );
395
395
ble_sm_alg_log_buf ("n2" , n2 , 16 );
396
396
397
397
swap_buf (ws , w , 32 );
398
398
399
- rc = ble_sm_alg_aes_cmac (salt , ws , 32 , t );
399
+ rc = na_ble_sm_alg_aes_cmac (salt , ws , 32 , t );
400
400
if (rc != 0 ) {
401
401
return BLE_HS_EUNKNOWN ;
402
402
}
@@ -410,7 +410,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
410
410
m [44 ] = a2t ;
411
411
swap_buf (m + 45 , a2 , 6 );
412
412
413
- rc = ble_sm_alg_aes_cmac (t , m , sizeof (m ), mackey );
413
+ rc = na_ble_sm_alg_aes_cmac (t , m , sizeof (m ), mackey );
414
414
if (rc != 0 ) {
415
415
return BLE_HS_EUNKNOWN ;
416
416
}
@@ -422,7 +422,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
422
422
/* Counter for ltk is 1. */
423
423
m [0 ] = 0x01 ;
424
424
425
- rc = ble_sm_alg_aes_cmac (t , m , sizeof (m ), ltk );
425
+ rc = na_ble_sm_alg_aes_cmac (t , m , sizeof (m ), ltk );
426
426
if (rc != 0 ) {
427
427
return BLE_HS_EUNKNOWN ;
428
428
}
@@ -435,7 +435,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
435
435
}
436
436
437
437
int
438
- ble_sm_alg_f6 (const uint8_t * w , const uint8_t * n1 , const uint8_t * n2 ,
438
+ na_ble_sm_alg_f6 (const uint8_t * w , const uint8_t * n1 , const uint8_t * n2 ,
439
439
const uint8_t * r , const uint8_t * iocap , uint8_t a1t ,
440
440
const uint8_t * a1 , uint8_t a2t , const uint8_t * a2 ,
441
441
uint8_t * check )
@@ -444,7 +444,7 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
444
444
uint8_t m [65 ];
445
445
int rc ;
446
446
447
- BLE_HS_LOG (DEBUG , "ble_sm_alg_f6 ()\n" );
447
+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_f6 ()\n" );
448
448
ble_sm_alg_log_buf ("w" , w , 16 );
449
449
ble_sm_alg_log_buf ("n1" , n1 , 16 );
450
450
ble_sm_alg_log_buf ("n2" , n2 , 16 );
@@ -470,7 +470,7 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
470
470
471
471
swap_buf (ws , w , 16 );
472
472
473
- rc = ble_sm_alg_aes_cmac (ws , m , sizeof (m ), check );
473
+ rc = na_ble_sm_alg_aes_cmac (ws , m , sizeof (m ), check );
474
474
if (rc != 0 ) {
475
475
return BLE_HS_EUNKNOWN ;
476
476
}
@@ -483,13 +483,13 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
483
483
}
484
484
485
485
int
486
- ble_sm_alg_g2 (const uint8_t * u , const uint8_t * v , const uint8_t * x ,
486
+ na_ble_sm_alg_g2 (const uint8_t * u , const uint8_t * v , const uint8_t * x ,
487
487
const uint8_t * y , uint32_t * passkey )
488
488
{
489
489
uint8_t m [80 ], xs [16 ];
490
490
int rc ;
491
491
492
- BLE_HS_LOG (DEBUG , "ble_sm_alg_g2 ()\n" );
492
+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_g2 ()\n" );
493
493
ble_sm_alg_log_buf ("u" , u , 32 );
494
494
ble_sm_alg_log_buf ("v" , v , 32 );
495
495
ble_sm_alg_log_buf ("x" , x , 16 );
@@ -502,7 +502,7 @@ ble_sm_alg_g2(const uint8_t *u, const uint8_t *v, const uint8_t *x,
502
502
swap_buf (xs , x , 16 );
503
503
504
504
/* reuse xs (key) as buffer for result */
505
- rc = ble_sm_alg_aes_cmac (xs , m , sizeof (m ), xs );
505
+ rc = na_ble_sm_alg_aes_cmac (xs , m , sizeof (m ), xs );
506
506
if (rc != 0 ) {
507
507
return BLE_HS_EUNKNOWN ;
508
508
}
@@ -688,7 +688,7 @@ mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
688
688
return 0 ;
689
689
}
690
690
691
- void mbedtls_free_keypair (void )
691
+ void na_mbedtls_free_keypair (void )
692
692
{
693
693
mbedtls_ecp_keypair_free (& keypair );
694
694
}
@@ -765,7 +765,7 @@ ble_sm_alg_rand(uint8_t *dst, unsigned int size)
765
765
#endif
766
766
767
767
void
768
- ble_sm_alg_ecc_init (void )
768
+ na_ble_sm_alg_ecc_init (void )
769
769
{
770
770
#if (!MYNEWT_VAL (BLE_CRYPTO_STACK_MBEDTLS ))
771
771
uECC_set_rng (ble_sm_alg_rand );
0 commit comments