dsa.c
Go to the documentation of this file.
1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
2  * All rights reserved.
3  *
4  * This package is an SSL implementation written
5  * by Eric Young (eay@cryptsoft.com).
6  * The implementation was written so as to conform with Netscapes SSL.
7  *
8  * This library is free for commercial and non-commercial use as long as
9  * the following conditions are aheared to. The following conditions
10  * apply to all code found in this distribution, be it the RC4, RSA,
11  * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12  * included with this distribution is covered by the same copyright terms
13  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
14  *
15  * Copyright remains Eric Young's, and as such any Copyright notices in
16  * the code are not to be removed.
17  * If this package is used in a product, Eric Young should be given attribution
18  * as the author of the parts of the library used.
19  * This can be in the form of a textual message at program startup or
20  * in documentation (online or textual) provided with the package.
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions
24  * are met:
25  * 1. Redistributions of source code must retain the copyright
26  * notice, this list of conditions and the following disclaimer.
27  * 2. Redistributions in binary form must reproduce the above copyright
28  * notice, this list of conditions and the following disclaimer in the
29  * documentation and/or other materials provided with the distribution.
30  * 3. All advertising materials mentioning features or use of this software
31  * must display the following acknowledgement:
32  * "This product includes cryptographic software written by
33  * Eric Young (eay@cryptsoft.com)"
34  * The word 'cryptographic' can be left out if the rouines from the library
35  * being used are not cryptographic related :-).
36  * 4. If you include any Windows specific code (or a derivative thereof) from
37  * the apps directory (application code) you must include an acknowledgement:
38  * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
39  *
40  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  *
52  * The licence and distribution terms for any publically available version or
53  * derivative of this code cannot be changed. i.e. this code cannot simply be
54  * copied and put under another distribution licence
55  * [including the GNU Public Licence.]
56  *
57  * The DSS routines are based on patches supplied by
58  * Steven Schoch <schoch@sheba.arc.nasa.gov>. */
59 
60 #include <openssl/dsa.h>
61 
62 #include <string.h>
63 
64 #include <openssl/bn.h>
65 #include <openssl/dh.h>
66 #include <openssl/digest.h>
67 #include <openssl/engine.h>
68 #include <openssl/err.h>
69 #include <openssl/ex_data.h>
70 #include <openssl/mem.h>
71 #include <openssl/rand.h>
72 #include <openssl/sha.h>
73 #include <openssl/thread.h>
74 
75 #include "internal.h"
76 #include "../fipsmodule/bn/internal.h"
77 #include "../internal.h"
78 
79 
80 // Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
81 // Miller-Rabin.
82 #define DSS_prime_checks 50
83 
84 static int dsa_sign_setup(const DSA *dsa, BN_CTX *ctx_in, BIGNUM **out_kinv,
85  BIGNUM **out_r);
86 
88 
89 DSA *DSA_new(void) {
90  DSA *dsa = OPENSSL_malloc(sizeof(DSA));
91  if (dsa == NULL) {
93  return NULL;
94  }
95 
96  OPENSSL_memset(dsa, 0, sizeof(DSA));
97 
98  dsa->references = 1;
99 
102 
103  return dsa;
104 }
105 
106 void DSA_free(DSA *dsa) {
107  if (dsa == NULL) {
108  return;
109  }
110 
112  return;
113  }
114 
116 
117  BN_clear_free(dsa->p);
118  BN_clear_free(dsa->q);
119  BN_clear_free(dsa->g);
120  BN_clear_free(dsa->pub_key);
121  BN_clear_free(dsa->priv_key);
125  OPENSSL_free(dsa);
126 }
127 
128 int DSA_up_ref(DSA *dsa) {
130  return 1;
131 }
132 
133 const BIGNUM *DSA_get0_pub_key(const DSA *dsa) { return dsa->pub_key; }
134 
135 const BIGNUM *DSA_get0_priv_key(const DSA *dsa) { return dsa->priv_key; }
136 
137 const BIGNUM *DSA_get0_p(const DSA *dsa) { return dsa->p; }
138 
139 const BIGNUM *DSA_get0_q(const DSA *dsa) { return dsa->q; }
140 
141 const BIGNUM *DSA_get0_g(const DSA *dsa) { return dsa->g; }
142 
143 void DSA_get0_key(const DSA *dsa, const BIGNUM **out_pub_key,
144  const BIGNUM **out_priv_key) {
145  if (out_pub_key != NULL) {
146  *out_pub_key = dsa->pub_key;
147  }
148  if (out_priv_key != NULL) {
149  *out_priv_key = dsa->priv_key;
150  }
151 }
152 
153 void DSA_get0_pqg(const DSA *dsa, const BIGNUM **out_p, const BIGNUM **out_q,
154  const BIGNUM **out_g) {
155  if (out_p != NULL) {
156  *out_p = dsa->p;
157  }
158  if (out_q != NULL) {
159  *out_q = dsa->q;
160  }
161  if (out_g != NULL) {
162  *out_g = dsa->g;
163  }
164 }
165 
166 int DSA_set0_key(DSA *dsa, BIGNUM *pub_key, BIGNUM *priv_key) {
167  if (dsa->pub_key == NULL && pub_key == NULL) {
168  return 0;
169  }
170 
171  if (pub_key != NULL) {
172  BN_free(dsa->pub_key);
173  dsa->pub_key = pub_key;
174  }
175  if (priv_key != NULL) {
176  BN_free(dsa->priv_key);
177  dsa->priv_key = priv_key;
178  }
179 
180  return 1;
181 }
182 
183 int DSA_set0_pqg(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g) {
184  if ((dsa->p == NULL && p == NULL) ||
185  (dsa->q == NULL && q == NULL) ||
186  (dsa->g == NULL && g == NULL)) {
187  return 0;
188  }
189 
190  if (p != NULL) {
191  BN_free(dsa->p);
192  dsa->p = p;
193  }
194  if (q != NULL) {
195  BN_free(dsa->q);
196  dsa->q = q;
197  }
198  if (g != NULL) {
199  BN_free(dsa->g);
200  dsa->g = g;
201  }
202 
203  return 1;
204 }
205 
206 int DSA_generate_parameters_ex(DSA *dsa, unsigned bits, const uint8_t *seed_in,
207  size_t seed_len, int *out_counter,
208  unsigned long *out_h, BN_GENCB *cb) {
209  int ok = 0;
210  unsigned char seed[SHA256_DIGEST_LENGTH];
211  unsigned char md[SHA256_DIGEST_LENGTH];
213  BIGNUM *r0, *W, *X, *c, *test;
214  BIGNUM *g = NULL, *q = NULL, *p = NULL;
215  BN_MONT_CTX *mont = NULL;
216  int k, n = 0, m = 0;
217  unsigned i;
218  int counter = 0;
219  int r = 0;
220  BN_CTX *ctx = NULL;
221  unsigned int h = 2;
222  unsigned qsize;
223  const EVP_MD *evpmd;
224 
225  evpmd = (bits >= 2048) ? EVP_sha256() : EVP_sha1();
226  qsize = EVP_MD_size(evpmd);
227 
228  if (bits < 512) {
229  bits = 512;
230  }
231 
232  bits = (bits + 63) / 64 * 64;
233 
234  if (seed_in != NULL) {
235  if (seed_len < (size_t)qsize) {
236  return 0;
237  }
238  if (seed_len > (size_t)qsize) {
239  // Only consume as much seed as is expected.
240  seed_len = qsize;
241  }
242  OPENSSL_memcpy(seed, seed_in, seed_len);
243  }
244 
245  ctx = BN_CTX_new();
246  if (ctx == NULL) {
247  goto err;
248  }
249  BN_CTX_start(ctx);
250 
251  r0 = BN_CTX_get(ctx);
252  g = BN_CTX_get(ctx);
253  W = BN_CTX_get(ctx);
254  q = BN_CTX_get(ctx);
255  X = BN_CTX_get(ctx);
256  c = BN_CTX_get(ctx);
257  p = BN_CTX_get(ctx);
258  test = BN_CTX_get(ctx);
259 
260  if (test == NULL || !BN_lshift(test, BN_value_one(), bits - 1)) {
261  goto err;
262  }
263 
264  for (;;) {
265  // Find q.
266  for (;;) {
267  // step 1
268  if (!BN_GENCB_call(cb, BN_GENCB_GENERATED, m++)) {
269  goto err;
270  }
271 
272  int use_random_seed = (seed_in == NULL);
273  if (use_random_seed) {
274  if (!RAND_bytes(seed, qsize)) {
275  goto err;
276  }
277  } else {
278  // If we come back through, use random seed next time.
279  seed_in = NULL;
280  }
281  OPENSSL_memcpy(buf, seed, qsize);
282  OPENSSL_memcpy(buf2, seed, qsize);
283  // precompute "SEED + 1" for step 7:
284  for (i = qsize - 1; i < qsize; i--) {
285  buf[i]++;
286  if (buf[i] != 0) {
287  break;
288  }
289  }
290 
291  // step 2
292  if (!EVP_Digest(seed, qsize, md, NULL, evpmd, NULL) ||
293  !EVP_Digest(buf, qsize, buf2, NULL, evpmd, NULL)) {
294  goto err;
295  }
296  for (i = 0; i < qsize; i++) {
297  md[i] ^= buf2[i];
298  }
299 
300  // step 3
301  md[0] |= 0x80;
302  md[qsize - 1] |= 0x01;
303  if (!BN_bin2bn(md, qsize, q)) {
304  goto err;
305  }
306 
307  // step 4
308  r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx, use_random_seed, cb);
309  if (r > 0) {
310  break;
311  }
312  if (r != 0) {
313  goto err;
314  }
315 
316  // do a callback call
317  // step 5
318  }
319 
320  if (!BN_GENCB_call(cb, 2, 0) || !BN_GENCB_call(cb, 3, 0)) {
321  goto err;
322  }
323 
324  // step 6
325  counter = 0;
326  // "offset = 2"
327 
328  n = (bits - 1) / 160;
329 
330  for (;;) {
331  if ((counter != 0) && !BN_GENCB_call(cb, BN_GENCB_GENERATED, counter)) {
332  goto err;
333  }
334 
335  // step 7
336  BN_zero(W);
337  // now 'buf' contains "SEED + offset - 1"
338  for (k = 0; k <= n; k++) {
339  // obtain "SEED + offset + k" by incrementing:
340  for (i = qsize - 1; i < qsize; i--) {
341  buf[i]++;
342  if (buf[i] != 0) {
343  break;
344  }
345  }
346 
347  if (!EVP_Digest(buf, qsize, md, NULL, evpmd, NULL)) {
348  goto err;
349  }
350 
351  // step 8
352  if (!BN_bin2bn(md, qsize, r0) ||
353  !BN_lshift(r0, r0, (qsize << 3) * k) ||
354  !BN_add(W, W, r0)) {
355  goto err;
356  }
357  }
358 
359  // more of step 8
360  if (!BN_mask_bits(W, bits - 1) ||
361  !BN_copy(X, W) ||
362  !BN_add(X, X, test)) {
363  goto err;
364  }
365 
366  // step 9
367  if (!BN_lshift1(r0, q) ||
368  !BN_mod(c, X, r0, ctx) ||
369  !BN_sub(r0, c, BN_value_one()) ||
370  !BN_sub(p, X, r0)) {
371  goto err;
372  }
373 
374  // step 10
375  if (BN_cmp(p, test) >= 0) {
376  // step 11
378  if (r > 0) {
379  goto end; // found it
380  }
381  if (r != 0) {
382  goto err;
383  }
384  }
385 
386  // step 13
387  counter++;
388  // "offset = offset + n + 1"
389 
390  // step 14
391  if (counter >= 4096) {
392  break;
393  }
394  }
395  }
396 end:
397  if (!BN_GENCB_call(cb, 2, 1)) {
398  goto err;
399  }
400 
401  // We now need to generate g
402  // Set r0=(p-1)/q
403  if (!BN_sub(test, p, BN_value_one()) ||
404  !BN_div(r0, NULL, test, q, ctx)) {
405  goto err;
406  }
407 
409  if (mont == NULL ||
410  !BN_set_word(test, h)) {
411  goto err;
412  }
413 
414  for (;;) {
415  // g=test^r0%p
416  if (!BN_mod_exp_mont(g, test, r0, p, ctx, mont)) {
417  goto err;
418  }
419  if (!BN_is_one(g)) {
420  break;
421  }
422  if (!BN_add(test, test, BN_value_one())) {
423  goto err;
424  }
425  h++;
426  }
427 
428  if (!BN_GENCB_call(cb, 3, 1)) {
429  goto err;
430  }
431 
432  ok = 1;
433 
434 err:
435  if (ok) {
436  BN_free(dsa->p);
437  BN_free(dsa->q);
438  BN_free(dsa->g);
439  dsa->p = BN_dup(p);
440  dsa->q = BN_dup(q);
441  dsa->g = BN_dup(g);
442  if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) {
443  ok = 0;
444  goto err;
445  }
446  if (out_counter != NULL) {
447  *out_counter = counter;
448  }
449  if (out_h != NULL) {
450  *out_h = h;
451  }
452  }
453 
454  if (ctx) {
455  BN_CTX_end(ctx);
456  BN_CTX_free(ctx);
457  }
458 
459  BN_MONT_CTX_free(mont);
460 
461  return ok;
462 }
463 
464 DSA *DSAparams_dup(const DSA *dsa) {
465  DSA *ret = DSA_new();
466  if (ret == NULL) {
467  return NULL;
468  }
469  ret->p = BN_dup(dsa->p);
470  ret->q = BN_dup(dsa->q);
471  ret->g = BN_dup(dsa->g);
472  if (ret->p == NULL || ret->q == NULL || ret->g == NULL) {
473  DSA_free(ret);
474  return NULL;
475  }
476  return ret;
477 }
478 
480  int ok = 0;
481  BN_CTX *ctx = NULL;
482  BIGNUM *pub_key = NULL, *priv_key = NULL;
483 
484  ctx = BN_CTX_new();
485  if (ctx == NULL) {
486  goto err;
487  }
488 
489  priv_key = dsa->priv_key;
490  if (priv_key == NULL) {
491  priv_key = BN_new();
492  if (priv_key == NULL) {
493  goto err;
494  }
495  }
496 
497  if (!BN_rand_range_ex(priv_key, 1, dsa->q)) {
498  goto err;
499  }
500 
501  pub_key = dsa->pub_key;
502  if (pub_key == NULL) {
503  pub_key = BN_new();
504  if (pub_key == NULL) {
505  goto err;
506  }
507  }
508 
510  dsa->p, ctx) ||
511  !BN_mod_exp_mont_consttime(pub_key, dsa->g, priv_key, dsa->p, ctx,
512  dsa->method_mont_p)) {
513  goto err;
514  }
515 
516  dsa->priv_key = priv_key;
517  dsa->pub_key = pub_key;
518  ok = 1;
519 
520 err:
521  if (dsa->pub_key == NULL) {
522  BN_free(pub_key);
523  }
524  if (dsa->priv_key == NULL) {
525  BN_free(priv_key);
526  }
527  BN_CTX_free(ctx);
528 
529  return ok;
530 }
531 
533  DSA_SIG *sig;
534  sig = OPENSSL_malloc(sizeof(DSA_SIG));
535  if (!sig) {
536  return NULL;
537  }
538  sig->r = NULL;
539  sig->s = NULL;
540  return sig;
541 }
542 
543 void DSA_SIG_free(DSA_SIG *sig) {
544  if (!sig) {
545  return;
546  }
547 
548  BN_free(sig->r);
549  BN_free(sig->s);
550  OPENSSL_free(sig);
551 }
552 
553 void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **out_r,
554  const BIGNUM **out_s) {
555  if (out_r != NULL) {
556  *out_r = sig->r;
557  }
558  if (out_s != NULL) {
559  *out_s = sig->s;
560  }
561 }
562 
563 int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) {
564  if (r == NULL || s == NULL) {
565  return 0;
566  }
567  BN_free(sig->r);
568  BN_free(sig->s);
569  sig->r = r;
570  sig->s = s;
571  return 1;
572 }
573 
574 // mod_mul_consttime sets |r| to |a| * |b| modulo |mont->N|, treating |a| and
575 // |b| as secret. This function internally uses Montgomery reduction, but
576 // neither inputs nor outputs are in Montgomery form.
577 static int mod_mul_consttime(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
578  const BN_MONT_CTX *mont, BN_CTX *ctx) {
579  BN_CTX_start(ctx);
580  BIGNUM *tmp = BN_CTX_get(ctx);
581  // |BN_mod_mul_montgomery| removes a factor of R, so we cancel it with a
582  // single |BN_to_montgomery| which adds one factor of R.
583  int ok = tmp != NULL &&
584  BN_to_montgomery(tmp, a, mont, ctx) &&
585  BN_mod_mul_montgomery(r, tmp, b, mont, ctx);
586  BN_CTX_end(ctx);
587  return ok;
588 }
589 
590 DSA_SIG *DSA_do_sign(const uint8_t *digest, size_t digest_len, const DSA *dsa) {
591  if (!dsa_check_parameters(dsa)) {
592  return NULL;
593  }
594 
595  BIGNUM *kinv = NULL, *r = NULL, *s = NULL;
596  BIGNUM m;
597  BIGNUM xr;
598  BN_CTX *ctx = NULL;
599  DSA_SIG *ret = NULL;
600 
601  BN_init(&m);
602  BN_init(&xr);
603  s = BN_new();
604  if (s == NULL) {
605  goto err;
606  }
607  ctx = BN_CTX_new();
608  if (ctx == NULL) {
609  goto err;
610  }
611 
612 redo:
613  if (!dsa_sign_setup(dsa, ctx, &kinv, &r)) {
614  goto err;
615  }
616 
617  if (digest_len > BN_num_bytes(dsa->q)) {
618  // If the digest length is greater than the size of |dsa->q| use the
619  // BN_num_bits(dsa->q) leftmost bits of the digest, see FIPS 186-3, 4.2.
620  // Note the above check that |dsa->q| is a multiple of 8 bits.
621  digest_len = BN_num_bytes(dsa->q);
622  }
623 
624  if (BN_bin2bn(digest, digest_len, &m) == NULL) {
625  goto err;
626  }
627 
628  // |m| is bounded by 2^(num_bits(q)), which is slightly looser than q. This
629  // violates |bn_mod_add_consttime| and |mod_mul_consttime|'s preconditions.
630  // (The underlying algorithms could accept looser bounds, but we reduce for
631  // simplicity.)
632  size_t q_width = bn_minimal_width(dsa->q);
633  if (!bn_resize_words(&m, q_width) ||
634  !bn_resize_words(&xr, q_width)) {
635  goto err;
636  }
637  bn_reduce_once_in_place(m.d, 0 /* no carry word */, dsa->q->d,
638  xr.d /* scratch space */, q_width);
639 
640  // Compute s = inv(k) (m + xr) mod q. Note |dsa->method_mont_q| is
641  // initialized by |dsa_sign_setup|.
642  if (!mod_mul_consttime(&xr, dsa->priv_key, r, dsa->method_mont_q, ctx) ||
643  !bn_mod_add_consttime(s, &xr, &m, dsa->q, ctx) ||
644  !mod_mul_consttime(s, s, kinv, dsa->method_mont_q, ctx)) {
645  goto err;
646  }
647 
648  // Redo if r or s is zero as required by FIPS 186-3: this is
649  // very unlikely.
650  if (BN_is_zero(r) || BN_is_zero(s)) {
651  goto redo;
652  }
653  ret = DSA_SIG_new();
654  if (ret == NULL) {
655  goto err;
656  }
657  ret->r = r;
658  ret->s = s;
659 
660 err:
661  if (ret == NULL) {
663  BN_free(r);
664  BN_free(s);
665  }
666  BN_CTX_free(ctx);
667  BN_clear_free(&m);
668  BN_clear_free(&xr);
669  BN_clear_free(kinv);
670 
671  return ret;
672 }
673 
674 int DSA_do_verify(const uint8_t *digest, size_t digest_len, DSA_SIG *sig,
675  const DSA *dsa) {
676  int valid;
677  if (!DSA_do_check_signature(&valid, digest, digest_len, sig, dsa)) {
678  return -1;
679  }
680  return valid;
681 }
682 
683 int DSA_do_check_signature(int *out_valid, const uint8_t *digest,
684  size_t digest_len, DSA_SIG *sig, const DSA *dsa) {
685  *out_valid = 0;
686  if (!dsa_check_parameters(dsa)) {
687  return 0;
688  }
689 
690  int ret = 0;
691  BIGNUM u1, u2, t1;
692  BN_init(&u1);
693  BN_init(&u2);
694  BN_init(&t1);
695  BN_CTX *ctx = BN_CTX_new();
696  if (ctx == NULL) {
697  goto err;
698  }
699 
700  if (BN_is_zero(sig->r) || BN_is_negative(sig->r) ||
701  BN_ucmp(sig->r, dsa->q) >= 0) {
702  ret = 1;
703  goto err;
704  }
705  if (BN_is_zero(sig->s) || BN_is_negative(sig->s) ||
706  BN_ucmp(sig->s, dsa->q) >= 0) {
707  ret = 1;
708  goto err;
709  }
710 
711  // Calculate W = inv(S) mod Q
712  // save W in u2
713  if (BN_mod_inverse(&u2, sig->s, dsa->q, ctx) == NULL) {
714  goto err;
715  }
716 
717  // save M in u1
718  unsigned q_bits = BN_num_bits(dsa->q);
719  if (digest_len > (q_bits >> 3)) {
720  // if the digest length is greater than the size of q use the
721  // BN_num_bits(dsa->q) leftmost bits of the digest, see
722  // fips 186-3, 4.2
723  digest_len = (q_bits >> 3);
724  }
725 
726  if (BN_bin2bn(digest, digest_len, &u1) == NULL) {
727  goto err;
728  }
729 
730  // u1 = M * w mod q
731  if (!BN_mod_mul(&u1, &u1, &u2, dsa->q, ctx)) {
732  goto err;
733  }
734 
735  // u2 = r * w mod q
736  if (!BN_mod_mul(&u2, sig->r, &u2, dsa->q, ctx)) {
737  goto err;
738  }
739 
741  (CRYPTO_MUTEX *)&dsa->method_mont_lock, dsa->p,
742  ctx)) {
743  goto err;
744  }
745 
746  if (!BN_mod_exp2_mont(&t1, dsa->g, &u1, dsa->pub_key, &u2, dsa->p, ctx,
747  dsa->method_mont_p)) {
748  goto err;
749  }
750 
751  // BN_copy(&u1,&t1);
752  // let u1 = u1 mod q
753  if (!BN_mod(&u1, &t1, dsa->q, ctx)) {
754  goto err;
755  }
756 
757  // V is now in u1. If the signature is correct, it will be
758  // equal to R.
759  *out_valid = BN_ucmp(&u1, sig->r) == 0;
760  ret = 1;
761 
762 err:
763  if (ret != 1) {
765  }
766  BN_CTX_free(ctx);
767  BN_free(&u1);
768  BN_free(&u2);
769  BN_free(&t1);
770 
771  return ret;
772 }
773 
774 int DSA_sign(int type, const uint8_t *digest, size_t digest_len,
775  uint8_t *out_sig, unsigned int *out_siglen, const DSA *dsa) {
776  DSA_SIG *s;
777 
778  s = DSA_do_sign(digest, digest_len, dsa);
779  if (s == NULL) {
780  *out_siglen = 0;
781  return 0;
782  }
783 
784  *out_siglen = i2d_DSA_SIG(s, &out_sig);
785  DSA_SIG_free(s);
786  return 1;
787 }
788 
789 int DSA_verify(int type, const uint8_t *digest, size_t digest_len,
790  const uint8_t *sig, size_t sig_len, const DSA *dsa) {
791  int valid;
792  if (!DSA_check_signature(&valid, digest, digest_len, sig, sig_len, dsa)) {
793  return -1;
794  }
795  return valid;
796 }
797 
798 int DSA_check_signature(int *out_valid, const uint8_t *digest,
799  size_t digest_len, const uint8_t *sig, size_t sig_len,
800  const DSA *dsa) {
801  DSA_SIG *s = NULL;
802  int ret = 0;
803  uint8_t *der = NULL;
804 
805  s = DSA_SIG_new();
806  if (s == NULL) {
807  goto err;
808  }
809 
810  const uint8_t *sigp = sig;
811  if (d2i_DSA_SIG(&s, &sigp, sig_len) == NULL || sigp != sig + sig_len) {
812  goto err;
813  }
814 
815  // Ensure that the signature uses DER and doesn't have trailing garbage.
816  int der_len = i2d_DSA_SIG(s, &der);
817  if (der_len < 0 || (size_t)der_len != sig_len ||
818  OPENSSL_memcmp(sig, der, sig_len)) {
819  goto err;
820  }
821 
822  ret = DSA_do_check_signature(out_valid, digest, digest_len, s, dsa);
823 
824 err:
825  OPENSSL_free(der);
826  DSA_SIG_free(s);
827  return ret;
828 }
829 
830 // der_len_len returns the number of bytes needed to represent a length of |len|
831 // in DER.
832 static size_t der_len_len(size_t len) {
833  if (len < 0x80) {
834  return 1;
835  }
836  size_t ret = 1;
837  while (len > 0) {
838  ret++;
839  len >>= 8;
840  }
841  return ret;
842 }
843 
844 int DSA_size(const DSA *dsa) {
845  size_t order_len = BN_num_bytes(dsa->q);
846  // Compute the maximum length of an |order_len| byte integer. Defensively
847  // assume that the leading 0x00 is included.
848  size_t integer_len = 1 /* tag */ + der_len_len(order_len + 1) + 1 + order_len;
849  if (integer_len < order_len) {
850  return 0;
851  }
852  // A DSA signature is two INTEGERs.
853  size_t value_len = 2 * integer_len;
854  if (value_len < integer_len) {
855  return 0;
856  }
857  // Add the header.
858  size_t ret = 1 /* tag */ + der_len_len(value_len) + value_len;
859  if (ret < value_len) {
860  return 0;
861  }
862  return ret;
863 }
864 
865 static int dsa_sign_setup(const DSA *dsa, BN_CTX *ctx, BIGNUM **out_kinv,
866  BIGNUM **out_r) {
867  if (!dsa->p || !dsa->q || !dsa->g) {
869  return 0;
870  }
871 
872  int ret = 0;
873  BIGNUM k;
874  BN_init(&k);
875  BIGNUM *r = BN_new();
876  BIGNUM *kinv = BN_new();
877  if (r == NULL || kinv == NULL ||
878  // Get random k
879  !BN_rand_range_ex(&k, 1, dsa->q) ||
881  (CRYPTO_MUTEX *)&dsa->method_mont_lock, dsa->p,
882  ctx) ||
884  (CRYPTO_MUTEX *)&dsa->method_mont_lock, dsa->q,
885  ctx) ||
886  // Compute r = (g^k mod p) mod q
887  !BN_mod_exp_mont_consttime(r, dsa->g, &k, dsa->p, ctx,
888  dsa->method_mont_p) ||
889  // Note |BN_mod| below is not constant-time and may leak information about
890  // |r|. |dsa->p| may be significantly larger than |dsa->q|, so this is not
891  // easily performed in constant-time with Montgomery reduction.
892  //
893  // However, |r| at this point is g^k (mod p). It is almost the value of
894  // |r| revealed in the signature anyway (g^k (mod p) (mod q)), going from
895  // it to |k| would require computing a discrete log.
896  !BN_mod(r, r, dsa->q, ctx) ||
897  // Compute part of 's = inv(k) (m + xr) mod q' using Fermat's Little
898  // Theorem.
899  !bn_mod_inverse_prime(kinv, &k, dsa->q, ctx, dsa->method_mont_q)) {
901  goto err;
902  }
903 
904  BN_clear_free(*out_kinv);
905  *out_kinv = kinv;
906  kinv = NULL;
907 
908  BN_clear_free(*out_r);
909  *out_r = r;
910  r = NULL;
911 
912  ret = 1;
913 
914 err:
915  BN_clear_free(&k);
916  BN_clear_free(r);
917  BN_clear_free(kinv);
918  return ret;
919 }
920 
921 int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused,
922  CRYPTO_EX_dup *dup_unused, CRYPTO_EX_free *free_func) {
923  int index;
925  free_func)) {
926  return -1;
927  }
928  return index;
929 }
930 
931 int DSA_set_ex_data(DSA *dsa, int idx, void *arg) {
932  return CRYPTO_set_ex_data(&dsa->ex_data, idx, arg);
933 }
934 
935 void *DSA_get_ex_data(const DSA *dsa, int idx) {
936  return CRYPTO_get_ex_data(&dsa->ex_data, idx);
937 }
938 
939 DH *DSA_dup_DH(const DSA *dsa) {
940  if (dsa == NULL) {
941  return NULL;
942  }
943 
944  DH *ret = DH_new();
945  if (ret == NULL) {
946  goto err;
947  }
948  if (dsa->q != NULL) {
949  ret->priv_length = BN_num_bits(dsa->q);
950  if ((ret->q = BN_dup(dsa->q)) == NULL) {
951  goto err;
952  }
953  }
954  if ((dsa->p != NULL && (ret->p = BN_dup(dsa->p)) == NULL) ||
955  (dsa->g != NULL && (ret->g = BN_dup(dsa->g)) == NULL) ||
956  (dsa->pub_key != NULL && (ret->pub_key = BN_dup(dsa->pub_key)) == NULL) ||
957  (dsa->priv_key != NULL &&
958  (ret->priv_key = BN_dup(dsa->priv_key)) == NULL)) {
959  goto err;
960  }
961 
962  return ret;
963 
964 err:
965  DH_free(ret);
966  return NULL;
967 }
bn.h
DSA_verify
int DSA_verify(int type, const uint8_t *digest, size_t digest_len, const uint8_t *sig, size_t sig_len, const DSA *dsa)
Definition: dsa.c:789
test_server.argp
argp
Definition: test_server.py:33
DH_free
#define DH_free
Definition: boringssl_prefix_symbols.h:1224
DSS_prime_checks
#define DSS_prime_checks
Definition: dsa.c:82
RAND_bytes
#define RAND_bytes
Definition: boringssl_prefix_symbols.h:2060
CRYPTO_EX_DATA_CLASS_INIT
#define CRYPTO_EX_DATA_CLASS_INIT
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:687
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
DSA_set_ex_data
int DSA_set_ex_data(DSA *dsa, int idx, void *arg)
Definition: dsa.c:931
X
#define X(c)
ctx
Definition: benchmark-async.c:30
DSA_dup_DH
DH * DSA_dup_DH(const DSA *dsa)
Definition: dsa.c:939
BN_dup
#define BN_dup
Definition: boringssl_prefix_symbols.h:919
DSA_up_ref
int DSA_up_ref(DSA *dsa)
Definition: dsa.c:128
bn_resize_words
#define bn_resize_words
Definition: boringssl_prefix_symbols.h:2899
dsa_st::references
CRYPTO_refcount_t references
Definition: dsa.h:412
DSA_SIG_st::s
BIGNUM * s
Definition: dsa.h:182
CRYPTO_EX_dup
int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, void **from_d, int index, long argl, void *argp)
Definition: ex_data.h:184
BN_clear_free
#define BN_clear_free
Definition: boringssl_prefix_symbols.h:911
env_md_st
Definition: third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/internal.h:67
BN_mask_bits
#define BN_mask_bits
Definition: boringssl_prefix_symbols.h:945
CRYPTO_EX_DATA_CLASS
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:679
DSA_get0_p
const BIGNUM * DSA_get0_p(const DSA *dsa)
Definition: dsa.c:137
test
Definition: spinlock_test.cc:36
BN_bin2bn
#define BN_bin2bn
Definition: boringssl_prefix_symbols.h:900
OPENSSL_PUT_ERROR
#define OPENSSL_PUT_ERROR(library, reason)
Definition: err.h:423
bn_mod_inverse_prime
#define bn_mod_inverse_prime
Definition: boringssl_prefix_symbols.h:2875
string.h
seed
static const uint8_t seed[20]
Definition: dsa_test.cc:79
buf
voidpf void * buf
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
error_ref_leak.err
err
Definition: error_ref_leak.py:35
dsa_st::ex_data
CRYPTO_EX_DATA ex_data
Definition: dsa.h:413
DSA_get_ex_new_index
int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_unused *unused, CRYPTO_EX_dup *dup_unused, CRYPTO_EX_free *free_func)
Definition: dsa.c:921
DSA_get0_g
const BIGNUM * DSA_get0_g(const DSA *dsa)
Definition: dsa.c:141
BN_mod
#define BN_mod(rem, numerator, divisor, ctx)
Definition: bn.h:527
bn_mont_ctx_st
Definition: bn.h:984
DSA_check_signature
int DSA_check_signature(int *out_valid, const uint8_t *digest, size_t digest_len, const uint8_t *sig, size_t sig_len, const DSA *dsa)
Definition: dsa.c:798
BN_free
#define BN_free
Definition: boringssl_prefix_symbols.h:923
BN_GENCB_GENERATED
#define BN_GENCB_GENERATED
Definition: bn.h:635
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
DSA_do_verify
int DSA_do_verify(const uint8_t *digest, size_t digest_len, DSA_SIG *sig, const DSA *dsa)
Definition: dsa.c:674
internal.h
bignum_ctx
Definition: ctx.c:91
BN_CTX_get
#define BN_CTX_get
Definition: boringssl_prefix_symbols.h:884
xds_manager.p
p
Definition: xds_manager.py:60
DSA_get0_pqg
void DSA_get0_pqg(const DSA *dsa, const BIGNUM **out_p, const BIGNUM **out_q, const BIGNUM **out_g)
Definition: dsa.c:153
dsa_st::method_mont_lock
CRYPTO_MUTEX method_mont_lock
Definition: dsa.h:409
BN_num_bytes
#define BN_num_bytes
Definition: boringssl_prefix_symbols.h:976
CRYPTO_MUTEX_init
#define CRYPTO_MUTEX_init
Definition: boringssl_prefix_symbols.h:1124
BN_set_word
#define BN_set_word
Definition: boringssl_prefix_symbols.h:992
EVP_sha256
const OPENSSL_EXPORT EVP_MD * EVP_sha256(void)
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
setup.k
k
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
DSAparams_dup
DSA * DSAparams_dup(const DSA *dsa)
Definition: dsa.c:464
BN_sub
#define BN_sub
Definition: boringssl_prefix_symbols.h:995
OPENSSL_memset
static void * OPENSSL_memset(void *dst, int c, size_t n)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:835
BN_to_montgomery
#define BN_to_montgomery
Definition: boringssl_prefix_symbols.h:999
BN_value_one
const OPENSSL_EXPORT BIGNUM * BN_value_one(void)
dsa_check_parameters
#define dsa_check_parameters
Definition: boringssl_prefix_symbols.h:3057
BN_lshift
#define BN_lshift
Definition: boringssl_prefix_symbols.h:942
bn_minimal_width
#define bn_minimal_width
Definition: boringssl_prefix_symbols.h:2868
CRYPTO_free_ex_data
#define CRYPTO_free_ex_data
Definition: boringssl_prefix_symbols.h:1151
OPENSSL_malloc
#define OPENSSL_malloc
Definition: boringssl_prefix_symbols.h:1885
DSA_SIG_st::r
BIGNUM * r
Definition: dsa.h:182
dh.h
W
#define W
Definition: zlib/crc32.c:85
c
void c(T a)
Definition: miscompile_with_no_unique_address_test.cc:40
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
DSA_set0_key
int DSA_set0_key(DSA *dsa, BIGNUM *pub_key, BIGNUM *priv_key)
Definition: dsa.c:166
DSA_SIG_set0
int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s)
Definition: dsa.c:563
dsa_st::p
BIGNUM * p
Definition: dsa.h:400
BN_mod_exp_mont
#define BN_mod_exp_mont
Definition: boringssl_prefix_symbols.h:950
DSA_do_check_signature
int DSA_do_check_signature(int *out_valid, const uint8_t *digest, size_t digest_len, DSA_SIG *sig, const DSA *dsa)
Definition: dsa.c:683
EVP_MD_size
#define EVP_MD_size
Definition: boringssl_prefix_symbols.h:1579
sha.h
dsa_st::q
BIGNUM * q
Definition: dsa.h:401
OPENSSL_memcpy
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
Definition: third_party/boringssl-with-bazel/src/crypto/internal.h:819
bits
OPENSSL_EXPORT ASN1_BIT_STRING * bits
Definition: x509v3.h:482
err.h
counter
static int counter
Definition: abseil-cpp/absl/flags/reflection_test.cc:131
valid
@ valid
Definition: base64_test.cc:37
arg
Definition: cmdline.cc:40
CRYPTO_EX_unused
int CRYPTO_EX_unused
Definition: ex_data.h:192
CRYPTO_new_ex_data
#define CRYPTO_new_ex_data
Definition: boringssl_prefix_symbols.h:1179
BN_GENCB_call
#define BN_GENCB_call
Definition: boringssl_prefix_symbols.h:887
BN_mod_inverse
#define BN_mod_inverse
Definition: boringssl_prefix_symbols.h:953
BN_mod_mul
#define BN_mod_mul
Definition: boringssl_prefix_symbols.h:960
dsa.h
ERR_R_BN_LIB
#define ERR_R_BN_LIB
Definition: err.h:331
DSA_SIG_new
DSA_SIG * DSA_SIG_new(void)
Definition: dsa.c:532
der_len_len
static size_t der_len_len(size_t len)
Definition: dsa.c:832
BN_ucmp
#define BN_ucmp
Definition: boringssl_prefix_symbols.h:1001
dsa_st::priv_key
BIGNUM * priv_key
Definition: dsa.h:405
BN_is_zero
#define BN_is_zero
Definition: boringssl_prefix_symbols.h:940
BN_CTX_new
#define BN_CTX_new
Definition: boringssl_prefix_symbols.h:885
DSA_get0_priv_key
const BIGNUM * DSA_get0_priv_key(const DSA *dsa)
Definition: dsa.c:135
DSA_get0_q
const BIGNUM * DSA_get0_q(const DSA *dsa)
Definition: dsa.c:139
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
DSA_SIG_st
Definition: dsa.h:181
g
struct @717 g
dsa_st::method_mont_q
BN_MONT_CTX * method_mont_q
Definition: dsa.h:411
CRYPTO_EX_free
void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int index, long argl, void *argp)
Definition: ex_data.h:174
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
DSA_generate_key
int DSA_generate_key(DSA *dsa)
Definition: dsa.c:479
setup.idx
idx
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:197
BN_MONT_CTX_set_locked
#define BN_MONT_CTX_set_locked
Definition: boringssl_prefix_symbols.h:895
BN_MONT_CTX_new_for_modulus
#define BN_MONT_CTX_new_for_modulus
Definition: boringssl_prefix_symbols.h:893
bn_gencb_st
Definition: bn.h:656
g_ex_data_class
static CRYPTO_EX_DATA_CLASS g_ex_data_class
Definition: dsa.c:87
BN_copy
#define BN_copy
Definition: boringssl_prefix_symbols.h:914
BN_num_bits
#define BN_num_bits
Definition: boringssl_prefix_symbols.h:974
DSA_free
void DSA_free(DSA *dsa)
Definition: dsa.c:106
CRYPTO_get_ex_data
#define CRYPTO_get_ex_data
Definition: boringssl_prefix_symbols.h:1164
dsa_sign_setup
static int dsa_sign_setup(const DSA *dsa, BN_CTX *ctx_in, BIGNUM **out_kinv, BIGNUM **out_r)
Definition: dsa.c:865
BN_zero
#define BN_zero
Definition: boringssl_prefix_symbols.h:1004
update_failure_list.test
test
Definition: bloaty/third_party/protobuf/conformance/update_failure_list.py:69
CRYPTO_MUTEX_cleanup
#define CRYPTO_MUTEX_cleanup
Definition: boringssl_prefix_symbols.h:1123
benchmark.md
md
Definition: benchmark.py:86
BN_lshift1
#define BN_lshift1
Definition: boringssl_prefix_symbols.h:943
rand.h
digest.h
CRYPTO_get_ex_new_index
#define CRYPTO_get_ex_new_index
Definition: boringssl_prefix_symbols.h:1165
EVP_Digest
#define EVP_Digest
Definition: boringssl_prefix_symbols.h:1506
DH_new
#define DH_new
Definition: boringssl_prefix_symbols.h:1236
DSA_do_sign
DSA_SIG * DSA_do_sign(const uint8_t *digest, size_t digest_len, const DSA *dsa)
Definition: dsa.c:590
BN_CTX_start
#define BN_CTX_start
Definition: boringssl_prefix_symbols.h:886
bignum_st
Definition: bn.h:957
BN_is_one
#define BN_is_one
Definition: boringssl_prefix_symbols.h:935
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
BN_CTX_free
#define BN_CTX_free
Definition: boringssl_prefix_symbols.h:883
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
DSA_get0_key
void DSA_get0_key(const DSA *dsa, const BIGNUM **out_pub_key, const BIGNUM **out_priv_key)
Definition: dsa.c:143
dsa_st::method_mont_p
BN_MONT_CTX * method_mont_p
Definition: dsa.h:410
SHA256_DIGEST_LENGTH
#define SHA256_DIGEST_LENGTH
Definition: sha.h:155
fix_build_deps.r
r
Definition: fix_build_deps.py:491
bignum_st::d
BN_ULONG * d
Definition: bn.h:960
DSA_get0_pub_key
const BIGNUM * DSA_get0_pub_key(const DSA *dsa)
Definition: dsa.c:133
BN_cmp
#define BN_cmp
Definition: boringssl_prefix_symbols.h:912
BN_mod_exp_mont_consttime
#define BN_mod_exp_mont_consttime
Definition: boringssl_prefix_symbols.h:951
dsa_st
Definition: dsa.h:398
BN_rand_range_ex
#define BN_rand_range_ex
Definition: boringssl_prefix_symbols.h:986
ok
bool ok
Definition: async_end2end_test.cc:197
BN_is_prime_fasttest_ex
#define BN_is_prime_fasttest_ex
Definition: boringssl_prefix_symbols.h:938
dsa_st::g
BIGNUM * g
Definition: dsa.h:402
EVP_sha1
const OPENSSL_EXPORT EVP_MD * EVP_sha1(void)
BN_init
#define BN_init
Definition: boringssl_prefix_symbols.h:931
buf2
static char buf2[32]
Definition: test-fs.c:127
BN_is_negative
#define BN_is_negative
Definition: boringssl_prefix_symbols.h:933
BN_MONT_CTX_free
#define BN_MONT_CTX_free
Definition: boringssl_prefix_symbols.h:890
engine.h
DSA_sign
int DSA_sign(int type, const uint8_t *digest, size_t digest_len, uint8_t *out_sig, unsigned int *out_siglen, const DSA *dsa)
Definition: dsa.c:774
CRYPTO_refcount_inc
#define CRYPTO_refcount_inc
Definition: boringssl_prefix_symbols.h:1191
BN_CTX_end
#define BN_CTX_end
Definition: boringssl_prefix_symbols.h:882
DSA_set0_pqg
int DSA_set0_pqg(DSA *dsa, BIGNUM *p, BIGNUM *q, BIGNUM *g)
Definition: dsa.c:183
DSA_new
DSA * DSA_new(void)
Definition: dsa.c:89
dsa_st::pub_key
BIGNUM * pub_key
Definition: dsa.h:404
BN_add
#define BN_add
Definition: boringssl_prefix_symbols.h:897
dh_st
Definition: dh.h:305
mem.h
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
ex_data.h
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
i2d_DSA_SIG
#define i2d_DSA_SIG
Definition: boringssl_prefix_symbols.h:3217
bn_mod_add_consttime
#define bn_mod_add_consttime
Definition: boringssl_prefix_symbols.h:2869
DSA_SIG_get0
void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **out_r, const BIGNUM **out_s)
Definition: dsa.c:553
CRYPTO_set_ex_data
#define CRYPTO_set_ex_data
Definition: boringssl_prefix_symbols.h:1196
BN_mod_mul_montgomery
#define BN_mod_mul_montgomery
Definition: boringssl_prefix_symbols.h:961
regress.m
m
Definition: regress/regress.py:25
BN_mod_exp2_mont
#define BN_mod_exp2_mont
Definition: boringssl_prefix_symbols.h:949
thread.h
DSA_generate_parameters_ex
int DSA_generate_parameters_ex(DSA *dsa, unsigned bits, const uint8_t *seed_in, size_t seed_len, int *out_counter, unsigned long *out_h, BN_GENCB *cb)
Definition: dsa.c:206
t1
Table t1
Definition: abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc:185
OPENSSL_free
#define OPENSSL_free
Definition: boringssl_prefix_symbols.h:1869
d2i_DSA_SIG
#define d2i_DSA_SIG
Definition: boringssl_prefix_symbols.h:2978
crypto_mutex_st
Definition: thread.h:70
DSA_R_MISSING_PARAMETERS
#define DSA_R_MISSING_PARAMETERS
Definition: dsa.h:435
BN_div
#define BN_div
Definition: boringssl_prefix_symbols.h:917
BN_new
#define BN_new
Definition: boringssl_prefix_symbols.h:971
mod_mul_consttime
static int mod_mul_consttime(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BN_MONT_CTX *mont, BN_CTX *ctx)
Definition: dsa.c:577
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
DSA_get_ex_data
void * DSA_get_ex_data(const DSA *dsa, int idx)
Definition: dsa.c:935
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
ERR_R_MALLOC_FAILURE
#define ERR_R_MALLOC_FAILURE
Definition: err.h:371
bn_reduce_once_in_place
#define bn_reduce_once_in_place
Definition: boringssl_prefix_symbols.h:2898
DSA_SIG_free
void DSA_SIG_free(DSA_SIG *sig)
Definition: dsa.c:543
DSA_size
int DSA_size(const DSA *dsa)
Definition: dsa.c:844
CRYPTO_refcount_dec_and_test_zero
#define CRYPTO_refcount_dec_and_test_zero
Definition: boringssl_prefix_symbols.h:1190


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:13