EVP_PKEY-DSA.pod 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY-DSA, EVP_KEYMGMT-DSA - EVP_PKEY DSA keytype and algorithm support
  4. =head1 DESCRIPTION
  5. For B<DSA> the FIPS186-4 standard specifies that the values used for FFC
  6. parameter generation are also required for parameter validation.
  7. This means that optional FFC domain parameter values for I<seed>, I<pcounter>
  8. and I<gindex> may need to be stored for validation purposes. For B<DSA> these
  9. fields are not stored in the ASN1 data so they need to be stored externally if
  10. validation is required.
  11. =head2 DSA parameters
  12. The B<DSA> key type supports the FFC parameters (see
  13. L<EVP_PKEY-FFC(7)/FFC parameters>).
  14. =head2 DSA key generation parameters
  15. The B<DSA> key type supports the FFC key generation parameters (see
  16. L<EVP_PKEY-FFC(7)/FFC key generation parameters>
  17. The following restrictions apply to the "pbits" field:
  18. For "fips186_4" this must be either 2048 or 3072.
  19. For "fips186_2" this must be 1024.
  20. For "group" this can be any one of 2048, 3072, 4096, 6144 or 8192.
  21. =head2 DSA key validation
  22. For DSA keys, L<EVP_PKEY_param_check(3)> behaves in the following way:
  23. The OpenSSL FIPS provider conforms to the rules within the FIPS186-4
  24. standard for FFC parameter validation. For backwards compatibility the OpenSSL
  25. default provider uses a much simpler check (see below) for parameter validation,
  26. unless the seed parameter is set.
  27. For DSA keys, L<EVP_PKEY_param_check_quick(3)> behaves in the following way:
  28. A simple check of L and N and partial g is performed. The default provider
  29. also supports validation of legacy "fips186_2" keys.
  30. For DSA keys, L<EVP_PKEY_public_check(3)>, L<EVP_PKEY_private_check(3)> and
  31. L<EVP_PKEY_pairwise_check(3)> the OpenSSL default and FIPS providers conform to
  32. the rules within SP800-56Ar3 for public, private and pairwise tests respectively.
  33. =head1 EXAMPLES
  34. An B<EVP_PKEY> context can be obtained by calling:
  35. EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
  36. The B<DSA> domain parameters can be generated by calling:
  37. unsigned int pbits = 2048;
  38. unsigned int qbits = 256;
  39. int gindex = 1;
  40. OSSL_PARAM params[5];
  41. EVP_PKEY *param_key = NULL;
  42. EVP_PKEY_CTX *pctx = NULL;
  43. pctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL);
  44. EVP_PKEY_paramgen_init(pctx);
  45. params[0] = OSSL_PARAM_construct_uint("pbits", &pbits);
  46. params[1] = OSSL_PARAM_construct_uint("qbits", &qbits);
  47. params[2] = OSSL_PARAM_construct_int("gindex", &gindex);
  48. params[3] = OSSL_PARAM_construct_utf8_string("digest", "SHA384", 0);
  49. params[4] = OSSL_PARAM_construct_end();
  50. EVP_PKEY_CTX_set_params(pctx, params);
  51. EVP_PKEY_generate(pctx, &param_key);
  52. EVP_PKEY_CTX_free(pctx);
  53. EVP_PKEY_print_params(bio_out, param_key, 0, NULL);
  54. A B<DSA> key can be generated using domain parameters by calling:
  55. EVP_PKEY *key = NULL;
  56. EVP_PKEY_CTX *gctx = NULL;
  57. gctx = EVP_PKEY_CTX_new_from_pkey(NULL, param_key, NULL);
  58. EVP_PKEY_keygen_init(gctx);
  59. EVP_PKEY_generate(gctx, &key);
  60. EVP_PKEY_CTX_free(gctx);
  61. EVP_PKEY_print_private(bio_out, key, 0, NULL);
  62. =head1 CONFORMING TO
  63. The following sections of FIPS186-4:
  64. =over 4
  65. =item A.1.1.2 Generation of Probable Primes p and q Using an Approved Hash Function.
  66. =item A.2.3 Generation of canonical generator g.
  67. =item A.2.1 Unverifiable Generation of the Generator g.
  68. =back
  69. =head1 SEE ALSO
  70. L<EVP_PKEY-FFC(7)>,
  71. L<EVP_SIGNATURE-DSA(7)>
  72. L<EVP_PKEY(3)>,
  73. L<provider-keymgmt(7)>,
  74. L<EVP_KEYMGMT(3)>,
  75. L<OSSL_PROVIDER-default(7)>,
  76. L<OSSL_PROVIDER-FIPS(7)>
  77. =head1 COPYRIGHT
  78. Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  79. Licensed under the Apache License 2.0 (the "License"). You may not use
  80. this file except in compliance with the License. You can obtain a copy
  81. in the file LICENSE in the source distribution or at
  82. L<https://www.openssl.org/source/license.html>.
  83. =cut