-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathp256-cortex-m4-config.h
134 lines (110 loc) · 4.24 KB
/
p256-cortex-m4-config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Copyright (c) 2017-2021 Emil Lenngren
* Copyright (c) 2021 Shortcut Labs AB
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef P256_CORTEX_M4_CONFIG
#define P256_CORTEX_M4_CONFIG
// To enable a flag, define to 1. To disable, define to 0.
// Algorithm inclusion settings
// See p256-cortex-m4.h to understand what functions are included for each flag.
#ifndef include_p256_verify
#define include_p256_verify 1
#endif
#ifndef include_p256_sign
#define include_p256_sign 1
#endif
#ifndef include_p256_keygen
#define include_p256_keygen 1
#endif
#ifndef include_p256_ecdh
#define include_p256_ecdh 1
#endif
#ifndef include_p256_raw_scalarmult_generic
#define include_p256_raw_scalarmult_generic 1
#endif
#ifndef include_p256_raw_scalarmult_base
#define include_p256_raw_scalarmult_base 1
#endif
#ifndef include_p256_to_octet_string_uncompressed
#define include_p256_to_octet_string_uncompressed 1
#endif
#ifndef include_p256_to_octet_string_compressed
#define include_p256_to_octet_string_compressed 1
#endif
#ifndef include_p256_to_octet_string_hybrid
#define include_p256_to_octet_string_hybrid 1
#endif
#ifndef include_p256_decompress_point
#define include_p256_decompress_point 1
#endif
#ifndef include_p256_decode_point
#define include_p256_decode_point 1
#endif
// Target settings
/**
* Enables the use of FPU instructions (vmov, vldm).
* This will only work if the CPU has an FPU, such as Cortex-M4F.
* It will not work on Cortex-M4 (without FPU).
* If enabled, the code will run faster.
* The default is to use the __ARM_FP macro that the compiler defines.
*/
#ifndef has_fpu
#ifdef __ARM_FP
#define has_fpu 1
#else
#define has_fpu 0
#endif
#endif
/**
* If 0, the implementation conditionally loads data from different RAM locations depending
* on secret data, so 0 should not be used on CPUs that have data cache, such as Cortex-A53.
*
* 0 is suited for embedded devices running CPUs like Cortex-M4 and Cortex-M33, which don't
* have any data cache.
*
* 1 is suited for Cortex-A processors.
*/
#ifndef has_d_cache
#define has_d_cache 0
#endif
// Optimization settings
/**
* If enabled, keygen and sign uses a specialized scalar multiplication routine when multiplying by
* the base point, which dramatically improves performance, at the expense of using more code space.
* If disabled, keygen and sign will use the generic variable base scalar multiplication routine.
*/
#ifndef use_fast_p256_basemult
#define use_fast_p256_basemult 1
#endif
/**
* Enable this to save some code space, at expense of performance.
* When disabled, a specialized field squaring routine will be used rather
* than re-using the multiplication routine.
*/
#ifndef use_mul_for_sqr
#define use_mul_for_sqr 0
#endif
// Derived settings (do not modify)
#define include_p256_basemult (include_p256_keygen || include_p256_sign || include_p256_raw_scalarmult_base)
#define include_fast_p256_basemult (use_fast_p256_basemult && include_p256_basemult)
#define include_p256_varmult (include_p256_ecdh || include_p256_raw_scalarmult_generic)
#define include_p256_mult (include_p256_verify || include_p256_basemult || include_p256_varmult)
#endif