agent.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* agent.h - Interface for talking to gpg-agent.
  2. Copyright (C) 2006 g10 Code GmbH
  3. This file is part of Scute[1].
  4. [1] Derived from the RSA Security Inc. PKCS #11 Cryptographic Token
  5. Interface (Cryptoki).
  6. Scute is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. Scute is distributed in the hope that it will be useful, but
  11. WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Scute; if not, write to the Free Software Foundation,
  16. Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. In addition, as a special exception, g10 Code GmbH gives permission
  18. to link this library: with the Mozilla Foundation's code for
  19. Mozilla (or with modified versions of it that use the same license
  20. as the "Mozilla" code), and distribute the linked executables. You
  21. must obey the GNU General Public License in all respects for all of
  22. the code used other than "Mozilla". If you modify this file, you
  23. may extend this exception to your version of the file, but you are
  24. not obligated to do so. If you do not wish to do so, delete this
  25. exception statement from your version. */
  26. #ifndef AGENT_H
  27. #define AGENT_H 1
  28. #include <gpg-error.h>
  29. /* The information structure for a smart card. */
  30. struct agent_card_info_s
  31. {
  32. char *serialno; /* Malloced hex string. */
  33. char *disp_name; /* Malloced. */
  34. char *disp_lang; /* Malloced. */
  35. int disp_sex; /* 0 = unspecified, 1 = male, 2 = female. */
  36. char *pubkey_url; /* Malloced. */
  37. char *login_data; /* Malloced. */
  38. char *private_do[4]; /* Malloced. */
  39. char cafpr1valid;
  40. char cafpr2valid;
  41. char cafpr3valid;
  42. char cafpr1[20];
  43. char cafpr2[20];
  44. char cafpr3[20];
  45. char fpr1valid;
  46. char fpr2valid;
  47. char fpr3valid;
  48. char fpr1[20];
  49. char fpr2[20];
  50. char fpr3[20];
  51. unsigned int fpr1time;
  52. unsigned int fpr2time;
  53. unsigned int fpr3time;
  54. unsigned long sig_counter;
  55. int chv1_cached; /* True if a PIN is not required for each
  56. signing. Note that the gpg-agent might
  57. cache it anyway. */
  58. int chvmaxlen[3]; /* Maximum allowed length of a CHV. */
  59. int chvretry[3]; /* Allowed retries for the CHV; 0 = blocked. */
  60. char grip1valid;
  61. char grip2valid;
  62. char grip3valid;
  63. char grip1[41];
  64. char grip2[41];
  65. char grip3[41];
  66. };
  67. /* Try to connect to the agent via socket. Handle the server's
  68. initial greeting. */
  69. gpg_error_t scute_agent_initialize (void);
  70. /* Tear down the agent connection and release all associated
  71. resources. */
  72. void scute_agent_finalize (void);
  73. /* Check the agent status. This returns 0 if a token is present,
  74. GPG_ERR_CARD_REMOVED if no token is present, and an error code
  75. otherwise. */
  76. gpg_error_t scute_agent_check_status (void);
  77. /* Call the agent to learn about a smartcard. */
  78. gpg_error_t scute_agent_learn (struct agent_card_info_s *info);
  79. /* Release the card info structure INFO. */
  80. void scute_agent_release_card_info (struct agent_card_info_s *info);
  81. /* Sign the data DATA of length LEN with the key GRIP and return the
  82. signature in SIG_RESULT and SIG_LEN. */
  83. gpg_error_t scute_agent_sign (char *grip, unsigned char *data, int len,
  84. unsigned char *sig_result,
  85. unsigned int *sig_len);
  86. #endif /* AGENT_H */