2
0

evp_pkey_export_to_provider.pod 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. =pod
  2. =head1 NAME
  3. evp_pkey_export_to_provider, evp_pkey_copy_downgraded, evp_pkey_get_legacy
  4. - internal EVP_PKEY support functions for providers
  5. =head1 SYNOPSIS
  6. /* Only for EVP source */
  7. #include "evp_local.h"
  8. void *evp_pkey_export_to_provider(EVP_PKEY *pk, OSSL_LIB_CTX *libctx,
  9. EVP_KEYMGMT **keymgmt,
  10. const char *propquery);
  11. int evp_pkey_copy_downgraded(EVP_PKEY **dest, const EVP_PKEY *src);
  12. void *evp_pkey_get_legacy(EVP_PKEY *pk);
  13. =head1 DESCRIPTION
  14. This manual uses the term "origin", which is explained in internal
  15. L<EVP_PKEY(7)>.
  16. evp_pkey_export_to_provider() exports the "origin" key contained in I<pk>
  17. to its operation cache to make it suitable for an B<EVP_KEYMGMT> given either
  18. with I<*keymgmt> or with an implicit fetch using I<libctx> (NULL means the
  19. default context), the name of the legacy type of I<pk>, and the I<propquery>
  20. (NULL means the default property query settings).
  21. If I<keymgmt> isn't NULL but I<*keymgmt> is, and the "origin" was successfully
  22. exported, then I<*keymgmt> is assigned the implicitly fetched B<EVP_KEYMGMT>.
  23. evp_pkey_copy_downgraded() makes a copy of I<src> in legacy form into I<*dest>,
  24. if there's a corresponding legacy implementation. This should be used if the
  25. use of a downgraded key is temporary.
  26. For example, L<PEM_write_bio_PrivateKey_traditional(3)> uses this to try its
  27. best to get "traditional" PEM output even if the input B<EVP_PKEY> has a
  28. provider-native internal key.
  29. evp_pkey_get_legacy() obtains and returns a legacy key structure. If the
  30. EVP_PKEY already contains a legacy key then it is simply returned. If it is a
  31. provider based key, then a new legacy key is constructed based on the provider
  32. key. The legacy key is cached inside the EVP_PKEY and its value returned from
  33. this function. Subsequent calls to evp_pkey_get_legacy() will return the cached
  34. key. Subsequent changes to the provider key are not reflected back in the
  35. legacy key. Similarly changes to the legacy key are not reflected back in the
  36. provider key.
  37. =head1 RETURN VALUES
  38. evp_pkey_export_to_provider() returns the provider key data if there was any
  39. allocated. It also either sets I<*keymgmt> to the B<EVP_KEYMGMT> associated
  40. with the returned key data, or NULL on error.
  41. evp_pkey_get_legacy() returns the legacy key or NULL on error.
  42. =head1 NOTES
  43. Some functions calling evp_pkey_export_to_provider() may have received a const
  44. key, and may therefore have to cast the key to non-const form to call this
  45. function. Since B<EVP_PKEY> is always dynamically allocated, this is OK.
  46. =head1 SEE ALSO
  47. L<OSSL_LIB_CTX(3)>, L<EVP_KEYMGMT(3)>
  48. =head1 HISTORY
  49. The functions described here were all added in OpenSSL 3.0.
  50. =head1 COPYRIGHT
  51. Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
  52. Licensed under the Apache License 2.0 (the "License"). You may not use
  53. this file except in compliance with the License. You can obtain a copy
  54. in the file LICENSE in the source distribution or at
  55. L<https://www.openssl.org/source/license.html>.
  56. =cut