evp_keymgmt_util_export_to_provider.pod 3.8 KB

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