/src/cryptofuzz/operation.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | #include <cryptofuzz/operations.h> |
2 | | #include <cryptofuzz/util.h> |
3 | | #include <cryptofuzz/repository.h> |
4 | | #include <sstream> |
5 | | |
6 | | namespace cryptofuzz { |
7 | | namespace operation { |
8 | | |
9 | 0 | std::string Digest::Name(void) const { return "Digest"; } |
10 | 0 | std::string Digest::ToString(void) const { |
11 | 0 | std::stringstream ss; |
12 | |
|
13 | 0 | ss << "operation name: Digest" << std::endl; |
14 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
15 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
16 | |
|
17 | 0 | return ss.str(); |
18 | 0 | } |
19 | | |
20 | 0 | nlohmann::json Digest::ToJSON(void) const { |
21 | 0 | nlohmann::json j; |
22 | 0 | j["operation"] = "Digest"; |
23 | 0 | j["cleartext"] = cleartext.ToJSON(); |
24 | 0 | j["digestType"] = digestType.ToJSON(); |
25 | 0 | j["modifier"] = modifier.ToJSON(); |
26 | 0 | return j; |
27 | 0 | } |
28 | | |
29 | 0 | std::string HMAC::Name(void) const { return "HMAC"; } |
30 | 0 | std::string HMAC::ToString(void) const { |
31 | 0 | std::stringstream ss; |
32 | |
|
33 | 0 | ss << "operation name: HMAC" << std::endl; |
34 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
35 | 0 | ss << "key: " << util::HexDump(cipher.key.Get()) << std::endl; |
36 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
37 | |
|
38 | 0 | return ss.str(); |
39 | 0 | } |
40 | | |
41 | 0 | nlohmann::json HMAC::ToJSON(void) const { |
42 | 0 | nlohmann::json j; |
43 | 0 | j["operation"] = "HMAC"; |
44 | 0 | j["cleartext"] = cleartext.ToJSON(); |
45 | 0 | j["digestType"] = digestType.ToJSON(); |
46 | 0 | j["cipher"] = cipher.ToJSON(); |
47 | 0 | j["modifier"] = modifier.ToJSON(); |
48 | 0 | return j; |
49 | 0 | } |
50 | | |
51 | 0 | std::string UMAC::Name(void) const { return "UMAC"; } |
52 | 0 | std::string UMAC::ToString(void) const { |
53 | 0 | std::stringstream ss; |
54 | |
|
55 | 0 | ss << "operation name: UMAC" << std::endl; |
56 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
57 | 0 | ss << "key: " << util::HexDump(key.Get()) << std::endl; |
58 | 0 | ss << "iv: " << util::HexDump(iv.Get()) << std::endl; |
59 | 0 | ss << "type: " << std::to_string(type) << std::endl; |
60 | 0 | ss << "outSize: " << std::to_string(outSize) << std::endl; |
61 | |
|
62 | 0 | return ss.str(); |
63 | 0 | } |
64 | | |
65 | 0 | nlohmann::json UMAC::ToJSON(void) const { |
66 | 0 | nlohmann::json j; |
67 | 0 | j["operation"] = "UMAC"; |
68 | 0 | j["cleartext"] = cleartext.ToJSON(); |
69 | 0 | j["key"] = key.ToJSON(); |
70 | 0 | j["iv"] = iv.ToJSON(); |
71 | 0 | j["type"] = type; |
72 | 0 | j["outSize"] = outSize; |
73 | 0 | j["modifier"] = modifier.ToJSON(); |
74 | 0 | return j; |
75 | 0 | } |
76 | | |
77 | 0 | std::string SymmetricEncrypt::Name(void) const { return "SymmetricEncrypt"; } |
78 | 0 | std::string SymmetricEncrypt::ToString(void) const { |
79 | 0 | std::stringstream ss; |
80 | |
|
81 | 0 | ss << "operation name: SymmetricEncrypt" << std::endl; |
82 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
83 | 0 | ss << "aad: " << (aad ? util::HexDump(aad->Get()) : "nullopt") << std::endl; |
84 | 0 | ss << "cipher iv: " << util::HexDump(cipher.iv.Get()) << std::endl; |
85 | 0 | ss << "cipher key: " << util::HexDump(cipher.key.Get()) << std::endl; |
86 | 0 | ss << "cipher: " << repository::CipherToString(cipher.cipherType.Get()) << std::endl; |
87 | 0 | ss << "ciphertextSize: " << std::to_string(ciphertextSize) << std::endl; |
88 | 0 | ss << "tagSize: " << (tagSize ? std::to_string(*tagSize) : "nullopt") << std::endl; |
89 | |
|
90 | 0 | return ss.str(); |
91 | 0 | } |
92 | | |
93 | 0 | nlohmann::json SymmetricEncrypt::ToJSON(void) const { |
94 | 0 | nlohmann::json j; |
95 | 0 | j["operation"] = "SymmetricEncrypt"; |
96 | 0 | j["cleartext"] = cleartext.ToJSON(); |
97 | 0 | j["cipher"] = cipher.ToJSON(); |
98 | 0 | j["aad_enabled"] = (bool)(aad != std::nullopt); |
99 | 0 | j["aad"] = aad != std::nullopt ? aad->ToJSON() : ""; |
100 | 0 | j["ciphertextSize"] = ciphertextSize; |
101 | 0 | j["tagSize_enabled"] = (bool)(tagSize != std::nullopt); |
102 | 0 | j["tagSize"] = tagSize != std::nullopt ? *tagSize : 0; |
103 | 0 | j["modifier"] = modifier.ToJSON(); |
104 | 0 | return j; |
105 | 0 | } |
106 | | |
107 | 0 | std::string SymmetricDecrypt::Name(void) const { return "SymmetricDecrypt"; } |
108 | 0 | std::string SymmetricDecrypt::ToString(void) const { |
109 | 0 | std::stringstream ss; |
110 | |
|
111 | 0 | ss << "operation name: SymmetricDecrypt" << std::endl; |
112 | 0 | ss << "ciphertext: " << util::HexDump(ciphertext.Get()) << std::endl; |
113 | 0 | ss << "tag: " << (tag ? util::HexDump(tag->Get()) : "nullopt") << std::endl; |
114 | 0 | ss << "aad: " << (aad ? util::HexDump(aad->Get()) : "nullopt") << std::endl; |
115 | 0 | ss << "cipher iv: " << util::HexDump(cipher.iv.Get()) << std::endl; |
116 | 0 | ss << "cipher key: " << util::HexDump(cipher.key.Get()) << std::endl; |
117 | 0 | ss << "cipher: " << repository::CipherToString(cipher.cipherType.Get()) << std::endl; |
118 | 0 | ss << "cleartextSize: " << std::to_string(cleartextSize) << std::endl; |
119 | |
|
120 | 0 | return ss.str(); |
121 | 0 | } |
122 | | |
123 | 0 | nlohmann::json SymmetricDecrypt::ToJSON(void) const { |
124 | 0 | nlohmann::json j; |
125 | 0 | j["operation"] = "SymmetricDecrypt"; |
126 | 0 | j["ciphertext"] = ciphertext.ToJSON(); |
127 | 0 | j["cipher"] = cipher.ToJSON(); |
128 | 0 | j["aad_enabled"] = (bool)(aad != std::nullopt); |
129 | 0 | j["aad"] = aad != std::nullopt ? aad->ToJSON() : ""; |
130 | 0 | j["tag_enabled"] = (bool)(tag != std::nullopt); |
131 | 0 | j["tag"] = tag != std::nullopt ? tag->ToJSON() : ""; |
132 | 0 | j["cleartextSize"] = cleartextSize; |
133 | 0 | j["modifier"] = modifier.ToJSON(); |
134 | 0 | return j; |
135 | 0 | } |
136 | | |
137 | | /* Construct SymmetricDecrypt from SymmetricEncrypt */ |
138 | | SymmetricDecrypt::SymmetricDecrypt(const SymmetricEncrypt& opSymmetricEncrypt, const component::Ciphertext ciphertext, const uint64_t cleartextSize, std::optional<component::AAD> aad, component::Modifier modifier) : |
139 | | Operation(std::move(modifier)), |
140 | | ciphertext(ciphertext.ciphertext), |
141 | | cipher(opSymmetricEncrypt.cipher), |
142 | | tag(ciphertext.tag), |
143 | | aad(aad), |
144 | | cleartextSize(cleartextSize) |
145 | 997 | { } |
146 | | |
147 | 0 | std::string KDF_SCRYPT::Name(void) const { return "KDF_SCRYPT"; } |
148 | 0 | std::string KDF_SCRYPT::ToString(void) const { |
149 | 0 | std::stringstream ss; |
150 | |
|
151 | 0 | ss << "operation name: KDF_SCRYPT" << std::endl; |
152 | 0 | ss << "password: " << util::HexDump(password.Get()) << std::endl; |
153 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
154 | 0 | ss << "N: " << std::to_string(N) << std::endl; |
155 | 0 | ss << "r: " << std::to_string(r) << std::endl; |
156 | 0 | ss << "p: " << std::to_string(p) << std::endl; |
157 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
158 | |
|
159 | 0 | return ss.str(); |
160 | 0 | } |
161 | | |
162 | 0 | nlohmann::json KDF_SCRYPT::ToJSON(void) const { |
163 | 0 | nlohmann::json j; |
164 | 0 | j["operation"] = "KDF_SCRYPT"; |
165 | 0 | j["password"] = password.ToJSON(); |
166 | 0 | j["salt"] = salt.ToJSON(); |
167 | 0 | j["N"] = N; |
168 | 0 | j["r"] = r; |
169 | 0 | j["p"] = p; |
170 | 0 | j["keySize"] = keySize; |
171 | 0 | j["modifier"] = modifier.ToJSON(); |
172 | 0 | return j; |
173 | 0 | } |
174 | | |
175 | 0 | std::string KDF_HKDF::Name(void) const { return "KDF_HKDF"; } |
176 | 0 | std::string KDF_HKDF::ToString(void) const { |
177 | 0 | std::stringstream ss; |
178 | |
|
179 | 0 | ss << "operation name: KDF_HKDF" << std::endl; |
180 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
181 | 0 | ss << "password: " << util::HexDump(password.Get()) << std::endl; |
182 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
183 | 0 | ss << "info: " << util::HexDump(info.Get()) << std::endl; |
184 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
185 | |
|
186 | 0 | return ss.str(); |
187 | 0 | } |
188 | | |
189 | 0 | nlohmann::json KDF_HKDF::ToJSON(void) const { |
190 | 0 | nlohmann::json j; |
191 | 0 | j["operation"] = "KDF_HKDF"; |
192 | 0 | j["digestType"] = digestType.ToJSON(); |
193 | 0 | j["password"] = password.ToJSON(); |
194 | 0 | j["salt"] = salt.ToJSON(); |
195 | 0 | j["info"] = info.ToJSON(); |
196 | 0 | j["keySize"] = keySize; |
197 | 0 | j["modifier"] = modifier.ToJSON(); |
198 | 0 | return j; |
199 | 0 | } |
200 | | |
201 | 0 | std::string KDF_TLS1_PRF::Name(void) const { return "KDF_TLS1_PRF"; } |
202 | 0 | std::string KDF_TLS1_PRF::ToString(void) const { |
203 | 0 | std::stringstream ss; |
204 | |
|
205 | 0 | ss << "operation name: KDF_TLS1_PRF" << std::endl; |
206 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
207 | 0 | ss << "secret: " << util::HexDump(secret.Get()) << std::endl; |
208 | 0 | ss << "seed: " << util::HexDump(seed.Get()) << std::endl; |
209 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
210 | |
|
211 | 0 | return ss.str(); |
212 | 0 | } |
213 | | |
214 | 0 | nlohmann::json KDF_TLS1_PRF::ToJSON(void) const { |
215 | 0 | nlohmann::json j; |
216 | 0 | j["operation"] = "KDF_TLS1_PRF"; |
217 | 0 | j["digestType"] = digestType.ToJSON(); |
218 | 0 | j["secret"] = secret.ToJSON(); |
219 | 0 | j["seed"] = seed.ToJSON(); |
220 | 0 | j["keySize"] = keySize; |
221 | 0 | j["modifier"] = modifier.ToJSON(); |
222 | 0 | return j; |
223 | 0 | } |
224 | | |
225 | 0 | std::string KDF_PBKDF::Name(void) const { return "KDF_PBKDF"; } |
226 | 0 | std::string KDF_PBKDF::ToString(void) const { |
227 | 0 | std::stringstream ss; |
228 | |
|
229 | 0 | ss << "operation name: KDF_PBKDF" << std::endl; |
230 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
231 | 0 | ss << "password: " << util::HexDump(password.Get()) << std::endl; |
232 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
233 | 0 | ss << "iterations: " << std::to_string(iterations) << std::endl; |
234 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
235 | |
|
236 | 0 | return ss.str(); |
237 | 0 | } |
238 | | |
239 | 0 | nlohmann::json KDF_PBKDF::ToJSON(void) const { |
240 | 0 | nlohmann::json j; |
241 | 0 | j["operation"] = "KDF_PBKDF"; |
242 | 0 | j["digestType"] = digestType.ToJSON(); |
243 | 0 | j["password"] = password.ToJSON(); |
244 | 0 | j["salt"] = salt.ToJSON(); |
245 | 0 | j["iterations"] = iterations; |
246 | 0 | j["keySize"] = keySize; |
247 | 0 | j["modifier"] = modifier.ToJSON(); |
248 | 0 | return j; |
249 | 0 | } |
250 | | |
251 | 0 | std::string KDF_PBKDF1::Name(void) const { return "KDF_PBKDF1"; } |
252 | 0 | std::string KDF_PBKDF1::ToString(void) const { |
253 | 0 | std::stringstream ss; |
254 | |
|
255 | 0 | ss << "operation name: KDF_PBKDF1" << std::endl; |
256 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
257 | 0 | ss << "password: " << util::HexDump(password.Get()) << std::endl; |
258 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
259 | 0 | ss << "iterations: " << std::to_string(iterations) << std::endl; |
260 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
261 | |
|
262 | 0 | return ss.str(); |
263 | 0 | } |
264 | | |
265 | 0 | nlohmann::json KDF_PBKDF1::ToJSON(void) const { |
266 | 0 | nlohmann::json j; |
267 | 0 | j["operation"] = "KDF_PBKDF1"; |
268 | 0 | j["digestType"] = digestType.ToJSON(); |
269 | 0 | j["password"] = password.ToJSON(); |
270 | 0 | j["salt"] = salt.ToJSON(); |
271 | 0 | j["iterations"] = iterations; |
272 | 0 | j["keySize"] = keySize; |
273 | 0 | j["modifier"] = modifier.ToJSON(); |
274 | 0 | return j; |
275 | 0 | } |
276 | | |
277 | 0 | std::string KDF_PBKDF2::Name(void) const { return "KDF_PBKDF2"; } |
278 | 0 | std::string KDF_PBKDF2::ToString(void) const { |
279 | 0 | std::stringstream ss; |
280 | |
|
281 | 0 | ss << "operation name: KDF_PBKDF2" << std::endl; |
282 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
283 | 0 | ss << "password: " << util::HexDump(password.Get()) << std::endl; |
284 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
285 | 0 | ss << "iterations: " << std::to_string(iterations) << std::endl; |
286 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
287 | |
|
288 | 0 | return ss.str(); |
289 | 0 | } |
290 | | |
291 | 0 | nlohmann::json KDF_PBKDF2::ToJSON(void) const { |
292 | 0 | nlohmann::json j; |
293 | 0 | j["operation"] = "KDF_PBKDF2"; |
294 | 0 | j["digestType"] = digestType.ToJSON(); |
295 | 0 | j["password"] = password.ToJSON(); |
296 | 0 | j["salt"] = salt.ToJSON(); |
297 | 0 | j["iterations"] = iterations; |
298 | 0 | j["keySize"] = keySize; |
299 | 0 | j["modifier"] = modifier.ToJSON(); |
300 | 0 | return j; |
301 | 0 | } |
302 | | |
303 | 0 | std::string KDF_ARGON2::Name(void) const { return "KDF_ARGON2"; } |
304 | 0 | std::string KDF_ARGON2::ToString(void) const { |
305 | 0 | std::stringstream ss; |
306 | |
|
307 | 0 | ss << "operation name: KDF_ARGON2" << std::endl; |
308 | 0 | ss << "password: " << util::HexDump(password.Get()) << std::endl; |
309 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
310 | 0 | ss << "type: " << std::to_string(type) << std::endl; |
311 | 0 | ss << "threads: " << std::to_string(threads) << std::endl; |
312 | 0 | ss << "memory: " << std::to_string(memory) << std::endl; |
313 | 0 | ss << "iterations: " << std::to_string(iterations) << std::endl; |
314 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
315 | |
|
316 | 0 | return ss.str(); |
317 | 0 | } |
318 | | |
319 | 0 | nlohmann::json KDF_ARGON2::ToJSON(void) const { |
320 | 0 | nlohmann::json j; |
321 | 0 | j["operation"] = "KDF_ARGON2"; |
322 | 0 | j["password"] = password.ToJSON(); |
323 | 0 | j["salt"] = salt.ToJSON(); |
324 | 0 | j["type"] = type; |
325 | 0 | j["threads"] = threads; |
326 | 0 | j["memory"] = memory; |
327 | 0 | j["iterations"] = iterations; |
328 | 0 | j["modifier"] = modifier.ToJSON(); |
329 | 0 | return j; |
330 | 0 | } |
331 | | |
332 | 0 | std::string KDF_SSH::Name(void) const { return "KDF_SSH"; } |
333 | 0 | std::string KDF_SSH::ToString(void) const { |
334 | 0 | std::stringstream ss; |
335 | |
|
336 | 0 | ss << "operation name: KDF_SSH" << std::endl; |
337 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
338 | 0 | ss << "key: " << util::HexDump(key.Get()) << std::endl; |
339 | 0 | ss << "xcghash: " << util::HexDump(xcghash.Get()) << std::endl; |
340 | 0 | ss << "session_id: " << util::HexDump(session_id.Get()) << std::endl; |
341 | 0 | ss << "type: " << util::HexDump(type.Get()) << std::endl; |
342 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
343 | |
|
344 | 0 | return ss.str(); |
345 | 0 | } |
346 | | |
347 | 0 | nlohmann::json KDF_SSH::ToJSON(void) const { |
348 | 0 | nlohmann::json j; |
349 | 0 | j["operation"] = "KDF_SSH"; |
350 | 0 | j["digestType"] = digestType.ToJSON(); |
351 | 0 | j["key"] = key.ToJSON(); |
352 | 0 | j["xcghash"] = xcghash.ToJSON(); |
353 | 0 | j["session_id"] = session_id.ToJSON(); |
354 | 0 | j["type"] = type.ToJSON(); |
355 | 0 | j["keySize"] = keySize; |
356 | 0 | j["modifier"] = modifier.ToJSON(); |
357 | 0 | return j; |
358 | 0 | } |
359 | | |
360 | 0 | std::string KDF_X963::Name(void) const { return "KDF_X963"; } |
361 | 0 | std::string KDF_X963::ToString(void) const { |
362 | 0 | std::stringstream ss; |
363 | |
|
364 | 0 | ss << "operation name: KDF_X963" << std::endl; |
365 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
366 | 0 | ss << "secret: " << util::HexDump(secret.Get()) << std::endl; |
367 | 0 | ss << "info: " << util::HexDump(info.Get()) << std::endl; |
368 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
369 | |
|
370 | 0 | return ss.str(); |
371 | 0 | } |
372 | | |
373 | 0 | nlohmann::json KDF_X963::ToJSON(void) const { |
374 | 0 | nlohmann::json j; |
375 | 0 | j["operation"] = "KDF_X963"; |
376 | 0 | j["digestType"] = digestType.ToJSON(); |
377 | 0 | j["secret"] = secret.ToJSON(); |
378 | 0 | j["info"] = info.ToJSON(); |
379 | 0 | j["keySize"] = keySize; |
380 | 0 | j["modifier"] = modifier.ToJSON(); |
381 | 0 | return j; |
382 | 0 | } |
383 | | |
384 | 0 | std::string KDF_BCRYPT::Name(void) const { return "KDF_BCRYPT"; } |
385 | 0 | std::string KDF_BCRYPT::ToString(void) const { |
386 | 0 | std::stringstream ss; |
387 | |
|
388 | 0 | ss << "operation name: KDF_BCRYPT" << std::endl; |
389 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
390 | 0 | ss << "secret: " << util::HexDump(secret.Get()) << std::endl; |
391 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
392 | 0 | ss << "iterations: " << std::to_string(iterations) << std::endl; |
393 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
394 | |
|
395 | 0 | return ss.str(); |
396 | 0 | } |
397 | | |
398 | 0 | nlohmann::json KDF_BCRYPT::ToJSON(void) const { |
399 | 0 | nlohmann::json j; |
400 | 0 | j["operation"] = "KDF_BCRYPT"; |
401 | 0 | j["digestType"] = digestType.ToJSON(); |
402 | 0 | j["secret"] = secret.ToJSON(); |
403 | 0 | j["salt"] = salt.ToJSON(); |
404 | 0 | j["iterations"] = iterations; |
405 | 0 | j["keySize"] = keySize; |
406 | 0 | j["modifier"] = modifier.ToJSON(); |
407 | 0 | return j; |
408 | 0 | } |
409 | | |
410 | 0 | std::string KDF_SP_800_108::Name(void) const { return "KDF_SP_800_108"; } |
411 | 0 | std::string KDF_SP_800_108::ToString(void) const { |
412 | 0 | std::stringstream ss; |
413 | |
|
414 | 0 | ss << "operation name: KDF_SP_800_108" << std::endl; |
415 | 0 | ss << "hmac/cmac: " << (mech.mode ? "HMAC" : "CMAC") << std::endl; |
416 | 0 | if ( mech.mode == true ) { |
417 | 0 | ss << "digest: " << repository::DigestToString(mech.type.Get()) << std::endl; |
418 | 0 | } else { |
419 | 0 | ss << "cipher: " << repository::CipherToString(mech.type.Get()) << std::endl; |
420 | 0 | } |
421 | 0 | ss << "secret: " << util::HexDump(secret.Get()) << std::endl; |
422 | 0 | ss << "salt: " << util::HexDump(salt.Get()) << std::endl; |
423 | 0 | ss << "label: " << util::HexDump(label.Get()) << std::endl; |
424 | 0 | ss << "mode: " << std::to_string(mode) << std::endl; |
425 | 0 | ss << "keySize: " << std::to_string(keySize) << std::endl; |
426 | |
|
427 | 0 | return ss.str(); |
428 | 0 | } |
429 | | |
430 | 0 | nlohmann::json KDF_SP_800_108::ToJSON(void) const { |
431 | 0 | nlohmann::json j; |
432 | 0 | j["operation"] = "KDF_SP_800_108"; |
433 | 0 | j["mech"] = mech.ToJSON(); |
434 | 0 | j["secret"] = secret.ToJSON(); |
435 | 0 | j["salt"] = salt.ToJSON(); |
436 | 0 | j["label"] = label.ToJSON(); |
437 | 0 | j["mode"] = mode; |
438 | 0 | j["modifier"] = modifier.ToJSON(); |
439 | 0 | return j; |
440 | 0 | } |
441 | | |
442 | 0 | std::string CMAC::Name(void) const { return "CMAC"; } |
443 | 0 | std::string CMAC::ToString(void) const { |
444 | 0 | std::stringstream ss; |
445 | |
|
446 | 0 | ss << "operation name: CMAC" << std::endl; |
447 | 0 | ss << "cipher iv: " << util::HexDump(cipher.iv.Get()) << std::endl; |
448 | 0 | ss << "cipher key: " << util::HexDump(cipher.key.Get()) << std::endl; |
449 | 0 | ss << "cipher: " << repository::CipherToString(cipher.cipherType.Get()) << std::endl; |
450 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
451 | 0 | ss << "key: " << util::HexDump(cipher.key.Get()) << std::endl; |
452 | |
|
453 | 0 | return ss.str(); |
454 | 0 | } |
455 | | |
456 | 0 | nlohmann::json CMAC::ToJSON(void) const { |
457 | 0 | nlohmann::json j; |
458 | 0 | j["operation"] = "CMAC"; |
459 | 0 | j["cleartext"] = cleartext.ToJSON(); |
460 | 0 | j["cipher"] = cipher.ToJSON(); |
461 | 0 | j["modifier"] = modifier.ToJSON(); |
462 | 0 | return j; |
463 | 0 | } |
464 | | |
465 | 0 | std::string ECC_PrivateToPublic::Name(void) const { return "ECC_PrivateToPublic"; } |
466 | 0 | std::string ECC_PrivateToPublic::ToString(void) const { |
467 | 0 | std::stringstream ss; |
468 | |
|
469 | 0 | ss << "operation name: ECC_PrivateToPublic" << std::endl; |
470 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
471 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
472 | |
|
473 | 0 | return ss.str(); |
474 | 0 | } |
475 | | |
476 | 0 | nlohmann::json ECC_PrivateToPublic::ToJSON(void) const { |
477 | 0 | nlohmann::json j; |
478 | 0 | j["operation"] = "ECC_PrivateToPublic"; |
479 | 0 | j["priv"] = priv.ToJSON(); |
480 | 0 | j["curveType"] = curveType.ToJSON(); |
481 | 0 | j["modifier"] = modifier.ToJSON(); |
482 | 0 | return j; |
483 | 0 | } |
484 | | |
485 | 0 | std::string ECC_ValidatePubkey::Name(void) const { return "ECC_ValidatePubkey"; } |
486 | 0 | std::string ECC_ValidatePubkey::ToString(void) const { |
487 | 0 | std::stringstream ss; |
488 | |
|
489 | 0 | ss << "operation name: ECC_ValidatePubkey" << std::endl; |
490 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
491 | 0 | ss << "public key X: " << pub.first.ToString() << std::endl; |
492 | 0 | ss << "public key Y: " << pub.second.ToString() << std::endl; |
493 | |
|
494 | 0 | return ss.str(); |
495 | 0 | } |
496 | | |
497 | 0 | nlohmann::json ECC_ValidatePubkey::ToJSON(void) const { |
498 | 0 | nlohmann::json j; |
499 | 0 | j["operation"] = "ECC_ValidatePubkey"; |
500 | 0 | j["pub_x"] = pub.first.ToJSON(); |
501 | 0 | j["pub_y"] = pub.second.ToJSON(); |
502 | 0 | j["curveType"] = curveType.ToJSON(); |
503 | 0 | j["modifier"] = modifier.ToJSON(); |
504 | 0 | return j; |
505 | 0 | } |
506 | | |
507 | 0 | std::string ECC_GenerateKeyPair::Name(void) const { return "ECC_GenerateKeyPair"; } |
508 | 0 | std::string ECC_GenerateKeyPair::ToString(void) const { |
509 | 0 | std::stringstream ss; |
510 | |
|
511 | 0 | ss << "operation name: ECC_GenerateKeyPair" << std::endl; |
512 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
513 | |
|
514 | 0 | return ss.str(); |
515 | 0 | } |
516 | | |
517 | 0 | nlohmann::json ECC_GenerateKeyPair::ToJSON(void) const { |
518 | 0 | nlohmann::json j; |
519 | 0 | j["operation"] = "ECC_GenerateKeyPair"; |
520 | 0 | j["curveType"] = curveType.ToJSON(); |
521 | 0 | j["modifier"] = modifier.ToJSON(); |
522 | 0 | return j; |
523 | 0 | } |
524 | | |
525 | 0 | std::string ECDSA_Sign::Name(void) const { return "ECDSA_Sign"; } |
526 | 0 | std::string ECDSA_Sign::ToString(void) const { |
527 | 0 | std::stringstream ss; |
528 | |
|
529 | 0 | ss << "operation name: ECDSA_Sign" << std::endl; |
530 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
531 | 0 | ss << "nonce: " << nonce.ToString() << std::endl; |
532 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
533 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
534 | 0 | ss << "nonce source: "; |
535 | 0 | if ( UseRandomNonce() ) { |
536 | 0 | ss << "random"; |
537 | 0 | } else if ( UseRFC6979Nonce() ) { |
538 | 0 | ss << "RFC 6979"; |
539 | 0 | } else if ( UseSpecifiedNonce() ) { |
540 | 0 | ss << "specified"; |
541 | 0 | } else { |
542 | 0 | ss << "(unknown)"; |
543 | 0 | } |
544 | 0 | ss << std::endl; |
545 | |
|
546 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
547 | |
|
548 | 0 | return ss.str(); |
549 | 0 | } |
550 | | |
551 | 0 | nlohmann::json ECDSA_Sign::ToJSON(void) const { |
552 | 0 | nlohmann::json j; |
553 | 0 | j["operation"] = "ECDSA_Sign"; |
554 | 0 | j["priv"] = priv.ToJSON(); |
555 | 0 | j["nonce"] = priv.ToJSON(); |
556 | 0 | j["curveType"] = curveType.ToJSON(); |
557 | 0 | j["cleartext"] = cleartext.ToJSON(); |
558 | 0 | j["nonceSource"] = nonceSource; |
559 | 0 | j["digestType"] = digestType.ToJSON(); |
560 | 0 | j["modifier"] = modifier.ToJSON(); |
561 | 0 | return j; |
562 | 0 | } |
563 | | |
564 | 0 | std::string ECGDSA_Sign::Name(void) const { return "ECGDSA_Sign"; } |
565 | 0 | std::string ECGDSA_Sign::ToString(void) const { |
566 | 0 | std::stringstream ss; |
567 | |
|
568 | 0 | ss << "operation name: ECGDSA_Sign" << std::endl; |
569 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
570 | 0 | ss << "nonce: " << nonce.ToString() << std::endl; |
571 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
572 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
573 | 0 | ss << "nonce source: "; |
574 | 0 | if ( UseRandomNonce() ) { |
575 | 0 | ss << "random"; |
576 | 0 | } else if ( UseRFC6979Nonce() ) { |
577 | 0 | ss << "RFC 6979"; |
578 | 0 | } else if ( UseSpecifiedNonce() ) { |
579 | 0 | ss << "specified"; |
580 | 0 | } else { |
581 | 0 | ss << "(unknown)"; |
582 | 0 | } |
583 | 0 | ss << std::endl; |
584 | |
|
585 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
586 | |
|
587 | 0 | return ss.str(); |
588 | 0 | } |
589 | | |
590 | 0 | nlohmann::json ECGDSA_Sign::ToJSON(void) const { |
591 | 0 | nlohmann::json j; |
592 | 0 | j["operation"] = "ECGDSA_Sign"; |
593 | 0 | j["priv"] = priv.ToJSON(); |
594 | 0 | j["nonce"] = priv.ToJSON(); |
595 | 0 | j["curveType"] = curveType.ToJSON(); |
596 | 0 | j["cleartext"] = cleartext.ToJSON(); |
597 | 0 | j["nonceSource"] = nonceSource; |
598 | 0 | j["digestType"] = digestType.ToJSON(); |
599 | 0 | j["modifier"] = modifier.ToJSON(); |
600 | 0 | return j; |
601 | 0 | } |
602 | | |
603 | 0 | std::string ECRDSA_Sign::Name(void) const { return "ECRDSA_Sign"; } |
604 | 0 | std::string ECRDSA_Sign::ToString(void) const { |
605 | 0 | std::stringstream ss; |
606 | |
|
607 | 0 | ss << "operation name: ECRDSA_Sign" << std::endl; |
608 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
609 | 0 | ss << "nonce: " << nonce.ToString() << std::endl; |
610 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
611 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
612 | 0 | ss << "nonce source: "; |
613 | 0 | if ( UseRandomNonce() ) { |
614 | 0 | ss << "random"; |
615 | 0 | } else if ( UseRFC6979Nonce() ) { |
616 | 0 | ss << "RFC 6979"; |
617 | 0 | } else if ( UseSpecifiedNonce() ) { |
618 | 0 | ss << "specified"; |
619 | 0 | } else { |
620 | 0 | ss << "(unknown)"; |
621 | 0 | } |
622 | 0 | ss << std::endl; |
623 | |
|
624 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
625 | |
|
626 | 0 | return ss.str(); |
627 | 0 | } |
628 | | |
629 | 0 | nlohmann::json ECRDSA_Sign::ToJSON(void) const { |
630 | 0 | nlohmann::json j; |
631 | 0 | j["operation"] = "ECRDSA_Sign"; |
632 | 0 | j["priv"] = priv.ToJSON(); |
633 | 0 | j["nonce"] = priv.ToJSON(); |
634 | 0 | j["curveType"] = curveType.ToJSON(); |
635 | 0 | j["cleartext"] = cleartext.ToJSON(); |
636 | 0 | j["nonceSource"] = nonceSource; |
637 | 0 | j["digestType"] = digestType.ToJSON(); |
638 | 0 | j["modifier"] = modifier.ToJSON(); |
639 | 0 | return j; |
640 | 0 | } |
641 | | |
642 | 0 | std::string Schnorr_Sign::Name(void) const { return "Schnorr_Sign"; } |
643 | 0 | std::string Schnorr_Sign::ToString(void) const { |
644 | 0 | std::stringstream ss; |
645 | |
|
646 | 0 | ss << "operation name: Schnorr_Sign" << std::endl; |
647 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
648 | 0 | ss << "nonce: " << nonce.ToString() << std::endl; |
649 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
650 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
651 | 0 | ss << "nonce source: "; |
652 | 0 | if ( UseRandomNonce() ) { |
653 | 0 | ss << "random"; |
654 | 0 | } else if ( UseBIP340Nonce() ) { |
655 | 0 | ss << "BIP 340"; |
656 | 0 | } else if ( UseSpecifiedNonce() ) { |
657 | 0 | ss << "specified"; |
658 | 0 | } else { |
659 | 0 | ss << "(unknown)"; |
660 | 0 | } |
661 | 0 | ss << std::endl; |
662 | |
|
663 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
664 | |
|
665 | 0 | return ss.str(); |
666 | 0 | } |
667 | | |
668 | 0 | nlohmann::json Schnorr_Sign::ToJSON(void) const { |
669 | 0 | nlohmann::json j; |
670 | 0 | j["operation"] = "Schnorr_Sign"; |
671 | 0 | j["priv"] = priv.ToJSON(); |
672 | 0 | j["nonce"] = priv.ToJSON(); |
673 | 0 | j["curveType"] = curveType.ToJSON(); |
674 | 0 | j["cleartext"] = cleartext.ToJSON(); |
675 | 0 | j["nonceSource"] = nonceSource; |
676 | 0 | j["digestType"] = digestType.ToJSON(); |
677 | 0 | j["modifier"] = modifier.ToJSON(); |
678 | 0 | return j; |
679 | 0 | } |
680 | | |
681 | 0 | std::string ECDSA_Verify::Name(void) const { return "ECDSA_Verify"; } |
682 | 0 | std::string ECDSA_Verify::ToString(void) const { |
683 | 0 | std::stringstream ss; |
684 | |
|
685 | 0 | ss << "operation name: ECDSA_Verify" << std::endl; |
686 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
687 | 0 | ss << "public key X: " << signature.pub.first.ToString() << std::endl; |
688 | 0 | ss << "public key Y: " << signature.pub.second.ToString() << std::endl; |
689 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
690 | 0 | ss << "signature R: " << signature.signature.first.ToString() << std::endl; |
691 | 0 | ss << "signature S: " << signature.signature.second.ToString() << std::endl; |
692 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
693 | |
|
694 | 0 | return ss.str(); |
695 | 0 | } |
696 | | |
697 | 0 | nlohmann::json ECDSA_Verify::ToJSON(void) const { |
698 | 0 | nlohmann::json j; |
699 | 0 | j["operation"] = "ECDSA_Verify"; |
700 | 0 | j["curveType"] = curveType.ToJSON(); |
701 | 0 | j["pub_x"] = signature.pub.first.ToJSON(); |
702 | 0 | j["pub_y"] = signature.pub.second.ToJSON(); |
703 | 0 | j["cleartext"] = cleartext.ToJSON(); |
704 | 0 | j["sig_r"] = signature.signature.first.ToJSON(); |
705 | 0 | j["sig_s"] = signature.signature.second.ToJSON(); |
706 | 0 | j["digestType"] = digestType.ToJSON(); |
707 | 0 | j["modifier"] = modifier.ToJSON(); |
708 | 0 | return j; |
709 | 0 | } |
710 | | |
711 | | /* Construct ECDSA_Verify from ECDSA_Sign */ |
712 | | ECDSA_Verify::ECDSA_Verify(const ECDSA_Sign& opECDSA_Sign, const component::ECDSA_Signature signature, component::Modifier modifier) : |
713 | | Operation(std::move(modifier)), |
714 | | curveType(opECDSA_Sign.curveType), |
715 | | cleartext(opECDSA_Sign.cleartext), |
716 | | signature(signature), |
717 | | digestType(opECDSA_Sign.digestType) |
718 | 379 | { } |
719 | | |
720 | 0 | std::string ECGDSA_Verify::Name(void) const { return "ECGDSA_Verify"; } |
721 | 0 | std::string ECGDSA_Verify::ToString(void) const { |
722 | 0 | std::stringstream ss; |
723 | |
|
724 | 0 | ss << "operation name: ECGDSA_Verify" << std::endl; |
725 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
726 | 0 | ss << "public key X: " << signature.pub.first.ToString() << std::endl; |
727 | 0 | ss << "public key Y: " << signature.pub.second.ToString() << std::endl; |
728 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
729 | 0 | ss << "signature R: " << signature.signature.first.ToString() << std::endl; |
730 | 0 | ss << "signature S: " << signature.signature.second.ToString() << std::endl; |
731 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
732 | |
|
733 | 0 | return ss.str(); |
734 | 0 | } |
735 | | |
736 | 0 | nlohmann::json ECGDSA_Verify::ToJSON(void) const { |
737 | 0 | nlohmann::json j; |
738 | 0 | j["operation"] = "ECGDSA_Verify"; |
739 | 0 | j["curveType"] = curveType.ToJSON(); |
740 | 0 | j["pub_x"] = signature.pub.first.ToJSON(); |
741 | 0 | j["pub_y"] = signature.pub.second.ToJSON(); |
742 | 0 | j["cleartext"] = cleartext.ToJSON(); |
743 | 0 | j["sig_r"] = signature.signature.first.ToJSON(); |
744 | 0 | j["sig_s"] = signature.signature.second.ToJSON(); |
745 | 0 | j["digestType"] = digestType.ToJSON(); |
746 | 0 | j["modifier"] = modifier.ToJSON(); |
747 | 0 | return j; |
748 | 0 | } |
749 | | |
750 | 0 | std::string ECRDSA_Verify::Name(void) const { return "ECRDSA_Verify"; } |
751 | 0 | std::string ECRDSA_Verify::ToString(void) const { |
752 | 0 | std::stringstream ss; |
753 | |
|
754 | 0 | ss << "operation name: ECRDSA_Verify" << std::endl; |
755 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
756 | 0 | ss << "public key X: " << signature.pub.first.ToString() << std::endl; |
757 | 0 | ss << "public key Y: " << signature.pub.second.ToString() << std::endl; |
758 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
759 | 0 | ss << "signature R: " << signature.signature.first.ToString() << std::endl; |
760 | 0 | ss << "signature S: " << signature.signature.second.ToString() << std::endl; |
761 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
762 | |
|
763 | 0 | return ss.str(); |
764 | 0 | } |
765 | | |
766 | 0 | nlohmann::json ECRDSA_Verify::ToJSON(void) const { |
767 | 0 | nlohmann::json j; |
768 | 0 | j["operation"] = "ECRDSA_Verify"; |
769 | 0 | j["curveType"] = curveType.ToJSON(); |
770 | 0 | j["pub_x"] = signature.pub.first.ToJSON(); |
771 | 0 | j["pub_y"] = signature.pub.second.ToJSON(); |
772 | 0 | j["cleartext"] = cleartext.ToJSON(); |
773 | 0 | j["sig_r"] = signature.signature.first.ToJSON(); |
774 | 0 | j["sig_s"] = signature.signature.second.ToJSON(); |
775 | 0 | j["digestType"] = digestType.ToJSON(); |
776 | 0 | j["modifier"] = modifier.ToJSON(); |
777 | 0 | return j; |
778 | 0 | } |
779 | | |
780 | 0 | std::string Schnorr_Verify::Name(void) const { return "Schnorr_Verify"; } |
781 | 0 | std::string Schnorr_Verify::ToString(void) const { |
782 | 0 | std::stringstream ss; |
783 | |
|
784 | 0 | ss << "operation name: Schnorr_Verify" << std::endl; |
785 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
786 | 0 | ss << "public key X: " << signature.pub.first.ToString() << std::endl; |
787 | 0 | ss << "public key Y: " << signature.pub.second.ToString() << std::endl; |
788 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
789 | 0 | ss << "signature R: " << signature.signature.first.ToString() << std::endl; |
790 | 0 | ss << "signature S: " << signature.signature.second.ToString() << std::endl; |
791 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
792 | |
|
793 | 0 | return ss.str(); |
794 | 0 | } |
795 | | |
796 | 0 | nlohmann::json Schnorr_Verify::ToJSON(void) const { |
797 | 0 | nlohmann::json j; |
798 | 0 | j["operation"] = "Schnorr_Verify"; |
799 | 0 | j["curveType"] = curveType.ToJSON(); |
800 | 0 | j["pub_x"] = signature.pub.first.ToJSON(); |
801 | 0 | j["pub_y"] = signature.pub.second.ToJSON(); |
802 | 0 | j["cleartext"] = cleartext.ToJSON(); |
803 | 0 | j["sig_r"] = signature.signature.first.ToJSON(); |
804 | 0 | j["sig_s"] = signature.signature.second.ToJSON(); |
805 | 0 | j["digestType"] = digestType.ToJSON(); |
806 | 0 | j["modifier"] = modifier.ToJSON(); |
807 | 0 | return j; |
808 | 0 | } |
809 | | |
810 | 0 | std::string ECDSA_Recover::Name(void) const { return "ECDSA_Recover"; } |
811 | 0 | std::string ECDSA_Recover::ToString(void) const { |
812 | 0 | std::stringstream ss; |
813 | |
|
814 | 0 | ss << "operation name: ECDSA_Recover" << std::endl; |
815 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
816 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
817 | 0 | ss << "signature R: " << signature.first.ToString() << std::endl; |
818 | 0 | ss << "signature S: " << signature.second.ToString() << std::endl; |
819 | 0 | ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl; |
820 | 0 | ss << "recovery ID: " << std::to_string(id) << std::endl; |
821 | |
|
822 | 0 | return ss.str(); |
823 | 0 | } |
824 | | |
825 | 0 | nlohmann::json ECDSA_Recover::ToJSON(void) const { |
826 | 0 | nlohmann::json j; |
827 | 0 | j["operation"] = "ECDSA_Recover"; |
828 | 0 | j["curveType"] = curveType.ToJSON(); |
829 | 0 | j["cleartext"] = cleartext.ToJSON(); |
830 | 0 | j["sig_r"] = signature.first.ToJSON(); |
831 | 0 | j["sig_s"] = signature.second.ToJSON(); |
832 | 0 | j["digestType"] = digestType.ToJSON(); |
833 | 0 | j["modifier"] = modifier.ToJSON(); |
834 | 0 | return j; |
835 | 0 | } |
836 | | |
837 | 0 | std::string ECDH_Derive::Name(void) const { return "ECDH_Derive"; } |
838 | 0 | std::string ECDH_Derive::ToString(void) const { |
839 | 0 | std::stringstream ss; |
840 | |
|
841 | 0 | ss << "operation name: ECDH_Derive" << std::endl; |
842 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
843 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
844 | 0 | ss << "public key X: " << pub.first.ToString() << std::endl; |
845 | 0 | ss << "public key Y: " << pub.second.ToString() << std::endl; |
846 | |
|
847 | 0 | return ss.str(); |
848 | 0 | } |
849 | | |
850 | 0 | nlohmann::json ECDH_Derive::ToJSON(void) const { |
851 | 0 | nlohmann::json j; |
852 | 0 | j["operation"] = "ECDH_Derive"; |
853 | 0 | j["curveType"] = curveType.ToJSON(); |
854 | 0 | j["priv"] = priv.ToJSON(); |
855 | 0 | j["pub_x"] = pub.first.ToJSON(); |
856 | 0 | j["pub_y"] = pub.second.ToJSON(); |
857 | 0 | j["modifier"] = modifier.ToJSON(); |
858 | 0 | return j; |
859 | 0 | } |
860 | | |
861 | 0 | std::string ECIES_Encrypt::Name(void) const { return "ECIES_Encrypt"; } |
862 | 0 | std::string ECIES_Encrypt::ToString(void) const { |
863 | 0 | std::stringstream ss; |
864 | |
|
865 | 0 | ss << "operation name: ECIES_Encrypt" << std::endl; |
866 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
867 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
868 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
869 | 0 | ss << "public key X: " << pub.first.ToString() << std::endl; |
870 | 0 | ss << "public key Y: " << pub.second.ToString() << std::endl; |
871 | 0 | ss << "cipher: " << repository::CipherToString(cipherType.Get()) << std::endl; |
872 | 0 | ss << "iv: " << (iv ? util::HexDump(iv->Get()) : "nullopt") << std::endl; |
873 | |
|
874 | 0 | return ss.str(); |
875 | 0 | } |
876 | | |
877 | 0 | nlohmann::json ECIES_Encrypt::ToJSON(void) const { |
878 | 0 | nlohmann::json j; |
879 | 0 | j["operation"] = "ECIES_Encrypt"; |
880 | 0 | j["cleartext"] = cleartext.ToJSON(); |
881 | 0 | j["curveType"] = curveType.ToJSON(); |
882 | 0 | j["priv"] = priv.ToJSON(); |
883 | 0 | j["pub_x"] = pub.first.ToJSON(); |
884 | 0 | j["pub_y"] = pub.second.ToJSON(); |
885 | 0 | j["cipherType"] = cipherType.ToJSON(); |
886 | 0 | j["iv_enabled"] = (bool)(iv != std::nullopt); |
887 | 0 | j["iv"] = iv != std::nullopt ? iv->ToJSON() : ""; |
888 | 0 | j["modifier"] = modifier.ToJSON(); |
889 | 0 | return j; |
890 | 0 | } |
891 | | |
892 | 0 | std::string ECIES_Decrypt::Name(void) const { return "ECIES_Decrypt"; } |
893 | 0 | std::string ECIES_Decrypt::ToString(void) const { |
894 | 0 | std::stringstream ss; |
895 | |
|
896 | 0 | ss << "operation name: ECIES_Decrypt" << std::endl; |
897 | 0 | ss << "ciphertext: " << util::HexDump(ciphertext.Get()) << std::endl; |
898 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
899 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
900 | 0 | ss << "public key X: " << pub.first.ToString() << std::endl; |
901 | 0 | ss << "public key Y: " << pub.second.ToString() << std::endl; |
902 | 0 | ss << "cipher: " << repository::CipherToString(cipherType.Get()) << std::endl; |
903 | 0 | ss << "iv: " << (iv ? util::HexDump(iv->Get()) : "nullopt") << std::endl; |
904 | |
|
905 | 0 | return ss.str(); |
906 | 0 | } |
907 | | |
908 | 0 | nlohmann::json ECIES_Decrypt::ToJSON(void) const { |
909 | 0 | nlohmann::json j; |
910 | 0 | j["operation"] = "ECIES_Decrypt"; |
911 | 0 | j["ciphertext"] = ciphertext.ToJSON(); |
912 | 0 | j["curveType"] = curveType.ToJSON(); |
913 | 0 | j["priv"] = priv.ToJSON(); |
914 | 0 | j["pub_x"] = pub.first.ToJSON(); |
915 | 0 | j["pub_y"] = pub.second.ToJSON(); |
916 | 0 | j["cipherType"] = cipherType.ToJSON(); |
917 | 0 | j["iv_enabled"] = (bool)(iv != std::nullopt); |
918 | 0 | j["iv"] = iv != std::nullopt ? iv->ToJSON() : ""; |
919 | 0 | j["modifier"] = modifier.ToJSON(); |
920 | 0 | return j; |
921 | 0 | } |
922 | | |
923 | 0 | std::string ECC_Point_Add::Name(void) const { return "ECC_Point_Add"; } |
924 | 0 | std::string ECC_Point_Add::ToString(void) const { |
925 | 0 | std::stringstream ss; |
926 | |
|
927 | 0 | ss << "operation name: ECC_Point_Add" << std::endl; |
928 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
929 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
930 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
931 | 0 | ss << "B X: " << b.first.ToString() << std::endl; |
932 | 0 | ss << "B Y: " << b.second.ToString() << std::endl; |
933 | |
|
934 | 0 | return ss.str(); |
935 | 0 | } |
936 | | |
937 | 0 | nlohmann::json ECC_Point_Add::ToJSON(void) const { |
938 | 0 | nlohmann::json j; |
939 | 0 | j["curveType"] = curveType.ToJSON(); |
940 | |
|
941 | 0 | j["a_x"] = a.first.ToJSON(); |
942 | 0 | j["a_y"] = a.second.ToJSON(); |
943 | |
|
944 | 0 | j["b_x"] = b.first.ToJSON(); |
945 | 0 | j["b_y"] = b.second.ToJSON(); |
946 | |
|
947 | 0 | j["modifier"] = modifier.ToJSON(); |
948 | 0 | return j; |
949 | 0 | } |
950 | | |
951 | 0 | std::string ECC_Point_Mul::Name(void) const { return "ECC_Point_Mul"; } |
952 | 0 | std::string ECC_Point_Mul::ToString(void) const { |
953 | 0 | std::stringstream ss; |
954 | |
|
955 | 0 | ss << "operation name: ECC_Point_Mul" << std::endl; |
956 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
957 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
958 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
959 | 0 | ss << "B: " << b.ToString() << std::endl; |
960 | |
|
961 | 0 | return ss.str(); |
962 | 0 | } |
963 | | |
964 | 0 | nlohmann::json ECC_Point_Mul::ToJSON(void) const { |
965 | 0 | nlohmann::json j; |
966 | 0 | j["curveType"] = curveType.ToJSON(); |
967 | |
|
968 | 0 | j["a_x"] = a.first.ToJSON(); |
969 | 0 | j["a_y"] = a.second.ToJSON(); |
970 | |
|
971 | 0 | j["b"] = b.ToJSON(); |
972 | |
|
973 | 0 | j["modifier"] = modifier.ToJSON(); |
974 | 0 | return j; |
975 | 0 | } |
976 | | |
977 | 0 | std::string ECC_Point_Neg::Name(void) const { return "ECC_Point_Neg"; } |
978 | 0 | std::string ECC_Point_Neg::ToString(void) const { |
979 | 0 | std::stringstream ss; |
980 | |
|
981 | 0 | ss << "operation name: ECC_Point_Neg" << std::endl; |
982 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
983 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
984 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
985 | |
|
986 | 0 | return ss.str(); |
987 | 0 | } |
988 | | |
989 | 0 | nlohmann::json ECC_Point_Neg::ToJSON(void) const { |
990 | 0 | nlohmann::json j; |
991 | 0 | j["curveType"] = curveType.ToJSON(); |
992 | |
|
993 | 0 | j["a_x"] = a.first.ToJSON(); |
994 | 0 | j["a_y"] = a.second.ToJSON(); |
995 | |
|
996 | 0 | j["modifier"] = modifier.ToJSON(); |
997 | 0 | return j; |
998 | 0 | } |
999 | | |
1000 | 0 | std::string ECC_Point_Dbl::Name(void) const { return "ECC_Point_Dbl"; } |
1001 | 0 | std::string ECC_Point_Dbl::ToString(void) const { |
1002 | 0 | std::stringstream ss; |
1003 | |
|
1004 | 0 | ss << "operation name: ECC_Point_Dbl" << std::endl; |
1005 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1006 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
1007 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
1008 | |
|
1009 | 0 | return ss.str(); |
1010 | 0 | } |
1011 | | |
1012 | 0 | nlohmann::json ECC_Point_Dbl::ToJSON(void) const { |
1013 | 0 | nlohmann::json j; |
1014 | 0 | j["curveType"] = curveType.ToJSON(); |
1015 | |
|
1016 | 0 | j["a_x"] = a.first.ToJSON(); |
1017 | 0 | j["a_y"] = a.second.ToJSON(); |
1018 | |
|
1019 | 0 | j["modifier"] = modifier.ToJSON(); |
1020 | 0 | return j; |
1021 | 0 | } |
1022 | | |
1023 | 0 | std::string DH_GenerateKeyPair::Name(void) const { return "DH_GenerateKeyPair"; } |
1024 | 0 | std::string DH_GenerateKeyPair::ToString(void) const { |
1025 | 0 | std::stringstream ss; |
1026 | |
|
1027 | 0 | ss << "operation name: DH_GenerateKeyPair" << std::endl; |
1028 | 0 | ss << "prime: " << prime.ToString() << std::endl; |
1029 | 0 | ss << "base: " << base.ToString() << std::endl; |
1030 | |
|
1031 | 0 | return ss.str(); |
1032 | 0 | } |
1033 | | |
1034 | 0 | nlohmann::json DH_GenerateKeyPair::ToJSON(void) const { |
1035 | 0 | nlohmann::json j; |
1036 | 0 | j["operation"] = "DH_GenerateKeyPair"; |
1037 | 0 | j["prime"] = prime.ToJSON(); |
1038 | 0 | j["base"] = base.ToJSON(); |
1039 | 0 | j["modifier"] = modifier.ToJSON(); |
1040 | 0 | return j; |
1041 | 0 | } |
1042 | | |
1043 | 0 | std::string DH_Derive::Name(void) const { return "DH_Derive"; } |
1044 | 0 | std::string DH_Derive::ToString(void) const { |
1045 | 0 | std::stringstream ss; |
1046 | |
|
1047 | 0 | ss << "operation name: DH_Derive" << std::endl; |
1048 | 0 | ss << "prime: " << prime.ToString() << std::endl; |
1049 | 0 | ss << "base: " << base.ToString() << std::endl; |
1050 | 0 | ss << "public key: " << pub.ToString() << std::endl; |
1051 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
1052 | |
|
1053 | 0 | return ss.str(); |
1054 | 0 | } |
1055 | | |
1056 | 0 | nlohmann::json DH_Derive::ToJSON(void) const { |
1057 | 0 | nlohmann::json j; |
1058 | 0 | j["operation"] = "DH_Derive"; |
1059 | 0 | j["prime"] = prime.ToJSON(); |
1060 | 0 | j["base"] = base.ToJSON(); |
1061 | 0 | j["pub"] = pub.ToJSON(); |
1062 | 0 | j["priv"] = priv.ToJSON(); |
1063 | 0 | j["modifier"] = modifier.ToJSON(); |
1064 | 0 | return j; |
1065 | 0 | } |
1066 | | |
1067 | 0 | std::string BignumCalc::Name(void) const { return "BignumCalc"; } |
1068 | 0 | std::string BignumCalc::ToString(void) const { |
1069 | 0 | std::stringstream ss; |
1070 | |
|
1071 | 0 | ss << "operation name: BignumCalc" << std::endl; |
1072 | 0 | ss << "calc operation: " << repository::CalcOpToString(calcOp.Get()) << std::endl; |
1073 | 0 | ss << "bignum 1: " << bn0.ToString() << std::endl; |
1074 | 0 | ss << "bignum 2: " << bn1.ToString() << std::endl; |
1075 | 0 | ss << "bignum 3: " << bn2.ToString() << std::endl; |
1076 | 0 | ss << "bignum 4: " << bn3.ToString() << std::endl; |
1077 | |
|
1078 | 0 | return ss.str(); |
1079 | 0 | } |
1080 | | |
1081 | 0 | nlohmann::json BignumCalc::ToJSON(void) const { |
1082 | 0 | nlohmann::json j; |
1083 | 0 | j["operation"] = "BignumCalc"; |
1084 | 0 | j["calcOp"] = calcOp.ToJSON(); |
1085 | 0 | j["bn0"] = bn0.ToJSON(); |
1086 | 0 | j["bn1"] = bn1.ToJSON(); |
1087 | 0 | j["bn2"] = bn2.ToJSON(); |
1088 | 0 | j["bn3"] = bn3.ToJSON(); |
1089 | 0 | j["modifier"] = modifier.ToJSON(); |
1090 | 0 | return j; |
1091 | 0 | } |
1092 | | |
1093 | 0 | std::string BignumCalc_Fp2::Name(void) const { return "BignumCalc_Fp2"; } |
1094 | 0 | std::string BignumCalc_Fp2::ToString(void) const { |
1095 | 0 | std::stringstream ss; |
1096 | |
|
1097 | 0 | ss << "operation name: BignumCalc_Fp2" << std::endl; |
1098 | 0 | ss << "calc operation: " << repository::CalcOpToString(calcOp.Get()) << std::endl; |
1099 | 0 | ss << "Fp2 1 x: " << bn0.first.ToString() << std::endl; |
1100 | 0 | ss << "Fp2 1 x: " << bn0.second.ToString() << std::endl; |
1101 | 0 | ss << "Fp2 2 x: " << bn1.first.ToString() << std::endl; |
1102 | 0 | ss << "Fp2 2 x: " << bn1.second.ToString() << std::endl; |
1103 | 0 | ss << "Fp2 3 x: " << bn2.first.ToString() << std::endl; |
1104 | 0 | ss << "Fp2 3 x: " << bn2.second.ToString() << std::endl; |
1105 | 0 | ss << "Fp2 4 x: " << bn3.first.ToString() << std::endl; |
1106 | 0 | ss << "Fp2 4 x: " << bn3.second.ToString() << std::endl; |
1107 | |
|
1108 | 0 | return ss.str(); |
1109 | 0 | } |
1110 | | |
1111 | 0 | nlohmann::json BignumCalc_Fp2::ToJSON(void) const { |
1112 | 0 | nlohmann::json j; |
1113 | | /* TODO */ |
1114 | 0 | return j; |
1115 | 0 | } |
1116 | | |
1117 | 0 | std::string BignumCalc_Fp12::Name(void) const { return "BignumCalc_Fp12"; } |
1118 | 0 | std::string BignumCalc_Fp12::ToString(void) const { |
1119 | 0 | std::stringstream ss; |
1120 | |
|
1121 | 0 | ss << "operation name: BignumCalc_Fp12" << std::endl; |
1122 | 0 | ss << "calc operation: " << repository::CalcOpToString(calcOp.Get()) << std::endl; |
1123 | 0 | ss << "bn0 1: " << bn0.bn1.ToString() << std::endl; |
1124 | 0 | ss << "bn0 2: " << bn0.bn2.ToString() << std::endl; |
1125 | 0 | ss << "bn0 3: " << bn0.bn3.ToString() << std::endl; |
1126 | 0 | ss << "bn0 4: " << bn0.bn4.ToString() << std::endl; |
1127 | 0 | ss << "bn0 5: " << bn0.bn5.ToString() << std::endl; |
1128 | 0 | ss << "bn0 6: " << bn0.bn6.ToString() << std::endl; |
1129 | 0 | ss << "bn0 7: " << bn0.bn7.ToString() << std::endl; |
1130 | 0 | ss << "bn0 8: " << bn0.bn8.ToString() << std::endl; |
1131 | 0 | ss << "bn0 9: " << bn0.bn9.ToString() << std::endl; |
1132 | 0 | ss << "bn0 10: " << bn0.bn10.ToString() << std::endl; |
1133 | 0 | ss << "bn0 11: " << bn0.bn11.ToString() << std::endl; |
1134 | 0 | ss << "bn0 12: " << bn0.bn12.ToString() << std::endl; |
1135 | |
|
1136 | 0 | ss << std::endl; |
1137 | |
|
1138 | 0 | ss << "bn1 1: " << bn1.bn1.ToString() << std::endl; |
1139 | 0 | ss << "bn1 2: " << bn1.bn2.ToString() << std::endl; |
1140 | 0 | ss << "bn1 3: " << bn1.bn3.ToString() << std::endl; |
1141 | 0 | ss << "bn1 4: " << bn1.bn4.ToString() << std::endl; |
1142 | 0 | ss << "bn1 5: " << bn1.bn5.ToString() << std::endl; |
1143 | 0 | ss << "bn1 6: " << bn1.bn6.ToString() << std::endl; |
1144 | 0 | ss << "bn1 7: " << bn1.bn7.ToString() << std::endl; |
1145 | 0 | ss << "bn1 8: " << bn1.bn8.ToString() << std::endl; |
1146 | 0 | ss << "bn1 9: " << bn1.bn9.ToString() << std::endl; |
1147 | 0 | ss << "bn1 10: " << bn1.bn10.ToString() << std::endl; |
1148 | 0 | ss << "bn1 11: " << bn1.bn11.ToString() << std::endl; |
1149 | 0 | ss << "bn1 12: " << bn1.bn12.ToString() << std::endl; |
1150 | |
|
1151 | 0 | return ss.str(); |
1152 | 0 | } |
1153 | | |
1154 | 0 | nlohmann::json BignumCalc_Fp12::ToJSON(void) const { |
1155 | 0 | nlohmann::json j; |
1156 | | /* TODO */ |
1157 | 0 | return j; |
1158 | 0 | } |
1159 | | |
1160 | 0 | std::string BLS_PrivateToPublic::Name(void) const { return "BLS_PrivateToPublic"; } |
1161 | 0 | std::string BLS_PrivateToPublic::ToString(void) const { |
1162 | 0 | std::stringstream ss; |
1163 | |
|
1164 | 0 | ss << "operation name: BLS_PrivateToPublic" << std::endl; |
1165 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1166 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
1167 | |
|
1168 | 0 | return ss.str(); |
1169 | 0 | } |
1170 | | |
1171 | 0 | nlohmann::json BLS_PrivateToPublic::ToJSON(void) const { |
1172 | 0 | nlohmann::json j; |
1173 | 0 | j["priv"] = priv.ToJSON(); |
1174 | 0 | j["curveType"] = curveType.ToJSON(); |
1175 | 0 | j["modifier"] = modifier.ToJSON(); |
1176 | 0 | return j; |
1177 | 0 | } |
1178 | | |
1179 | 0 | std::string BLS_PrivateToPublic_G2::Name(void) const { return "BLS_PrivateToPublic_G2"; } |
1180 | 0 | std::string BLS_PrivateToPublic_G2::ToString(void) const { |
1181 | 0 | std::stringstream ss; |
1182 | |
|
1183 | 0 | ss << "operation name: BLS_PrivateToPublic_G2" << std::endl; |
1184 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1185 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
1186 | |
|
1187 | 0 | return ss.str(); |
1188 | 0 | } |
1189 | | |
1190 | 0 | nlohmann::json BLS_PrivateToPublic_G2::ToJSON(void) const { |
1191 | 0 | nlohmann::json j; |
1192 | 0 | j["priv"] = priv.ToJSON(); |
1193 | 0 | j["curveType"] = curveType.ToJSON(); |
1194 | 0 | j["modifier"] = modifier.ToJSON(); |
1195 | 0 | return j; |
1196 | 0 | } |
1197 | | |
1198 | 0 | std::string BLS_Sign::Name(void) const { return "BLS_Sign"; } |
1199 | 0 | std::string BLS_Sign::ToString(void) const { |
1200 | 0 | std::stringstream ss; |
1201 | |
|
1202 | 0 | ss << "operation name: BLS_Sign" << std::endl; |
1203 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1204 | 0 | ss << "private key: " << priv.ToString() << std::endl; |
1205 | 0 | if ( hashOrPoint == true ) { |
1206 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
1207 | 0 | } else { |
1208 | 0 | ss << "point V: " << point.first.first.ToString() << std::endl; |
1209 | 0 | ss << "point W: " << point.first.second.ToString() << std::endl; |
1210 | 0 | ss << "point X: " << point.second.first.ToString() << std::endl; |
1211 | 0 | ss << "point Y: " << point.second.second.ToString() << std::endl; |
1212 | 0 | } |
1213 | 0 | ss << "dest: " << util::HexDump(dest.Get()) << std::endl; |
1214 | 0 | ss << "aug: " << util::HexDump(aug.Get()) << std::endl; |
1215 | |
|
1216 | 0 | return ss.str(); |
1217 | 0 | } |
1218 | | |
1219 | 0 | nlohmann::json BLS_Sign::ToJSON(void) const { |
1220 | 0 | nlohmann::json j; |
1221 | |
|
1222 | 0 | j["curveType"] = curveType.ToJSON(); |
1223 | |
|
1224 | 0 | j["hashOrPoint"] = hashOrPoint; |
1225 | |
|
1226 | 0 | j["priv"] = priv.ToJSON(); |
1227 | |
|
1228 | 0 | if ( hashOrPoint == true ) { |
1229 | 0 | j["cleartext"] = cleartext.ToJSON(); |
1230 | 0 | } else { |
1231 | 0 | j["g2_v"] = point.first.first.ToJSON(); |
1232 | 0 | j["g2_w"] = point.first.second.ToJSON(); |
1233 | 0 | j["g2_x"] = point.second.first.ToJSON(); |
1234 | 0 | j["g2_y"] = point.second.second.ToJSON(); |
1235 | 0 | } |
1236 | 0 | j["dest"] = dest.ToJSON(); |
1237 | 0 | j["aug"] = aug.ToJSON(); |
1238 | |
|
1239 | 0 | j["modifier"] = modifier.ToJSON(); |
1240 | |
|
1241 | 0 | return j; |
1242 | 0 | } |
1243 | | |
1244 | 0 | std::string BLS_Verify::Name(void) const { return "BLS_Verify"; } |
1245 | 0 | std::string BLS_Verify::ToString(void) const { |
1246 | 0 | std::stringstream ss; |
1247 | |
|
1248 | 0 | ss << "operation name: BLS_Verify" << std::endl; |
1249 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1250 | 0 | ss << "public key X: " << pub.first.ToString() << std::endl; |
1251 | 0 | ss << "public key Y: " << pub.second.ToString() << std::endl; |
1252 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
1253 | 0 | ss << "signature V: " << signature.first.first.ToString() << std::endl; |
1254 | 0 | ss << "signature W: " << signature.first.second.ToString() << std::endl; |
1255 | 0 | ss << "signature X: " << signature.second.first.ToString() << std::endl; |
1256 | 0 | ss << "signature Y: " << signature.second.second.ToString() << std::endl; |
1257 | 0 | ss << "dest: " << util::HexDump(dest.Get()) << std::endl; |
1258 | |
|
1259 | 0 | return ss.str(); |
1260 | 0 | } |
1261 | | |
1262 | 0 | nlohmann::json BLS_Verify::ToJSON(void) const { |
1263 | 0 | nlohmann::json j; |
1264 | 0 | j["curveType"] = curveType.ToJSON(); |
1265 | |
|
1266 | 0 | j["cleartext"] = cleartext.ToJSON(); |
1267 | |
|
1268 | 0 | j["g1_x"] = pub.first.ToJSON(); |
1269 | 0 | j["g1_y"] = pub.second.ToJSON(); |
1270 | |
|
1271 | 0 | j["g2_v"] = signature.first.first.ToJSON(); |
1272 | 0 | j["g2_w"] = signature.first.second.ToJSON(); |
1273 | 0 | j["g2_x"] = signature.second.first.ToJSON(); |
1274 | 0 | j["g2_y"] = signature.second.second.ToJSON(); |
1275 | |
|
1276 | 0 | j["dest"] = dest.ToJSON(); |
1277 | |
|
1278 | 0 | j["modifier"] = modifier.ToJSON(); |
1279 | 0 | return j; |
1280 | 0 | } |
1281 | | |
1282 | 0 | std::string BLS_BatchSign::Name(void) const { return "BLS_BatchSign"; } |
1283 | 0 | std::string BLS_BatchSign::ToString(void) const { |
1284 | 0 | std::stringstream ss; |
1285 | |
|
1286 | 0 | ss << "operation name: BLS_BatchSign" << std::endl; |
1287 | |
|
1288 | 0 | for (const auto& cur : bf.c) { |
1289 | 0 | ss << "priv: " << cur.priv.ToString() << std::endl; |
1290 | 0 | ss << "G1 X: " << cur.g1.first.ToString() << std::endl; |
1291 | 0 | ss << "G1 Y: " << cur.g1.second.ToString() << std::endl; |
1292 | 0 | } |
1293 | 0 | return ss.str(); |
1294 | 0 | } |
1295 | | |
1296 | 0 | nlohmann::json BLS_BatchSign::ToJSON(void) const { |
1297 | 0 | nlohmann::json j; |
1298 | | /* TODO */ |
1299 | 0 | return j; |
1300 | 0 | } |
1301 | | |
1302 | 0 | std::string BLS_BatchVerify::Name(void) const { return "BLS_BatchVerify"; } |
1303 | 0 | std::string BLS_BatchVerify::ToString(void) const { |
1304 | 0 | std::stringstream ss; |
1305 | |
|
1306 | 0 | for (const auto& cur : bf.c) { |
1307 | 0 | ss << "G1 X: " << cur.g1.first.ToString() << std::endl; |
1308 | 0 | ss << "G1 Y: " << cur.g1.second.ToString() << std::endl; |
1309 | 0 | ss << std::endl; |
1310 | 0 | ss << "G2 V: " << cur.g2.first.first.ToString() << std::endl; |
1311 | 0 | ss << "G2 W: " << cur.g2.first.second.ToString() << std::endl; |
1312 | 0 | ss << "G2 X: " << cur.g2.second.first.ToString() << std::endl; |
1313 | 0 | ss << "G2 Y: " << cur.g2.second.second.ToString() << std::endl; |
1314 | 0 | ss << "----------" << std::endl; |
1315 | 0 | } |
1316 | | |
1317 | | /* TODO */ |
1318 | 0 | return ss.str(); |
1319 | 0 | } |
1320 | | |
1321 | 0 | nlohmann::json BLS_BatchVerify::ToJSON(void) const { |
1322 | 0 | nlohmann::json j; |
1323 | 0 | j["modifier"] = modifier.ToJSON(); |
1324 | 0 | j["bf"] = bf.ToJSON(); |
1325 | 0 | return j; |
1326 | 0 | } |
1327 | | |
1328 | 0 | std::string BLS_Pairing::Name(void) const { return "BLS_Pairing"; } |
1329 | 0 | std::string BLS_Pairing::ToString(void) const { |
1330 | 0 | std::stringstream ss; |
1331 | |
|
1332 | 0 | ss << "operation name: BLS_Pairing" << std::endl; |
1333 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1334 | 0 | ss << "G1 X: " << g1.first.ToString() << std::endl; |
1335 | 0 | ss << "G1 Y: " << g1.second.ToString() << std::endl; |
1336 | 0 | ss << "G2 V: " << g2.first.first.ToString() << std::endl; |
1337 | 0 | ss << "G2 W: " << g2.first.second.ToString() << std::endl; |
1338 | 0 | ss << "G2 X: " << g2.second.first.ToString() << std::endl; |
1339 | 0 | ss << "G2 Y: " << g2.second.second.ToString() << std::endl; |
1340 | |
|
1341 | 0 | return ss.str(); |
1342 | 0 | } |
1343 | | |
1344 | 0 | nlohmann::json BLS_Pairing::ToJSON(void) const { |
1345 | 0 | nlohmann::json j; |
1346 | 0 | j["curveType"] = curveType.ToJSON(); |
1347 | 0 | j["modifier"] = modifier.ToJSON(); |
1348 | 0 | j["g1_x"] = g1.first.ToJSON(); |
1349 | 0 | j["g1_y"] = g1.second.ToJSON(); |
1350 | 0 | j["g2_v"] = g2.first.first.ToJSON(); |
1351 | 0 | j["g2_w"] = g2.first.second.ToJSON(); |
1352 | 0 | j["g2_x"] = g2.second.first.ToJSON(); |
1353 | 0 | j["g2_y"] = g2.second.second.ToJSON(); |
1354 | 0 | return j; |
1355 | 0 | } |
1356 | | |
1357 | 0 | std::string BLS_MillerLoop::Name(void) const { return "BLS_MillerLoop"; } |
1358 | 0 | std::string BLS_MillerLoop::ToString(void) const { |
1359 | 0 | std::stringstream ss; |
1360 | |
|
1361 | 0 | ss << "operation name: BLS_MillerLoop" << std::endl; |
1362 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1363 | 0 | ss << "G1 X: " << g1.first.ToString() << std::endl; |
1364 | 0 | ss << "G1 Y: " << g1.second.ToString() << std::endl; |
1365 | 0 | ss << "G2 V: " << g2.first.first.ToString() << std::endl; |
1366 | 0 | ss << "G2 W: " << g2.first.second.ToString() << std::endl; |
1367 | 0 | ss << "G2 X: " << g2.second.first.ToString() << std::endl; |
1368 | 0 | ss << "G2 Y: " << g2.second.second.ToString() << std::endl; |
1369 | |
|
1370 | 0 | return ss.str(); |
1371 | 0 | } |
1372 | | |
1373 | 0 | nlohmann::json BLS_MillerLoop::ToJSON(void) const { |
1374 | 0 | nlohmann::json j; |
1375 | 0 | j["curveType"] = curveType.ToJSON(); |
1376 | 0 | j["modifier"] = modifier.ToJSON(); |
1377 | 0 | return j; |
1378 | 0 | } |
1379 | | |
1380 | 0 | std::string BLS_FinalExp::Name(void) const { return "BLS_FinalExp"; } |
1381 | 0 | std::string BLS_FinalExp::ToString(void) const { |
1382 | 0 | std::stringstream ss; |
1383 | |
|
1384 | 0 | ss << "operation name: BLS_FinalExp" << std::endl; |
1385 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1386 | | /* TODO */ |
1387 | |
|
1388 | 0 | return ss.str(); |
1389 | 0 | } |
1390 | | |
1391 | 0 | nlohmann::json BLS_FinalExp::ToJSON(void) const { |
1392 | 0 | nlohmann::json j; |
1393 | 0 | j["curveType"] = curveType.ToJSON(); |
1394 | 0 | j["modifier"] = modifier.ToJSON(); |
1395 | | /* TODO q,p */ |
1396 | 0 | return j; |
1397 | 0 | } |
1398 | | |
1399 | 0 | std::string BLS_Aggregate_G1::Name(void) const { return "BLS_Aggregate_G1"; } |
1400 | 0 | std::string BLS_Aggregate_G1::ToString(void) const { |
1401 | 0 | std::stringstream ss; |
1402 | |
|
1403 | 0 | ss << "operation name: BLS_Aggregate_G1" << std::endl; |
1404 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1405 | |
|
1406 | 0 | for (const auto& g1 : points.points) { |
1407 | 0 | ss << " X: " << g1.first.ToString() << std::endl; |
1408 | 0 | ss << " Y: " << g1.second.ToString() << std::endl; |
1409 | 0 | ss << std::endl; |
1410 | 0 | } |
1411 | |
|
1412 | 0 | return ss.str(); |
1413 | 0 | } |
1414 | | |
1415 | 0 | nlohmann::json BLS_Aggregate_G1::ToJSON(void) const { |
1416 | 0 | nlohmann::json j; |
1417 | 0 | j["curveType"] = curveType.ToJSON(); |
1418 | 0 | j["modifier"] = modifier.ToJSON(); |
1419 | |
|
1420 | 0 | nlohmann::json points_json = nlohmann::json::array(); |
1421 | |
|
1422 | 0 | for (const auto& g1 : points.points) { |
1423 | 0 | nlohmann::json point; |
1424 | |
|
1425 | 0 | point["x"] = g1.first.ToJSON(); |
1426 | 0 | point["y"] = g1.second.ToJSON(); |
1427 | |
|
1428 | 0 | points_json.push_back(point); |
1429 | 0 | } |
1430 | |
|
1431 | 0 | j["points"] = points_json; |
1432 | |
|
1433 | 0 | return j; |
1434 | 0 | } |
1435 | | |
1436 | 0 | std::string BLS_Aggregate_G2::Name(void) const { return "BLS_Aggregate_G2"; } |
1437 | 0 | std::string BLS_Aggregate_G2::ToString(void) const { |
1438 | 0 | std::stringstream ss; |
1439 | |
|
1440 | 0 | ss << "operation name: BLS_Aggregate_G2" << std::endl; |
1441 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1442 | |
|
1443 | 0 | for (const auto& g2 : points.points) { |
1444 | 0 | ss << " V:" << g2.first.first.ToString() << std::endl; |
1445 | 0 | ss << " W:" << g2.first.second.ToString() << std::endl; |
1446 | 0 | ss << " X:" << g2.second.first.ToString() << std::endl; |
1447 | 0 | ss << " Y:" << g2.second.second.ToString() << std::endl; |
1448 | 0 | ss << std::endl; |
1449 | 0 | } |
1450 | |
|
1451 | 0 | return ss.str(); |
1452 | 0 | } |
1453 | | |
1454 | 0 | nlohmann::json BLS_Aggregate_G2::ToJSON(void) const { |
1455 | 0 | nlohmann::json j; |
1456 | 0 | j["curveType"] = curveType.ToJSON(); |
1457 | 0 | j["modifier"] = modifier.ToJSON(); |
1458 | |
|
1459 | 0 | nlohmann::json points_json = nlohmann::json::array(); |
1460 | |
|
1461 | 0 | for (const auto& g2 : points.points) { |
1462 | 0 | nlohmann::json point; |
1463 | |
|
1464 | 0 | point["v"] = g2.first.first.ToJSON(); |
1465 | 0 | point["w"] = g2.first.second.ToJSON(); |
1466 | 0 | point["x"] = g2.second.first.ToJSON(); |
1467 | 0 | point["y"] = g2.second.second.ToJSON(); |
1468 | |
|
1469 | 0 | points_json.push_back(point); |
1470 | 0 | } |
1471 | |
|
1472 | 0 | j["points"] = points_json; |
1473 | 0 | return j; |
1474 | 0 | } |
1475 | | |
1476 | 0 | std::string BLS_HashToG1::Name(void) const { return "BLS_HashToG1"; } |
1477 | 0 | std::string BLS_HashToG1::ToString(void) const { |
1478 | 0 | std::stringstream ss; |
1479 | |
|
1480 | 0 | ss << "operation name: BLS_HashToG1" << std::endl; |
1481 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1482 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
1483 | 0 | ss << "dest: " << util::HexDump(dest.Get()) << std::endl; |
1484 | 0 | ss << "aug: " << util::HexDump(aug.Get()) << std::endl; |
1485 | |
|
1486 | 0 | return ss.str(); |
1487 | 0 | } |
1488 | | |
1489 | 0 | nlohmann::json BLS_HashToG1::ToJSON(void) const { |
1490 | 0 | nlohmann::json j; |
1491 | 0 | j["curveType"] = curveType.ToJSON(); |
1492 | 0 | j["cleartext"] = cleartext.ToJSON(); |
1493 | 0 | j["dest"] = dest.ToJSON(); |
1494 | 0 | j["aug"] = aug.ToJSON(); |
1495 | 0 | j["modifier"] = modifier.ToJSON(); |
1496 | 0 | return j; |
1497 | 0 | } |
1498 | | |
1499 | 0 | std::string BLS_HashToG2::Name(void) const { return "BLS_HashToG2"; } |
1500 | 0 | std::string BLS_HashToG2::ToString(void) const { |
1501 | 0 | std::stringstream ss; |
1502 | |
|
1503 | 0 | ss << "operation name: BLS_HashToG2" << std::endl; |
1504 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1505 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
1506 | 0 | ss << "dest: " << util::HexDump(dest.Get()) << std::endl; |
1507 | 0 | ss << "aug: " << util::HexDump(aug.Get()) << std::endl; |
1508 | |
|
1509 | 0 | return ss.str(); |
1510 | 0 | } |
1511 | | |
1512 | 0 | nlohmann::json BLS_HashToG2::ToJSON(void) const { |
1513 | 0 | nlohmann::json j; |
1514 | 0 | j["curveType"] = curveType.ToJSON(); |
1515 | 0 | j["cleartext"] = cleartext.ToJSON(); |
1516 | 0 | j["dest"] = dest.ToJSON(); |
1517 | 0 | j["aug"] = aug.ToJSON(); |
1518 | 0 | j["modifier"] = modifier.ToJSON(); |
1519 | 0 | return j; |
1520 | 0 | } |
1521 | | |
1522 | 0 | std::string BLS_MapToG1::Name(void) const { return "BLS_MapToG1"; } |
1523 | 0 | std::string BLS_MapToG1::ToString(void) const { |
1524 | 0 | std::stringstream ss; |
1525 | |
|
1526 | 0 | ss << "operation name: BLS_MapToG1" << std::endl; |
1527 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1528 | 0 | ss << "u: " << u.ToString() << std::endl; |
1529 | 0 | ss << "v: " << v.ToString() << std::endl; |
1530 | |
|
1531 | 0 | return ss.str(); |
1532 | 0 | } |
1533 | | |
1534 | 0 | nlohmann::json BLS_MapToG1::ToJSON(void) const { |
1535 | 0 | nlohmann::json j; |
1536 | 0 | j["curveType"] = curveType.ToJSON(); |
1537 | 0 | j["u"] = u.ToJSON(); |
1538 | 0 | j["v"] = v.ToJSON(); |
1539 | 0 | j["modifier"] = modifier.ToJSON(); |
1540 | 0 | return j; |
1541 | 0 | } |
1542 | | |
1543 | 0 | std::string BLS_MapToG2::Name(void) const { return "BLS_MapToG2"; } |
1544 | 0 | std::string BLS_MapToG2::ToString(void) const { |
1545 | 0 | std::stringstream ss; |
1546 | |
|
1547 | 0 | ss << "operation name: BLS_MapToG2" << std::endl; |
1548 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1549 | 0 | ss << "u_x: " << u.first.ToString() << std::endl; |
1550 | 0 | ss << "u_y: " << u.second.ToString() << std::endl; |
1551 | 0 | ss << "v_x: " << v.first.ToString() << std::endl; |
1552 | 0 | ss << "v_y: " << v.second.ToString() << std::endl; |
1553 | |
|
1554 | 0 | return ss.str(); |
1555 | 0 | } |
1556 | | |
1557 | 0 | nlohmann::json BLS_MapToG2::ToJSON(void) const { |
1558 | 0 | nlohmann::json j; |
1559 | |
|
1560 | 0 | j["u_x"] = u.first.ToJSON(); |
1561 | 0 | j["u_y"] = u.second.ToJSON(); |
1562 | 0 | j["v_x"] = v.first.ToJSON(); |
1563 | 0 | j["v_y"] = v.second.ToJSON(); |
1564 | |
|
1565 | 0 | return j; |
1566 | 0 | } |
1567 | | |
1568 | 0 | std::string BLS_IsG1OnCurve::Name(void) const { return "BLS_IsG1OnCurve"; } |
1569 | 0 | std::string BLS_IsG1OnCurve::ToString(void) const { |
1570 | 0 | std::stringstream ss; |
1571 | |
|
1572 | 0 | ss << "operation name: BLS_IsG1OnCurve" << std::endl; |
1573 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1574 | 0 | ss << "G1 X: " << g1.first.ToString() << std::endl; |
1575 | 0 | ss << "G1 Y: " << g1.second.ToString() << std::endl; |
1576 | |
|
1577 | 0 | return ss.str(); |
1578 | 0 | } |
1579 | | |
1580 | 0 | nlohmann::json BLS_IsG1OnCurve::ToJSON(void) const { |
1581 | 0 | nlohmann::json j; |
1582 | 0 | j["curveType"] = curveType.ToJSON(); |
1583 | |
|
1584 | 0 | j["g1_x"] = g1.first.ToJSON(); |
1585 | 0 | j["g1_y"] = g1.second.ToJSON(); |
1586 | |
|
1587 | 0 | j["modifier"] = modifier.ToJSON(); |
1588 | 0 | return j; |
1589 | 0 | } |
1590 | | |
1591 | 0 | std::string BLS_IsG2OnCurve::Name(void) const { return "BLS_IsG2OnCurve"; } |
1592 | 0 | std::string BLS_IsG2OnCurve::ToString(void) const { |
1593 | 0 | std::stringstream ss; |
1594 | |
|
1595 | 0 | ss << "operation name: BLS_IsG2OnCurve" << std::endl; |
1596 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1597 | 0 | ss << "G2 V: " << g2.first.first.ToString() << std::endl; |
1598 | 0 | ss << "G2 W: " << g2.first.second.ToString() << std::endl; |
1599 | 0 | ss << "G2 X: " << g2.second.first.ToString() << std::endl; |
1600 | 0 | ss << "G2 Y: " << g2.second.second.ToString() << std::endl; |
1601 | |
|
1602 | 0 | return ss.str(); |
1603 | 0 | } |
1604 | | |
1605 | 0 | nlohmann::json BLS_IsG2OnCurve::ToJSON(void) const { |
1606 | 0 | nlohmann::json j; |
1607 | 0 | j["curveType"] = curveType.ToJSON(); |
1608 | |
|
1609 | 0 | j["g2_v"] = g2.first.first.ToJSON(); |
1610 | 0 | j["g2_w"] = g2.first.second.ToJSON(); |
1611 | 0 | j["g2_x"] = g2.second.first.ToJSON(); |
1612 | 0 | j["g2_y"] = g2.second.second.ToJSON(); |
1613 | |
|
1614 | 0 | j["modifier"] = modifier.ToJSON(); |
1615 | 0 | return j; |
1616 | 0 | } |
1617 | | |
1618 | 0 | std::string BLS_GenerateKeyPair::Name(void) const { return "BLS_GenerateKeyPair"; } |
1619 | 0 | std::string BLS_GenerateKeyPair::ToString(void) const { |
1620 | 0 | std::stringstream ss; |
1621 | |
|
1622 | 0 | ss << "operation name: BLS_GenerateKeyPair" << std::endl; |
1623 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1624 | 0 | ss << "ikm: " << util::HexDump(ikm.Get()) << std::endl; |
1625 | 0 | ss << "info: " << util::HexDump(info.Get()) << std::endl; |
1626 | |
|
1627 | 0 | return ss.str(); |
1628 | 0 | } |
1629 | | |
1630 | 0 | nlohmann::json BLS_GenerateKeyPair::ToJSON(void) const { |
1631 | 0 | nlohmann::json j; |
1632 | 0 | j["curveType"] = curveType.ToJSON(); |
1633 | 0 | j["modifier"] = modifier.ToJSON(); |
1634 | 0 | j["ikm"] = ikm.ToJSON(); |
1635 | 0 | j["info"] = info.ToJSON(); |
1636 | 0 | return j; |
1637 | 0 | } |
1638 | | |
1639 | 0 | std::string BLS_Decompress_G1::Name(void) const { return "BLS_Decompress_G1"; } |
1640 | 0 | std::string BLS_Decompress_G1::ToString(void) const { |
1641 | 0 | std::stringstream ss; |
1642 | |
|
1643 | 0 | ss << "operation name: BLS_Decompress_G1" << std::endl; |
1644 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1645 | 0 | ss << "compressed: " << compressed.ToString() << std::endl; |
1646 | |
|
1647 | 0 | return ss.str(); |
1648 | 0 | } |
1649 | | |
1650 | 0 | nlohmann::json BLS_Decompress_G1::ToJSON(void) const { |
1651 | 0 | nlohmann::json j; |
1652 | 0 | j["curveType"] = curveType.ToJSON(); |
1653 | 0 | j["compressed"] = compressed.ToJSON(); |
1654 | 0 | j["modifier"] = modifier.ToJSON(); |
1655 | 0 | return j; |
1656 | 0 | } |
1657 | | |
1658 | 0 | std::string BLS_Compress_G1::Name(void) const { return "BLS_Compress_G1"; } |
1659 | 0 | std::string BLS_Compress_G1::ToString(void) const { |
1660 | 0 | std::stringstream ss; |
1661 | |
|
1662 | 0 | ss << "operation name: BLS_Compress_G1" << std::endl; |
1663 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1664 | 0 | ss << "uncompressed X:" << uncompressed.first.ToString() << std::endl; |
1665 | 0 | ss << "uncompressed Y:" << uncompressed.second.ToString() << std::endl; |
1666 | |
|
1667 | 0 | return ss.str(); |
1668 | 0 | } |
1669 | | |
1670 | 0 | nlohmann::json BLS_Compress_G1::ToJSON(void) const { |
1671 | 0 | nlohmann::json j; |
1672 | 0 | j["curveType"] = curveType.ToJSON(); |
1673 | 0 | j["g1_x"] = uncompressed.first.ToJSON(); |
1674 | 0 | j["g1_y"] = uncompressed.second.ToJSON(); |
1675 | 0 | j["modifier"] = modifier.ToJSON(); |
1676 | 0 | return j; |
1677 | 0 | } |
1678 | | |
1679 | 0 | std::string BLS_Decompress_G2::Name(void) const { return "BLS_Decompress_G2"; } |
1680 | 0 | std::string BLS_Decompress_G2::ToString(void) const { |
1681 | 0 | std::stringstream ss; |
1682 | |
|
1683 | 0 | ss << "operation name: BLS_Decompress_G2" << std::endl; |
1684 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1685 | 0 | ss << "compressed X: " << compressed.first.ToString() << std::endl; |
1686 | 0 | ss << "compressed Y: " << compressed.second.ToString() << std::endl; |
1687 | |
|
1688 | 0 | return ss.str(); |
1689 | 0 | } |
1690 | | |
1691 | 0 | nlohmann::json BLS_Decompress_G2::ToJSON(void) const { |
1692 | 0 | nlohmann::json j; |
1693 | 0 | j["curveType"] = curveType.ToJSON(); |
1694 | 0 | j["g1_x"] = compressed.first.ToJSON(); |
1695 | 0 | j["g1_y"] = compressed.second.ToJSON(); |
1696 | 0 | j["modifier"] = modifier.ToJSON(); |
1697 | 0 | return j; |
1698 | 0 | } |
1699 | | |
1700 | 0 | std::string BLS_Compress_G2::Name(void) const { return "BLS_Compress_G2"; } |
1701 | 0 | std::string BLS_Compress_G2::ToString(void) const { |
1702 | 0 | std::stringstream ss; |
1703 | |
|
1704 | 0 | ss << "operation name: BLS_Compress_G2" << std::endl; |
1705 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1706 | 0 | ss << "uncompressed V:" << uncompressed.first.first.ToString() << std::endl; |
1707 | 0 | ss << "uncompressed W:" << uncompressed.first.second.ToString() << std::endl; |
1708 | 0 | ss << "uncompressed X:" << uncompressed.second.first.ToString() << std::endl; |
1709 | 0 | ss << "uncompressed Y:" << uncompressed.second.second.ToString() << std::endl; |
1710 | |
|
1711 | 0 | return ss.str(); |
1712 | 0 | } |
1713 | | |
1714 | 0 | nlohmann::json BLS_Compress_G2::ToJSON(void) const { |
1715 | 0 | nlohmann::json j; |
1716 | 0 | j["curveType"] = curveType.ToJSON(); |
1717 | 0 | j["g2_v"] = uncompressed.first.first.ToJSON(); |
1718 | 0 | j["g2_w"] = uncompressed.first.second.ToJSON(); |
1719 | 0 | j["g2_x"] = uncompressed.second.first.ToJSON(); |
1720 | 0 | j["g2_y"] = uncompressed.second.second.ToJSON(); |
1721 | 0 | j["modifier"] = modifier.ToJSON(); |
1722 | 0 | return j; |
1723 | 0 | } |
1724 | | |
1725 | 0 | std::string BLS_G1_Add::Name(void) const { return "BLS_G1_Add"; } |
1726 | 0 | std::string BLS_G1_Add::ToString(void) const { |
1727 | 0 | std::stringstream ss; |
1728 | |
|
1729 | 0 | ss << "operation name: BLS_G1_Add" << std::endl; |
1730 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1731 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
1732 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
1733 | 0 | ss << "B X: " << b.first.ToString() << std::endl; |
1734 | 0 | ss << "B Y: " << b.second.ToString() << std::endl; |
1735 | |
|
1736 | 0 | return ss.str(); |
1737 | 0 | } |
1738 | | |
1739 | 0 | nlohmann::json BLS_G1_Add::ToJSON(void) const { |
1740 | 0 | nlohmann::json j; |
1741 | 0 | j["curveType"] = curveType.ToJSON(); |
1742 | |
|
1743 | 0 | j["a_x"] = a.first.ToJSON(); |
1744 | 0 | j["a_y"] = a.second.ToJSON(); |
1745 | |
|
1746 | 0 | j["b_x"] = b.first.ToJSON(); |
1747 | 0 | j["b_y"] = b.second.ToJSON(); |
1748 | |
|
1749 | 0 | j["modifier"] = modifier.ToJSON(); |
1750 | 0 | return j; |
1751 | 0 | } |
1752 | | |
1753 | 0 | std::string BLS_G1_Mul::Name(void) const { return "BLS_G1_Mul"; } |
1754 | 0 | std::string BLS_G1_Mul::ToString(void) const { |
1755 | 0 | std::stringstream ss; |
1756 | |
|
1757 | 0 | ss << "operation name: BLS_G1_Mul" << std::endl; |
1758 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1759 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
1760 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
1761 | 0 | ss << "B: " << b.ToString() << std::endl; |
1762 | |
|
1763 | 0 | return ss.str(); |
1764 | 0 | } |
1765 | | |
1766 | 0 | nlohmann::json BLS_G1_Mul::ToJSON(void) const { |
1767 | 0 | nlohmann::json j; |
1768 | 0 | j["curveType"] = curveType.ToJSON(); |
1769 | |
|
1770 | 0 | j["a_x"] = a.first.ToJSON(); |
1771 | 0 | j["a_y"] = a.second.ToJSON(); |
1772 | |
|
1773 | 0 | j["b"] = b.ToJSON(); |
1774 | |
|
1775 | 0 | j["modifier"] = modifier.ToJSON(); |
1776 | 0 | return j; |
1777 | 0 | } |
1778 | | |
1779 | 0 | std::string BLS_G1_IsEq::Name(void) const { return "BLS_G1_IsEq"; } |
1780 | 0 | std::string BLS_G1_IsEq::ToString(void) const { |
1781 | 0 | std::stringstream ss; |
1782 | |
|
1783 | 0 | ss << "operation name: BLS_G1_IsEq" << std::endl; |
1784 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1785 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
1786 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
1787 | 0 | ss << "B X: " << b.first.ToString() << std::endl; |
1788 | 0 | ss << "B Y: " << b.second.ToString() << std::endl; |
1789 | |
|
1790 | 0 | return ss.str(); |
1791 | 0 | } |
1792 | | |
1793 | 0 | nlohmann::json BLS_G1_IsEq::ToJSON(void) const { |
1794 | 0 | nlohmann::json j; |
1795 | 0 | j["curveType"] = curveType.ToJSON(); |
1796 | |
|
1797 | 0 | j["a_x"] = a.first.ToJSON(); |
1798 | 0 | j["a_y"] = a.second.ToJSON(); |
1799 | |
|
1800 | 0 | j["b_x"] = b.first.ToJSON(); |
1801 | 0 | j["b_y"] = b.second.ToJSON(); |
1802 | |
|
1803 | 0 | j["modifier"] = modifier.ToJSON(); |
1804 | 0 | return j; |
1805 | 0 | } |
1806 | | |
1807 | 0 | std::string BLS_G1_Neg::Name(void) const { return "BLS_G1_Neg"; } |
1808 | 0 | std::string BLS_G1_Neg::ToString(void) const { |
1809 | 0 | std::stringstream ss; |
1810 | |
|
1811 | 0 | ss << "operation name: BLS_G1_Neg" << std::endl; |
1812 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1813 | 0 | ss << "A X: " << a.first.ToString() << std::endl; |
1814 | 0 | ss << "A Y: " << a.second.ToString() << std::endl; |
1815 | |
|
1816 | 0 | return ss.str(); |
1817 | 0 | } |
1818 | | |
1819 | 0 | nlohmann::json BLS_G1_Neg::ToJSON(void) const { |
1820 | 0 | nlohmann::json j; |
1821 | 0 | j["curveType"] = curveType.ToJSON(); |
1822 | |
|
1823 | 0 | j["a_x"] = a.first.ToJSON(); |
1824 | 0 | j["a_y"] = a.second.ToJSON(); |
1825 | |
|
1826 | 0 | j["modifier"] = modifier.ToJSON(); |
1827 | 0 | return j; |
1828 | 0 | } |
1829 | | |
1830 | 0 | std::string BLS_G2_Add::Name(void) const { return "BLS_G2_Add"; } |
1831 | 0 | std::string BLS_G2_Add::ToString(void) const { |
1832 | 0 | std::stringstream ss; |
1833 | |
|
1834 | 0 | ss << "operation name: BLS_G2_Add" << std::endl; |
1835 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1836 | 0 | ss << "A V:" << a.first.first.ToString() << std::endl; |
1837 | 0 | ss << "A W:" << a.first.second.ToString() << std::endl; |
1838 | 0 | ss << "A X:" << a.second.first.ToString() << std::endl; |
1839 | 0 | ss << "A Y:" << a.second.second.ToString() << std::endl; |
1840 | 0 | ss << "B V:" << b.first.first.ToString() << std::endl; |
1841 | 0 | ss << "B W:" << b.first.second.ToString() << std::endl; |
1842 | 0 | ss << "B X:" << b.second.first.ToString() << std::endl; |
1843 | 0 | ss << "B Y:" << b.second.second.ToString() << std::endl; |
1844 | |
|
1845 | 0 | return ss.str(); |
1846 | 0 | } |
1847 | | |
1848 | 0 | nlohmann::json BLS_G2_Add::ToJSON(void) const { |
1849 | 0 | nlohmann::json j; |
1850 | 0 | j["curveType"] = curveType.ToJSON(); |
1851 | |
|
1852 | 0 | j["a_v"] = a.first.first.ToJSON(); |
1853 | 0 | j["a_w"] = a.first.second.ToJSON(); |
1854 | 0 | j["a_x"] = a.second.first.ToJSON(); |
1855 | 0 | j["a_y"] = a.second.second.ToJSON(); |
1856 | |
|
1857 | 0 | j["b_v"] = b.first.first.ToJSON(); |
1858 | 0 | j["b_w"] = b.first.second.ToJSON(); |
1859 | 0 | j["b_x"] = b.second.first.ToJSON(); |
1860 | 0 | j["b_y"] = b.second.second.ToJSON(); |
1861 | |
|
1862 | 0 | j["modifier"] = modifier.ToJSON(); |
1863 | 0 | return j; |
1864 | 0 | } |
1865 | | |
1866 | 0 | std::string BLS_G2_Mul::Name(void) const { return "BLS_G2_Mul"; } |
1867 | 0 | std::string BLS_G2_Mul::ToString(void) const { |
1868 | 0 | std::stringstream ss; |
1869 | |
|
1870 | 0 | ss << "operation name: BLS_G2_Mul" << std::endl; |
1871 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1872 | 0 | ss << "A V:" << a.first.first.ToString() << std::endl; |
1873 | 0 | ss << "A W:" << a.first.second.ToString() << std::endl; |
1874 | 0 | ss << "A X:" << a.second.first.ToString() << std::endl; |
1875 | 0 | ss << "A Y:" << a.second.second.ToString() << std::endl; |
1876 | 0 | ss << "B: " << b.ToString() << std::endl; |
1877 | |
|
1878 | 0 | return ss.str(); |
1879 | 0 | } |
1880 | | |
1881 | 0 | nlohmann::json BLS_G2_Mul::ToJSON(void) const { |
1882 | 0 | nlohmann::json j; |
1883 | 0 | j["curveType"] = curveType.ToJSON(); |
1884 | |
|
1885 | 0 | j["a_v"] = a.first.first.ToJSON(); |
1886 | 0 | j["a_w"] = a.first.second.ToJSON(); |
1887 | 0 | j["a_x"] = a.second.first.ToJSON(); |
1888 | 0 | j["a_y"] = a.second.second.ToJSON(); |
1889 | |
|
1890 | 0 | j["b"] = b.ToJSON(); |
1891 | |
|
1892 | 0 | j["modifier"] = modifier.ToJSON(); |
1893 | 0 | return j; |
1894 | 0 | } |
1895 | | |
1896 | 0 | std::string BLS_G2_IsEq::Name(void) const { return "BLS_G2_IsEq"; } |
1897 | 0 | std::string BLS_G2_IsEq::ToString(void) const { |
1898 | 0 | std::stringstream ss; |
1899 | |
|
1900 | 0 | ss << "operation name: BLS_G2_IsEq" << std::endl; |
1901 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1902 | 0 | ss << "A V:" << a.first.first.ToString() << std::endl; |
1903 | 0 | ss << "A W:" << a.first.second.ToString() << std::endl; |
1904 | 0 | ss << "A X:" << a.second.first.ToString() << std::endl; |
1905 | 0 | ss << "A Y:" << a.second.second.ToString() << std::endl; |
1906 | 0 | ss << "B V:" << b.first.first.ToString() << std::endl; |
1907 | 0 | ss << "B W:" << b.first.second.ToString() << std::endl; |
1908 | 0 | ss << "B X:" << b.second.first.ToString() << std::endl; |
1909 | 0 | ss << "B Y:" << b.second.second.ToString() << std::endl; |
1910 | |
|
1911 | 0 | return ss.str(); |
1912 | 0 | } |
1913 | | |
1914 | 0 | nlohmann::json BLS_G2_IsEq::ToJSON(void) const { |
1915 | 0 | nlohmann::json j; |
1916 | 0 | j["curveType"] = curveType.ToJSON(); |
1917 | |
|
1918 | 0 | j["a_v"] = a.first.first.ToJSON(); |
1919 | 0 | j["a_w"] = a.first.second.ToJSON(); |
1920 | 0 | j["a_x"] = a.second.first.ToJSON(); |
1921 | 0 | j["a_y"] = a.second.second.ToJSON(); |
1922 | |
|
1923 | 0 | j["b_v"] = b.first.first.ToJSON(); |
1924 | 0 | j["b_w"] = b.first.second.ToJSON(); |
1925 | 0 | j["b_x"] = b.second.first.ToJSON(); |
1926 | 0 | j["b_y"] = b.second.second.ToJSON(); |
1927 | |
|
1928 | 0 | j["modifier"] = modifier.ToJSON(); |
1929 | 0 | return j; |
1930 | 0 | } |
1931 | | |
1932 | 0 | std::string BLS_G2_Neg::Name(void) const { return "BLS_G2_Neg"; } |
1933 | 0 | std::string BLS_G2_Neg::ToString(void) const { |
1934 | 0 | std::stringstream ss; |
1935 | |
|
1936 | 0 | ss << "operation name: BLS_G2_Neg" << std::endl; |
1937 | 0 | ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl; |
1938 | 0 | ss << "A V:" << a.first.first.ToString() << std::endl; |
1939 | 0 | ss << "A W:" << a.first.second.ToString() << std::endl; |
1940 | 0 | ss << "A X:" << a.second.first.ToString() << std::endl; |
1941 | 0 | ss << "A Y:" << a.second.second.ToString() << std::endl; |
1942 | |
|
1943 | 0 | return ss.str(); |
1944 | 0 | } |
1945 | | |
1946 | 0 | nlohmann::json BLS_G2_Neg::ToJSON(void) const { |
1947 | 0 | nlohmann::json j; |
1948 | 0 | j["curveType"] = curveType.ToJSON(); |
1949 | |
|
1950 | 0 | j["a_v"] = a.first.first.ToJSON(); |
1951 | 0 | j["a_w"] = a.first.second.ToJSON(); |
1952 | 0 | j["a_x"] = a.second.first.ToJSON(); |
1953 | 0 | j["a_y"] = a.second.second.ToJSON(); |
1954 | |
|
1955 | 0 | j["modifier"] = modifier.ToJSON(); |
1956 | 0 | return j; |
1957 | 0 | } |
1958 | | |
1959 | 0 | std::string Misc::Name(void) const { return "Misc"; } |
1960 | 0 | std::string Misc::ToString(void) const { |
1961 | 0 | std::stringstream ss; |
1962 | |
|
1963 | 0 | ss << "operation name: Misc" << std::endl; |
1964 | 0 | ss << "operation: " << std::to_string(operation.Get()) << std::endl; |
1965 | |
|
1966 | 0 | return ss.str(); |
1967 | 0 | } |
1968 | | |
1969 | 0 | nlohmann::json Misc::ToJSON(void) const { |
1970 | 0 | nlohmann::json j; |
1971 | 0 | j["operation"] = operation.ToJSON(); |
1972 | 0 | j["modifier"] = modifier.ToJSON(); |
1973 | 0 | return j; |
1974 | 0 | } |
1975 | | |
1976 | 0 | std::string SR25519_Verify::Name(void) const { return "ECDSA_Verify"; } |
1977 | 0 | std::string SR25519_Verify::ToString(void) const { |
1978 | 0 | std::stringstream ss; |
1979 | |
|
1980 | 0 | ss << "operation name: SR25519_Verify" << std::endl; |
1981 | 0 | ss << "public key: " << signature.pub.ToString() << std::endl; |
1982 | 0 | ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl; |
1983 | 0 | ss << "signature R: " << signature.signature.first.ToString() << std::endl; |
1984 | 0 | ss << "signature S: " << signature.signature.second.ToString() << std::endl; |
1985 | |
|
1986 | 0 | return ss.str(); |
1987 | 0 | } |
1988 | | |
1989 | 0 | nlohmann::json SR25519_Verify::ToJSON(void) const { |
1990 | 0 | nlohmann::json j; |
1991 | 0 | j["operation"] = "SR25519_Verify"; |
1992 | 0 | j["pub"] = signature.pub.ToJSON(); |
1993 | 0 | j["cleartext"] = cleartext.ToJSON(); |
1994 | 0 | j["sig_r"] = signature.signature.first.ToJSON(); |
1995 | 0 | j["sig_s"] = signature.signature.second.ToJSON(); |
1996 | 0 | j["modifier"] = modifier.ToJSON(); |
1997 | 0 | return j; |
1998 | 0 | } |
1999 | | |
2000 | | } /* namespace operation */ |
2001 | | } /* namespace cryptofuzz */ |