iter.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2013,2016 Red Hat, Inc
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above
  9. * copyright notice, this list of conditions and the
  10. * following disclaimer.
  11. * * Redistributions in binary form must reproduce the
  12. * above copyright notice, this list of conditions and
  13. * the following disclaimer in the documentation and/or
  14. * other materials provided with the distribution.
  15. * * The names of contributors to this software may not be
  16. * used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  30. * DAMAGE.
  31. *
  32. * Author: Stef Walter <stefw@redhat.com>
  33. */
  34. #ifndef P11_KIT_ITER_H
  35. #define P11_KIT_ITER_H
  36. #include "p11-kit/p11-kit.h"
  37. #include "p11-kit/pkcs11.h"
  38. #include "p11-kit/uri.h"
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. #ifdef P11_KIT_FUTURE_UNSTABLE_API
  43. /*
  44. * If the caller is using the PKCS#11 GNU calling convention, then we cater
  45. * to that here.
  46. */
  47. #ifdef CRYPTOKI_GNU
  48. typedef unsigned char CK_BBOOL;
  49. typedef ck_object_handle_t CK_OBJECT_HANDLE;
  50. typedef ck_session_handle_t CK_SESSION_HANDLE;
  51. #endif
  52. typedef struct p11_kit_iter P11KitIter;
  53. typedef P11KitIter p11_kit_iter;
  54. typedef enum {
  55. P11_KIT_ITER_KIND_MODULE,
  56. P11_KIT_ITER_KIND_SLOT,
  57. P11_KIT_ITER_KIND_TOKEN,
  58. P11_KIT_ITER_KIND_OBJECT,
  59. P11_KIT_ITER_KIND_UNKNOWN = -1,
  60. } P11KitIterKind;
  61. typedef enum {
  62. P11_KIT_ITER_BUSY_SESSIONS = 1 << 1,
  63. P11_KIT_ITER_WANT_WRITABLE = 1 << 2,
  64. P11_KIT_ITER_WITH_MODULES = 1 << 3,
  65. P11_KIT_ITER_WITH_SLOTS = 1 << 4,
  66. P11_KIT_ITER_WITH_TOKENS = 1 << 5,
  67. P11_KIT_ITER_WITHOUT_OBJECTS = 1 << 6,
  68. } P11KitIterBehavior;
  69. typedef CK_RV (* p11_kit_iter_callback) (P11KitIter *iter,
  70. CK_BBOOL *matches,
  71. void *data);
  72. P11KitIter * p11_kit_iter_new (P11KitUri *uri,
  73. P11KitIterBehavior behavior);
  74. void p11_kit_iter_free (P11KitIter *iter);
  75. void p11_kit_iter_add_callback (P11KitIter *iter,
  76. p11_kit_iter_callback callback,
  77. void *callback_data,
  78. p11_kit_destroyer callback_destroy);
  79. void p11_kit_iter_add_filter (P11KitIter *iter,
  80. CK_ATTRIBUTE *matching,
  81. CK_ULONG count);
  82. void p11_kit_iter_set_uri (P11KitIter *iter,
  83. P11KitUri *uri);
  84. void p11_kit_iter_begin (P11KitIter *iter,
  85. CK_FUNCTION_LIST_PTR *modules);
  86. void p11_kit_iter_begin_with (P11KitIter *iter,
  87. CK_FUNCTION_LIST_PTR module,
  88. CK_SLOT_ID slot,
  89. CK_SESSION_HANDLE session);
  90. CK_RV p11_kit_iter_next (P11KitIter *iter);
  91. P11KitIterKind p11_kit_iter_get_kind (P11KitIter *iter);
  92. CK_FUNCTION_LIST_PTR p11_kit_iter_get_module (P11KitIter *iter);
  93. CK_SLOT_ID p11_kit_iter_get_slot (P11KitIter *iter);
  94. CK_SLOT_INFO * p11_kit_iter_get_slot_info (P11KitIter *iter);
  95. CK_TOKEN_INFO * p11_kit_iter_get_token (P11KitIter *iter);
  96. CK_SESSION_HANDLE p11_kit_iter_get_session (P11KitIter *iter);
  97. CK_OBJECT_HANDLE p11_kit_iter_get_object (P11KitIter *iter);
  98. CK_RV p11_kit_iter_get_attributes (P11KitIter *iter,
  99. CK_ATTRIBUTE *template,
  100. CK_ULONG count);
  101. CK_RV p11_kit_iter_load_attributes (P11KitIter *iter,
  102. CK_ATTRIBUTE *template,
  103. CK_ULONG count);
  104. CK_SESSION_HANDLE p11_kit_iter_keep_session (P11KitIter *iter);
  105. CK_RV p11_kit_iter_destroy_object (P11KitIter *iter);
  106. #endif /* P11_KIT_FUTURE_UNSTABLE_API */
  107. #ifdef __cplusplus
  108. } /* extern "C" */
  109. #endif
  110. #endif /* P11_KIT_ITER_H */