EVP_PKEY_set1_RSA.pod 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_set1_RSA, EVP_PKEY_set1_DSA, EVP_PKEY_set1_DH, EVP_PKEY_set1_EC_KEY,
  4. EVP_PKEY_get1_RSA, EVP_PKEY_get1_DSA, EVP_PKEY_get1_DH, EVP_PKEY_get1_EC_KEY,
  5. EVP_PKEY_get0_RSA, EVP_PKEY_get0_DSA, EVP_PKEY_get0_DH, EVP_PKEY_get0_EC_KEY,
  6. EVP_PKEY_assign_RSA, EVP_PKEY_assign_DSA, EVP_PKEY_assign_DH,
  7. EVP_PKEY_assign_EC_KEY, EVP_PKEY_get0_hmac, EVP_PKEY_type, EVP_PKEY_id,
  8. EVP_PKEY_base_id, EVP_PKEY_set1_engine - EVP_PKEY assignment functions
  9. =head1 SYNOPSIS
  10. #include <openssl/evp.h>
  11. int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key);
  12. int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key);
  13. int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key);
  14. int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
  15. RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
  16. DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
  17. DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
  18. EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
  19. const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
  20. RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
  21. DSA *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);
  22. DH *EVP_PKEY_get0_DH(EVP_PKEY *pkey);
  23. EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
  24. int EVP_PKEY_assign_RSA(EVP_PKEY *pkey, RSA *key);
  25. int EVP_PKEY_assign_DSA(EVP_PKEY *pkey, DSA *key);
  26. int EVP_PKEY_assign_DH(EVP_PKEY *pkey, DH *key);
  27. int EVP_PKEY_assign_EC_KEY(EVP_PKEY *pkey, EC_KEY *key);
  28. int EVP_PKEY_id(const EVP_PKEY *pkey);
  29. int EVP_PKEY_base_id(const EVP_PKEY *pkey);
  30. int EVP_PKEY_type(int type);
  31. int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *engine);
  32. =head1 DESCRIPTION
  33. EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
  34. EVP_PKEY_set1_EC_KEY() set the key referenced by B<pkey> to B<key>.
  35. EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
  36. EVP_PKEY_get1_EC_KEY() return the referenced key in B<pkey> or
  37. B<NULL> if the key is not of the correct type.
  38. EVP_PKEY_get0_hmac(), EVP_PKEY_get0_RSA(), EVP_PKEY_get0_DSA(),
  39. EVP_PKEY_get0_DH() and EVP_PKEY_get0_EC_KEY() also return the
  40. referenced key in B<pkey> or B<NULL> if the key is not of the
  41. correct type but the reference count of the returned key is
  42. B<not> incremented and so must not be freed up after use.
  43. EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
  44. and EVP_PKEY_assign_EC_KEY() also set the referenced key to B<key>
  45. however these use the supplied B<key> internally and so B<key>
  46. will be freed when the parent B<pkey> is freed.
  47. EVP_PKEY_base_id() returns the type of B<pkey>. For example
  48. an RSA key will return B<EVP_PKEY_RSA>.
  49. EVP_PKEY_id() returns the actual OID associated with B<pkey>. Historically keys
  50. using the same algorithm could use different OIDs. For example an RSA key could
  51. use the OIDs corresponding to the NIDs B<NID_rsaEncryption> (equivalent to
  52. B<EVP_PKEY_RSA>) or B<NID_rsa> (equivalent to B<EVP_PKEY_RSA2>). The use of
  53. alternative non-standard OIDs is now rare so B<EVP_PKEY_RSA2> et al are not
  54. often seen in practice.
  55. EVP_PKEY_type() returns the underlying type of the NID B<type>. For example
  56. EVP_PKEY_type(EVP_PKEY_RSA2) will return B<EVP_PKEY_RSA>.
  57. EVP_PKEY_set1_engine() sets the ENGINE handling B<pkey> to B<engine>. It
  58. must be called after the key algorithm and components are set up.
  59. If B<engine> does not include an B<EVP_PKEY_METHOD> for B<pkey> an
  60. error occurs.
  61. =head1 NOTES
  62. In accordance with the OpenSSL naming convention the key obtained
  63. from or assigned to the B<pkey> using the B<1> functions must be
  64. freed as well as B<pkey>.
  65. EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
  66. and EVP_PKEY_assign_EC_KEY() are implemented as macros.
  67. Most applications wishing to know a key type will simply call
  68. EVP_PKEY_base_id() and will not care about the actual type:
  69. which will be identical in almost all cases.
  70. Previous versions of this document suggested using EVP_PKEY_type(pkey->type)
  71. to determine the type of a key. Since B<EVP_PKEY> is now opaque this
  72. is no longer possible: the equivalent is EVP_PKEY_base_id(pkey).
  73. EVP_PKEY_set1_engine() is typically used by an ENGINE returning an HSM
  74. key as part of its routine to load a private key.
  75. =head1 RETURN VALUES
  76. EVP_PKEY_set1_RSA(), EVP_PKEY_set1_DSA(), EVP_PKEY_set1_DH() and
  77. EVP_PKEY_set1_EC_KEY() return 1 for success or 0 for failure.
  78. EVP_PKEY_get1_RSA(), EVP_PKEY_get1_DSA(), EVP_PKEY_get1_DH() and
  79. EVP_PKEY_get1_EC_KEY() return the referenced key or B<NULL> if
  80. an error occurred.
  81. EVP_PKEY_assign_RSA(), EVP_PKEY_assign_DSA(), EVP_PKEY_assign_DH()
  82. and EVP_PKEY_assign_EC_KEY() return 1 for success and 0 for failure.
  83. EVP_PKEY_base_id(), EVP_PKEY_id() and EVP_PKEY_type() return a key
  84. type or B<NID_undef> (equivalently B<EVP_PKEY_NONE>) on error.
  85. EVP_PKEY_set1_engine() returns 1 for success and 0 for failure.
  86. =head1 SEE ALSO
  87. L<EVP_PKEY_new(3)>
  88. =head1 COPYRIGHT
  89. Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
  90. Licensed under the OpenSSL license (the "License"). You may not use
  91. this file except in compliance with the License. You can obtain a copy
  92. in the file LICENSE in the source distribution or at
  93. L<https://www.openssl.org/source/license.html>.
  94. =cut