-
Notifications
You must be signed in to change notification settings - Fork 0
/
ABY.patch
267 lines (246 loc) · 10 KB
/
ABY.patch
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
Submodule extern/ENCRYPTO_utils contains modified content
diff --git i/extern/ENCRYPTO_utils/CMakeLists.txt w/extern/ENCRYPTO_utils/CMakeLists.txt
index 3a67fe3..f24ae8b 100644
--- i/extern/ENCRYPTO_utils/CMakeLists.txt
+++ w/extern/ENCRYPTO_utils/CMakeLists.txt
@@ -53,19 +53,6 @@ set(SHLIB off CACHE BOOL "Relic shared library")
set(STLIB on CACHE BOOL "Relic static library")
add_subdirectory(extern/relic)
-#looks dirty, but since the relic library is poorly exported let's treat it as an external library
-if(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
- set(RELIC_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/librelic_s.a")
-else()
- set(RELIC_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/extern/relic/lib/librelic_s.a")
-endif()
-
-add_library(RELIC::relic STATIC IMPORTED)
-set_target_properties(RELIC::relic PROPERTIES
- IMPORTED_LOCATION ${RELIC_LIB_DIR}
- INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/extern/relic/include;${CMAKE_CURRENT_SOURCE_DIR}/extern/relic/include/low;${CMAKE_CURRENT_BINARY_DIR}/extern/relic/include"
-)
-
add_subdirectory(src)
if(ENCRYPTO_UTILS_BUILD_TESTS)
Submodule extern/relic contains modified content
diff --git i/extern/ENCRYPTO_utils/extern/relic/bench/bench_bn.c w/extern/ENCRYPTO_utils/extern/relic/bench/bench_bn.c
index 447f46e..9f135af 100644
--- i/extern/ENCRYPTO_utils/extern/relic/bench/bench_bn.c
+++ w/extern/ENCRYPTO_utils/extern/relic/bench/bench_bn.c
@@ -51,7 +51,7 @@ static void memory(void) {
bn_new(a[i]);
bn_clean(a[i]);
}
- BENCH_SMALL("bn_init", bn_init(a[i], RLC_BN_DIGS));
+ BENCH_SMALL("relic_bn_init", relic_bn_init(a[i], RLC_BN_DIGS));
for (int i = 0; i < BENCH; i++) {
bn_free(a[i]);
}
diff --git i/extern/ENCRYPTO_utils/extern/relic/include/relic_bn.h w/extern/ENCRYPTO_utils/extern/relic/include/relic_bn.h
index 8f9855b..d1f17ef 100644
--- i/extern/ENCRYPTO_utils/extern/relic/include/relic_bn.h
+++ w/extern/ENCRYPTO_utils/extern/relic/include/relic_bn.h
@@ -144,16 +144,16 @@ typedef bn_st *bn_t;
if ((A) == NULL) { \
THROW(ERR_NO_MEMORY); \
} \
- bn_init(A, RLC_BN_SIZE); \
+ relic_bn_init(A, RLC_BN_SIZE); \
#elif ALLOC == AUTO
#define bn_new(A) \
- bn_init(A, RLC_BN_SIZE); \
+ relic_bn_init(A, RLC_BN_SIZE); \
#elif ALLOC == STACK
#define bn_new(A) \
A = (bn_t)alloca(sizeof(bn_st)); \
- bn_init(A, RLC_BN_SIZE); \
+ relic_bn_init(A, RLC_BN_SIZE); \
#endif
@@ -173,16 +173,16 @@ typedef bn_st *bn_t;
if (A == NULL) { \
THROW(ERR_NO_MEMORY); \
} \
- bn_init(A, D); \
+ relic_bn_init(A, D); \
#elif ALLOC == AUTO
#define bn_new_size(A, D) \
- bn_init(A, D); \
+ relic_bn_init(A, D); \
#elif ALLOC == STACK
#define bn_new_size(A, D) \
A = (bn_t)alloca(sizeof(bn_st)); \
- bn_init(A, D); \
+ relic_bn_init(A, D); \
#endif
@@ -384,7 +384,7 @@ typedef bn_st *bn_t;
* @throw ERR_PRECISION - if the required precision cannot be represented
* by the library.
*/
-void bn_init(bn_t a, int digits);
+void relic_bn_init(bn_t a, int digits);
/**
* Cleans a multiple precision integer.
diff --git i/extern/ENCRYPTO_utils/extern/relic/include/relic_label.h w/extern/ENCRYPTO_utils/extern/relic/include/relic_label.h
index 2d37c2a..a9f60dc 100644
--- i/extern/ENCRYPTO_utils/extern/relic/include/relic_label.h
+++ w/extern/ENCRYPTO_utils/extern/relic/include/relic_label.h
@@ -164,7 +164,7 @@
#define bn_st PREFIX(bn_st)
#define bn_t PREFIX(bn_t)
-#undef bn_init
+#undef relic_bn_init
#undef bn_clean
#undef bn_grow
#undef bn_trim
@@ -266,7 +266,7 @@
#undef bn_rec_jsf
#undef bn_rec_glv
-#define bn_init PREFIX(bn_init)
+#define relic_bn_init PREFIX(relic_bn_init)
#define bn_clean PREFIX(bn_clean)
#define bn_grow PREFIX(bn_grow)
#define bn_trim PREFIX(bn_trim)
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/CMakeLists.txt w/extern/ENCRYPTO_utils/extern/relic/src/CMakeLists.txt
index 4255bc0..b033cb7 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/CMakeLists.txt
+++ w/extern/ENCRYPTO_utils/extern/relic/src/CMakeLists.txt
@@ -211,5 +211,20 @@ if (STLIB)
add_dependencies(${RELIC_S} arith_objs)
target_link_libraries(${RELIC_S} ${ARITH_LIBS})
link_libs(${RELIC_S})
- install(TARGETS ${RELIC_S} ARCHIVE DESTINATION lib)
+
+ add_library(${PROJECT_NAME}::${RELIC_S} ALIAS ${RELIC_S})
+ target_include_directories(${RELIC_S}
+ INTERFACE
+ $<INSTALL_INTERFACE:include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
+ )
+ install(TARGETS ${RELIC_S}
+ EXPORT "${PROJECT_NAME}Targets"
+ ARCHIVE DESTINATION lib
+ INCLUDES DESTINATION include
+ )
+ export(TARGETS ${RELIC_S} NAMESPACE "${PROJECT_NAME}::" FILE "${PROJECT_NAME}Targets.cmake")
endif(STLIB)
+
+install(EXPORT "${PROJECT_NAME}Targets" NAMESPACE "${PROJECT_NAME}::" DESTINATION "lib/cmake/${PROJECT_NAME}")
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/bn/relic_bn_mem.c w/extern/ENCRYPTO_utils/extern/relic/src/bn/relic_bn_mem.c
index ca0ae3b..68d04a1 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/bn/relic_bn_mem.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/bn/relic_bn_mem.c
@@ -41,7 +41,7 @@
/* Public definitions */
/*============================================================================*/
-void bn_init(bn_t a, int digits) {
+void relic_bn_init(bn_t a, int digits) {
#if ALLOC == DYNAMIC
if (digits % RLC_BN_SIZE != 0) {
/* Pad the number of digits to a multiple of the block. */
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/eb/relic_eb_curve.c w/extern/ENCRYPTO_utils/extern/relic/src/eb/relic_eb_curve.c
index e163436..6b4eb6a 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/eb/relic_eb_curve.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/eb/relic_eb_curve.c
@@ -73,8 +73,8 @@ void eb_curve_init(void) {
fb_zero(ctx->eb_g.x);
fb_zero(ctx->eb_g.y);
fb_zero(ctx->eb_g.z);
- bn_init(&(ctx->eb_r), RLC_FB_DIGS);
- bn_init(&(ctx->eb_h), RLC_FB_DIGS);
+ relic_bn_init(&(ctx->eb_r), RLC_FB_DIGS);
+ relic_bn_init(&(ctx->eb_h), RLC_FB_DIGS);
}
void eb_curve_clean(void) {
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/ed/relic_ed_curve.c w/extern/ENCRYPTO_utils/extern/relic/src/ed/relic_ed_curve.c
index fcd27d2..f49accf 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/ed/relic_ed_curve.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/ed/relic_ed_curve.c
@@ -40,8 +40,8 @@ void ed_curve_init(void) {
}
#endif
ed_set_infty(&ctx->ed_g);
- bn_init(&ctx->ed_r, RLC_FP_DIGS);
- bn_init(&ctx->ed_h, RLC_FP_DIGS);
+ relic_bn_init(&ctx->ed_r, RLC_FP_DIGS);
+ relic_bn_init(&ctx->ed_h, RLC_FP_DIGS);
}
void ed_curve_clean(void) {
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/ep/relic_ep_curve.c w/extern/ENCRYPTO_utils/extern/relic/src/ep/relic_ep_curve.c
index d48abb6..dd7488a 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/ep/relic_ep_curve.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/ep/relic_ep_curve.c
@@ -94,12 +94,12 @@ void ep_curve_init(void) {
}
#endif
ep_set_infty(&ctx->ep_g);
- bn_init(&ctx->ep_r, RLC_FP_DIGS);
- bn_init(&ctx->ep_h, RLC_FP_DIGS);
+ relic_bn_init(&ctx->ep_r, RLC_FP_DIGS);
+ relic_bn_init(&ctx->ep_h, RLC_FP_DIGS);
#if defined(EP_ENDOM) && (EP_MUL == LWNAF || EP_FIX == COMBS || EP_FIX == LWNAF || !defined(STRIP))
for (int i = 0; i < 3; i++) {
- bn_init(&(ctx->ep_v1[i]), RLC_FP_DIGS);
- bn_init(&(ctx->ep_v2[i]), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->ep_v1[i]), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->ep_v2[i]), RLC_FP_DIGS);
}
#endif
}
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/epx/relic_ep2_curve.c w/extern/ENCRYPTO_utils/extern/relic/src/epx/relic_ep2_curve.c
index bf7a3f9..9dc0b32 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/epx/relic_ep2_curve.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/epx/relic_ep2_curve.c
@@ -290,8 +290,8 @@ void ep2_curve_init(void) {
#endif
#endif
ep2_set_infty(&(ctx->ep2_g));
- bn_init(&(ctx->ep2_r), RLC_FP_DIGS);
- bn_init(&(ctx->ep2_h), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->ep2_r), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->ep2_h), RLC_FP_DIGS);
}
void ep2_curve_clean(void) {
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/fp/relic_fp_prime.c w/extern/ENCRYPTO_utils/extern/relic/src/fp/relic_fp_prime.c
index 0174b9d..3ba2323 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/fp/relic_fp_prime.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/fp/relic_fp_prime.c
@@ -135,14 +135,14 @@ static void fp_prime_set(const bn_t p) {
void fp_prime_init(void) {
ctx_t *ctx = core_get();
ctx->fp_id = 0;
- bn_init(&(ctx->prime), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->prime), RLC_FP_DIGS);
#if FP_RDC == QUICK || !defined(STRIP)
ctx->sps_len = 0;
memset(ctx->sps, 0, sizeof(ctx->sps));
#endif
#if FP_RDC == MONTY || !defined(STRIP)
- bn_init(&(ctx->conv), RLC_FP_DIGS);
- bn_init(&(ctx->one), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->conv), RLC_FP_DIGS);
+ relic_bn_init(&(ctx->one), RLC_FP_DIGS);
#endif
}
diff --git i/extern/ENCRYPTO_utils/extern/relic/src/low/easy/relic_fp_inv_low.c w/extern/ENCRYPTO_utils/extern/relic/src/low/easy/relic_fp_inv_low.c
index fbc1585..42f02a0 100644
--- i/extern/ENCRYPTO_utils/extern/relic/src/low/easy/relic_fp_inv_low.c
+++ w/extern/ENCRYPTO_utils/extern/relic/src/low/easy/relic_fp_inv_low.c
@@ -43,7 +43,7 @@
void fp_invn_low(dig_t *c, const dig_t *a) {
bn_st e;
- bn_init(&e, RLC_FP_DIGS);
+ relic_bn_init(&e, RLC_FP_DIGS);
e.used = RLC_FP_DIGS;
dv_copy(e.dp, fp_prime_get(), RLC_FP_DIGS);
diff --git i/extern/ENCRYPTO_utils/src/CMakeLists.txt w/extern/ENCRYPTO_utils/src/CMakeLists.txt
index 2e80478..afa63e2 100644
--- i/extern/ENCRYPTO_utils/src/CMakeLists.txt
+++ w/extern/ENCRYPTO_utils/src/CMakeLists.txt
@@ -42,7 +42,7 @@ target_link_libraries(encrypto_utils
GMP::GMP
GMP::GMPXX
OpenSSL::Crypto
- RELIC::relic
+ RELIC::relic_s
)
install(TARGETS encrypto_utils