modulewrapper.cc
Go to the documentation of this file.
1 /* Copyright (c) 2019, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #include <map>
16 #include <string>
17 #include <vector>
18 
19 #include <assert.h>
20 #include <errno.h>
21 #include <limits.h>
22 #include <string.h>
23 #include <sys/uio.h>
24 #include <unistd.h>
25 #include <cstdarg>
26 
27 #include <openssl/aead.h>
28 #include <openssl/aes.h>
29 #include <openssl/bn.h>
30 #include <openssl/cipher.h>
31 #include <openssl/cmac.h>
32 #include <openssl/dh.h>
33 #include <openssl/digest.h>
34 #include <openssl/ec.h>
35 #include <openssl/ec_key.h>
36 #include <openssl/ecdh.h>
37 #include <openssl/ecdsa.h>
38 #include <openssl/err.h>
39 #include <openssl/hmac.h>
40 #include <openssl/obj.h>
41 #include <openssl/rsa.h>
42 #include <openssl/sha.h>
43 #include <openssl/span.h>
44 
45 #include "../../../../crypto/fipsmodule/ec/internal.h"
46 #include "../../../../crypto/fipsmodule/rand/internal.h"
47 #include "../../../../crypto/fipsmodule/tls/internal.h"
48 #include "modulewrapper.h"
49 
50 
51 namespace bssl {
52 namespace acvp {
53 
54 #if defined(OPENSSL_TRUSTY)
55 #include <trusty_log.h>
56 #define LOG_ERROR(...) TLOGE(__VA_ARGS__)
57 #define TLOG_TAG "modulewrapper"
58 #else
59 #define LOG_ERROR(...) fprintf(stderr, __VA_ARGS__)
60 #endif // OPENSSL_TRUSTY
61 
62 constexpr size_t kMaxArgLength = (1 << 20);
63 
65 
67  public:
68  ~RequestBufferImpl() = default;
69 
70  std::vector<uint8_t> buf;
72 };
73 
74 // static
75 std::unique_ptr<RequestBuffer> RequestBuffer::New() {
76  return std::unique_ptr<RequestBuffer>(new RequestBufferImpl);
77 }
78 
79 static bool ReadAll(int fd, void *in_data, size_t data_len) {
80  uint8_t *data = reinterpret_cast<uint8_t *>(in_data);
81  size_t done = 0;
82 
83  while (done < data_len) {
84  ssize_t r;
85  do {
86  r = read(fd, &data[done], data_len - done);
87  } while (r == -1 && errno == EINTR);
88 
89  if (r <= 0) {
90  return false;
91  }
92 
93  done += r;
94  }
95 
96  return true;
97 }
98 
100  RequestBuffer *in_buffer) {
101  RequestBufferImpl *buffer = reinterpret_cast<RequestBufferImpl *>(in_buffer);
102  uint32_t nums[1 + kMaxArgs];
103  const Span<const Span<const uint8_t>> empty_span;
104 
105  if (!ReadAll(fd, nums, sizeof(uint32_t) * 2)) {
106  return empty_span;
107  }
108 
109  const size_t num_args = nums[0];
110  if (num_args == 0) {
111  LOG_ERROR("Invalid, zero-argument operation requested.\n");
112  return empty_span;
113  } else if (num_args > kMaxArgs) {
114  LOG_ERROR("Operation requested with %zu args, but %zu is the limit.\n",
115  num_args, kMaxArgs);
116  return empty_span;
117  }
118 
119  if (num_args > 1 &&
120  !ReadAll(fd, &nums[2], sizeof(uint32_t) * (num_args - 1))) {
121  return empty_span;
122  }
123 
124  size_t need = 0;
125  for (size_t i = 0; i < num_args; i++) {
126  const size_t arg_length = nums[i + 1];
127  if (i == 0 && arg_length > kMaxNameLength) {
128  LOG_ERROR("Operation with name of length %zu exceeded limit of %zu.\n",
129  arg_length, kMaxNameLength);
130  return empty_span;
131  } else if (arg_length > kMaxArgLength) {
132  LOG_ERROR(
133  "Operation with argument of length %zu exceeded limit of %zu.\n",
134  arg_length, kMaxArgLength);
135  return empty_span;
136  }
137 
138  // This static_assert confirms that the following addition doesn't
139  // overflow.
140  static_assert((kMaxArgs - 1 * kMaxArgLength) + kMaxNameLength > (1 << 30),
141  "Argument limits permit excessive messages");
142  need += arg_length;
143  }
144 
145  if (need > buffer->buf.size()) {
146  size_t alloced = need + (need >> 1);
147  if (alloced < need) {
148  abort();
149  }
150  buffer->buf.resize(alloced);
151  }
152 
153  if (!ReadAll(fd, buffer->buf.data(), need)) {
154  return empty_span;
155  }
156 
157  size_t offset = 0;
158  for (size_t i = 0; i < num_args; i++) {
159  buffer->args[i] = Span<const uint8_t>(&buffer->buf[offset], nums[i + 1]);
160  offset += nums[i + 1];
161  }
162 
163  return Span<const Span<const uint8_t>>(buffer->args, num_args);
164 }
165 
166 bool WriteReplyToFd(int fd, const std::vector<Span<const uint8_t>> &spans) {
167  if (spans.empty() || spans.size() > kMaxArgs) {
168  abort();
169  }
170 
171  uint32_t nums[1 + kMaxArgs];
172  iovec iovs[kMaxArgs + 1];
173  nums[0] = spans.size();
174  iovs[0].iov_base = nums;
175  iovs[0].iov_len = sizeof(uint32_t) * (1 + spans.size());
176 
177  size_t num_iov = 1;
178  for (size_t i = 0; i < spans.size(); i++) {
179  const auto &span = spans[i];
180  nums[i + 1] = span.size();
181  if (span.empty()) {
182  continue;
183  }
184 
185  iovs[num_iov].iov_base = const_cast<uint8_t *>(span.data());
186  iovs[num_iov].iov_len = span.size();
187  num_iov++;
188  }
189 
190  size_t iov_done = 0;
191  while (iov_done < num_iov) {
192  ssize_t r;
193  do {
194  r = writev(fd, &iovs[iov_done], num_iov - iov_done);
195  } while (r == -1 && errno == EINTR);
196 
197  if (r <= 0) {
198  return false;
199  }
200 
201  size_t written = r;
202  for (size_t i = iov_done; i < num_iov && written > 0; i++) {
203  iovec &iov = iovs[i];
204 
205  size_t done = written;
206  if (done > iov.iov_len) {
207  done = iov.iov_len;
208  }
209 
210  iov.iov_base = reinterpret_cast<uint8_t *>(iov.iov_base) + done;
211  iov.iov_len -= done;
212  written -= done;
213 
214  if (iov.iov_len == 0) {
215  iov_done++;
216  }
217  }
218 
219  assert(written == 0);
220  }
221 
222  return true;
223 }
224 
225 static bool GetConfig(const Span<const uint8_t> args[], ReplyCallback write_reply) {
226  static constexpr char kConfig[] =
227  R"([
228  {
229  "algorithm": "SHA2-224",
230  "revision": "1.0",
231  "messageLength": [{
232  "min": 0, "max": 65528, "increment": 8
233  }]
234  },
235  {
236  "algorithm": "SHA2-256",
237  "revision": "1.0",
238  "messageLength": [{
239  "min": 0, "max": 65528, "increment": 8
240  }]
241  },
242  {
243  "algorithm": "SHA2-384",
244  "revision": "1.0",
245  "messageLength": [{
246  "min": 0, "max": 65528, "increment": 8
247  }]
248  },
249  {
250  "algorithm": "SHA2-512",
251  "revision": "1.0",
252  "messageLength": [{
253  "min": 0, "max": 65528, "increment": 8
254  }]
255  },
256  {
257  "algorithm": "SHA2-512/256",
258  "revision": "1.0",
259  "messageLength": [{
260  "min": 0, "max": 65528, "increment": 8
261  }]
262  },
263  {
264  "algorithm": "SHA-1",
265  "revision": "1.0",
266  "messageLength": [{
267  "min": 0, "max": 65528, "increment": 8
268  }]
269  },
270  {
271  "algorithm": "ACVP-AES-ECB",
272  "revision": "1.0",
273  "direction": ["encrypt", "decrypt"],
274  "keyLen": [128, 192, 256]
275  },
276  {
277  "algorithm": "ACVP-AES-CTR",
278  "revision": "1.0",
279  "direction": ["encrypt", "decrypt"],
280  "keyLen": [128, 192, 256],
281  "payloadLen": [{
282  "min": 8, "max": 128, "increment": 8
283  }],
284  "incrementalCounter": true,
285  "overflowCounter": true,
286  "performCounterTests": true
287  },
288  {
289  "algorithm": "ACVP-AES-CBC",
290  "revision": "1.0",
291  "direction": ["encrypt", "decrypt"],
292  "keyLen": [128, 192, 256]
293  },
294  {
295  "algorithm": "ACVP-AES-GCM",
296  "revision": "1.0",
297  "direction": ["encrypt", "decrypt"],
298  "keyLen": [128, 192, 256],
299  "payloadLen": [{
300  "min": 0, "max": 256, "increment": 8
301  }],
302  "aadLen": [{
303  "min": 0, "max": 320, "increment": 8
304  }],
305  "tagLen": [32, 64, 96, 104, 112, 120, 128],
306  "ivLen": [96],
307  "ivGen": "external"
308  },
309  {
310  "algorithm": "ACVP-AES-GMAC",
311  "revision": "1.0",
312  "direction": ["encrypt", "decrypt"],
313  "keyLen": [128, 192, 256],
314  "payloadLen": [{
315  "min": 0, "max": 256, "increment": 8
316  }],
317  "aadLen": [{
318  "min": 0, "max": 320, "increment": 8
319  }],
320  "tagLen": [32, 64, 96, 104, 112, 120, 128],
321  "ivLen": [96],
322  "ivGen": "external"
323  },
324  {
325  "algorithm": "ACVP-AES-KW",
326  "revision": "1.0",
327  "direction": [
328  "encrypt",
329  "decrypt"
330  ],
331  "kwCipher": [
332  "cipher"
333  ],
334  "keyLen": [
335  128, 192, 256
336  ],
337  "payloadLen": [{"min": 128, "max": 1024, "increment": 64}]
338  },
339  {
340  "algorithm": "ACVP-AES-KWP",
341  "revision": "1.0",
342  "direction": [
343  "encrypt",
344  "decrypt"
345  ],
346  "kwCipher": [
347  "cipher"
348  ],
349  "keyLen": [
350  128, 192, 256
351  ],
352  "payloadLen": [{"min": 8, "max": 4096, "increment": 8}]
353  },
354  {
355  "algorithm": "ACVP-AES-CCM",
356  "revision": "1.0",
357  "direction": [
358  "encrypt",
359  "decrypt"
360  ],
361  "keyLen": [
362  128
363  ],
364  "payloadLen": [{"min": 0, "max": 256, "increment": 8}],
365  "ivLen": [104],
366  "tagLen": [32],
367  "aadLen": [{"min": 0, "max": 1024, "increment": 8}]
368  },
369  {
370  "algorithm": "ACVP-TDES-ECB",
371  "revision": "1.0",
372  "direction": ["encrypt", "decrypt"],
373  "keyLen": [192],
374  "keyingOption": [1]
375  },
376  {
377  "algorithm": "ACVP-TDES-CBC",
378  "revision": "1.0",
379  "direction": ["encrypt", "decrypt"],
380  "keyLen": [192],
381  "keyingOption": [1]
382  },
383  {
384  "algorithm": "HMAC-SHA-1",
385  "revision": "1.0",
386  "keyLen": [{
387  "min": 8, "max": 2048, "increment": 8
388  }],
389  "macLen": [{
390  "min": 32, "max": 160, "increment": 8
391  }]
392  },
393  {
394  "algorithm": "HMAC-SHA2-224",
395  "revision": "1.0",
396  "keyLen": [{
397  "min": 8, "max": 2048, "increment": 8
398  }],
399  "macLen": [{
400  "min": 32, "max": 224, "increment": 8
401  }]
402  },
403  {
404  "algorithm": "HMAC-SHA2-256",
405  "revision": "1.0",
406  "keyLen": [{
407  "min": 8, "max": 2048, "increment": 8
408  }],
409  "macLen": [{
410  "min": 32, "max": 256, "increment": 8
411  }]
412  },
413  {
414  "algorithm": "HMAC-SHA2-384",
415  "revision": "1.0",
416  "keyLen": [{
417  "min": 8, "max": 2048, "increment": 8
418  }],
419  "macLen": [{
420  "min": 32, "max": 384, "increment": 8
421  }]
422  },
423  {
424  "algorithm": "HMAC-SHA2-512",
425  "revision": "1.0",
426  "keyLen": [{
427  "min": 8, "max": 2048, "increment": 8
428  }],
429  "macLen": [{
430  "min": 32, "max": 512, "increment": 8
431  }]
432  },
433  {
434  "algorithm": "ctrDRBG",
435  "revision": "1.0",
436  "predResistanceEnabled": [false],
437  "reseedImplemented": false,
438  "capabilities": [{
439  "mode": "AES-256",
440  "derFuncEnabled": false,
441  "entropyInputLen": [384],
442  "nonceLen": [0],
443  "persoStringLen": [{"min": 0, "max": 384, "increment": 16}],
444  "additionalInputLen": [
445  {"min": 0, "max": 384, "increment": 16}
446  ],
447  "returnedBitsLen": 2048
448  }]
449  },
450  {
451  "algorithm": "ECDSA",
452  "mode": "keyGen",
453  "revision": "1.0",
454  "curve": [
455  "P-224",
456  "P-256",
457  "P-384",
458  "P-521"
459  ],
460  "secretGenerationMode": [
461  "testing candidates"
462  ]
463  },
464  {
465  "algorithm": "ECDSA",
466  "mode": "keyVer",
467  "revision": "1.0",
468  "curve": [
469  "P-224",
470  "P-256",
471  "P-384",
472  "P-521"
473  ]
474  },
475  {
476  "algorithm": "ECDSA",
477  "mode": "sigGen",
478  "revision": "1.0",
479  "capabilities": [{
480  "curve": [
481  "P-224",
482  "P-256",
483  "P-384",
484  "P-521"
485  ],
486  "hashAlg": [
487  "SHA2-224",
488  "SHA2-256",
489  "SHA2-384",
490  "SHA2-512"
491  ]
492  }]
493  },
494  {
495  "algorithm": "ECDSA",
496  "mode": "sigVer",
497  "revision": "1.0",
498  "capabilities": [{
499  "curve": [
500  "P-224",
501  "P-256",
502  "P-384",
503  "P-521"
504  ],
505  "hashAlg": [
506  "SHA-1",
507  "SHA2-224",
508  "SHA2-256",
509  "SHA2-384",
510  "SHA2-512"
511  ]
512  }]
513  },
514  {
515  "algorithm": "RSA",
516  "mode": "keyGen",
517  "revision": "FIPS186-4",
518  "infoGeneratedByServer": true,
519  "pubExpMode": "fixed",
520  "fixedPubExp": "010001",
521  "keyFormat": "standard",
522  "capabilities": [{
523  "randPQ": "B.3.3",
524  "properties": [{
525  "modulo": 2048,
526  "primeTest": [
527  "tblC2"
528  ]
529  },{
530  "modulo": 3072,
531  "primeTest": [
532  "tblC2"
533  ]
534  },{
535  "modulo": 4096,
536  "primeTest": [
537  "tblC2"
538  ]
539  }]
540  }]
541  },
542  {
543  "algorithm": "RSA",
544  "mode": "sigGen",
545  "revision": "FIPS186-4",
546  "capabilities": [{
547  "sigType": "pkcs1v1.5",
548  "properties": [{
549  "modulo": 2048,
550  "hashPair": [{
551  "hashAlg": "SHA2-224"
552  }, {
553  "hashAlg": "SHA2-256"
554  }, {
555  "hashAlg": "SHA2-384"
556  }, {
557  "hashAlg": "SHA2-512"
558  }]
559  }]
560  },{
561  "sigType": "pkcs1v1.5",
562  "properties": [{
563  "modulo": 3072,
564  "hashPair": [{
565  "hashAlg": "SHA2-224"
566  }, {
567  "hashAlg": "SHA2-256"
568  }, {
569  "hashAlg": "SHA2-384"
570  }, {
571  "hashAlg": "SHA2-512"
572  }]
573  }]
574  },{
575  "sigType": "pkcs1v1.5",
576  "properties": [{
577  "modulo": 4096,
578  "hashPair": [{
579  "hashAlg": "SHA2-224"
580  }, {
581  "hashAlg": "SHA2-256"
582  }, {
583  "hashAlg": "SHA2-384"
584  }, {
585  "hashAlg": "SHA2-512"
586  }]
587  }]
588  },{
589  "sigType": "pss",
590  "properties": [{
591  "modulo": 2048,
592  "hashPair": [{
593  "hashAlg": "SHA2-224",
594  "saltLen": 28
595  }, {
596  "hashAlg": "SHA2-256",
597  "saltLen": 32
598  }, {
599  "hashAlg": "SHA2-384",
600  "saltLen": 48
601  }, {
602  "hashAlg": "SHA2-512",
603  "saltLen": 64
604  }]
605  }]
606  },{
607  "sigType": "pss",
608  "properties": [{
609  "modulo": 3072,
610  "hashPair": [{
611  "hashAlg": "SHA2-224",
612  "saltLen": 28
613  }, {
614  "hashAlg": "SHA2-256",
615  "saltLen": 32
616  }, {
617  "hashAlg": "SHA2-384",
618  "saltLen": 48
619  }, {
620  "hashAlg": "SHA2-512",
621  "saltLen": 64
622  }]
623  }]
624  },{
625  "sigType": "pss",
626  "properties": [{
627  "modulo": 4096,
628  "hashPair": [{
629  "hashAlg": "SHA2-224",
630  "saltLen": 28
631  }, {
632  "hashAlg": "SHA2-256",
633  "saltLen": 32
634  }, {
635  "hashAlg": "SHA2-384",
636  "saltLen": 48
637  }, {
638  "hashAlg": "SHA2-512",
639  "saltLen": 64
640  }]
641  }]
642  }]
643  },
644  {
645  "algorithm": "RSA",
646  "mode": "sigVer",
647  "revision": "FIPS186-4",
648  "pubExpMode": "fixed",
649  "fixedPubExp": "010001",
650  "capabilities": [{
651  "sigType": "pkcs1v1.5",
652  "properties": [{
653  "modulo": 1024,
654  "hashPair": [{
655  "hashAlg": "SHA2-224"
656  }, {
657  "hashAlg": "SHA2-256"
658  }, {
659  "hashAlg": "SHA2-384"
660  }, {
661  "hashAlg": "SHA2-512"
662  }, {
663  "hashAlg": "SHA-1"
664  }]
665  }]
666  },{
667  "sigType": "pkcs1v1.5",
668  "properties": [{
669  "modulo": 2048,
670  "hashPair": [{
671  "hashAlg": "SHA2-224"
672  }, {
673  "hashAlg": "SHA2-256"
674  }, {
675  "hashAlg": "SHA2-384"
676  }, {
677  "hashAlg": "SHA2-512"
678  }, {
679  "hashAlg": "SHA-1"
680  }]
681  }]
682  },{
683  "sigType": "pkcs1v1.5",
684  "properties": [{
685  "modulo": 3072,
686  "hashPair": [{
687  "hashAlg": "SHA2-224"
688  }, {
689  "hashAlg": "SHA2-256"
690  }, {
691  "hashAlg": "SHA2-384"
692  }, {
693  "hashAlg": "SHA2-512"
694  }, {
695  "hashAlg": "SHA-1"
696  }]
697  }]
698  },{
699  "sigType": "pkcs1v1.5",
700  "properties": [{
701  "modulo": 4096,
702  "hashPair": [{
703  "hashAlg": "SHA2-224"
704  }, {
705  "hashAlg": "SHA2-256"
706  }, {
707  "hashAlg": "SHA2-384"
708  }, {
709  "hashAlg": "SHA2-512"
710  }, {
711  "hashAlg": "SHA-1"
712  }]
713  }]
714  },{
715  "sigType": "pss",
716  "properties": [{
717  "modulo": 2048,
718  "hashPair": [{
719  "hashAlg": "SHA2-224",
720  "saltLen": 28
721  }, {
722  "hashAlg": "SHA2-256",
723  "saltLen": 32
724  }, {
725  "hashAlg": "SHA2-384",
726  "saltLen": 48
727  }, {
728  "hashAlg": "SHA2-512",
729  "saltLen": 64
730  }, {
731  "hashAlg": "SHA-1",
732  "saltLen": 20
733  }]
734  }]
735  },{
736  "sigType": "pss",
737  "properties": [{
738  "modulo": 3072,
739  "hashPair": [{
740  "hashAlg": "SHA2-224",
741  "saltLen": 28
742  }, {
743  "hashAlg": "SHA2-256",
744  "saltLen": 32
745  }, {
746  "hashAlg": "SHA2-384",
747  "saltLen": 48
748  }, {
749  "hashAlg": "SHA2-512",
750  "saltLen": 64
751  }, {
752  "hashAlg": "SHA-1",
753  "saltLen": 20
754  }]
755  }]
756  },{
757  "sigType": "pss",
758  "properties": [{
759  "modulo": 4096,
760  "hashPair": [{
761  "hashAlg": "SHA2-224",
762  "saltLen": 28
763  }, {
764  "hashAlg": "SHA2-256",
765  "saltLen": 32
766  }, {
767  "hashAlg": "SHA2-384",
768  "saltLen": 48
769  }, {
770  "hashAlg": "SHA2-512",
771  "saltLen": 64
772  }, {
773  "hashAlg": "SHA-1",
774  "saltLen": 20
775  }]
776  }]
777  }]
778  },
779  {
780  "algorithm": "CMAC-AES",
781  "acvptoolTestOnly": true,
782  "revision": "1.0",
783  "capabilities": [{
784  "direction": ["gen", "ver"],
785  "msgLen": [{
786  "min": 0,
787  "max": 65536,
788  "increment": 8
789  }],
790  "keyLen": [128, 256],
791  "macLen": [{
792  "min": 32,
793  "max": 128,
794  "increment": 8
795  }]
796  }]
797  },
798  {
799  "algorithm": "kdf-components",
800  "revision": "1.0",
801  "mode": "tls",
802  "tlsVersion": [
803  "v1.0/1.1",
804  "v1.2"
805  ],
806  "hashAlg": [
807  "SHA2-256",
808  "SHA2-384",
809  "SHA2-512"
810  ]
811  },
812  {
813  "algorithm": "KAS-ECC-SSC",
814  "revision": "Sp800-56Ar3",
815  "scheme": {
816  "ephemeralUnified": {
817  "kasRole": [
818  "initiator",
819  "responder"
820  ]
821  },
822  "staticUnified": {
823  "kasRole": [
824  "initiator",
825  "responder"
826  ]
827  }
828  },
829  "domainParameterGenerationMethods": [
830  "P-224",
831  "P-256",
832  "P-384",
833  "P-521"
834  ]
835  },
836  {
837  "algorithm": "KAS-FFC-SSC",
838  "revision": "Sp800-56Ar3",
839  "scheme": {
840  "dhEphem": {
841  "kasRole": [
842  "initiator"
843  ]
844  }
845  },
846  "domainParameterGenerationMethods": [
847  "FB",
848  "FC"
849  ]
850  }
851  ])";
852  return write_reply({Span<const uint8_t>(
853  reinterpret_cast<const uint8_t *>(kConfig), sizeof(kConfig) - 1)});
854 }
855 
856 template <uint8_t *(*OneShotHash)(const uint8_t *, size_t, uint8_t *),
857  size_t DigestLength>
858 static bool Hash(const Span<const uint8_t> args[], ReplyCallback write_reply) {
859  uint8_t digest[DigestLength];
860  OneShotHash(args[0].data(), args[0].size(), digest);
861  return write_reply({Span<const uint8_t>(digest)});
862 }
863 
864 template <uint8_t *(*OneShotHash)(const uint8_t *, size_t, uint8_t *),
865  size_t DigestLength>
866 static bool HashMCT(const Span<const uint8_t> args[],
867  ReplyCallback write_reply) {
868  if (args[0].size() != DigestLength) {
869  return false;
870  }
871 
872  uint8_t buf[DigestLength * 3];
873  memcpy(buf, args[0].data(), DigestLength);
874  memcpy(buf + DigestLength, args[0].data(), DigestLength);
875  memcpy(buf + 2 * DigestLength, args[0].data(), DigestLength);
876 
877  for (size_t i = 0; i < 1000; i++) {
878  uint8_t digest[DigestLength];
879  OneShotHash(buf, sizeof(buf), digest);
880  memmove(buf, buf + DigestLength, DigestLength * 2);
881  memcpy(buf + DigestLength * 2, digest, DigestLength);
882  }
883 
884  return write_reply(
885  {Span<const uint8_t>(buf + 2 * DigestLength, DigestLength)});
886 }
887 
888 static uint32_t GetIterations(const Span<const uint8_t> iterations_bytes) {
889  uint32_t iterations;
890  if (iterations_bytes.size() != sizeof(iterations)) {
891  LOG_ERROR(
892  "Expected %u-byte input for number of iterations, but found %u "
893  "bytes.\n",
894  static_cast<unsigned>(sizeof(iterations)),
895  static_cast<unsigned>(iterations_bytes.size()));
896  abort();
897  }
898 
899  memcpy(&iterations, iterations_bytes.data(), sizeof(iterations));
900  if (iterations == 0 || iterations == UINT32_MAX) {
901  LOG_ERROR("Invalid number of iterations: %x.\n",
902  static_cast<unsigned>(iterations));
903  abort();
904  }
905 
906  return iterations;
907 }
908 
909 template <int (*SetKey)(const uint8_t *key, unsigned bits, AES_KEY *out),
910  void (*Block)(const uint8_t *in, uint8_t *out, const AES_KEY *key)>
911 static bool AES(const Span<const uint8_t> args[], ReplyCallback write_reply) {
912  AES_KEY key;
913  if (SetKey(args[0].data(), args[0].size() * 8, &key) != 0) {
914  return false;
915  }
916  if (args[1].size() % AES_BLOCK_SIZE != 0) {
917  return false;
918  }
919  std::vector<uint8_t> result(args[1].begin(), args[1].end());
920  const uint32_t iterations = GetIterations(args[2]);
921 
922  std::vector<uint8_t> prev_result;
923  for (uint32_t j = 0; j < iterations; j++) {
924  if (j == iterations - 1) {
925  prev_result = result;
926  }
927 
928  for (size_t i = 0; i < args[1].size(); i += AES_BLOCK_SIZE) {
929  Block(result.data() + i, result.data() + i, &key);
930  }
931  }
932 
933  return write_reply(
935 }
936 
937 template <int (*SetKey)(const uint8_t *key, unsigned bits, AES_KEY *out),
938  int Direction>
939 static bool AES_CBC(const Span<const uint8_t> args[], ReplyCallback write_reply) {
940  AES_KEY key;
941  if (SetKey(args[0].data(), args[0].size() * 8, &key) != 0) {
942  return false;
943  }
944  if (args[1].size() % AES_BLOCK_SIZE != 0 || args[1].empty() ||
945  args[2].size() != AES_BLOCK_SIZE) {
946  return false;
947  }
948  std::vector<uint8_t> input(args[1].begin(), args[1].end());
949  std::vector<uint8_t> iv(args[2].begin(), args[2].end());
950  const uint32_t iterations = GetIterations(args[3]);
951 
952  std::vector<uint8_t> result(input.size());
953  std::vector<uint8_t> prev_result, prev_input;
954 
955  for (uint32_t j = 0; j < iterations; j++) {
956  prev_result = result;
957  if (j > 0) {
958  if (Direction == AES_ENCRYPT) {
959  iv = result;
960  } else {
961  iv = prev_input;
962  }
963  }
964 
965  // AES_cbc_encrypt will mutate the given IV, but we need it later.
966  uint8_t iv_copy[AES_BLOCK_SIZE];
967  memcpy(iv_copy, iv.data(), sizeof(iv_copy));
968  AES_cbc_encrypt(input.data(), result.data(), input.size(), &key, iv_copy,
969  Direction);
970 
971  if (Direction == AES_DECRYPT) {
972  prev_input = input;
973  }
974 
975  if (j == 0) {
976  input = iv;
977  } else {
978  input = prev_result;
979  }
980  }
981 
982  return write_reply(
984 }
985 
986 static bool AES_CTR(const Span<const uint8_t> args[], ReplyCallback write_reply) {
987  static const uint32_t kOneIteration = 1;
988  if (args[3].size() != sizeof(kOneIteration) ||
989  memcmp(args[3].data(), &kOneIteration, sizeof(kOneIteration))) {
990  LOG_ERROR("Only a single iteration supported with AES-CTR\n");
991  return false;
992  }
993 
994  AES_KEY key;
995  if (AES_set_encrypt_key(args[0].data(), args[0].size() * 8, &key) != 0) {
996  return false;
997  }
998  if (args[2].size() != AES_BLOCK_SIZE) {
999  return false;
1000  }
1001  uint8_t iv[AES_BLOCK_SIZE];
1002  memcpy(iv, args[2].data(), AES_BLOCK_SIZE);
1003  if (GetIterations(args[3]) != 1) {
1004  LOG_ERROR("Multiple iterations of AES-CTR is not supported.\n");
1005  return false;
1006  }
1007 
1008  std::vector<uint8_t> out;
1009  out.resize(args[1].size());
1010  unsigned num = 0;
1011  uint8_t ecount_buf[AES_BLOCK_SIZE];
1012  AES_ctr128_encrypt(args[1].data(), out.data(), args[1].size(), &key, iv,
1013  ecount_buf, &num);
1014  return write_reply({Span<const uint8_t>(out)});
1015 }
1016 
1019  uint32_t tag_len_32;
1020  if (tag_len_span.size() != sizeof(tag_len_32)) {
1021  LOG_ERROR("Tag size value is %u bytes, not an uint32_t\n",
1022  static_cast<unsigned>(tag_len_span.size()));
1023  return false;
1024  }
1025  memcpy(&tag_len_32, tag_len_span.data(), sizeof(tag_len_32));
1026 
1027  const EVP_AEAD *aead;
1028  switch (key.size()) {
1029  case 16:
1030  aead = EVP_aead_aes_128_gcm();
1031  break;
1032  case 24:
1033  aead = EVP_aead_aes_192_gcm();
1034  break;
1035  case 32:
1036  aead = EVP_aead_aes_256_gcm();
1037  break;
1038  default:
1039  LOG_ERROR("Bad AES-GCM key length %u\n", static_cast<unsigned>(key.size()));
1040  return false;
1041  }
1042 
1043  if (!EVP_AEAD_CTX_init(ctx, aead, key.data(), key.size(), tag_len_32,
1044  nullptr)) {
1045  LOG_ERROR("Failed to setup AES-GCM with tag length %u\n",
1046  static_cast<unsigned>(tag_len_32));
1047  return false;
1048  }
1049 
1050  return true;
1051 }
1052 
1053 static bool AESCCMSetup(EVP_AEAD_CTX *ctx, Span<const uint8_t> tag_len_span,
1055  uint32_t tag_len_32;
1056  if (tag_len_span.size() != sizeof(tag_len_32)) {
1057  LOG_ERROR("Tag size value is %u bytes, not an uint32_t\n",
1058  static_cast<unsigned>(tag_len_span.size()));
1059  return false;
1060  }
1061  memcpy(&tag_len_32, tag_len_span.data(), sizeof(tag_len_32));
1062  if (tag_len_32 != 4) {
1063  LOG_ERROR("AES-CCM only supports 4-byte tags, but %u was requested\n",
1064  static_cast<unsigned>(tag_len_32));
1065  return false;
1066  }
1067 
1068  if (key.size() != 16) {
1069  LOG_ERROR("AES-CCM only supports 128-bit keys, but %u bits were given\n",
1070  static_cast<unsigned>(key.size() * 8));
1071  return false;
1072  }
1073 
1075  key.size(), tag_len_32, nullptr)) {
1076  LOG_ERROR("Failed to setup AES-CCM with tag length %u\n",
1077  static_cast<unsigned>(tag_len_32));
1078  return false;
1079  }
1080 
1081  return true;
1082 }
1084 template <bool (*SetupFunc)(EVP_AEAD_CTX *ctx, Span<const uint8_t> tag_len_span,
1085  Span<const uint8_t> key)>
1086 static bool AEADSeal(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1087  Span<const uint8_t> tag_len_span = args[0];
1090  Span<const uint8_t> nonce = args[3];
1091  Span<const uint8_t> ad = args[4];
1092 
1093  bssl::ScopedEVP_AEAD_CTX ctx;
1094  if (!SetupFunc(ctx.get(), tag_len_span, key)) {
1095  return false;
1096  }
1097 
1099  return false;
1100  }
1101  std::vector<uint8_t> out(EVP_AEAD_MAX_OVERHEAD + plaintext.size());
1102 
1103  size_t out_len;
1104  if (!EVP_AEAD_CTX_seal(ctx.get(), out.data(), &out_len, out.size(),
1105  nonce.data(), nonce.size(), plaintext.data(),
1106  plaintext.size(), ad.data(), ad.size())) {
1107  return false;
1108  }
1109 
1110  out.resize(out_len);
1111  return write_reply({Span<const uint8_t>(out)});
1112 }
1113 
1114 template <bool (*SetupFunc)(EVP_AEAD_CTX *ctx, Span<const uint8_t> tag_len_span,
1115  Span<const uint8_t> key)>
1116 static bool AEADOpen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1117  Span<const uint8_t> tag_len_span = args[0];
1120  Span<const uint8_t> nonce = args[3];
1121  Span<const uint8_t> ad = args[4];
1122 
1123  bssl::ScopedEVP_AEAD_CTX ctx;
1124  if (!SetupFunc(ctx.get(), tag_len_span, key)) {
1125  return false;
1126  }
1127 
1128  std::vector<uint8_t> out(ciphertext.size());
1129  size_t out_len;
1130  uint8_t success_flag[1] = {0};
1131 
1132  if (!EVP_AEAD_CTX_open(ctx.get(), out.data(), &out_len, out.size(),
1133  nonce.data(), nonce.size(), ciphertext.data(),
1134  ciphertext.size(), ad.data(), ad.size())) {
1135  return write_reply(
1136  {Span<const uint8_t>(success_flag), Span<const uint8_t>()});
1137  }
1138 
1139  out.resize(out_len);
1140  success_flag[0] = 1;
1141  return write_reply(
1142  {Span<const uint8_t>(success_flag), Span<const uint8_t>(out)});
1143 }
1144 
1145 static bool AESPaddedKeyWrapSetup(AES_KEY *out, bool decrypt,
1147  if ((decrypt ? AES_set_decrypt_key : AES_set_encrypt_key)(
1148  key.data(), key.size() * 8, out) != 0) {
1149  LOG_ERROR("Invalid AES key length for AES-KW(P): %u\n",
1150  static_cast<unsigned>(key.size()));
1151  return false;
1152  }
1153  return true;
1154 }
1155 
1156 static bool AESKeyWrapSetup(AES_KEY *out, bool decrypt, Span<const uint8_t> key,
1158  if (!AESPaddedKeyWrapSetup(out, decrypt, key)) {
1159  return false;
1160  }
1161 
1162  if (input.size() % 8) {
1163  LOG_ERROR("Invalid AES-KW input length: %u\n",
1164  static_cast<unsigned>(input.size()));
1165  return false;
1166  }
1167 
1168  return true;
1169 }
1170 
1171 static bool AESKeyWrapSeal(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1174 
1175  AES_KEY aes;
1176  if (!AESKeyWrapSetup(&aes, /*decrypt=*/false, key, plaintext) ||
1177  plaintext.size() > INT_MAX - 8) {
1178  return false;
1179  }
1180 
1181  std::vector<uint8_t> out(plaintext.size() + 8);
1182  if (AES_wrap_key(&aes, /*iv=*/nullptr, out.data(), plaintext.data(),
1183  plaintext.size()) != static_cast<int>(out.size())) {
1184  LOG_ERROR("AES-KW failed\n");
1185  return false;
1186  }
1187 
1188  return write_reply({Span<const uint8_t>(out)});
1189 }
1190 
1191 static bool AESKeyWrapOpen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1194 
1195  AES_KEY aes;
1196  if (!AESKeyWrapSetup(&aes, /*decrypt=*/true, key, ciphertext) ||
1197  ciphertext.size() < 8 || ciphertext.size() > INT_MAX) {
1198  return false;
1199  }
1200 
1201  std::vector<uint8_t> out(ciphertext.size() - 8);
1202  uint8_t success_flag[1] = {0};
1203  if (AES_unwrap_key(&aes, /*iv=*/nullptr, out.data(), ciphertext.data(),
1204  ciphertext.size()) != static_cast<int>(out.size())) {
1205  return write_reply(
1206  {Span<const uint8_t>(success_flag), Span<const uint8_t>()});
1207  }
1208 
1209  success_flag[0] = 1;
1210  return write_reply(
1211  {Span<const uint8_t>(success_flag), Span<const uint8_t>(out)});
1212 }
1213 
1214 static bool AESPaddedKeyWrapSeal(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1217 
1218  AES_KEY aes;
1219  if (!AESPaddedKeyWrapSetup(&aes, /*decrypt=*/false, key) ||
1220  plaintext.size() + 15 < 15) {
1221  return false;
1222  }
1223 
1224  std::vector<uint8_t> out(plaintext.size() + 15);
1225  size_t out_len;
1226  if (!AES_wrap_key_padded(&aes, out.data(), &out_len, out.size(),
1227  plaintext.data(), plaintext.size())) {
1228  LOG_ERROR("AES-KWP failed\n");
1229  return false;
1230  }
1231 
1232  out.resize(out_len);
1233  return write_reply({Span<const uint8_t>(out)});
1234 }
1235 
1236 static bool AESPaddedKeyWrapOpen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1239 
1240  AES_KEY aes;
1241  if (!AESPaddedKeyWrapSetup(&aes, /*decrypt=*/true, key) ||
1242  ciphertext.size() % 8) {
1243  return false;
1244  }
1245 
1246  std::vector<uint8_t> out(ciphertext.size());
1247  size_t out_len;
1248  uint8_t success_flag[1] = {0};
1249  if (!AES_unwrap_key_padded(&aes, out.data(), &out_len, out.size(),
1250  ciphertext.data(), ciphertext.size())) {
1251  return write_reply(
1252  {Span<const uint8_t>(success_flag), Span<const uint8_t>()});
1253  }
1255  success_flag[0] = 1;
1256  out.resize(out_len);
1257  return write_reply(
1258  {Span<const uint8_t>(success_flag), Span<const uint8_t>(out)});
1259 }
1260 
1261 template <bool Encrypt>
1262 static bool TDES(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1263  const EVP_CIPHER *cipher = EVP_des_ede3();
1264 
1265  if (args[0].size() != 24) {
1266  LOG_ERROR("Bad key length %u for 3DES.\n",
1267  static_cast<unsigned>(args[0].size()));
1268  return false;
1269  }
1270  bssl::ScopedEVP_CIPHER_CTX ctx;
1271  if (!EVP_CipherInit_ex(ctx.get(), cipher, nullptr, args[0].data(), nullptr,
1272  Encrypt ? 1 : 0) ||
1273  !EVP_CIPHER_CTX_set_padding(ctx.get(), 0)) {
1274  return false;
1275  }
1276 
1277  if (args[1].size() % 8) {
1278  LOG_ERROR("Bad input length %u for 3DES.\n",
1279  static_cast<unsigned>(args[1].size()));
1280  return false;
1281  }
1282  std::vector<uint8_t> result(args[1].begin(), args[1].end());
1283 
1284  const uint32_t iterations = GetIterations(args[2]);
1285  std::vector<uint8_t> prev_result, prev_prev_result;
1286 
1287  for (uint32_t j = 0; j < iterations; j++) {
1288  if (j == iterations - 1) {
1289  prev_result = result;
1290  } else if (iterations >= 2 && j == iterations - 2) {
1291  prev_prev_result = result;
1292  }
1293 
1294  int out_len;
1295  if (!EVP_CipherUpdate(ctx.get(), result.data(), &out_len, result.data(),
1296  result.size()) ||
1297  out_len != static_cast<int>(result.size())) {
1298  return false;
1299  }
1300  }
1301 
1302  return write_reply({Span<const uint8_t>(result),
1303  Span<const uint8_t>(prev_result),
1304  Span<const uint8_t>(prev_prev_result)});
1305 }
1306 
1307 template <bool Encrypt>
1308 static bool TDES_CBC(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1309  const EVP_CIPHER *cipher = EVP_des_ede3_cbc();
1310 
1311  if (args[0].size() != 24) {
1312  LOG_ERROR("Bad key length %u for 3DES.\n",
1313  static_cast<unsigned>(args[0].size()));
1314  return false;
1315  }
1316 
1317  if (args[1].size() % 8 || args[1].size() == 0) {
1318  LOG_ERROR("Bad input length %u for 3DES.\n",
1319  static_cast<unsigned>(args[1].size()));
1320  return false;
1321  }
1322  std::vector<uint8_t> input(args[1].begin(), args[1].end());
1323 
1324  if (args[2].size() != EVP_CIPHER_iv_length(cipher)) {
1325  LOG_ERROR("Bad IV length %u for 3DES.\n",
1326  static_cast<unsigned>(args[2].size()));
1327  return false;
1328  }
1329  std::vector<uint8_t> iv(args[2].begin(), args[2].end());
1330  const uint32_t iterations = GetIterations(args[3]);
1331 
1332  std::vector<uint8_t> result(input.size());
1333  std::vector<uint8_t> prev_result, prev_prev_result;
1334  bssl::ScopedEVP_CIPHER_CTX ctx;
1335  if (!EVP_CipherInit_ex(ctx.get(), cipher, nullptr, args[0].data(), iv.data(),
1336  Encrypt ? 1 : 0) ||
1337  !EVP_CIPHER_CTX_set_padding(ctx.get(), 0)) {
1338  return false;
1339  }
1340 
1341  for (uint32_t j = 0; j < iterations; j++) {
1342  prev_prev_result = prev_result;
1343  prev_result = result;
1344 
1345  int out_len, out_len2;
1346  if (!EVP_CipherInit_ex(ctx.get(), nullptr, nullptr, nullptr, iv.data(),
1347  -1) ||
1348  !EVP_CipherUpdate(ctx.get(), result.data(), &out_len, input.data(),
1349  input.size()) ||
1350  !EVP_CipherFinal_ex(ctx.get(), result.data() + out_len, &out_len2) ||
1351  (out_len + out_len2) != static_cast<int>(result.size())) {
1352  return false;
1353  }
1354 
1355  if (Encrypt) {
1356  if (j == 0) {
1357  input = iv;
1358  } else {
1359  input = prev_result;
1360  }
1361  iv = result;
1362  } else {
1363  iv = input;
1364  input = result;
1365  }
1366  }
1367 
1368  return write_reply({Span<const uint8_t>(result),
1369  Span<const uint8_t>(prev_result),
1370  Span<const uint8_t>(prev_prev_result)});
1371 }
1372 
1373 template <const EVP_MD *HashFunc()>
1374 static bool HMAC(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1375  const EVP_MD *const md = HashFunc();
1376  uint8_t digest[EVP_MAX_MD_SIZE];
1377  unsigned digest_len;
1378  if (::HMAC(md, args[1].data(), args[1].size(), args[0].data(), args[0].size(),
1379  digest, &digest_len) == nullptr) {
1380  return false;
1381  }
1382  return write_reply({Span<const uint8_t>(digest, digest_len)});
1383 }
1384 
1385 static bool DRBG(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1386  const auto out_len_bytes = args[0];
1387  const auto entropy = args[1];
1388  const auto personalisation = args[2];
1389  const auto additional_data1 = args[3];
1390  const auto additional_data2 = args[4];
1391  const auto nonce = args[5];
1392 
1393  uint32_t out_len;
1394  if (out_len_bytes.size() != sizeof(out_len) ||
1395  entropy.size() != CTR_DRBG_ENTROPY_LEN ||
1396  // nonces are not supported
1397  nonce.size() != 0) {
1398  return false;
1399  }
1400  memcpy(&out_len, out_len_bytes.data(), sizeof(out_len));
1401  if (out_len > (1 << 24)) {
1402  return false;
1403  }
1404  std::vector<uint8_t> out(out_len);
1405 
1406  CTR_DRBG_STATE drbg;
1407  if (!CTR_DRBG_init(&drbg, entropy.data(), personalisation.data(),
1408  personalisation.size()) ||
1409  !CTR_DRBG_generate(&drbg, out.data(), out_len, additional_data1.data(),
1410  additional_data1.size()) ||
1411  !CTR_DRBG_generate(&drbg, out.data(), out_len, additional_data2.data(),
1412  additional_data2.size())) {
1413  return false;
1414  }
1415 
1416  return write_reply({Span<const uint8_t>(out)});
1417 }
1418 
1419 static bool StringEq(Span<const uint8_t> a, const char *b) {
1420  const size_t len = strlen(b);
1421  return a.size() == len && memcmp(a.data(), b, len) == 0;
1422 }
1423 
1424 static bssl::UniquePtr<EC_KEY> ECKeyFromName(Span<const uint8_t> name) {
1425  int nid;
1426  if (StringEq(name, "P-224")) {
1427  nid = NID_secp224r1;
1428  } else if (StringEq(name, "P-256")) {
1430  } else if (StringEq(name, "P-384")) {
1431  nid = NID_secp384r1;
1432  } else if (StringEq(name, "P-521")) {
1433  nid = NID_secp521r1;
1434  } else {
1435  return nullptr;
1436  }
1437 
1438  return bssl::UniquePtr<EC_KEY>(EC_KEY_new_by_curve_name(nid));
1439 }
1440 
1441 static std::vector<uint8_t> BIGNUMBytes(const BIGNUM *bn) {
1442  const size_t len = BN_num_bytes(bn);
1443  std::vector<uint8_t> ret(len);
1444  BN_bn2bin(bn, ret.data());
1445  return ret;
1446 }
1447 
1448 static std::pair<std::vector<uint8_t>, std::vector<uint8_t>> GetPublicKeyBytes(
1449  const EC_KEY *key) {
1450  bssl::UniquePtr<BIGNUM> x(BN_new());
1451  bssl::UniquePtr<BIGNUM> y(BN_new());
1453  EC_KEY_get0_public_key(key), x.get(),
1454  y.get(), /*ctx=*/nullptr)) {
1455  abort();
1456  }
1457 
1458  std::vector<uint8_t> x_bytes = BIGNUMBytes(x.get());
1459  std::vector<uint8_t> y_bytes = BIGNUMBytes(y.get());
1460 
1461  return std::make_pair(std::move(x_bytes), std::move(y_bytes));
1462 }
1463 
1464 static bool ECDSAKeyGen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1465  bssl::UniquePtr<EC_KEY> key = ECKeyFromName(args[0]);
1466  if (!key || !EC_KEY_generate_key_fips(key.get())) {
1467  return false;
1468  }
1469 
1470  const auto pub_key = GetPublicKeyBytes(key.get());
1471  std::vector<uint8_t> d_bytes =
1473 
1474  return write_reply({Span<const uint8_t>(d_bytes),
1475  Span<const uint8_t>(pub_key.first),
1476  Span<const uint8_t>(pub_key.second)});
1477 }
1478 
1479 static bssl::UniquePtr<BIGNUM> BytesToBIGNUM(Span<const uint8_t> bytes) {
1480  bssl::UniquePtr<BIGNUM> bn(BN_new());
1481  BN_bin2bn(bytes.data(), bytes.size(), bn.get());
1482  return bn;
1483 }
1484 
1485 static bool ECDSAKeyVer(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1486  bssl::UniquePtr<EC_KEY> key = ECKeyFromName(args[0]);
1487  if (!key) {
1488  return false;
1489  }
1490 
1491  bssl::UniquePtr<BIGNUM> x(BytesToBIGNUM(args[1]));
1492  bssl::UniquePtr<BIGNUM> y(BytesToBIGNUM(args[2]));
1493 
1494  bssl::UniquePtr<EC_POINT> point(EC_POINT_new(EC_KEY_get0_group(key.get())));
1495  uint8_t reply[1];
1497  point.get(), x.get(), y.get(),
1498  /*ctx=*/nullptr) ||
1499  !EC_KEY_set_public_key(key.get(), point.get()) ||
1500  !EC_KEY_check_fips(key.get())) {
1501  reply[0] = 0;
1502  } else {
1503  reply[0] = 1;
1504  }
1505 
1506  return write_reply({Span<const uint8_t>(reply)});
1507 }
1508 
1510  if (StringEq(name, "SHA-1")) {
1511  return EVP_sha1();
1512  } else if (StringEq(name, "SHA2-224")) {
1513  return EVP_sha224();
1514  } else if (StringEq(name, "SHA2-256")) {
1515  return EVP_sha256();
1516  } else if (StringEq(name, "SHA2-384")) {
1517  return EVP_sha384();
1518  } else if (StringEq(name, "SHA2-512")) {
1519  return EVP_sha512();
1520  } else {
1521  return nullptr;
1522  }
1523 }
1524 
1525 static bool ECDSASigGen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1526  bssl::UniquePtr<EC_KEY> key = ECKeyFromName(args[0]);
1527  bssl::UniquePtr<BIGNUM> d = BytesToBIGNUM(args[1]);
1528  const EVP_MD *hash = HashFromName(args[2]);
1529  uint8_t digest[EVP_MAX_MD_SIZE];
1530  unsigned digest_len;
1531  if (!key || !hash ||
1532  !EVP_Digest(args[3].data(), args[3].size(), digest, &digest_len, hash,
1533  /*impl=*/nullptr) ||
1534  !EC_KEY_set_private_key(key.get(), d.get())) {
1535  return false;
1536  }
1537 
1538  bssl::UniquePtr<ECDSA_SIG> sig(ECDSA_do_sign(digest, digest_len, key.get()));
1539  if (!sig) {
1540  return false;
1541  }
1542 
1543  std::vector<uint8_t> r_bytes(BIGNUMBytes(sig->r));
1544  std::vector<uint8_t> s_bytes(BIGNUMBytes(sig->s));
1545 
1546  return write_reply(
1547  {Span<const uint8_t>(r_bytes), Span<const uint8_t>(s_bytes)});
1548 }
1549 
1550 static bool ECDSASigVer(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1551  bssl::UniquePtr<EC_KEY> key = ECKeyFromName(args[0]);
1552  const EVP_MD *hash = HashFromName(args[1]);
1553  auto msg = args[2];
1554  bssl::UniquePtr<BIGNUM> x(BytesToBIGNUM(args[3]));
1555  bssl::UniquePtr<BIGNUM> y(BytesToBIGNUM(args[4]));
1556  bssl::UniquePtr<BIGNUM> r(BytesToBIGNUM(args[5]));
1557  bssl::UniquePtr<BIGNUM> s(BytesToBIGNUM(args[6]));
1558  ECDSA_SIG sig;
1559  sig.r = r.get();
1560  sig.s = s.get();
1561 
1562  uint8_t digest[EVP_MAX_MD_SIZE];
1563  unsigned digest_len;
1564  if (!key || !hash ||
1565  !EVP_Digest(msg.data(), msg.size(), digest, &digest_len, hash,
1566  /*impl=*/nullptr)) {
1567  return false;
1568  }
1569 
1570  bssl::UniquePtr<EC_POINT> point(EC_POINT_new(EC_KEY_get0_group(key.get())));
1571  uint8_t reply[1];
1573  point.get(), x.get(), y.get(),
1574  /*ctx=*/nullptr) ||
1575  !EC_KEY_set_public_key(key.get(), point.get()) ||
1576  !EC_KEY_check_fips(key.get()) ||
1577  !ECDSA_do_verify(digest, digest_len, &sig, key.get())) {
1578  reply[0] = 0;
1579  } else {
1580  reply[0] = 1;
1581  }
1582 
1583  return write_reply({Span<const uint8_t>(reply)});
1584 }
1585 
1586 static bool CMAC_AES(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1587  uint8_t mac[16];
1588  if (!AES_CMAC(mac, args[1].data(), args[1].size(), args[2].data(),
1589  args[2].size())) {
1590  return false;
1591  }
1592 
1593  uint32_t mac_len;
1594  if (args[0].size() != sizeof(mac_len)) {
1595  return false;
1596  }
1597  memcpy(&mac_len, args[0].data(), sizeof(mac_len));
1598  if (mac_len > sizeof(mac)) {
1599  return false;
1600  }
1601 
1602  return write_reply({Span<const uint8_t>(mac, mac_len)});
1603 }
1604 
1605 static bool CMAC_AESVerify(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1606  // This function is just for testing since libcrypto doesn't do the
1607  // verification itself. The regcap doesn't advertise "ver" support.
1608  uint8_t mac[16];
1609  if (!AES_CMAC(mac, args[0].data(), args[0].size(), args[1].data(),
1610  args[1].size()) ||
1611  args[2].size() > sizeof(mac)) {
1612  return false;
1613  }
1614 
1615  const uint8_t ok = (OPENSSL_memcmp(mac, args[2].data(), args[2].size()) == 0);
1616  return write_reply({Span<const uint8_t>(&ok, sizeof(ok))});
1617 }
1618 
1619 static std::map<unsigned, bssl::UniquePtr<RSA>>& CachedRSAKeys() {
1620  static std::map<unsigned, bssl::UniquePtr<RSA>> keys;
1621  return keys;
1622 }
1623 
1624 static RSA* GetRSAKey(unsigned bits) {
1625  auto it = CachedRSAKeys().find(bits);
1626  if (it != CachedRSAKeys().end()) {
1627  return it->second.get();
1628  }
1629 
1630  bssl::UniquePtr<RSA> key(RSA_new());
1631  if (!RSA_generate_key_fips(key.get(), bits, nullptr)) {
1632  abort();
1633  }
1634 
1635  RSA *const ret = key.get();
1636  CachedRSAKeys().emplace(static_cast<unsigned>(bits), std::move(key));
1637 
1638  return ret;
1639 }
1640 
1641 static bool RSAKeyGen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1642  uint32_t bits;
1643  if (args[0].size() != sizeof(bits)) {
1644  return false;
1645  }
1646  memcpy(&bits, args[0].data(), sizeof(bits));
1647 
1648  bssl::UniquePtr<RSA> key(RSA_new());
1649  if (!RSA_generate_key_fips(key.get(), bits, nullptr)) {
1650  LOG_ERROR("RSA_generate_key_fips failed for modulus length %u.\n", bits);
1651  return false;
1652  }
1653 
1654  const BIGNUM *n, *e, *d, *p, *q;
1655  RSA_get0_key(key.get(), &n, &e, &d);
1656  RSA_get0_factors(key.get(), &p, &q);
1657 
1658  if (!write_reply({BIGNUMBytes(e), BIGNUMBytes(p), BIGNUMBytes(q),
1659  BIGNUMBytes(n), BIGNUMBytes(d)})) {
1660  return false;
1661  }
1662 
1663  CachedRSAKeys().emplace(static_cast<unsigned>(bits), std::move(key));
1664  return true;
1665 }
1666 
1667 template <const EVP_MD *(MDFunc)(), bool UsePSS>
1668 static bool RSASigGen(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1669  uint32_t bits;
1670  if (args[0].size() != sizeof(bits)) {
1671  return false;
1672  }
1673  memcpy(&bits, args[0].data(), sizeof(bits));
1674  const Span<const uint8_t> msg = args[1];
1675 
1676  RSA *const key = GetRSAKey(bits);
1677  const EVP_MD *const md = MDFunc();
1678  uint8_t digest_buf[EVP_MAX_MD_SIZE];
1679  unsigned digest_len;
1680  if (!EVP_Digest(msg.data(), msg.size(), digest_buf, &digest_len, md, NULL)) {
1681  return false;
1682  }
1683 
1684  std::vector<uint8_t> sig(RSA_size(key));
1685  size_t sig_len;
1686  if (UsePSS) {
1687  if (!RSA_sign_pss_mgf1(key, &sig_len, sig.data(), sig.size(), digest_buf,
1688  digest_len, md, md, -1)) {
1689  return false;
1690  }
1691  } else {
1692  unsigned sig_len_u;
1693  if (!RSA_sign(EVP_MD_type(md), digest_buf, digest_len, sig.data(),
1694  &sig_len_u, key)) {
1695  return false;
1696  }
1697  sig_len = sig_len_u;
1698  }
1699 
1700  sig.resize(sig_len);
1701 
1702  return write_reply(
1704 }
1705 
1706 template <const EVP_MD *(MDFunc)(), bool UsePSS>
1707 static bool RSASigVer(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1708  const Span<const uint8_t> n_bytes = args[0];
1709  const Span<const uint8_t> e_bytes = args[1];
1710  const Span<const uint8_t> msg = args[2];
1711  const Span<const uint8_t> sig = args[3];
1712 
1713  BIGNUM *n = BN_new();
1714  BIGNUM *e = BN_new();
1715  bssl::UniquePtr<RSA> key(RSA_new());
1716  if (!BN_bin2bn(n_bytes.data(), n_bytes.size(), n) ||
1717  !BN_bin2bn(e_bytes.data(), e_bytes.size(), e) ||
1718  !RSA_set0_key(key.get(), n, e, /*d=*/nullptr)) {
1719  return false;
1720  }
1721 
1722  const EVP_MD *const md = MDFunc();
1723  uint8_t digest_buf[EVP_MAX_MD_SIZE];
1724  unsigned digest_len;
1725  if (!EVP_Digest(msg.data(), msg.size(), digest_buf, &digest_len, md, NULL)) {
1726  return false;
1727  }
1728 
1729  uint8_t ok;
1730  if (UsePSS) {
1731  ok = RSA_verify_pss_mgf1(key.get(), digest_buf, digest_len, md, md, -1,
1732  sig.data(), sig.size());
1733  } else {
1734  ok = RSA_verify(EVP_MD_type(md), digest_buf, digest_len, sig.data(),
1735  sig.size(), key.get());
1736  }
1737  ERR_clear_error();
1738 
1739  return write_reply({Span<const uint8_t>(&ok, 1)});
1740 }
1741 
1742 template <const EVP_MD *(MDFunc)()>
1743 static bool TLSKDF(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1744  const Span<const uint8_t> out_len_bytes = args[0];
1745  const Span<const uint8_t> secret = args[1];
1746  const Span<const uint8_t> label = args[2];
1747  const Span<const uint8_t> seed1 = args[3];
1748  const Span<const uint8_t> seed2 = args[4];
1749  const EVP_MD *md = MDFunc();
1750 
1751  uint32_t out_len;
1752  if (out_len_bytes.size() != sizeof(out_len)) {
1753  return 0;
1754  }
1755  memcpy(&out_len, out_len_bytes.data(), sizeof(out_len));
1756 
1757  std::vector<uint8_t> out(static_cast<size_t>(out_len));
1758  if (!CRYPTO_tls1_prf(md, out.data(), out.size(), secret.data(), secret.size(),
1759  reinterpret_cast<const char *>(label.data()),
1760  label.size(), seed1.data(), seed1.size(), seed2.data(),
1761  seed2.size())) {
1762  return 0;
1763  }
1764 
1765  return write_reply({out});
1766 }
1767 
1768 template <int Nid>
1769 static bool ECDH(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1770  bssl::UniquePtr<BIGNUM> their_x(BytesToBIGNUM(args[0]));
1771  bssl::UniquePtr<BIGNUM> their_y(BytesToBIGNUM(args[1]));
1773 
1774  bssl::UniquePtr<EC_KEY> ec_key(EC_KEY_new_by_curve_name(Nid));
1775  bssl::UniquePtr<BN_CTX> ctx(BN_CTX_new());
1776 
1777  const EC_GROUP *const group = EC_KEY_get0_group(ec_key.get());
1778  bssl::UniquePtr<EC_POINT> their_point(EC_POINT_new(group));
1780  group, their_point.get(), their_x.get(), their_y.get(), ctx.get())) {
1781  LOG_ERROR("Invalid peer point for ECDH.\n");
1782  return false;
1783  }
1784 
1785  if (!private_key.empty()) {
1786  bssl::UniquePtr<BIGNUM> our_k(BytesToBIGNUM(private_key));
1787  if (!EC_KEY_set_private_key(ec_key.get(), our_k.get())) {
1788  LOG_ERROR("EC_KEY_set_private_key failed.\n");
1789  return false;
1790  }
1791 
1792  bssl::UniquePtr<EC_POINT> our_pub(EC_POINT_new(group));
1793  if (!EC_POINT_mul(group, our_pub.get(), our_k.get(), nullptr, nullptr,
1794  ctx.get()) ||
1795  !EC_KEY_set_public_key(ec_key.get(), our_pub.get())) {
1796  LOG_ERROR("Calculating public key failed.\n");
1797  return false;
1798  }
1799  } else if (!EC_KEY_generate_key_fips(ec_key.get())) {
1800  LOG_ERROR("EC_KEY_generate_key_fips failed.\n");
1801  return false;
1802  }
1803 
1804  // The output buffer is one larger than |EC_MAX_BYTES| so that truncation
1805  // can be detected.
1806  std::vector<uint8_t> output(EC_MAX_BYTES + 1);
1807  const int out_len =
1808  ECDH_compute_key(output.data(), output.size(), their_point.get(),
1809  ec_key.get(), /*kdf=*/nullptr);
1810  if (out_len < 0) {
1811  LOG_ERROR("ECDH_compute_key failed.\n");
1812  return false;
1813  } else if (static_cast<size_t>(out_len) == output.size()) {
1814  LOG_ERROR("ECDH_compute_key output may have been truncated.\n");
1815  return false;
1816  }
1817  output.resize(static_cast<size_t>(out_len));
1818 
1819  const EC_POINT *pub = EC_KEY_get0_public_key(ec_key.get());
1820  bssl::UniquePtr<BIGNUM> x(BN_new());
1821  bssl::UniquePtr<BIGNUM> y(BN_new());
1822  if (!EC_POINT_get_affine_coordinates_GFp(group, pub, x.get(), y.get(),
1823  ctx.get())) {
1824  LOG_ERROR("EC_POINT_get_affine_coordinates_GFp failed.\n");
1825  return false;
1826  }
1827 
1828  return write_reply({BIGNUMBytes(x.get()), BIGNUMBytes(y.get()), output});
1829 }
1830 
1831 static bool FFDH(const Span<const uint8_t> args[], ReplyCallback write_reply) {
1832  bssl::UniquePtr<BIGNUM> p(BytesToBIGNUM(args[0]));
1833  bssl::UniquePtr<BIGNUM> q(BytesToBIGNUM(args[1]));
1834  bssl::UniquePtr<BIGNUM> g(BytesToBIGNUM(args[2]));
1835  bssl::UniquePtr<BIGNUM> their_pub(BytesToBIGNUM(args[3]));
1836  const Span<const uint8_t> private_key_span = args[4];
1837  const Span<const uint8_t> public_key_span = args[5];
1838 
1839  bssl::UniquePtr<DH> dh(DH_new());
1840  if (!DH_set0_pqg(dh.get(), p.get(), q.get(), g.get())) {
1841  LOG_ERROR("DH_set0_pqg failed.\n");
1842  return 0;
1843  }
1844 
1845  // DH_set0_pqg took ownership of these values.
1846  p.release();
1847  q.release();
1848  g.release();
1849 
1850  if (!private_key_span.empty()) {
1851  bssl::UniquePtr<BIGNUM> private_key(BytesToBIGNUM(private_key_span));
1852  bssl::UniquePtr<BIGNUM> public_key(BytesToBIGNUM(public_key_span));
1853 
1854  if (!DH_set0_key(dh.get(), public_key.get(), private_key.get())) {
1855  LOG_ERROR("DH_set0_key failed.\n");
1856  return 0;
1857  }
1858 
1859  // DH_set0_key took ownership of these values.
1860  public_key.release();
1861  private_key.release();
1862  } else if (!DH_generate_key(dh.get())) {
1863  LOG_ERROR("DH_generate_key failed.\n");
1864  return false;
1865  }
1866 
1867  std::vector<uint8_t> z(DH_size(dh.get()));
1868  if (DH_compute_key_padded(z.data(), their_pub.get(), dh.get()) !=
1869  static_cast<int>(z.size())) {
1870  LOG_ERROR("DH_compute_key_hashed failed.\n");
1871  return false;
1872  }
1873 
1874  return write_reply({BIGNUMBytes(DH_get0_pub_key(dh.get())), z});
1875 }
1876 
1877 static constexpr struct {
1878  char name[kMaxNameLength + 1];
1880  bool (*handler)(const Span<const uint8_t> args[], ReplyCallback write_reply);
1881 } kFunctions[] = {
1882  {"getConfig", 0, GetConfig},
1883  {"SHA-1", 1, Hash<SHA1, SHA_DIGEST_LENGTH>},
1884  {"SHA2-224", 1, Hash<SHA224, SHA224_DIGEST_LENGTH>},
1885  {"SHA2-256", 1, Hash<SHA256, SHA256_DIGEST_LENGTH>},
1886  {"SHA2-384", 1, Hash<SHA384, SHA384_DIGEST_LENGTH>},
1887  {"SHA2-512", 1, Hash<SHA512, SHA512_DIGEST_LENGTH>},
1888  {"SHA2-512/256", 1, Hash<SHA512_256, SHA512_256_DIGEST_LENGTH>},
1889  {"SHA-1/MCT", 1, HashMCT<SHA1, SHA_DIGEST_LENGTH>},
1890  {"SHA2-224/MCT", 1, HashMCT<SHA224, SHA224_DIGEST_LENGTH>},
1891  {"SHA2-256/MCT", 1, HashMCT<SHA256, SHA256_DIGEST_LENGTH>},
1892  {"SHA2-384/MCT", 1, HashMCT<SHA384, SHA384_DIGEST_LENGTH>},
1893  {"SHA2-512/MCT", 1, HashMCT<SHA512, SHA512_DIGEST_LENGTH>},
1894  {"SHA2-512/256/MCT", 1, HashMCT<SHA512_256, SHA512_256_DIGEST_LENGTH>},
1895  {"AES/encrypt", 3, AES<AES_set_encrypt_key, AES_encrypt>},
1896  {"AES/decrypt", 3, AES<AES_set_decrypt_key, AES_decrypt>},
1897  {"AES-CBC/encrypt", 4, AES_CBC<AES_set_encrypt_key, AES_ENCRYPT>},
1898  {"AES-CBC/decrypt", 4, AES_CBC<AES_set_decrypt_key, AES_DECRYPT>},
1899  {"AES-CTR/encrypt", 4, AES_CTR},
1900  {"AES-CTR/decrypt", 4, AES_CTR},
1901  {"AES-GCM/seal", 5, AEADSeal<AESGCMSetup>},
1902  {"AES-GCM/open", 5, AEADOpen<AESGCMSetup>},
1903  {"AES-KW/seal", 5, AESKeyWrapSeal},
1904  {"AES-KW/open", 5, AESKeyWrapOpen},
1905  {"AES-KWP/seal", 5, AESPaddedKeyWrapSeal},
1906  {"AES-KWP/open", 5, AESPaddedKeyWrapOpen},
1907  {"AES-CCM/seal", 5, AEADSeal<AESCCMSetup>},
1908  {"AES-CCM/open", 5, AEADOpen<AESCCMSetup>},
1909  {"3DES-ECB/encrypt", 3, TDES<true>},
1910  {"3DES-ECB/decrypt", 3, TDES<false>},
1911  {"3DES-CBC/encrypt", 4, TDES_CBC<true>},
1912  {"3DES-CBC/decrypt", 4, TDES_CBC<false>},
1913  {"HMAC-SHA-1", 2, HMAC<EVP_sha1>},
1914  {"HMAC-SHA2-224", 2, HMAC<EVP_sha224>},
1915  {"HMAC-SHA2-256", 2, HMAC<EVP_sha256>},
1916  {"HMAC-SHA2-384", 2, HMAC<EVP_sha384>},
1917  {"HMAC-SHA2-512", 2, HMAC<EVP_sha512>},
1918  {"ctrDRBG/AES-256", 6, DRBG},
1919  {"ECDSA/keyGen", 1, ECDSAKeyGen},
1920  {"ECDSA/keyVer", 3, ECDSAKeyVer},
1921  {"ECDSA/sigGen", 4, ECDSASigGen},
1922  {"ECDSA/sigVer", 7, ECDSASigVer},
1923  {"CMAC-AES", 3, CMAC_AES},
1924  {"CMAC-AES/verify", 3, CMAC_AESVerify},
1925  {"RSA/keyGen", 1, RSAKeyGen},
1926  {"RSA/sigGen/SHA2-224/pkcs1v1.5", 2, RSASigGen<EVP_sha224, false>},
1927  {"RSA/sigGen/SHA2-256/pkcs1v1.5", 2, RSASigGen<EVP_sha256, false>},
1928  {"RSA/sigGen/SHA2-384/pkcs1v1.5", 2, RSASigGen<EVP_sha384, false>},
1929  {"RSA/sigGen/SHA2-512/pkcs1v1.5", 2, RSASigGen<EVP_sha512, false>},
1930  {"RSA/sigGen/SHA-1/pkcs1v1.5", 2, RSASigGen<EVP_sha1, false>},
1931  {"RSA/sigGen/SHA2-224/pss", 2, RSASigGen<EVP_sha224, true>},
1932  {"RSA/sigGen/SHA2-256/pss", 2, RSASigGen<EVP_sha256, true>},
1933  {"RSA/sigGen/SHA2-384/pss", 2, RSASigGen<EVP_sha384, true>},
1934  {"RSA/sigGen/SHA2-512/pss", 2, RSASigGen<EVP_sha512, true>},
1935  {"RSA/sigGen/SHA-1/pss", 2, RSASigGen<EVP_sha1, true>},
1936  {"RSA/sigVer/SHA2-224/pkcs1v1.5", 4, RSASigVer<EVP_sha224, false>},
1937  {"RSA/sigVer/SHA2-256/pkcs1v1.5", 4, RSASigVer<EVP_sha256, false>},
1938  {"RSA/sigVer/SHA2-384/pkcs1v1.5", 4, RSASigVer<EVP_sha384, false>},
1939  {"RSA/sigVer/SHA2-512/pkcs1v1.5", 4, RSASigVer<EVP_sha512, false>},
1940  {"RSA/sigVer/SHA-1/pkcs1v1.5", 4, RSASigVer<EVP_sha1, false>},
1941  {"RSA/sigVer/SHA2-224/pss", 4, RSASigVer<EVP_sha224, true>},
1942  {"RSA/sigVer/SHA2-256/pss", 4, RSASigVer<EVP_sha256, true>},
1943  {"RSA/sigVer/SHA2-384/pss", 4, RSASigVer<EVP_sha384, true>},
1944  {"RSA/sigVer/SHA2-512/pss", 4, RSASigVer<EVP_sha512, true>},
1945  {"RSA/sigVer/SHA-1/pss", 4, RSASigVer<EVP_sha1, true>},
1946  {"TLSKDF/1.0/SHA-1", 5, TLSKDF<EVP_md5_sha1>},
1947  {"TLSKDF/1.2/SHA2-256", 5, TLSKDF<EVP_sha256>},
1948  {"TLSKDF/1.2/SHA2-384", 5, TLSKDF<EVP_sha384>},
1949  {"TLSKDF/1.2/SHA2-512", 5, TLSKDF<EVP_sha512>},
1950  {"ECDH/P-224", 3, ECDH<NID_secp224r1>},
1951  {"ECDH/P-256", 3, ECDH<NID_X9_62_prime256v1>},
1952  {"ECDH/P-384", 3, ECDH<NID_secp384r1>},
1953  {"ECDH/P-521", 3, ECDH<NID_secp521r1>},
1954  {"FFDH", 6, FFDH},
1955 };
1956 
1958  const bssl::Span<const uint8_t> algorithm = args[0];
1959  for (const auto &func : kFunctions) {
1960  if (algorithm.size() == strlen(func.name) &&
1961  memcmp(algorithm.data(), func.name, algorithm.size()) == 0) {
1962  if (args.size() - 1 != func.num_expected_args) {
1963  LOG_ERROR("\'%s\' operation received %zu arguments but expected %u.\n",
1964  func.name, args.size() - 1, func.num_expected_args);
1965  return nullptr;
1966  }
1967 
1968  return func.handler;
1969  }
1970  }
1971 
1972  const std::string name(reinterpret_cast<const char *>(algorithm.data()),
1973  algorithm.size());
1974  LOG_ERROR("Unknown operation: %s\n", name.c_str());
1975  return nullptr;
1976 }
1977 
1978 } // namespace acvp
1979 } // namespace bssl
RSA_get0_n
#define RSA_get0_n
Definition: boringssl_prefix_symbols.h:2101
AES_ENCRYPT
#define AES_ENCRYPT
Definition: aes.h:62
EC_KEY_get0_private_key
#define EC_KEY_get0_private_key
Definition: boringssl_prefix_symbols.h:1345
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
RSA_get0_key
#define RSA_get0_key
Definition: boringssl_prefix_symbols.h:2100
bn.h
EC_POINT_new
#define EC_POINT_new
Definition: boringssl_prefix_symbols.h:1384
EVP_MD_type
#define EVP_MD_type
Definition: boringssl_prefix_symbols.h:1580
bssl::acvp::AESPaddedKeyWrapSetup
static bool AESPaddedKeyWrapSetup(AES_KEY *out, bool decrypt, Span< const uint8_t > key)
Definition: modulewrapper.cc:521
EC_KEY_new_by_curve_name
#define EC_KEY_new_by_curve_name
Definition: boringssl_prefix_symbols.h:1356
ecdsa_sig_st::r
BIGNUM * r
Definition: ecdsa.h:106
public_key
Definition: hrss.c:1881
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
bssl::acvp::AEADSeal
static bool AEADSeal(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:462
CRYPTO_tls1_prf
#define CRYPTO_tls1_prf
Definition: boringssl_prefix_symbols.h:1203
Hash
Hash
Definition: abseil-cpp/absl/container/internal/hash_function_defaults_test.cc:339
EVP_sha512
const OPENSSL_EXPORT EVP_MD * EVP_sha512(void)
bssl::acvp::AESKeyWrapSetup
static bool AESKeyWrapSetup(AES_KEY *out, bool decrypt, Span< const uint8_t > key, Span< const uint8_t > input)
Definition: modulewrapper.cc:532
AES_set_encrypt_key
#define AES_set_encrypt_key
Definition: boringssl_prefix_symbols.h:603
regen-readme.it
it
Definition: regen-readme.py:15
bssl::acvp::HashMCT
static bool HashMCT(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:242
bssl::acvp::RequestBuffer::~RequestBuffer
virtual ~RequestBuffer()
Span::size
size_t size() const
Definition: boringssl-with-bazel/src/include/openssl/span.h:133
absl::str_format_internal::LengthMod::j
@ j
EC_KEY_check_fips
#define EC_KEY_check_fips
Definition: boringssl_prefix_symbols.h:1337
OPENSSL_memcmp
static int OPENSSL_memcmp(const void *s1, const void *s2, size_t n)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:811
bssl::acvp::AEADOpen
static bool AEADOpen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:492
ctx
Definition: benchmark-async.c:30
bool
bool
Definition: setup_once.h:312
NID_X9_62_prime256v1
#define NID_X9_62_prime256v1
Definition: nid.h:1914
bssl::acvp::GetConfig
static bool GetConfig(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:225
bssl::acvp::ECDSASigGen
static bool ECDSASigGen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:901
EC_KEY_generate_key_fips
#define EC_KEY_generate_key_fips
Definition: boringssl_prefix_symbols.h:1343
env_md_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/internal.h:67
CTR_DRBG_init
#define CTR_DRBG_init
Definition: boringssl_prefix_symbols.h:1206
begin
char * begin
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1007
keys
const void * keys
Definition: abseil-cpp/absl/random/internal/randen.cc:49
RSA_size
#define RSA_size
Definition: boringssl_prefix_symbols.h:2139
ecdsa.h
EVP_sha384
const OPENSSL_EXPORT EVP_MD * EVP_sha384(void)
EVP_des_ede3
const OPENSSL_EXPORT EVP_CIPHER * EVP_des_ede3(void)
y
const double y
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3611
BN_bin2bn
#define BN_bin2bn
Definition: boringssl_prefix_symbols.h:900
RSA_get0_factors
#define RSA_get0_factors
Definition: boringssl_prefix_symbols.h:2098
string.h
bssl::acvp::name
char name[kMaxNameLength+1]
Definition: modulewrapper.cc:1254
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
bssl::acvp::AESGCMSetup
static bool AESGCMSetup(EVP_AEAD_CTX *ctx, Span< const uint8_t > tag_len_span, Span< const uint8_t > key)
Definition: modulewrapper.cc:393
bssl::acvp::TDES
static bool TDES(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:638
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
EC_KEY_set_public_key
#define EC_KEY_set_public_key
Definition: boringssl_prefix_symbols.h:1367
ciphertext
const char * ciphertext
Definition: protobuf/src/google/protobuf/stubs/strutil_unittest.cc:86
ecdh.h
RSA_set0_key
#define RSA_set0_key
Definition: boringssl_prefix_symbols.h:2134
UINT32_MAX
#define UINT32_MAX
Definition: stdint-msvc2008.h:142
bssl::acvp::GetIterations
static uint32_t GetIterations(const Span< const uint8_t > iterations_bytes)
Definition: modulewrapper.cc:264
ecdsa_sig_st::s
BIGNUM * s
Definition: ecdsa.h:107
bssl::acvp::RequestBufferImpl
Definition: modulewrapper.cc:66
EVP_CIPHER_iv_length
#define EVP_CIPHER_iv_length
Definition: boringssl_prefix_symbols.h:1485
bssl
Definition: hpke_test.cc:37
ctx
static struct test_ctx ctx
Definition: test-ipc-send-recv.c:65
bssl::acvp::AESKeyWrapOpen
static bool AESKeyWrapOpen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:567
absl::FormatConversionChar::s
@ s
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
bssl::acvp::kFunctions
static constexpr struct bssl::acvp::@380 kFunctions[]
xds_manager.p
p
Definition: xds_manager.py:60
ECDSA_do_sign
#define ECDSA_do_sign
Definition: boringssl_prefix_symbols.h:1309
BN_num_bytes
#define BN_num_bytes
Definition: boringssl_prefix_symbols.h:976
bssl::acvp::CMAC_AESVerify
static bool CMAC_AESVerify(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:981
z
Uncopyable z
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3612
bssl::acvp::RequestBufferImpl::~RequestBufferImpl
~RequestBufferImpl()=default
EVP_sha256
const OPENSSL_EXPORT EVP_MD * EVP_sha256(void)
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
EC_KEY_get0_group
#define EC_KEY_get0_group
Definition: boringssl_prefix_symbols.h:1344
AES_CMAC
#define AES_CMAC
Definition: boringssl_prefix_symbols.h:594
DH_get0_pub_key
#define DH_get0_pub_key
Definition: boringssl_prefix_symbols.h:1232
bssl::acvp::CachedRSAKeys
static std::map< unsigned, bssl::UniquePtr< RSA > > & CachedRSAKeys()
Definition: modulewrapper.cc:995
AES_wrap_key
#define AES_wrap_key
Definition: boringssl_prefix_symbols.h:606
bssl::acvp::BytesToBIGNUM
static bssl::UniquePtr< BIGNUM > BytesToBIGNUM(Span< const uint8_t > bytes)
Definition: modulewrapper.cc:855
bssl::acvp::RSASigVer
static bool RSASigVer(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1083
AES_BLOCK_SIZE
#define AES_BLOCK_SIZE
Definition: aes.h:68
bssl::acvp::GetPublicKeyBytes
static std::pair< std::vector< uint8_t >, std::vector< uint8_t > > GetPublicKeyBytes(const EC_KEY *key)
Definition: modulewrapper.cc:824
iov
static uv_buf_t iov
Definition: libuv/docs/code/uvcat/main.c:15
hash
uint64_t hash
Definition: ring_hash.cc:284
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
bssl::acvp::kMaxNameLength
constexpr size_t kMaxNameLength
Definition: modulewrapper.h:31
EVP_aead_aes_256_gcm
const OPENSSL_EXPORT EVP_AEAD * EVP_aead_aes_256_gcm(void)
bssl::acvp::BIGNUMBytes
static std::vector< uint8_t > BIGNUMBytes(const BIGNUM *bn)
Definition: modulewrapper.cc:817
EC_POINT_get_affine_coordinates_GFp
#define EC_POINT_get_affine_coordinates_GFp
Definition: boringssl_prefix_symbols.h:1379
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
dh.h
in
const char * in
Definition: third_party/abseil-cpp/absl/strings/internal/str_format/parser_test.cc:391
bssl::acvp::AES_CBC
static bool AES_CBC(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:315
absl::FormatConversionChar::e
@ e
bssl::acvp::ReadAll
static bool ReadAll(int fd, void *in_data, size_t data_len)
Definition: modulewrapper.cc:79
evp_cipher_st
Definition: cipher.h:585
bssl::acvp::AESPaddedKeyWrapOpen
static bool AESPaddedKeyWrapOpen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:612
EC_POINT_mul
#define EC_POINT_mul
Definition: boringssl_prefix_symbols.h:1383
ssize_t
intptr_t ssize_t
Definition: win.h:27
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
bssl::acvp::handler
bool(* handler)(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1256
EC_POINT_set_affine_coordinates_GFp
#define EC_POINT_set_affine_coordinates_GFp
Definition: boringssl_prefix_symbols.h:1389
xds_interop_client.int
int
Definition: xds_interop_client.py:113
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
bssl::acvp::HashFromName
static const EVP_MD * HashFromName(Span< const uint8_t > name)
Definition: modulewrapper.cc:885
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
bssl::acvp::DRBG
static bool DRBG(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:761
AES_ctr128_encrypt
#define AES_ctr128_encrypt
Definition: boringssl_prefix_symbols.h:597
EC_MAX_BYTES
#define EC_MAX_BYTES
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h:91
RSA_generate_key_fips
#define RSA_generate_key_fips
Definition: boringssl_prefix_symbols.h:2092
NID_secp521r1
#define NID_secp521r1
Definition: nid.h:3172
gen_synthetic_protos.label
label
Definition: gen_synthetic_protos.py:102
Span::empty
bool empty() const
Definition: boringssl-with-bazel/src/include/openssl/span.h:134
RSA_verify_pss_mgf1
#define RSA_verify_pss_mgf1
Definition: boringssl_prefix_symbols.h:2143
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
EVP_CIPHER_CTX_set_padding
#define EVP_CIPHER_CTX_set_padding
Definition: boringssl_prefix_symbols.h:1482
bssl::acvp::AES
static bool AES(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:287
aes.h
sha.h
evp_aead_ctx_st
Definition: aead.h:217
bssl::acvp::TDES_CBC
static bool TDES_CBC(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:684
EVP_AEAD_CTX_seal
#define EVP_AEAD_CTX_seal
Definition: boringssl_prefix_symbols.h:1454
modulewrapper.h
bits
OPENSSL_EXPORT ASN1_BIT_STRING * bits
Definition: x509v3.h:482
done
struct tab * done
Definition: bloaty/third_party/zlib/examples/enough.c:176
err.h
bssl::acvp::RequestBuffer::New
static std::unique_ptr< RequestBuffer > New()
Definition: modulewrapper.cc:75
rsa.h
cipher.h
EVP_AEAD_CTX_init
#define EVP_AEAD_CTX_init
Definition: boringssl_prefix_symbols.h:1449
EC_KEY_get0_public_key
#define EC_KEY_get0_public_key
Definition: boringssl_prefix_symbols.h:1346
DH_set0_key
#define DH_set0_key
Definition: boringssl_prefix_symbols.h:1239
writev
#define writev(s, ptr, cnt)
Definition: ares_private.h:124
ec_key.h
AES_unwrap_key_padded
#define AES_unwrap_key_padded
Definition: boringssl_prefix_symbols.h:605
x
int x
Definition: bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
bssl::acvp::ECDSAKeyGen
static bool ECDSAKeyGen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:840
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
BN_CTX_new
#define BN_CTX_new
Definition: boringssl_prefix_symbols.h:885
BN_bn2bin
#define BN_bn2bin
Definition: boringssl_prefix_symbols.h:901
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
RSA_new
#define RSA_new
Definition: boringssl_prefix_symbols.h:2110
aead.h
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
EVP_des_ede3_cbc
const OPENSSL_EXPORT EVP_CIPHER * EVP_des_ede3_cbc(void)
g
struct @717 g
ECDSA_do_verify
#define ECDSA_do_verify
Definition: boringssl_prefix_symbols.h:1310
Span< const uint8_t >
bssl::acvp::RequestBufferImpl::buf
std::vector< uint8_t > buf
Definition: modulewrapper.cc:70
bssl::acvp::ECDH
static bool ECDH(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1145
bssl::acvp::GetRSAKey
static RSA * GetRSAKey(unsigned bits)
Definition: modulewrapper.cc:1000
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
msg
std::string msg
Definition: client_interceptors_end2end_test.cc:372
nid
int nid
Definition: cipher_extra.c:71
AES_set_decrypt_key
#define AES_set_decrypt_key
Definition: boringssl_prefix_symbols.h:602
ec_key_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h:723
EVP_CipherFinal_ex
#define EVP_CipherFinal_ex
Definition: boringssl_prefix_symbols.h:1491
bssl::acvp::Handler
bool(* Handler)(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.h:61
EVP_AEAD_CTX_open
#define EVP_AEAD_CTX_open
Definition: boringssl_prefix_symbols.h:1452
point
Definition: bloaty/third_party/zlib/examples/zran.c:67
evp_aead_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/internal.h:77
RSA_verify
#define RSA_verify
Definition: boringssl_prefix_symbols.h:2141
EVP_CipherInit_ex
#define EVP_CipherInit_ex
Definition: boringssl_prefix_symbols.h:1493
bssl::acvp::Hash
static bool Hash(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:234
CTR_DRBG_ENTROPY_LEN
#define CTR_DRBG_ENTROPY_LEN
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h:111
benchmark.md
md
Definition: benchmark.py:86
iovec
Definition: gsec.h:33
read
int read(izstream &zs, T *x, Items items)
Definition: bloaty/third_party/zlib/contrib/iostream2/zstream.h:115
bssl::acvp::AESKeyWrapSeal
static bool AESKeyWrapSeal(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:547
digest.h
func
const EVP_CIPHER *(* func)(void)
Definition: cipher_extra.c:73
EVP_CipherUpdate
#define EVP_CipherUpdate
Definition: boringssl_prefix_symbols.h:1494
key
const char * key
Definition: hpack_parser_table.cc:164
upload.group
group
Definition: bloaty/third_party/googletest/googlemock/scripts/upload.py:397
EVP_Digest
#define EVP_Digest
Definition: boringssl_prefix_symbols.h:1506
bssl::acvp::RSASigGen
static bool RSASigGen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1044
bssl::acvp::CMAC_AES
static bool CMAC_AES(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:962
AES_cbc_encrypt
#define AES_cbc_encrypt
Definition: boringssl_prefix_symbols.h:595
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
DH_new
#define DH_new
Definition: boringssl_prefix_symbols.h:1236
iovec::iov_len
size_t iov_len
Definition: gsec.h:35
DH_size
#define DH_size
Definition: boringssl_prefix_symbols.h:1242
EVP_AEAD_MAX_OVERHEAD
#define EVP_AEAD_MAX_OVERHEAD
Definition: aead.h:235
bssl::acvp::StringEq
static bool StringEq(Span< const uint8_t > a, const char *b)
Definition: modulewrapper.cc:795
AES_DECRYPT
#define AES_DECRYPT
Definition: aes.h:63
bignum_st
Definition: bn.h:957
ec_point_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h:615
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
private_key
Definition: hrss.c:1885
ec_group_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h:573
bssl::acvp::AESCCMSetup
static bool AESCCMSetup(EVP_AEAD_CTX *ctx, Span< const uint8_t > tag_len_span, Span< const uint8_t > key)
Definition: modulewrapper.cc:429
DH_set0_pqg
#define DH_set0_pqg
Definition: boringssl_prefix_symbols.h:1240
fix_build_deps.r
r
Definition: fix_build_deps.py:491
DH_generate_key
#define DH_generate_key
Definition: boringssl_prefix_symbols.h:1225
EVP_MAX_MD_SIZE
#define EVP_MAX_MD_SIZE
Definition: digest.h:156
EVP_aead_aes_192_gcm
const OPENSSL_EXPORT EVP_AEAD * EVP_aead_aes_192_gcm(void)
xds_manager.num
num
Definition: xds_manager.py:56
ok
bool ok
Definition: async_end2end_test.cc:197
EC_KEY_set_private_key
#define EC_KEY_set_private_key
Definition: boringssl_prefix_symbols.h:1366
ERR_clear_error
#define ERR_clear_error
Definition: boringssl_prefix_symbols.h:1413
bssl::acvp::ReplyCallback
std::function< bool(const std::vector< Span< const uint8_t >> &)> ReplyCallback
Definition: modulewrapper.h:55
EVP_sha1
const OPENSSL_EXPORT EVP_MD * EVP_sha1(void)
bssl::acvp::HMAC
static bool HMAC(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:750
bssl::acvp::WriteReplyToFd
bool WriteReplyToFd(int fd, const std::vector< Span< const uint8_t >> &spans)
Definition: modulewrapper.cc:166
RSA_get0_e
#define RSA_get0_e
Definition: boringssl_prefix_symbols.h:2097
bssl::acvp::kMaxArgs
constexpr size_t kMaxArgs
Definition: modulewrapper.h:29
bssl::acvp::TLSKDF
static bool TLSKDF(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1119
bssl::acvp::RequestBuffer
Definition: modulewrapper.h:35
input
std::string input
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/tokenizer_unittest.cc:197
bssl::acvp::num_expected_args
uint8_t num_expected_args
Definition: modulewrapper.cc:1255
obj.h
absl::str_format_internal::LengthMod::q
@ q
RSA_sign
#define RSA_sign
Definition: boringssl_prefix_symbols.h:2136
NID_secp224r1
#define NID_secp224r1
Definition: nid.h:3160
plaintext
const char * plaintext
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil_unittest.cc:85
bssl::acvp::RequestBufferImpl::args
Span< const uint8_t > args[kMaxArgs]
Definition: modulewrapper.cc:71
Span::data
T * data() const
Definition: boringssl-with-bazel/src/include/openssl/span.h:132
RSA_sign_pss_mgf1
#define RSA_sign_pss_mgf1
Definition: boringssl_prefix_symbols.h:2137
bssl::acvp::ParseArgsFromFd
Span< const Span< const uint8_t > > ParseArgsFromFd(int fd, RequestBuffer *in_buffer)
Definition: modulewrapper.cc:99
span.h
ECDH_compute_key
#define ECDH_compute_key
Definition: boringssl_prefix_symbols.h:1296
make_curve25519_tables.d
int d
Definition: make_curve25519_tables.py:53
rsa_st
Definition: rsa.h:732
bssl::acvp::RSAKeyGen
static bool RSAKeyGen(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1017
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
bssl::acvp::FindHandler
Handler FindHandler(Span< const Span< const uint8_t >> args)
Definition: modulewrapper.cc:1333
CTR_DRBG_STATE
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h:99
AES_unwrap_key
#define AES_unwrap_key
Definition: boringssl_prefix_symbols.h:604
cmac.h
NID_secp384r1
#define NID_secp384r1
Definition: nid.h:3168
iovec::iov_base
void * iov_base
Definition: gsec.h:34
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
tests.interop.resources.private_key
def private_key()
Definition: interop/resources.py:29
AES_wrap_key_padded
#define AES_wrap_key_padded
Definition: boringssl_prefix_symbols.h:607
bssl::acvp::ECKeyFromName
static bssl::UniquePtr< EC_KEY > ECKeyFromName(Span< const uint8_t > name)
Definition: modulewrapper.cc:800
DH_compute_key_padded
#define DH_compute_key_padded
Definition: boringssl_prefix_symbols.h:1223
CTR_DRBG_generate
#define CTR_DRBG_generate
Definition: boringssl_prefix_symbols.h:1205
ec.h
bssl::acvp::kMaxArgLength
constexpr size_t kMaxArgLength
Definition: modulewrapper.cc:62
EVP_aead_aes_128_gcm
const OPENSSL_EXPORT EVP_AEAD * EVP_aead_aes_128_gcm(void)
bssl::acvp::AES_CTR
static bool AES_CTR(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:362
bssl::acvp::ECDSASigVer
static bool ECDSASigVer(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:926
EVP_aead_aes_128_ccm_bluetooth
#define EVP_aead_aes_128_ccm_bluetooth
Definition: boringssl_prefix_symbols.h:1677
LOG_ERROR
#define LOG_ERROR(...)
Definition: modulewrapper.cc:59
ecdsa_sig_st
Definition: ecdsa.h:105
bssl::acvp::ECDSAKeyVer
static bool ECDSAKeyVer(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:861
bssl::acvp::AESPaddedKeyWrapSeal
static bool AESPaddedKeyWrapSeal(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:590
EVP_sha224
const OPENSSL_EXPORT EVP_MD * EVP_sha224(void)
aes_key_st
Definition: aes.h:72
bssl::acvp::FFDH
static bool FFDH(const Span< const uint8_t > args[], ReplyCallback write_reply)
Definition: modulewrapper.cc:1207
BN_new
#define BN_new
Definition: boringssl_prefix_symbols.h:971
errno.h
hmac.h
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
offset
voidpf uLong offset
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:142


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:41