EVP_PKEY_CTX_ctrl.pod 5.5 KB

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