provider-keymgmt.pod 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. =pod
  2. =head1 NAME
  3. provider-keymgmt - The KEYMGMT library E<lt>-E<gt> provider functions
  4. =head1 SYNOPSIS
  5. #include <openssl/core_numbers.h>
  6. /*
  7. * None of these are actual functions, but are displayed like this for
  8. * the function signatures for functions that are offered as function
  9. * pointers in OSSL_DISPATCH arrays.
  10. */
  11. /* Key domain parameter creation and destruction */
  12. void *OP_keymgmt_importdomparams(void *provctx, const OSSL_PARAM params[]);
  13. void *OP_keymgmt_gendomparams(void *provctx, const OSSL_PARAM params[]);
  14. void OP_keymgmt_freedomparams(void *domparams);
  15. /* Key domain parameter export */
  16. int OP_keymgmt_exportdomparams(void *domparams, OSSL_PARAM params[]);
  17. /* Key domain parameter discovery */
  18. const OSSL_PARAM *OP_keymgmt_importdomparam_types(void);
  19. const OSSL_PARAM *OP_keymgmt_exportdomparam_types(void);
  20. /* Key creation and destruction */
  21. void *OP_keymgmt_importkey(void *provctx, const OSSL_PARAM params[]);
  22. void *OP_keymgmt_genkey(void *provctx,
  23. void *domparams, const OSSL_PARAM genkeyparams[]);
  24. void *OP_keymgmt_loadkey(void *provctx, void *id, size_t idlen);
  25. void OP_keymgmt_freekey(void *key);
  26. /* Key export */
  27. int OP_keymgmt_exportkey(void *key, OSSL_PARAM params[]);
  28. /* Key discovery */
  29. const OSSL_PARAM *OP_keymgmt_importkey_types(void);
  30. const OSSL_PARAM *OP_keymgmt_exportkey_types(void);
  31. =head1 DESCRIPTION
  32. The KEYMGMT operation doesn't have much public visibility in OpenSSL
  33. libraries, it's rather an internal operation that's designed to work
  34. in tandem with operations that use private/public key pairs.
  35. Because the KEYMGMT operation shares knowledge with the operations it
  36. works with in tandem, they must belong to the same provider.
  37. The OpenSSL libraries will ensure that they do.
  38. The primary responsibility of the KEYMGMT operation is to hold the
  39. provider side domain parameters and keys for the OpenSSL library
  40. EVP_PKEY structure.
  41. All "functions" mentioned here are passed as function pointers between
  42. F<libcrypto> and the provider in B<OSSL_DISPATCH> arrays via
  43. B<OSSL_ALGORITHM> arrays that are returned by the provider's
  44. provider_query_operation() function
  45. (see L<provider-base(7)/Provider Functions>).
  46. All these "functions" have a corresponding function type definition
  47. named B<OSSL_{name}_fn>, and a helper function to retrieve the
  48. function pointer from a B<OSSL_DISPATCH> element named
  49. B<OSSL_get_{name}>.
  50. For example, the "function" OP_keymgmt_importdomparams() has these:
  51. typedef void *
  52. (OSSL_OP_keymgmt_importdomparams_fn)(void *provctx,
  53. const OSSL_PARAM params[]);
  54. static ossl_inline OSSL_OP_keymgmt_importdomparams_fn
  55. OSSL_get_OP_keymgmt_importdomparams(const OSSL_DISPATCH *opf);
  56. B<OSSL_DISPATCH> arrays are indexed by numbers that are provided as
  57. macros in L<openssl-core_numbers.h(7)>, as follows:
  58. OP_keymgmt_importdomparams OSSL_FUNC_KEYMGMT_IMPORTDOMPARAMS
  59. OP_keymgmt_gendomparams OSSL_FUNC_KEYMGMT_GENDOMPARAMS
  60. OP_keymgmt_freedomparams OSSL_FUNC_KEYMGMT_FREEDOMPARAMS
  61. OP_keymgmt_exportdomparams OSSL_FUNC_KEYMGMT_EXPORTDOMPARAMS
  62. OP_keymgmt_importdomparam_types OSSL_FUNC_KEYMGMT_IMPORTDOMPARAM_TYPES
  63. OP_keymgmt_exportdomparam_types OSSL_FUNC_KEYMGMT_EXPORTDOMPARAM_TYPES
  64. OP_keymgmt_importkey OSSL_FUNC_KEYMGMT_IMPORTKEY
  65. OP_keymgmt_genkey OSSL_FUNC_KEYMGMT_GENKEY
  66. OP_keymgmt_loadkey OSSL_FUNC_KEYMGMT_LOADKEY
  67. OP_keymgmt_freekey OSSL_FUNC_KEYMGMT_FREEKEY
  68. OP_keymgmt_exportkey OSSL_FUNC_KEYMGMT_EXPORTKEY
  69. OP_keymgmt_importkey_types OSSL_FUNC_KEYMGMT_IMPORTKEY_TYPES
  70. OP_keymgmt_exportkey_types OSSL_FUNC_KEYMGMT_EXPORTKEY_TYPES
  71. =head2 Domain Parameter Functions
  72. OP_keymgmt_importdomparams() should create a provider side structure
  73. for domain parameters, with values taken from the passed B<OSSL_PARAM>
  74. array I<params>.
  75. OP_keymgmt_gendomparams() should generate domain parameters and create
  76. a provider side structure for them.
  77. Values of the passed B<OSSL_PARAM> array I<params> should be used as
  78. input for parameter generation.
  79. OP_keymgmt_freedomparams() should free the passed provider side domain
  80. parameter structure I<domparams>.
  81. OP_keymgmt_exportdomparams() should extract values from the passed
  82. provider side domain parameter structure I<domparams> into the passed
  83. B<OSSL_PARAM> I<params>.
  84. Only the values specified in I<params> should be extracted.
  85. OP_keymgmt_importdomparam_types() should return a constant array of
  86. descriptor B<OSSL_PARAM>, for parameters that OP_keymgmt_importdomparams()
  87. can handle.
  88. =for comment There should be one corresponding to OP_keymgmt_gendomparams()
  89. as well...
  90. OP_keymgmt_exportdomparam_types() should return a constant array of
  91. descriptor B<OSSL_PARAM>, for parameters that can be exported with
  92. OP_keymgmt_exportdomparams().
  93. =head2 Key functions
  94. OP_keymgmt_importkey() should create a provider side structure
  95. for keys, with values taken from the passed B<OSSL_PARAM> array
  96. I<params>.
  97. OP_keymgmt_genkey() should generate keys and create a provider side
  98. structure for them.
  99. Values from the passed domain parameters I<domparams> as well as from
  100. the passed B<OSSL_PARAM> array I<params> should be used as input for
  101. key generation.
  102. OP_keymgmt_loadkey() should return a provider side key structure with
  103. a key loaded from a location known only to the provider, identitified
  104. with the identity I<id> of size I<idlen>.
  105. This identity is internal to the provider and is retrieved from the
  106. provider through other means.
  107. =for comment Right now, OP_keymgmt_loadkey is useless, but will be
  108. useful as soon as we have a OSSL_STORE interface
  109. OP_keymgmt_freekey() should free the passed I<key>.
  110. OP_keymgmt_exportkey() should extract values from the passed
  111. provider side key I<key> into the passed B<OSSL_PARAM> I<params>.
  112. Only the values specified in I<params> should be extracted.
  113. OP_keymgmt_importkey_types() should return a constant array of
  114. descriptor B<OSSL_PARAM>, for parameters that OP_keymgmt_importkey()
  115. can handle.
  116. =for comment There should be one corresponding to OP_keymgmt_genkey()
  117. as well...
  118. OP_keymgmt_exportkey_types() should return a constant array of
  119. descriptor B<OSSL_PARAM>, for parameters that can be exported with
  120. OP_keymgmt_exportkeys().
  121. =head1 SEE ALSO
  122. L<provider(7)>
  123. =head1 HISTORY
  124. The KEYMGMT interface was introduced in OpenSSL 3.0.
  125. =head1 COPYRIGHT
  126. Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
  127. Licensed under the Apache License 2.0 (the "License"). You may not use
  128. this file except in compliance with the License. You can obtain a copy
  129. in the file LICENSE in the source distribution or at
  130. L<https://www.openssl.org/source/license.html>.
  131. =cut