63
63
#include <errno.h> /* perror() */
67
67
#include <getopt.h>
69
69
#define BUFFER_SIZE 256
72
static const char *certdir = "/conf/conf.d/mandos";
73
static const char *certfile = "openpgp-client.txt";
74
static const char *certkey = "openpgp-client-key.txt";
71
static int dh_bits = 1024;
73
static const char *keydir = "/conf/conf.d/mandos";
74
static const char *pubkeyfile = "pubkey.txt";
75
static const char *seckeyfile = "seckey.txt";
76
77
bool debug = false;
79
81
gnutls_session_t session;
80
82
gnutls_certificate_credentials_t cred;
282
284
fprintf(stderr, "Attempting to use OpenPGP certificate %s"
283
" and keyfile %s as GnuTLS credentials\n", certfile,
285
" and keyfile %s as GnuTLS credentials\n", pubkeyfile,
287
289
ret = gnutls_certificate_set_openpgp_key_file
288
(es->cred, certfile, certkey, GNUTLS_OPENPGP_FMT_BASE64);
290
(es->cred, pubkeyfile, seckeyfile, GNUTLS_OPENPGP_FMT_BASE64);
289
291
if (ret != GNUTLS_E_SUCCESS) {
291
293
(stderr, "Error[%d] while reading the OpenPGP key pair ('%s',"
293
ret, certfile, certkey);
295
ret, pubkeyfile, seckeyfile);
294
296
fprintf(stdout, "The Error is: %s\n",
295
297
safer_gnutls_strerror(ret));
307
if ((ret = gnutls_dh_params_generate2 (es->dh_params, DH_BITS))
309
if ((ret = gnutls_dh_params_generate2 (es->dh_params, dh_bits))
308
310
!= GNUTLS_E_SUCCESS) {
309
311
fprintf (stderr, "Error in prime generation: %s\n",
310
312
safer_gnutls_strerror(ret));
403
405
fprintf(stderr, "Connection to: %s, port %d\n", ip, port);
404
/* char addrstr[INET6_ADDRSTRLEN]; */
405
/* if(inet_ntop(to.sin6_family, &(to.sin6_addr), addrstr, */
406
/* sizeof(addrstr)) == NULL){ */
407
/* perror("inet_ntop"); */
409
/* fprintf(stderr, "Really connecting to: %s, port %d\n", */
410
/* addrstr, ntohs(to.sin6_port)); */
406
char addrstr[INET6_ADDRSTRLEN] = "";
407
if(inet_ntop(to.sin6_family, &(to.sin6_addr), addrstr,
408
sizeof(addrstr)) == NULL){
411
if(strcmp(addrstr, ip) != 0){
412
fprintf(stderr, "Canonical address form: %s\n",
413
addrstr, ntohs(to.sin6_port));
414
418
ret = connect(tcp_sd, (struct sockaddr *) &to, sizeof(to));
493
497
decrypted_buffer_size = pgp_packet_decrypt(buffer,
495
499
&decrypted_buffer,
497
501
if (decrypted_buffer_size >= 0){
498
502
while(written < (size_t) decrypted_buffer_size){
499
503
ret = (int)fwrite (decrypted_buffer + written, 1,
654
658
AvahiSServiceBrowser *sb = NULL;
657
662
int returncode = EXIT_SUCCESS;
658
663
const char *interface = NULL;
659
664
AvahiIfIndex if_index = AVAHI_IF_UNSPEC;
660
665
char *connect_to = NULL;
667
debug_int = debug ? 1 : 0;
663
669
static struct option long_options[] = {
664
{"debug", no_argument, (int *)&debug, 1},
665
{"connect", required_argument, 0, 'C'},
666
{"interface", required_argument, 0, 'i'},
667
{"certdir", required_argument, 0, 'd'},
668
{"certkey", required_argument, 0, 'c'},
669
{"certfile", required_argument, 0, 'k'},
670
{"debug", no_argument, &debug_int, 1},
671
{"connect", required_argument, NULL, 'C'},
672
{"interface", required_argument, NULL, 'i'},
673
{"keydir", required_argument, NULL, 'd'},
674
{"seckey", required_argument, NULL, 'c'},
675
{"pubkey", required_argument, NULL, 'k'},
676
{"dh-bits", required_argument, NULL, 'D'},
672
679
int option_index = 0;