summaryrefslogtreecommitdiff
path: root/gnutls-helpers.h
blob: c07997f3aada77df22ddc2a9f7aac648d567d82d (plain)
  1. /* Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net> */
  2. /* Date: Fri, 04 Apr 2008 19:31:16 -0400 */
  3. /* License: GPL v3 or later */
  4. #include <gnutls/gnutls.h>
  5. #include <gnutls/openpgp.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <errno.h>
  10. #include <sys/types.h>
  11. #include <sys/stat.h>
  12. #include <unistd.h>
  13. #include <stdarg.h>
  14. /* Functions to help dealing with GnuTLS for monkeysphere key
  15. translation projects: */
  16. /* set everything up, including logging levels. Return 0 on
  17. success */
  18. int init_gnutls();
  19. /* logging and output functions: */
  20. void err(const char* fmt, ...);
  21. void logfunc(int level, const char* string);
  22. /* basic datum manipulations: */
  23. void init_datum(gnutls_datum_t* d);
  24. void copy_datum(gnutls_datum_t* dest, const gnutls_datum_t* src);
  25. int compare_data(const gnutls_datum_t* a, const gnutls_datum_t* b);
  26. void free_datum(gnutls_datum_t* d);
  27. /* keyid manipulations: */
  28. typedef unsigned char printable_keyid[16];
  29. void init_keyid(gnutls_openpgp_keyid_t keyid);
  30. void make_keyid_printable(printable_keyid out, gnutls_openpgp_keyid_t keyid);
  31. /* functions to get data into datum objects: */
  32. /* read the passed-in string, store in a single datum */
  33. int set_datum_string(gnutls_datum_t* d, const char* s);
  34. /* read the passed-in file descriptor until EOF, store in a single
  35. datum */
  36. int set_datum_fd(gnutls_datum_t* d, int fd);
  37. /* read the file indicated (by na1me) in the fname parameter. store
  38. its entire contents in a single datum. */
  39. int set_datum_file(gnutls_datum_t* d, const char* fname);