cert.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* cert.h - Scute certificate management.
  2. Copyright (C) 2006, 2007 g10 Code GmbH
  3. This file is part of Scute.
  4. Scute is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. Scute is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Scute; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  15. In addition, as a special exception, g10 Code GmbH gives permission
  16. to link this library: with the Mozilla Foundation's code for
  17. Mozilla (or with modified versions of it that use the same license
  18. as the "Mozilla" code), and distribute the linked executables. You
  19. must obey the GNU General Public License in all respects for all of
  20. the code used other than "Mozilla". If you modify this file, you
  21. may extend this exception to your version of the file, but you are
  22. not obligated to do so. If you do not wish to do so, delete this
  23. exception statement from your version. */
  24. #ifndef CERT_H
  25. #define CERT_H 1
  26. #include <stdbool.h>
  27. #include <time.h>
  28. #include <gpg-error.h>
  29. #include <assuan.h>
  30. #include "cryptoki.h"
  31. /* A certificate structure holds all information of a certificate
  32. during a certificate search. */
  33. struct cert
  34. {
  35. /* True if we started to fill in a certificate. */
  36. bool valid;
  37. /* The key length. */
  38. int length;
  39. /* The public key algorithm. */
  40. int pubkey_algo;
  41. /* The key ID. */
  42. unsigned char keyid[17];
  43. /* The timestamp. */
  44. time_t timestamp;
  45. /* The expiration time. */
  46. time_t expires;
  47. /* The X.509 serial number. */
  48. char *issuer_serial;
  49. /* The X.509 issuer name. */
  50. char *issuer_name;
  51. /* The user ID strings. */
  52. char *uid;
  53. /* The fingerprint. */
  54. unsigned char fpr[41];
  55. /* The key grip. */
  56. unsigned char grip[41];
  57. /* The chain ID. */
  58. unsigned char chain_id[41];
  59. /* The certificate in DER format. This is not entered by the search
  60. function, but afterwards by the filter before converting it into
  61. a PKCS #11 object. */
  62. unsigned char *cert_der;
  63. int cert_der_len;
  64. /* If the certificate is trusted or not. For performance reasons,
  65. this is not entered by the search function, but afterwards by the
  66. filter before converting it into a PKCS #11 object. */
  67. bool is_trusted;
  68. };
  69. /* From cert-gpgsm.c. */
  70. /* The callback type invoked for each certificate found in the
  71. search. */
  72. typedef gpg_error_t (*cert_search_cb_t) (void *hook, struct cert *cert);
  73. /* Invoke SEARCH_CB for each certificate found using assuan connection
  74. CTX to GPGSM. */
  75. gpg_error_t scute_gpgsm_search_certs_by_grip (const char *grip,
  76. cert_search_cb_t search_cb,
  77. void *search_cb_hook);
  78. /* Invoke SEARCH_CB for each certificate found using assuan connection
  79. CTX to GPGSM. */
  80. gpg_error_t scute_gpgsm_search_certs_by_fpr (const char *fpr,
  81. cert_search_cb_t search_cb,
  82. void *search_cb_hook);
  83. /* From cert-object.c. */
  84. gpg_error_t scute_attr_cert (struct cert *cert,
  85. CK_ATTRIBUTE_PTR *attrp, CK_ULONG *attr_countp);
  86. gpg_error_t scute_attr_prv (struct cert *cert, CK_ATTRIBUTE_PTR *attrp,
  87. CK_ULONG *attr_countp);
  88. void scute_attr_free (CK_ATTRIBUTE_PTR attr, CK_ULONG attr_count);
  89. #endif /* !CERT_H */