EVP_PKEY_CTX_ctrl.pod 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_CTX_ctrl, EVP_PKEY_CTX_ctrl_str, EVP_PKEY_get_default_digest_nid,
  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 - algorithm specific control operations
  10. =head1 SYNOPSIS
  11. #include <openssl/evp.h>
  12. int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
  13. int cmd, int p1, void *p2);
  14. int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
  15. const char *value);
  16. int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
  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. =head1 DESCRIPTION
  31. The function EVP_PKEY_CTX_ctrl() sends a control operation to the context
  32. B<ctx>. The key type used must match B<keytype> if it is not -1. The parameter
  33. B<optype> is a mask indicating which operations the control can be applied to.
  34. The control command is indicated in B<cmd> and any additional arguments in
  35. B<p1> and B<p2>.
  36. Applications will not normally call EVP_PKEY_CTX_ctrl() directly but will
  37. instead call one of the algorithm specific macros below.
  38. The function EVP_PKEY_CTX_ctrl_str() allows an application to send an algorithm
  39. specific control operation to a context B<ctx> in string form. This is
  40. intended to be used for options specified on the command line or in text
  41. files. The commands supported are documented in the openssl utility
  42. command line pages for the option B<-pkeyopt> which is supported by the
  43. B<pkeyutl>, B<genpkey> and B<req> commands.
  44. All the remaining "functions" are implemented as macros.
  45. The EVP_PKEY_CTX_set_signature_md() macro sets the message digest type used
  46. in a signature. It can be used with any public key algorithm supporting
  47. signature operations.
  48. The macro EVP_PKEY_CTX_set_rsa_padding() sets the RSA padding mode for B<ctx>.
  49. The B<pad> parameter can take the value RSA_PKCS1_PADDING for PKCS#1 padding,
  50. RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no padding,
  51. RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt only),
  52. RSA_X931_PADDING for X9.31 padding (signature operations only) and
  53. RSA_PKCS1_PSS_PADDING (sign and verify only).
  54. Two RSA padding modes behave differently if EVP_PKEY_CTX_set_signature_md()
  55. is used. If this macro is called for PKCS#1 padding the plaintext buffer is
  56. an actual digest value and is encapsulated in a DigestInfo structure according
  57. to PKCS#1 when signing and this structure is expected (and stripped off) when
  58. verifying. If this control is not used with RSA and PKCS#1 padding then the
  59. supplied data is used directly and not encapsulated. In the case of X9.31
  60. padding for RSA the algorithm identifier byte is added or checked and removed
  61. if this control is called. If it is not called then the first byte of the plaintext buffer is expected to be the algorithm identifier byte.
  62. The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the RSA PSS salt length to
  63. B<len> as its name implies it is only supported for PSS padding. Two special
  64. values are supported: -1 sets the salt length to the digest length. When
  65. signing -2 sets the salt length to the maximum permissible value. When
  66. verifying -2 causes the salt length to be automatically determined based on the
  67. B<PSS> block structure. If this macro is not called a salt length value of -2
  68. is used by default.
  69. The EVP_PKEY_CTX_set_rsa_rsa_keygen_bits() macro sets the RSA key length for
  70. RSA key genration to B<bits>. If not specified 1024 bits is used.
  71. The EVP_PKEY_CTX_set_rsa_keygen_pubexp() macro sets the public exponent value
  72. for RSA key generation to B<pubexp> currently it should be an odd integer. The
  73. B<pubexp> pointer is used internally by this function so it should not be
  74. modified or free after the call. If this macro is not called then 65537 is used.
  75. The macro EVP_PKEY_CTX_set_dsa_paramgen_bits() sets the number of bits used
  76. for DSA parameter generation to B<bits>. If not specified 1024 is used.
  77. The macro EVP_PKEY_CTX_set_dh_paramgen_prime_len() sets the length of the DH
  78. prime parameter B<p> for DH parameter generation. If this macro is not called
  79. then 1024 is used.
  80. The EVP_PKEY_CTX_set_dh_paramgen_generator() macro sets DH generator to B<gen>
  81. for DH parameter generation. If not specified 2 is used.
  82. The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC parameter
  83. generation to B<nid>. For EC parameter generation this macro must be called
  84. or an error occurs because there is no default curve.
  85. =head1 RETURN VALUES
  86. EVP_PKEY_CTX_ctrl() and its macros return a positive value for success and 0
  87. or a negative value for failure. In particular a return value of -2
  88. indicates the operation is not supported by the public key algorithm.
  89. =head1 SEE ALSO
  90. L<EVP_PKEY_CTX_new(3)|EVP_PKEY_CTX_new(3)>,
  91. L<EVP_PKEY_encrypt(3)|EVP_PKEY_encrypt(3)>,
  92. L<EVP_PKEY_decrypt(3)|EVP_PKEY_decrypt(3)>,
  93. L<EVP_PKEY_sign(3)|EVP_PKEY_sign(3)>,
  94. L<EVP_PKEY_verify(3)|EVP_PKEY_verify(3)>,
  95. L<EVP_PKEY_verify_recover(3)|EVP_PKEY_verify_recover(3)>,
  96. L<EVP_PKEY_derive(3)|EVP_PKEY_derive(3)>
  97. L<EVP_PKEY_keygen(3)|EVP_PKEY_keygen(3)>
  98. =head1 HISTORY
  99. These functions were first added to OpenSSL 1.0.0.
  100. =cut