c07997f3aada77df22ddc2a9f7aac648d567d82d
[monkeysphere.git] / gnutls-helpers.h
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
5
6 #include <gnutls/gnutls.h>
7 #include <gnutls/openpgp.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <errno.h>
12 #include <sys/types.h>
13 #include <sys/stat.h>
14 #include <unistd.h>
15 #include <stdarg.h>
16
17 /* Functions to help dealing with GnuTLS for monkeysphere key
18    translation projects: */
19
20 /* set everything up, including logging levels.  Return 0 on
21    success */
22 int init_gnutls();
23
24 /* logging and output functions: */
25
26 void err(const char* fmt, ...);
27 void logfunc(int level, const char* string);
28
29 /* basic datum manipulations: */
30
31 void init_datum(gnutls_datum_t* d);
32 void copy_datum(gnutls_datum_t* dest, const gnutls_datum_t* src);
33 int compare_data(const gnutls_datum_t* a, const gnutls_datum_t* b);
34 void free_datum(gnutls_datum_t* d);
35
36 /* keyid manipulations: */
37 typedef unsigned char printable_keyid[16];
38
39 void init_keyid(gnutls_openpgp_keyid_t keyid);
40 void make_keyid_printable(printable_keyid out, gnutls_openpgp_keyid_t keyid);
41
42 /* functions to get data into datum objects: */
43
44 /* read the passed-in string, store in a single datum */
45 int set_datum_string(gnutls_datum_t* d, const char* s);
46
47 /* read the passed-in file descriptor until EOF, store in a single
48    datum */
49 int set_datum_fd(gnutls_datum_t* d, int fd);
50
51 /* read the file indicated (by na1me) in the fname parameter.  store
52    its entire contents in a single datum. */
53 int set_datum_file(gnutls_datum_t* d, const char* fname);
54