1 /* Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net> */
2 /* Date: Fri, 04 Apr 2008 19:31:16 -0400 */
3 /* License: GPL v3 or later */
6 #include <gnutls/gnutls.h>
7 #include <gnutls/openpgp.h>
12 #include <sys/types.h>
17 /* Functions to help dealing with GnuTLS for monkeysphere key
18 translation projects: */
20 /* set everything up, including logging levels. Return 0 on
24 /* logging and output functions: */
26 void err(int level, const char* fmt, ...);
27 void logfunc(int level, const char* string);
29 /* basic datum manipulations: */
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 int write_datum_fd(int fd, const gnutls_datum_t* d);
36 int write_datum_fd_with_length(int fd, const gnutls_datum_t* d);
37 int write_data_fd_with_length(int fd, const gnutls_datum_t** d, unsigned int num);
39 /* set up a datum from a null-terminated string */
40 int datum_from_string(gnutls_datum_t* d, const char* str);
42 /* keyid manipulations: */
43 typedef unsigned char printable_keyid[16];
45 void init_keyid(gnutls_openpgp_keyid_t keyid);
46 void make_keyid_printable(printable_keyid out, gnutls_openpgp_keyid_t keyid);
47 void collapse_printable_keyid(gnutls_openpgp_keyid_t out, printable_keyid in);
48 int convert_string_to_keyid(gnutls_openpgp_keyid_t out, const char* str);
49 int convert_string_to_printable_keyid(printable_keyid out, const char* str);
52 /* functions to get data into datum objects: */
54 /* read the passed-in string, store in a single datum */
55 int set_datum_string(gnutls_datum_t* d, const char* s);
57 /* read the passed-in file descriptor until EOF, store in a single
59 int set_datum_fd(gnutls_datum_t* d, int fd);
61 /* read the file indicated (by name) in the fname parameter. store
62 its entire contents in a single datum. */
63 int set_datum_file(gnutls_datum_t* d, const char* fname);
65 /* set up file descriptor pipe for writing (child process pid gets
66 stored in pid, fd is returned)*/
67 int create_writing_pipe(pid_t* pid, const char* path, char* const argv[]);
69 /* return 0 if userid matches the monkeysphere spec for ssh host user IDs */
70 int validate_ssh_host_userid(const char* userid);
72 /* how many bytes will it take to write out this datum in OpenPGP MPI form? */
73 size_t get_openpgp_mpi_size(gnutls_datum_t* d);
75 /* write the MPI stored in gnutls_datum_t to file descriptor fd: */
76 int write_openpgp_mpi_to_fd(int fd, gnutls_datum_t* d);