OSDN Git Service

Merge "A2DP SRC offload support" into cw-e-dev am: ffdfe1d26d
[android-x86/system-bt.git] / stack / smp / p_256_multprecision.h
1 /******************************************************************************
2  *
3  *  Copyright (C) 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   *
21   *  This file contains simple pairing algorithms
22   *
23   ******************************************************************************/
24 #pragma once
25
26 #include "bt_types.h"
27
28 /* Type definitions */
29 typedef unsigned long  DWORD;
30
31 #define DWORD_BITS      32
32 #define DWORD_BYTES     4
33 #define DWORD_BITS_SHIFT 5
34
35 #define KEY_LENGTH_DWORDS_P192 6
36 #define KEY_LENGTH_DWORDS_P256 8
37 /* Arithmetic Operations */
38
39 int multiprecision_compare(DWORD *a, DWORD *b, uint32_t keyLength);
40 int multiprecision_iszero(DWORD *a, uint32_t keyLength);
41 void multiprecision_init(DWORD *c, uint32_t keyLength);
42 void multiprecision_copy(DWORD *c, DWORD *a, uint32_t keyLength);
43 UINT32 multiprecision_dword_bits (DWORD a);
44 UINT32 multiprecision_most_signdwords(DWORD *a, uint32_t keyLength);
45 UINT32 multiprecision_most_signbits(DWORD *a, uint32_t keyLength);
46 void multiprecision_inv_mod(DWORD *aminus, DWORD *a, uint32_t keyLength);
47 DWORD multiprecision_add(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength); // c=a+b
48 void multiprecision_add_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
49 DWORD multiprecision_sub(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength); // c=a-b
50 void multiprecision_sub_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
51 void multiprecision_rshift(DWORD * c, DWORD * a, uint32_t keyLength);  // c=a>>1, return carrier
52 void multiprecision_lshift_mod(DWORD * c, DWORD * a, uint32_t keyLength); // c=a<<b, return carrier
53 DWORD multiprecision_lshift(DWORD * c, DWORD * a, uint32_t keyLength);  // c=a<<b, return carrier
54 void multiprecision_mult(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength); // c=a*b
55 void multiprecision_mersenns_mult_mod(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
56 void multiprecision_mersenns_squa_mod(DWORD *c, DWORD *a, uint32_t keyLength);
57 DWORD multiprecision_lshift(DWORD * c, DWORD * a, uint32_t keyLength);
58 void multiprecision_mult(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength);
59 void multiprecision_fast_mod(DWORD *c, DWORD *a);
60 void multiprecision_fast_mod_P256(DWORD *c, DWORD *a);
61
62