1 /* $OpenBSD: dsa_ameth.c,v 1.35 2022/04/07 17:38:24 tb Exp $ */ 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * project 2006. 4 */ 5 /* ==================================================================== 6 * Copyright (c) 2006 The OpenSSL Project. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. All advertising materials mentioning features or use of this 21 * software must display the following acknowledgment: 22 * "This product includes software developed by the OpenSSL Project 23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24 * 25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26 * endorse or promote products derived from this software without 27 * prior written permission. For written permission, please contact 28 * licensing@OpenSSL.org. 29 * 30 * 5. Products derived from this software may not be called "OpenSSL" 31 * nor may "OpenSSL" appear in their names without prior written 32 * permission of the OpenSSL Project. 33 * 34 * 6. Redistributions of any form whatsoever must retain the following 35 * acknowledgment: 36 * "This product includes software developed by the OpenSSL Project 37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38 * 39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50 * OF THE POSSIBILITY OF SUCH DAMAGE. 51 * ==================================================================== 52 * 53 * This product includes cryptographic software written by Eric Young 54 * (eay@cryptsoft.com). This product includes software written by Tim 55 * Hudson (tjh@cryptsoft.com). 56 * 57 */ 58 59 #include <stdio.h> 60 61 #include <openssl/opensslconf.h> 62 63 #include <openssl/asn1.h> 64 #include <openssl/bn.h> 65 #include <openssl/cms.h> 66 #include <openssl/dsa.h> 67 #include <openssl/err.h> 68 #include <openssl/x509.h> 69 70 #include "asn1_locl.h" 71 #include "bn_lcl.h" 72 #include "dsa_locl.h" 73 #include "evp_locl.h" 74 75 static int 76 dsa_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey) 77 { 78 const unsigned char *p, *pm; 79 int pklen, pmlen; 80 int ptype; 81 const void *pval; 82 const ASN1_STRING *pstr; 83 X509_ALGOR *palg; 84 ASN1_INTEGER *public_key = NULL; 85 86 DSA *dsa = NULL; 87 88 if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, &palg, pubkey)) 89 return 0; 90 X509_ALGOR_get0(NULL, &ptype, &pval, palg); 91 92 if (ptype == V_ASN1_SEQUENCE) { 93 pstr = pval; 94 pm = pstr->data; 95 pmlen = pstr->length; 96 97 if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) { 98 DSAerror(DSA_R_DECODE_ERROR); 99 goto err; 100 } 101 } else if (ptype == V_ASN1_NULL || ptype == V_ASN1_UNDEF) { 102 if (!(dsa = DSA_new())) { 103 DSAerror(ERR_R_MALLOC_FAILURE); 104 goto err; 105 } 106 } else { 107 DSAerror(DSA_R_PARAMETER_ENCODING_ERROR); 108 goto err; 109 } 110 111 if (!(public_key=d2i_ASN1_INTEGER(NULL, &p, pklen))) { 112 DSAerror(DSA_R_DECODE_ERROR); 113 goto err; 114 } 115 116 if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { 117 DSAerror(DSA_R_BN_DECODE_ERROR); 118 goto err; 119 } 120 121 ASN1_INTEGER_free(public_key); 122 EVP_PKEY_assign_DSA(pkey, dsa); 123 return 1; 124 125 err: 126 if (public_key) 127 ASN1_INTEGER_free(public_key); 128 DSA_free(dsa); 129 return 0; 130 } 131 132 static int 133 dsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) 134 { 135 DSA *dsa; 136 ASN1_INTEGER *pubint = NULL; 137 ASN1_STRING *str = NULL; 138 int ptype = V_ASN1_UNDEF; 139 unsigned char *penc = NULL; 140 int penclen; 141 142 dsa = pkey->pkey.dsa; 143 if (pkey->save_parameters && dsa->p && dsa->q && dsa->g) { 144 if ((str = ASN1_STRING_new()) == NULL) { 145 DSAerror(ERR_R_MALLOC_FAILURE); 146 goto err; 147 } 148 str->length = i2d_DSAparams(dsa, &str->data); 149 if (str->length <= 0) { 150 DSAerror(ERR_R_MALLOC_FAILURE); 151 goto err; 152 } 153 ptype = V_ASN1_SEQUENCE; 154 } 155 156 if ((pubint = BN_to_ASN1_INTEGER(dsa->pub_key, NULL)) == NULL) { 157 DSAerror(ERR_R_MALLOC_FAILURE); 158 goto err; 159 } 160 161 penclen = i2d_ASN1_INTEGER(pubint, &penc); 162 ASN1_INTEGER_free(pubint); 163 164 if (penclen <= 0) { 165 DSAerror(ERR_R_MALLOC_FAILURE); 166 goto err; 167 } 168 169 if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(EVP_PKEY_DSA), ptype, str, 170 penc, penclen)) 171 return 1; 172 173 err: 174 free(penc); 175 ASN1_STRING_free(str); 176 177 return 0; 178 } 179 180 /* In PKCS#8 DSA: you just get a private key integer and parameters in the 181 * AlgorithmIdentifier the pubkey must be recalculated. 182 */ 183 static int 184 dsa_priv_decode(EVP_PKEY *pkey, const PKCS8_PRIV_KEY_INFO *p8) 185 { 186 const unsigned char *p, *pm; 187 int pklen, pmlen; 188 int ptype; 189 const void *pval; 190 const ASN1_STRING *pstr; 191 const X509_ALGOR *palg; 192 ASN1_INTEGER *privkey = NULL; 193 BN_CTX *ctx = NULL; 194 DSA *dsa = NULL; 195 196 int ret = 0; 197 198 if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8)) 199 return 0; 200 X509_ALGOR_get0(NULL, &ptype, &pval, palg); 201 if (ptype != V_ASN1_SEQUENCE) 202 goto decerr; 203 204 if ((privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) 205 goto decerr; 206 if (privkey->type == V_ASN1_NEG_INTEGER) 207 goto decerr; 208 209 pstr = pval; 210 pm = pstr->data; 211 pmlen = pstr->length; 212 if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) 213 goto decerr; 214 /* We have parameters now set private key */ 215 if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { 216 DSAerror(DSA_R_BN_ERROR); 217 goto dsaerr; 218 } 219 /* Calculate public key */ 220 if (!(dsa->pub_key = BN_new())) { 221 DSAerror(ERR_R_MALLOC_FAILURE); 222 goto dsaerr; 223 } 224 if (!(ctx = BN_CTX_new())) { 225 DSAerror(ERR_R_MALLOC_FAILURE); 226 goto dsaerr; 227 } 228 229 if (!BN_mod_exp_ct(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) { 230 DSAerror(DSA_R_BN_ERROR); 231 goto dsaerr; 232 } 233 234 if (!EVP_PKEY_assign_DSA(pkey, dsa)) 235 goto decerr; 236 237 ret = 1; 238 goto done; 239 240 decerr: 241 DSAerror(DSA_R_DECODE_ERROR); 242 dsaerr: 243 DSA_free(dsa); 244 done: 245 BN_CTX_free(ctx); 246 ASN1_INTEGER_free(privkey); 247 return ret; 248 } 249 250 static int 251 dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) 252 { 253 ASN1_STRING *params = NULL; 254 ASN1_INTEGER *prkey = NULL; 255 unsigned char *dp = NULL; 256 int dplen; 257 258 params = ASN1_STRING_new(); 259 if (!params) { 260 DSAerror(ERR_R_MALLOC_FAILURE); 261 goto err; 262 } 263 264 params->length = i2d_DSAparams(pkey->pkey.dsa, ¶ms->data); 265 if (params->length <= 0) { 266 DSAerror(ERR_R_MALLOC_FAILURE); 267 goto err; 268 } 269 params->type = V_ASN1_SEQUENCE; 270 271 /* Get private key into integer */ 272 prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL); 273 if (!prkey) { 274 DSAerror(DSA_R_BN_ERROR); 275 goto err; 276 } 277 278 dplen = i2d_ASN1_INTEGER(prkey, &dp); 279 280 ASN1_INTEGER_free(prkey); 281 prkey = NULL; 282 283 if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0, V_ASN1_SEQUENCE, 284 params, dp, dplen)) 285 goto err; 286 287 return 1; 288 289 err: 290 free(dp); 291 ASN1_STRING_free(params); 292 ASN1_INTEGER_free(prkey); 293 return 0; 294 } 295 296 static int 297 int_dsa_size(const EVP_PKEY *pkey) 298 { 299 return DSA_size(pkey->pkey.dsa); 300 } 301 302 static int 303 dsa_bits(const EVP_PKEY *pkey) 304 { 305 return BN_num_bits(pkey->pkey.dsa->p); 306 } 307 308 static int 309 dsa_missing_parameters(const EVP_PKEY *pkey) 310 { 311 DSA *dsa; 312 313 dsa = pkey->pkey.dsa; 314 if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) 315 return 1; 316 return 0; 317 } 318 319 static int 320 dsa_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from) 321 { 322 BIGNUM *a; 323 324 if ((a = BN_dup(from->pkey.dsa->p)) == NULL) 325 return 0; 326 BN_free(to->pkey.dsa->p); 327 to->pkey.dsa->p = a; 328 329 if ((a = BN_dup(from->pkey.dsa->q)) == NULL) 330 return 0; 331 BN_free(to->pkey.dsa->q); 332 to->pkey.dsa->q = a; 333 334 if ((a = BN_dup(from->pkey.dsa->g)) == NULL) 335 return 0; 336 BN_free(to->pkey.dsa->g); 337 to->pkey.dsa->g = a; 338 return 1; 339 } 340 341 static int 342 dsa_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b) 343 { 344 if (BN_cmp(a->pkey.dsa->p, b->pkey.dsa->p) || 345 BN_cmp(a->pkey.dsa->q, b->pkey.dsa->q) || 346 BN_cmp(a->pkey.dsa->g, b->pkey.dsa->g)) 347 return 0; 348 else 349 return 1; 350 } 351 352 static int 353 dsa_pub_cmp(const EVP_PKEY *a, const EVP_PKEY *b) 354 { 355 if (BN_cmp(b->pkey.dsa->pub_key, a->pkey.dsa->pub_key) != 0) 356 return 0; 357 else 358 return 1; 359 } 360 361 static void 362 int_dsa_free(EVP_PKEY *pkey) 363 { 364 DSA_free(pkey->pkey.dsa); 365 } 366 367 static void 368 update_buflen(const BIGNUM *b, size_t *pbuflen) 369 { 370 size_t i; 371 372 if (!b) 373 return; 374 if (*pbuflen < (i = (size_t)BN_num_bytes(b))) 375 *pbuflen = i; 376 } 377 378 static int 379 do_dsa_print(BIO *bp, const DSA *x, int off, int ptype) 380 { 381 unsigned char *m = NULL; 382 int ret = 0; 383 size_t buf_len = 0; 384 const char *ktype = NULL; 385 const BIGNUM *priv_key, *pub_key; 386 387 if (ptype == 2) 388 priv_key = x->priv_key; 389 else 390 priv_key = NULL; 391 392 if (ptype > 0) 393 pub_key = x->pub_key; 394 else 395 pub_key = NULL; 396 397 if (ptype == 2) 398 ktype = "Private-Key"; 399 else if (ptype == 1) 400 ktype = "Public-Key"; 401 else 402 ktype = "DSA-Parameters"; 403 404 update_buflen(x->p, &buf_len); 405 update_buflen(x->q, &buf_len); 406 update_buflen(x->g, &buf_len); 407 update_buflen(priv_key, &buf_len); 408 update_buflen(pub_key, &buf_len); 409 410 m = malloc(buf_len + 10); 411 if (m == NULL) { 412 DSAerror(ERR_R_MALLOC_FAILURE); 413 goto err; 414 } 415 416 if (priv_key) { 417 if (!BIO_indent(bp, off, 128)) 418 goto err; 419 if (BIO_printf(bp, "%s: (%d bit)\n", ktype, 420 BN_num_bits(x->p)) <= 0) 421 goto err; 422 } 423 424 if (!ASN1_bn_print(bp, "priv:", priv_key, m, off)) 425 goto err; 426 if (!ASN1_bn_print(bp, "pub: ", pub_key, m, off)) 427 goto err; 428 if (!ASN1_bn_print(bp, "P: ", x->p, m, off)) 429 goto err; 430 if (!ASN1_bn_print(bp, "Q: ", x->q, m, off)) 431 goto err; 432 if (!ASN1_bn_print(bp, "G: ", x->g, m, off)) 433 goto err; 434 ret = 1; 435 err: 436 free(m); 437 return(ret); 438 } 439 440 static int 441 dsa_param_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) 442 { 443 DSA *dsa; 444 445 if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) { 446 DSAerror(ERR_R_DSA_LIB); 447 return 0; 448 } 449 EVP_PKEY_assign_DSA(pkey, dsa); 450 return 1; 451 } 452 453 static int 454 dsa_param_encode(const EVP_PKEY *pkey, unsigned char **pder) 455 { 456 return i2d_DSAparams(pkey->pkey.dsa, pder); 457 } 458 459 static int 460 dsa_param_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) 461 { 462 return do_dsa_print(bp, pkey->pkey.dsa, indent, 0); 463 } 464 465 static int 466 dsa_pub_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) 467 { 468 return do_dsa_print(bp, pkey->pkey.dsa, indent, 1); 469 } 470 471 static int 472 dsa_priv_print(BIO *bp, const EVP_PKEY *pkey, int indent, ASN1_PCTX *ctx) 473 { 474 return do_dsa_print(bp, pkey->pkey.dsa, indent, 2); 475 } 476 477 static int 478 old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder, int derlen) 479 { 480 DSA *dsa; 481 BN_CTX *ctx = NULL; 482 BIGNUM *j, *p1, *newp1, *powg; 483 int qbits; 484 485 if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) { 486 DSAerror(ERR_R_DSA_LIB); 487 return 0; 488 } 489 490 /* FIPS 186-3 allows only three different sizes for q. */ 491 qbits = BN_num_bits(dsa->q); 492 if (qbits != 160 && qbits != 224 && qbits != 256) { 493 DSAerror(DSA_R_BAD_Q_VALUE); 494 goto err; 495 } 496 if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS) { 497 DSAerror(DSA_R_MODULUS_TOO_LARGE); 498 goto err; 499 } 500 501 /* Check that 1 < g < p. */ 502 if (BN_cmp(dsa->g, BN_value_one()) <= 0 || 503 BN_cmp(dsa->g, dsa->p) >= 0) { 504 DSAerror(DSA_R_PARAMETER_ENCODING_ERROR); /* XXX */ 505 goto err; 506 } 507 508 ctx = BN_CTX_new(); 509 if (ctx == NULL) 510 goto err; 511 512 /* 513 * Check that p and q are consistent with each other. 514 */ 515 516 j = BN_CTX_get(ctx); 517 p1 = BN_CTX_get(ctx); 518 newp1 = BN_CTX_get(ctx); 519 powg = BN_CTX_get(ctx); 520 if (j == NULL || p1 == NULL || newp1 == NULL || powg == NULL) 521 goto err; 522 /* p1 = p - 1 */ 523 if (BN_sub(p1, dsa->p, BN_value_one()) == 0) 524 goto err; 525 /* j = (p - 1) / q */ 526 if (BN_div_ct(j, NULL, p1, dsa->q, ctx) == 0) 527 goto err; 528 /* q * j should == p - 1 */ 529 if (BN_mul(newp1, dsa->q, j, ctx) == 0) 530 goto err; 531 if (BN_cmp(newp1, p1) != 0) { 532 DSAerror(DSA_R_BAD_Q_VALUE); 533 goto err; 534 } 535 536 /* 537 * Check that g generates a multiplicative subgroup of order q. 538 * We only check that g^q == 1, so the order is a divisor of q. 539 * Once we know that q is prime, this is enough. 540 */ 541 542 if (!BN_mod_exp_ct(powg, dsa->g, dsa->q, dsa->p, ctx)) 543 goto err; 544 if (BN_cmp(powg, BN_value_one()) != 0) { 545 DSAerror(DSA_R_PARAMETER_ENCODING_ERROR); /* XXX */ 546 goto err; 547 } 548 549 /* 550 * Check that q is not a composite number. 551 */ 552 553 if (BN_is_prime_ex(dsa->q, BN_prime_checks, ctx, NULL) <= 0) { 554 DSAerror(DSA_R_BAD_Q_VALUE); 555 goto err; 556 } 557 558 BN_CTX_free(ctx); 559 560 EVP_PKEY_assign_DSA(pkey, dsa); 561 return 1; 562 563 err: 564 BN_CTX_free(ctx); 565 DSA_free(dsa); 566 return 0; 567 } 568 569 static int 570 old_dsa_priv_encode(const EVP_PKEY *pkey, unsigned char **pder) 571 { 572 return i2d_DSAPrivateKey(pkey->pkey.dsa, pder); 573 } 574 575 static int 576 dsa_sig_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig, 577 int indent, ASN1_PCTX *pctx) 578 { 579 DSA_SIG *dsa_sig; 580 const unsigned char *p; 581 582 if (!sig) { 583 if (BIO_puts(bp, "\n") <= 0) 584 return 0; 585 else 586 return 1; 587 } 588 p = sig->data; 589 dsa_sig = d2i_DSA_SIG(NULL, &p, sig->length); 590 if (dsa_sig) { 591 int rv = 0; 592 size_t buf_len = 0; 593 unsigned char *m = NULL; 594 595 update_buflen(dsa_sig->r, &buf_len); 596 update_buflen(dsa_sig->s, &buf_len); 597 m = malloc(buf_len + 10); 598 if (m == NULL) { 599 DSAerror(ERR_R_MALLOC_FAILURE); 600 goto err; 601 } 602 603 if (BIO_write(bp, "\n", 1) != 1) 604 goto err; 605 606 if (!ASN1_bn_print(bp, "r: ", dsa_sig->r, m, indent)) 607 goto err; 608 if (!ASN1_bn_print(bp, "s: ", dsa_sig->s, m, indent)) 609 goto err; 610 rv = 1; 611 err: 612 free(m); 613 DSA_SIG_free(dsa_sig); 614 return rv; 615 } 616 return X509_signature_dump(bp, sig, indent); 617 } 618 619 static int 620 dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) 621 { 622 switch (op) { 623 case ASN1_PKEY_CTRL_PKCS7_SIGN: 624 if (arg1 == 0) { 625 int snid, hnid; 626 X509_ALGOR *alg1, *alg2; 627 628 PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2); 629 if (alg1 == NULL || alg1->algorithm == NULL) 630 return -1; 631 hnid = OBJ_obj2nid(alg1->algorithm); 632 if (hnid == NID_undef) 633 return -1; 634 if (!OBJ_find_sigid_by_algs(&snid, hnid, 635 EVP_PKEY_id(pkey))) 636 return -1; 637 X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 638 0); 639 } 640 return 1; 641 642 #ifndef OPENSSL_NO_CMS 643 case ASN1_PKEY_CTRL_CMS_SIGN: 644 if (arg1 == 0) { 645 int snid, hnid; 646 X509_ALGOR *alg1, *alg2; 647 648 CMS_SignerInfo_get0_algs(arg2, NULL, NULL, &alg1, &alg2); 649 if (alg1 == NULL || alg1->algorithm == NULL) 650 return -1; 651 hnid = OBJ_obj2nid(alg1->algorithm); 652 if (hnid == NID_undef) 653 return -1; 654 if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) 655 return -1; 656 X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); 657 } 658 return 1; 659 660 case ASN1_PKEY_CTRL_CMS_RI_TYPE: 661 *(int *)arg2 = CMS_RECIPINFO_NONE; 662 return 1; 663 #endif 664 665 case ASN1_PKEY_CTRL_DEFAULT_MD_NID: 666 *(int *)arg2 = NID_sha1; 667 return 2; 668 669 default: 670 return -2; 671 } 672 } 673 674 /* NB these are sorted in pkey_id order, lowest first */ 675 676 const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = { 677 { 678 .pkey_id = EVP_PKEY_DSA2, 679 .pkey_base_id = EVP_PKEY_DSA, 680 .pkey_flags = ASN1_PKEY_ALIAS 681 }, 682 683 { 684 .pkey_id = EVP_PKEY_DSA1, 685 .pkey_base_id = EVP_PKEY_DSA, 686 .pkey_flags = ASN1_PKEY_ALIAS 687 }, 688 689 { 690 .pkey_id = EVP_PKEY_DSA4, 691 .pkey_base_id = EVP_PKEY_DSA, 692 .pkey_flags = ASN1_PKEY_ALIAS 693 }, 694 695 { 696 .pkey_id = EVP_PKEY_DSA3, 697 .pkey_base_id = EVP_PKEY_DSA, 698 .pkey_flags = ASN1_PKEY_ALIAS 699 }, 700 701 { 702 .pkey_id = EVP_PKEY_DSA, 703 .pkey_base_id = EVP_PKEY_DSA, 704 705 .pem_str = "DSA", 706 .info = "OpenSSL DSA method", 707 708 .pub_decode = dsa_pub_decode, 709 .pub_encode = dsa_pub_encode, 710 .pub_cmp = dsa_pub_cmp, 711 .pub_print = dsa_pub_print, 712 713 .priv_decode = dsa_priv_decode, 714 .priv_encode = dsa_priv_encode, 715 .priv_print = dsa_priv_print, 716 717 .pkey_size = int_dsa_size, 718 .pkey_bits = dsa_bits, 719 720 .param_decode = dsa_param_decode, 721 .param_encode = dsa_param_encode, 722 .param_missing = dsa_missing_parameters, 723 .param_copy = dsa_copy_parameters, 724 .param_cmp = dsa_cmp_parameters, 725 .param_print = dsa_param_print, 726 .sig_print = dsa_sig_print, 727 728 .pkey_free = int_dsa_free, 729 .pkey_ctrl = dsa_pkey_ctrl, 730 .old_priv_decode = old_dsa_priv_decode, 731 .old_priv_encode = old_dsa_priv_encode 732 } 733 }; 734