agent.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* agent.h - Interface for talking to gpg-agent.
  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 AGENT_H
  25. #define AGENT_H 1
  26. #include <gpg-error.h>
  27. #include <stdbool.h>
  28. /* The information structure for a smart card. */
  29. struct agent_card_info_s
  30. {
  31. char *serialno; /* Malloced hex string. */
  32. char *disp_name; /* Malloced. */
  33. char *disp_lang; /* Malloced. */
  34. int disp_sex; /* 0 = unspecified, 1 = male, 2 = female. */
  35. char *pubkey_url; /* Malloced. */
  36. char *login_data; /* Malloced. */
  37. char *private_do[4]; /* Malloced. */
  38. char cafpr1valid;
  39. char cafpr2valid;
  40. char cafpr3valid;
  41. char cafpr1[20];
  42. char cafpr2[20];
  43. char cafpr3[20];
  44. char fpr1valid;
  45. char fpr2valid;
  46. char fpr3valid;
  47. char fpr1[20];
  48. char fpr2[20];
  49. char fpr3[20];
  50. unsigned int fpr1time;
  51. unsigned int fpr2time;
  52. unsigned int fpr3time;
  53. unsigned long sig_counter;
  54. int chv1_cached; /* True if a PIN is not required for each
  55. signing. Note that the gpg-agent might
  56. cache it anyway. */
  57. int chvmaxlen[3]; /* Maximum allowed length of a CHV. */
  58. int chvretry[3]; /* Allowed retries for the CHV; 0 = blocked. */
  59. char grip1valid;
  60. char grip2valid;
  61. char grip3valid;
  62. char grip1[41];
  63. char grip2[41];
  64. char grip3[41];
  65. };
  66. /* Try to connect to the agent via socket. Handle the server's
  67. initial greeting. */
  68. gpg_error_t scute_agent_initialize (void);
  69. /* Return the major and minor version of the agent. */
  70. int scute_agent_get_agent_version (int *minor);
  71. /* Tear down the agent connection and release all associated
  72. resources. */
  73. void scute_agent_finalize (void);
  74. /* Check the agent status. This returns 0 if a token is present,
  75. GPG_ERR_CARD_REMOVED if no token is present, and an error code
  76. otherwise. */
  77. gpg_error_t scute_agent_check_status (void);
  78. /* Call the agent to learn about a smartcard. */
  79. gpg_error_t scute_agent_learn (struct agent_card_info_s *info);
  80. /* Release the card info structure INFO. */
  81. void scute_agent_release_card_info (struct agent_card_info_s *info);
  82. /* Sign the data DATA of length LEN with the key GRIP and return the
  83. signature in SIG_RESULT and SIG_LEN. */
  84. gpg_error_t scute_agent_sign (char *grip, unsigned char *data, int len,
  85. unsigned char *sig_result,
  86. unsigned int *sig_len);
  87. /* Determine if FPR is trusted. */
  88. gpg_error_t scute_agent_is_trusted (char *fpr, bool *is_trusted);
  89. #endif /* AGENT_H */