EVP_PKEY_CTX_ctrl.pod 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_CTX_ctrl, EVP_PKEY_CTX_ctrl_str,
  4. EVP_PKEY_CTX_set_signature_md, EVP_PKEY_CTX_set_rsa_padding,
  5. EVP_PKEY_CTX_set_rsa_pss_saltlen, EVP_PKEY_CTX_set_rsa_rsa_keygen_bits,
  6. EVP_PKEY_CTX_set_rsa_keygen_pubexp, EVP_PKEY_CTX_set_dsa_paramgen_bits,
  7. EVP_PKEY_CTX_set_dh_paramgen_prime_len,
  8. EVP_PKEY_CTX_set_dh_paramgen_generator,
  9. EVP_PKEY_CTX_set_ec_paramgen_curve_nid,
  10. EVP_PKEY_CTX_set_ec_param_enc - algorithm specific control operations
  11. =head1 SYNOPSIS
  12. #include <openssl/evp.h>
  13. int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
  14. int cmd, int p1, void *p2);
  15. int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
  16. const char *value);
  17. #include <openssl/rsa.h>
  18. int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
  19. int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad);
  20. int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len);
  21. int EVP_PKEY_CTX_set_rsa_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits);
  22. int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
  23. #include <openssl/dsa.h>
  24. int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits);
  25. #include <openssl/dh.h>
  26. int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len);
  27. int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen);
  28. #include <openssl/ec.h>
  29. int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid);
  30. int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc);
  31. =head1 DESCRIPTION
  32. The function EVP_PKEY_CTX_ctrl() sends a control operation to the context
  33. B<ctx>. The key type used must match B<keytype> if it is not -1. The parameter
  34. B<optype> is a mask indicating which operations the control can be applied to.
  35. The control command is indicated in B<cmd> and any additional arguments in
  36. B<p1> and B<p2>.
  37. Applications will not normally call EVP_PKEY_CTX_ctrl() directly but will
  38. instead call one of the algorithm specific macros below.
  39. The function EVP_PKEY_CTX_ctrl_str() allows an application to send an algorithm
  40. specific control operation to a context B<ctx> in string form. This is
  41. intended to be used for options specified on the command line or in text
  42. files. The commands supported are documented in the openssl utility
  43. command line pages for the option B<-pkeyopt> which is supported by the
  44. B<pkeyutl>, B<genpkey> and B<req> commands.
  45. All the remaining "functions" are implemented as macros.
  46. The EVP_PKEY_CTX_set_signature_md() macro sets the message digest type used
  47. in a signature. It can be used with any public key algorithm supporting
  48. signature operations.
  49. The macro EVP_PKEY_CTX_set_rsa_padding() sets the RSA padding mode for B<ctx>.
  50. The B<pad> parameter can take the value RSA_PKCS1_PADDING for PKCS#1 padding,
  51. RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no padding,
  52. RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt only),
  53. RSA_X931_PADDING for X9.31 padding (signature operations only) and
  54. RSA_PKCS1_PSS_PADDING (sign and verify only).
  55. Two RSA padding modes behave differently if EVP_PKEY_CTX_set_signature_md()
  56. is used. If this macro is called for PKCS#1 padding the plaintext buffer is
  57. an actual digest value and is encapsulated in a DigestInfo structure according
  58. to PKCS#1 when signing and this structure is expected (and stripped off) when
  59. verifying. If this control is not used with RSA and PKCS#1 padding then the
  60. supplied data is used directly and not encapsulated. In the case of X9.31
  61. padding for RSA the algorithm identifier byte is added or checked and removed
  62. if this control is called. If it is not called then the first byte of the plaintext
  63. buffer is expected to be the algorithm identifier byte.
  64. The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the RSA PSS salt length to
  65. B<len> as its name implies it is only supported for PSS padding. Two special
  66. values are supported: -1 sets the salt length to the digest length. When
  67. signing -2 sets the salt length to the maximum permissible value. When
  68. verifying -2 causes the salt length to be automatically determined based on the
  69. B<PSS> block structure. If this macro is not called a salt length value of -2
  70. is used by default.
  71. The EVP_PKEY_CTX_set_rsa_rsa_keygen_bits() macro sets the RSA key length for
  72. RSA key generation to B<bits>. If not specified 1024 bits is used.
  73. The EVP_PKEY_CTX_set_rsa_keygen_pubexp() macro sets the public exponent value
  74. for RSA key generation to B<pubexp> currently it should be an odd integer. The
  75. B<pubexp> pointer is used internally by this function so it should not be
  76. modified or free after the call. If this macro is not called then 65537 is used.
  77. The macro EVP_PKEY_CTX_set_dsa_paramgen_bits() sets the number of bits used
  78. for DSA parameter generation to B<bits>. If not specified 1024 is used.
  79. The macro EVP_PKEY_CTX_set_dh_paramgen_prime_len() sets the length of the DH
  80. prime parameter B<p> for DH parameter generation. If this macro is not called
  81. then 1024 is used.
  82. The EVP_PKEY_CTX_set_dh_paramgen_generator() macro sets DH generator to B<gen>
  83. for DH parameter generation. If not specified 2 is used.
  84. The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC parameter
  85. generation to B<nid>. For EC parameter generation this macro must be called
  86. or an error occurs because there is no default curve.
  87. This function can also be called to set the curve explicitly when
  88. generating an EC key.
  89. The EVP_PKEY_CTX_set_ec_param_enc() sets the EC parameter encoding to
  90. B<param_enc> when generating EC parameters or an EC key. The encoding can be
  91. B<OPENSSL_EC_EXPLICIT_CURVE> for explicit parameters (the default in versions
  92. of OpenSSL before 1.1.0) or B<OPENSSL_EC_NAMED_CURVE> to use named curve form.
  93. For maximum compatibility the named curve form should be used. Note: the
  94. B<OPENSSL_EC_NAMED_CURVE> value was only added to OpenSSL 1.1.0; previous
  95. versions should use 0 instead.
  96. =head1 RETURN VALUES
  97. EVP_PKEY_CTX_ctrl() and its macros return a positive value for success and 0
  98. or a negative value for failure. In particular a return value of -2
  99. indicates the operation is not supported by the public key algorithm.
  100. =head1 SEE ALSO
  101. L<EVP_PKEY_CTX_new(3)>,
  102. L<EVP_PKEY_encrypt(3)>,
  103. L<EVP_PKEY_decrypt(3)>,
  104. L<EVP_PKEY_sign(3)>,
  105. L<EVP_PKEY_verify(3)>,
  106. L<EVP_PKEY_verify_recover(3)>,
  107. L<EVP_PKEY_derive(3)>
  108. L<EVP_PKEY_keygen(3)>
  109. =head1 HISTORY
  110. These functions were first added to OpenSSL 1.0.0.
  111. =head1 COPYRIGHT
  112. Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
  113. Licensed under the OpenSSL license (the "License"). You may not use
  114. this file except in compliance with the License. You can obtain a copy
  115. in the file LICENSE in the source distribution or at
  116. L<https://www.openssl.org/source/license.html>.
  117. =cut