evp_pkey_export_to_provider.pod 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. =pod
  2. =head1 NAME
  3. evp_pkey_export_to_provider, evp_pkey_copy_downgraded, evp_pkey_downgrade
  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. int evp_pkey_downgrade(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_downgrade() converts an B<EVP_PKEY> with a provider side "origin" key
  30. to one with a legacy "origin", if there's a corresponding legacy implementation.
  31. This clears the operation cache, except for the provider side "origin" key.
  32. This function is used in spots where provider side keys aren't yet supported,
  33. in an attempt to keep operating with available implementations.
  34. =head1 RETURN VALUES
  35. evp_pkey_export_to_provider() returns the provider key data if there was any
  36. allocated. It also either sets I<*keymgmt> to the B<EVP_KEYMGMT> associated
  37. with the returned key data, or NULL on error.
  38. evp_pkey_downgrade() returns 1 on success or 0 on error.
  39. =head1 NOTES
  40. Some functions calling evp_pkey_export_to_provider() or evp_pkey_downgrade()
  41. may have received a const key, and may therefore have to cast the key to
  42. non-const form to call this function. Since B<EVP_PKEY> is always dynamically
  43. allocated, this is OK.
  44. =head1 SEE ALSO
  45. L<OSSL_LIB_CTX(3)>, L<EVP_KEYMGMT(3)>
  46. =head1 HISTORY
  47. The functions described here were all added in OpenSSL 3.0.
  48. =head1 COPYRIGHT
  49. Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
  50. Licensed under the Apache License 2.0 (the "License"). You may not use
  51. this file except in compliance with the License. You can obtain a copy
  52. in the file LICENSE in the source distribution or at
  53. L<https://www.openssl.org/source/license.html>.
  54. =cut