• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2006-2015 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License. *
16  ******************************************************************************/
17 
18 /*******************************************************************************
19  *
20  *  This file contains simple pairing algorithms
21  *
22  ******************************************************************************/
23 #pragma once
24 
25 #include "bt_types.h"
26 
27 #define DWORD_BITS 32
28 #define DWORD_BYTES 4
29 #define DWORD_BITS_SHIFT 5
30 
31 #define KEY_LENGTH_DWORDS_P256 8
32 /* Arithmetic Operations */
33 
34 int multiprecision_compare(uint32_t* a, uint32_t* b);
35 int multiprecision_iszero(uint32_t* a);
36 void multiprecision_init(uint32_t* c);
37 void multiprecision_copy(uint32_t* c, uint32_t* a);
38 uint32_t multiprecision_dword_bits(uint32_t a);
39 uint32_t multiprecision_most_signdwords(uint32_t* a);
40 uint32_t multiprecision_most_signbits(uint32_t* a);
41 void multiprecision_inv_mod(uint32_t* aminus, uint32_t* a);
42 uint32_t multiprecision_add(uint32_t* c, uint32_t* a, uint32_t* b);  // c=a+b
43 void multiprecision_add_mod(uint32_t* c, uint32_t* a, uint32_t* b);
44 uint32_t multiprecision_sub(uint32_t* c, uint32_t* a, uint32_t* b);  // c=a-b
45 void multiprecision_sub_mod(uint32_t* c, uint32_t* a, uint32_t* b);
46 void multiprecision_rshift(uint32_t* c, uint32_t* a);  // c=a>>1, return carrier
47 void multiprecision_lshift_mod(uint32_t* c,
48                                uint32_t* a);  // c=a<<b, return carrier
49 uint32_t multiprecision_lshift(uint32_t* c,
50                                uint32_t* a);  // c=a<<b, return carrier
51 void multiprecision_mult(uint32_t* c, uint32_t* a, uint32_t* b);  // c=a*b
52 void multiprecision_mersenns_mult_mod(uint32_t* c, uint32_t* a, uint32_t* b);
53 void multiprecision_mersenns_squa_mod(uint32_t* c, uint32_t* a);
54 uint32_t multiprecision_lshift(uint32_t* c, uint32_t* a);
55 void multiprecision_mult(uint32_t* c, uint32_t* a, uint32_t* b);
56 void multiprecision_fast_mod(uint32_t* c, uint32_t* a);
57 void multiprecision_fast_mod_P256(uint32_t* c, uint32_t* a);
58