@@ -91,7 +91,7 @@ ble_sm_alg_xor_128(const uint8_t *p, const uint8_t *q, uint8_t *r)
9191}
9292
9393int
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 ,
9595 uint8_t * enc_data )
9696{
9797 uint8_t tmp [16 ];
@@ -135,7 +135,7 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext,
135135}
136136
137137int
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 ,
139139 uint8_t * out )
140140{
141141 int rc ;
@@ -152,12 +152,12 @@ ble_sm_alg_s1(const uint8_t *k, const uint8_t *r1, const uint8_t *r2,
152152 memcpy (out + 8 , r1 , 8 );
153153
154154 /* 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 );
156156 if (rc != 0 ) {
157157 return rc ;
158158 }
159159
160- BLE_HS_LOG (DEBUG , "ble_sm_alg_s1 ()\n k=" );
160+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_s1 ()\n k=" );
161161 ble_hs_log_flat_buf (k , 16 );
162162 BLE_HS_LOG (DEBUG , "\n r1=" );
163163 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,
171171}
172172
173173int
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 ,
175175 const uint8_t * preq , const uint8_t * pres ,
176176 uint8_t iat , uint8_t rat ,
177177 const uint8_t * ia , const uint8_t * ra ,
@@ -180,7 +180,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
180180 uint8_t p1 [16 ], p2 [16 ];
181181 int rc ;
182182
183- BLE_HS_LOG (DEBUG , "ble_sm_alg_c1 ()\n k=" );
183+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_c1 ()\n k=" );
184184 ble_hs_log_flat_buf (k , 16 );
185185 BLE_HS_LOG (DEBUG , "\n r=" );
186186 ble_hs_log_flat_buf (r , 16 );
@@ -208,7 +208,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
208208 /* Using out_enc_data as temporary output buffer */
209209 ble_sm_alg_xor_128 (r , p1 , out_enc_data );
210210
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 );
212212 if (rc != 0 ) {
213213 rc = BLE_HS_EUNKNOWN ;
214214 goto done ;
@@ -224,7 +224,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
224224
225225 ble_sm_alg_xor_128 (out_enc_data , p2 , out_enc_data );
226226
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 );
228228 if (rc != 0 ) {
229229 rc = BLE_HS_EUNKNOWN ;
230230 goto done ;
@@ -251,7 +251,7 @@ ble_sm_alg_c1(const uint8_t *k, const uint8_t *r,
251251
252252#if MYNEWT_VAL (BLE_CRYPTO_STACK_MBEDTLS )
253253int
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 ,
255255 uint8_t * out )
256256{
257257 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,
289289
290290#else
291291int
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 ,
293293 uint8_t * out )
294294{
295295 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)
322322}
323323
324324int
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 ,
326326 uint8_t z , uint8_t * out_enc_data )
327327{
328328 uint8_t xs [16 ];
329329 uint8_t m [65 ];
330330 int rc ;
331331
332- BLE_HS_LOG (DEBUG , "ble_sm_alg_f4 ()\n u=" );
332+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_f4 ()\n u=" );
333333 ble_hs_log_flat_buf (u , 32 );
334334 BLE_HS_LOG (DEBUG , "\n v=" );
335335 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,
344344 * Core Spec 4.2 Vol 3 Part H 2.2.5
345345 *
346346 * 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.
348348 */
349349 swap_buf (m , u , 32 );
350350 swap_buf (m + 32 , v , 32 );
351351 m [64 ] = z ;
352352
353353 swap_buf (xs , x , 16 );
354354
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 );
356356 if (rc != 0 ) {
357357 return BLE_HS_EUNKNOWN ;
358358 }
@@ -367,7 +367,7 @@ ble_sm_alg_f4(const uint8_t *u, const uint8_t *v, const uint8_t *x,
367367}
368368
369369int
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 ,
371371 uint8_t a1t , const uint8_t * a1 , uint8_t a2t , const uint8_t * a2 ,
372372 uint8_t * mackey , uint8_t * ltk )
373373{
@@ -389,14 +389,14 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
389389 uint8_t t [16 ];
390390 int rc ;
391391
392- BLE_HS_LOG (DEBUG , "ble_sm_alg_f5 ()\n" );
392+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_f5 ()\n" );
393393 ble_sm_alg_log_buf ("w" , w , 32 );
394394 ble_sm_alg_log_buf ("n1" , n1 , 16 );
395395 ble_sm_alg_log_buf ("n2" , n2 , 16 );
396396
397397 swap_buf (ws , w , 32 );
398398
399- rc = ble_sm_alg_aes_cmac (salt , ws , 32 , t );
399+ rc = na_ble_sm_alg_aes_cmac (salt , ws , 32 , t );
400400 if (rc != 0 ) {
401401 return BLE_HS_EUNKNOWN ;
402402 }
@@ -410,7 +410,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
410410 m [44 ] = a2t ;
411411 swap_buf (m + 45 , a2 , 6 );
412412
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 );
414414 if (rc != 0 ) {
415415 return BLE_HS_EUNKNOWN ;
416416 }
@@ -422,7 +422,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
422422 /* Counter for ltk is 1. */
423423 m [0 ] = 0x01 ;
424424
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 );
426426 if (rc != 0 ) {
427427 return BLE_HS_EUNKNOWN ;
428428 }
@@ -435,7 +435,7 @@ ble_sm_alg_f5(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
435435}
436436
437437int
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 ,
439439 const uint8_t * r , const uint8_t * iocap , uint8_t a1t ,
440440 const uint8_t * a1 , uint8_t a2t , const uint8_t * a2 ,
441441 uint8_t * check )
@@ -444,7 +444,7 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
444444 uint8_t m [65 ];
445445 int rc ;
446446
447- BLE_HS_LOG (DEBUG , "ble_sm_alg_f6 ()\n" );
447+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_f6 ()\n" );
448448 ble_sm_alg_log_buf ("w" , w , 16 );
449449 ble_sm_alg_log_buf ("n1" , n1 , 16 );
450450 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,
470470
471471 swap_buf (ws , w , 16 );
472472
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 );
474474 if (rc != 0 ) {
475475 return BLE_HS_EUNKNOWN ;
476476 }
@@ -483,13 +483,13 @@ ble_sm_alg_f6(const uint8_t *w, const uint8_t *n1, const uint8_t *n2,
483483}
484484
485485int
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 ,
487487 const uint8_t * y , uint32_t * passkey )
488488{
489489 uint8_t m [80 ], xs [16 ];
490490 int rc ;
491491
492- BLE_HS_LOG (DEBUG , "ble_sm_alg_g2 ()\n" );
492+ BLE_HS_LOG (DEBUG , "na_ble_sm_alg_g2 ()\n" );
493493 ble_sm_alg_log_buf ("u" , u , 32 );
494494 ble_sm_alg_log_buf ("v" , v , 32 );
495495 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,
502502 swap_buf (xs , x , 16 );
503503
504504 /* 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 );
506506 if (rc != 0 ) {
507507 return BLE_HS_EUNKNOWN ;
508508 }
@@ -688,7 +688,7 @@ mbedtls_gen_keypair(uint8_t *public_key, uint8_t *private_key)
688688 return 0 ;
689689}
690690
691- void mbedtls_free_keypair (void )
691+ void na_mbedtls_free_keypair (void )
692692{
693693 mbedtls_ecp_keypair_free (& keypair );
694694}
@@ -765,7 +765,7 @@ ble_sm_alg_rand(uint8_t *dst, unsigned int size)
765765#endif
766766
767767void
768- ble_sm_alg_ecc_init (void )
768+ na_ble_sm_alg_ecc_init (void )
769769{
770770#if (!MYNEWT_VAL (BLE_CRYPTO_STACK_MBEDTLS ))
771771 uECC_set_rng (ble_sm_alg_rand );
0 commit comments