OSSL_STORE_SEARCH.pod 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. =pod
  2. =head1 NAME
  3. OSSL_STORE_SEARCH,
  4. OSSL_STORE_SEARCH_by_name,
  5. OSSL_STORE_SEARCH_by_issuer_serial,
  6. OSSL_STORE_SEARCH_by_key_fingerprint,
  7. OSSL_STORE_SEARCH_by_alias,
  8. OSSL_STORE_SEARCH_free,
  9. OSSL_STORE_SEARCH_get_type,
  10. OSSL_STORE_SEARCH_get0_name,
  11. OSSL_STORE_SEARCH_get0_serial,
  12. OSSL_STORE_SEARCH_get0_bytes,
  13. OSSL_STORE_SEARCH_get0_string,
  14. OSSL_STORE_SEARCH_get0_digest
  15. - Type and functions to create OSSL_STORE search criteria
  16. =head1 SYNOPSIS
  17. #include <openssl/store.h>
  18. typedef struct ossl_store_search_st OSSL_STORE_SEARCH;
  19. OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_name(X509_NAME *name);
  20. OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_issuer_serial(X509_NAME *name,
  21. const ASN1_INTEGER
  22. *serial);
  23. OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_key_fingerprint(const EVP_MD *digest,
  24. const unsigned char
  25. *bytes, int len);
  26. OSSL_STORE_SEARCH *OSSL_STORE_SEARCH_by_alias(const char *alias);
  27. void OSSL_STORE_SEARCH_free(OSSL_STORE_SEARCH *search);
  28. int OSSL_STORE_SEARCH_get_type(const OSSL_STORE_SEARCH *criterion);
  29. X509_NAME *OSSL_STORE_SEARCH_get0_name(OSSL_STORE_SEARCH *criterion);
  30. const ASN1_INTEGER *OSSL_STORE_SEARCH_get0_serial(const OSSL_STORE_SEARCH
  31. *criterion);
  32. const unsigned char *OSSL_STORE_SEARCH_get0_bytes(const OSSL_STORE_SEARCH
  33. *criterion, size_t *length);
  34. const char *OSSL_STORE_SEARCH_get0_string(const OSSL_STORE_SEARCH *criterion);
  35. const EVP_MD *OSSL_STORE_SEARCH_get0_digest(const OSSL_STORE_SEARCH
  36. *criterion);
  37. =head1 DESCRIPTION
  38. These functions are used to specify search criteria to help search for specific
  39. objects through other names than just the URI that's given to OSSL_STORE_open().
  40. For example, this can be useful for an application that has received a URI
  41. and then wants to add on search criteria in a uniform and supported manner.
  42. =head2 Types
  43. B<OSSL_STORE_SEARCH> is an opaque type that holds the constructed search
  44. criterion, and that can be given to an OSSL_STORE context with
  45. OSSL_STORE_find().
  46. The calling application owns the allocation of an B<OSSL_STORE_SEARCH> at all
  47. times, and should therefore be careful not to deallocate it before
  48. OSSL_STORE_close() has been called for the OSSL_STORE context it was given
  49. to.
  50. =head2 Application Functions
  51. OSSL_STORE_SEARCH_by_name(),
  52. OSSL_STORE_SEARCH_by_issuer_serial(),
  53. OSSL_STORE_SEARCH_by_key_fingerprint(),
  54. and OSSL_STORE_SEARCH_by_alias()
  55. are used to create an B<OSSL_STORE_SEARCH> from a subject name, an issuer name
  56. and serial number pair, a key fingerprint, and an alias (for example a friendly
  57. name).
  58. The parameters that are provided are not copied, only referred to in a
  59. criterion, so they must have at least the same life time as the created
  60. B<OSSL_STORE_SEARCH>.
  61. OSSL_STORE_SEARCH_free() is used to free the B<OSSL_STORE_SEARCH>.
  62. If the argument is NULL, nothing is done.
  63. =head2 Loader Functions
  64. OSSL_STORE_SEARCH_get_type() returns the criterion type for the given
  65. B<OSSL_STORE_SEARCH>.
  66. OSSL_STORE_SEARCH_get0_name(), OSSL_STORE_SEARCH_get0_serial(),
  67. OSSL_STORE_SEARCH_get0_bytes(), OSSL_STORE_SEARCH_get0_string(),
  68. and OSSL_STORE_SEARCH_get0_digest()
  69. are used to retrieve different data from a B<OSSL_STORE_SEARCH>, as
  70. available for each type.
  71. For more information, see L</SUPPORTED CRITERION TYPES> below.
  72. =head1 SUPPORTED CRITERION TYPES
  73. Currently supported criterion types are:
  74. =over 4
  75. =item OSSL_STORE_SEARCH_BY_NAME
  76. This criterion supports a search by exact match of subject name.
  77. The subject name itself is a B<X509_NAME> pointer.
  78. A criterion of this type is created with OSSL_STORE_SEARCH_by_name(),
  79. and the actual subject name is retrieved with OSSL_STORE_SEARCH_get0_name().
  80. =item OSSL_STORE_SEARCH_BY_ISSUER_SERIAL
  81. This criterion supports a search by exact match of both issuer name and serial
  82. number.
  83. The issuer name itself is a B<X509_NAME> pointer, and the serial number is
  84. a B<ASN1_INTEGER> pointer.
  85. A criterion of this type is created with OSSL_STORE_SEARCH_by_issuer_serial()
  86. and the actual issuer name and serial number are retrieved with
  87. OSSL_STORE_SEARCH_get0_name() and OSSL_STORE_SEARCH_get0_serial().
  88. =item OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT
  89. This criterion supports a search by exact match of key fingerprint.
  90. The key fingerprint in itself is a string of bytes and its length, as
  91. well as the algorithm that was used to compute the fingerprint.
  92. The digest may be left unspecified (NULL), and in that case, the
  93. loader has to decide on a default digest and compare fingerprints
  94. accordingly.
  95. A criterion of this type is created with OSSL_STORE_SEARCH_by_key_fingerprint()
  96. and the actual fingerprint and its length can be retrieved with
  97. OSSL_STORE_SEARCH_get0_bytes().
  98. The digest can be retrieved with OSSL_STORE_SEARCH_get0_digest().
  99. =item OSSL_STORE_SEARCH_BY_ALIAS
  100. This criterion supports a search by match of an alias of some kind.
  101. The alias in itself is a simple C string.
  102. A criterion of this type is created with OSSL_STORE_SEARCH_by_alias()
  103. and the actual alias is retrieved with OSSL_STORE_SEARCH_get0_string().
  104. =back
  105. =head1 RETURN VALUES
  106. OSSL_STORE_SEARCH_by_name(),
  107. OSSL_STORE_SEARCH_by_issuer_serial(),
  108. OSSL_STORE_SEARCH_by_key_fingerprint(),
  109. and OSSL_STORE_SEARCH_by_alias()
  110. return a B<OSSL_STORE_SEARCH> pointer on success, or NULL on failure.
  111. OSSL_STORE_SEARCH_get_type() returns the criterion type of the given
  112. B<OSSL_STORE_SEARCH>.
  113. There is no error value.
  114. OSSL_STORE_SEARCH_get0_name() returns a B<X509_NAME> pointer on success,
  115. or NULL when the given B<OSSL_STORE_SEARCH> was of a different type.
  116. OSSL_STORE_SEARCH_get0_serial() returns a B<ASN1_INTEGER> pointer on success,
  117. or NULL when the given B<OSSL_STORE_SEARCH> was of a different type.
  118. OSSL_STORE_SEARCH_get0_bytes() returns a B<const unsigned char> pointer and
  119. sets I<*length> to the strings length on success, or NULL when the given
  120. B<OSSL_STORE_SEARCH> was of a different type.
  121. OSSL_STORE_SEARCH_get0_string() returns a B<const char> pointer on success,
  122. or NULL when the given B<OSSL_STORE_SEARCH> was of a different type.
  123. OSSL_STORE_SEARCH_get0_digest() returns a B<const EVP_MD> pointer.
  124. NULL is a valid value and means that the store loader default will
  125. be used when applicable.
  126. =head1 SEE ALSO
  127. L<ossl_store(7)>, L<OSSL_STORE_supports_search(3)>, L<OSSL_STORE_find(3)>
  128. =head1 HISTORY
  129. B<OSSL_STORE_SEARCH>,
  130. OSSL_STORE_SEARCH_by_name(),
  131. OSSL_STORE_SEARCH_by_issuer_serial(),
  132. OSSL_STORE_SEARCH_by_key_fingerprint(),
  133. OSSL_STORE_SEARCH_by_alias(),
  134. OSSL_STORE_SEARCH_free(),
  135. OSSL_STORE_SEARCH_get_type(),
  136. OSSL_STORE_SEARCH_get0_name(),
  137. OSSL_STORE_SEARCH_get0_serial(),
  138. OSSL_STORE_SEARCH_get0_bytes(),
  139. and OSSL_STORE_SEARCH_get0_string()
  140. were added in OpenSSL 1.1.1.
  141. =head1 COPYRIGHT
  142. Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved.
  143. Licensed under the Apache License 2.0 (the "License"). You may not use
  144. this file except in compliance with the License. You can obtain a copy
  145. in the file LICENSE in the source distribution or at
  146. L<https://www.openssl.org/source/license.html>.
  147. =cut