pin.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) 2011 Collabora Ltd.
  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@collabora.co.uk>
  33. */
  34. #ifndef P11_KIT_PIN_H
  35. #define P11_KIT_PIN_H
  36. #include <p11-kit/uri.h>
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. typedef struct p11_kit_pin P11KitPin;
  41. typedef enum {
  42. P11_KIT_PIN_FLAGS_USER_LOGIN = 1<<0,
  43. P11_KIT_PIN_FLAGS_SO_LOGIN = 1<<1,
  44. P11_KIT_PIN_FLAGS_CONTEXT_LOGIN = 1<<2,
  45. P11_KIT_PIN_FLAGS_RETRY = 1<<3,
  46. P11_KIT_PIN_FLAGS_MANY_TRIES = 1<<4,
  47. P11_KIT_PIN_FLAGS_FINAL_TRY = 1<<5
  48. } P11KitPinFlags;
  49. #define P11_KIT_PIN_FALLBACK ""
  50. typedef void (*p11_kit_pin_destroy_func) (void *data);
  51. P11KitPin* p11_kit_pin_new (const unsigned char *value,
  52. size_t length);
  53. P11KitPin* p11_kit_pin_new_for_string (const char *value);
  54. P11KitPin* p11_kit_pin_new_for_buffer (unsigned char *buffer,
  55. size_t length,
  56. p11_kit_pin_destroy_func destroy);
  57. P11KitPin* p11_kit_pin_ref (P11KitPin *pin);
  58. void p11_kit_pin_unref (P11KitPin *pin);
  59. const unsigned char * p11_kit_pin_get_value (P11KitPin *pin,
  60. size_t *length);
  61. size_t p11_kit_pin_get_length (P11KitPin *pin);
  62. typedef P11KitPin* (*p11_kit_pin_callback) (const char *pin_source,
  63. P11KitUri *pin_uri,
  64. const char *pin_description,
  65. P11KitPinFlags pin_flags,
  66. void *callback_data);
  67. int p11_kit_pin_register_callback (const char *pin_source,
  68. p11_kit_pin_callback callback,
  69. void *callback_data,
  70. p11_kit_pin_destroy_func callback_destroy);
  71. void p11_kit_pin_unregister_callback (const char *pin_source,
  72. p11_kit_pin_callback callback,
  73. void *callback_data);
  74. P11KitPin* p11_kit_pin_request (const char *pin_source,
  75. P11KitUri *pin_uri,
  76. const char *pin_description,
  77. P11KitPinFlags pin_flags);
  78. P11KitPin* p11_kit_pin_file_callback (const char *pin_source,
  79. P11KitUri *pin_uri,
  80. const char *pin_description,
  81. P11KitPinFlags pin_flags,
  82. void *callback_data);
  83. #ifdef __cplusplus
  84. } /* extern "C" */
  85. #endif
  86. #endif /* P11_KIT_URI_H */