X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=gnutls-helpers.c;h=6eae29e0aa3a32352c62212587a33118d5ca973f;hb=19b2668dfef84687e052c42638ad7e696d5fa6a6;hp=50b611446a32145c12edb5ba91bc149a93968705;hpb=e64a37b7ee2e4f91171f3893934b325858f5f6ce;p=monkeysphere.git diff --git a/gnutls-helpers.c b/gnutls-helpers.c index 50b6114..6eae29e 100644 --- a/gnutls-helpers.c +++ b/gnutls-helpers.c @@ -20,6 +20,7 @@ void err(const char* fmt, ...) { va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); + fflush(stderr); } void logfunc(int level, const char* string) { @@ -286,6 +287,10 @@ int create_writing_pipe(pid_t* pid, const char* path, char* const argv[]) { } execv(path, argv); err("exec %s failed (error: %d \"%s\")\n", path, errno, strerror(errno)); + /* close the open file descriptors */ + close(p[0]); + close(0); + exit(1); } else { /* this is the parent */ close(p[0]); /* close unused read end */ @@ -340,3 +345,20 @@ int validate_ssh_host_userid(const char* userid) { setlocale(LC_ALL, oldlocale); return 1; } + +/* http://tools.ietf.org/html/rfc4880#section-5.5.2 */ +size_t get_openpgp_mpi_size(gnutls_datum_t* d) { + return 2 + d->size; +} + +int write_openpgp_mpi_to_fd(int fd, gnutls_datum_t* d) { + uint16_t x; + + x = d->size * 8; + x = htons(x); + + write(fd, &x, sizeof(x)); + write(fd, d->data, d->size); + + return 0; +}