evp_keymgmt_util_export_to_provider.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. =pod
  2. =head1 NAME
  3. evp_keymgmt_util_export,
  4. evp_keymgmt_util_export_to_provider,
  5. evp_keymgmt_util_find_operation_cache,
  6. evp_keymgmt_util_clear_operation_cache,
  7. evp_keymgmt_util_cache_keydata,
  8. evp_keymgmt_util_cache_keyinfo,
  9. evp_keymgmt_util_fromdata,
  10. OP_CACHE_ELEM
  11. - internal KEYMGMT utility functions
  12. =head1 SYNOPSIS
  13. #include "crypto/evp.h"
  14. typedef struct OP_CACHE_ELEM;
  15. int evp_keymgmt_util_export(const EVP_PKEY *pk, int selection,
  16. OSSL_CALLBACK *export_cb, void *export_cbarg);
  17. void *evp_keymgmt_util_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt);
  18. OP_CACHE_ELEM *evp_keymgmt_util_find_operation_cache(EVP_PKEY *pk,
  19. EVP_KEYMGMT *keymgmt);
  20. int evp_keymgmt_util_clear_operation_cache(EVP_PKEY *pk, int locking);
  21. int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk,
  22. EVP_KEYMGMT *keymgmt, void *keydata);
  23. void evp_keymgmt_util_cache_keyinfo(EVP_PKEY *pk);
  24. void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
  25. int selection, const OSSL_PARAM params[]);
  26. =head1 DESCRIPTION
  27. evp_keymgmt_util_export() calls L<evp_keymgmt_export(3)> with the
  28. I<keymgmt> and I<keydata> from I<pk>. This is used as a
  29. helper for L<EVP_PKEY_todata(3)>.
  30. evp_keymgmt_util_export_to_provider() exports cached key material
  31. (provider side key material) from the given key I<pk> to a provider
  32. via a B<EVP_KEYMGMT> interface, if this hasn't already been done.
  33. It maintains a cache of provider key references in I<pk> to keep track
  34. of all provider side keys.
  35. To export a legacy key, use L<evp_pkey_export_to_provider(3)> instead,
  36. as this function ignores any legacy key data.
  37. evp_keymgmt_util_find_operation_cache() finds
  38. I<keymgmt> in I<pk>'s cache of provided keys for operations.
  39. It should only be called while holding I<pk>'s lock (read or write).
  40. evp_keymgmt_util_clear_operation_cache() can be used to explicitly
  41. clear the cache of operation key references. If I<locking> is set to 1 then
  42. then I<pk>'s lock will be obtained while doing the clear. Otherwise it will be
  43. assumed that the lock has already been obtained or is not required.
  44. evp_keymgmt_util_cache_keydata() can be used to add a provider key
  45. object to a B<PKEY>.
  46. evp_keymgmt_util_cache_keyinfo() can be used to get all kinds of
  47. information from the provvider "origin" and save it in I<pk>'s
  48. information cache.
  49. evp_keymgmt_util_fromdata() can be used to add key object data to a
  50. given key I<target> via a B<EVP_KEYMGMT> interface. This is used as a
  51. helper for L<EVP_PKEY_fromdata(3)>.
  52. =head1 RETURN VALUES
  53. evp_keymgmt_export_to_provider() and evp_keymgmt_util_fromdata()
  54. return a pointer to the appropriate provider side key (created or
  55. found again), or NULL on error.
  56. evp_keymgmt_util_find_operation_cache() returns a pointer to the
  57. operation cache slot. If I<keymgmt> is NULL, or if there is no slot
  58. with a match for I<keymgmt>, NULL is returned.
  59. evp_keymgmt_util_cache_keydata() and evp_keymgmt_util_clear_operation_cache()
  60. return 1 on success or 0 otherwise.
  61. =head1 NOTES
  62. "Legacy key" is the term used for any key that has been assigned to an
  63. B<EVP_PKEY> with EVP_PKEY_assign_RSA() and similar functions.
  64. =head1 SEE ALSO
  65. L<EVP_PKEY_ASN1_METHOD(3)>, L<EVP_PKEY_assign_RSA(3)>
  66. =head1 COPYRIGHT
  67. Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  68. Licensed under the Apache License 2.0 (the "License"). You may not use
  69. this file except in compliance with the License. You can obtain a copy
  70. in the file LICENSE in the source distribution or at
  71. L<https://www.openssl.org/source/license.html>.
  72. =cut