63
63
#include <errno.h> /* perror() */
67
67
#include <getopt.h>
69
69
#define BUFFER_SIZE 256
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";
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";
77
76
bool debug = false;
81
79
gnutls_session_t session;
82
80
gnutls_certificate_credentials_t cred;
284
282
fprintf(stderr, "Attempting to use OpenPGP certificate %s"
285
" and keyfile %s as GnuTLS credentials\n", pubkeyfile,
283
" and keyfile %s as GnuTLS credentials\n", certfile,
289
287
ret = gnutls_certificate_set_openpgp_key_file
290
(es->cred, pubkeyfile, seckeyfile, GNUTLS_OPENPGP_FMT_BASE64);
288
(es->cred, certfile, certkey, GNUTLS_OPENPGP_FMT_BASE64);
291
289
if (ret != GNUTLS_E_SUCCESS) {
293
291
(stderr, "Error[%d] while reading the OpenPGP key pair ('%s',"
295
ret, pubkeyfile, seckeyfile);
293
ret, certfile, certkey);
296
294
fprintf(stdout, "The Error is: %s\n",
297
295
safer_gnutls_strerror(ret));
309
if ((ret = gnutls_dh_params_generate2 (es->dh_params, dh_bits))
307
if ((ret = gnutls_dh_params_generate2 (es->dh_params, DH_BITS))
310
308
!= GNUTLS_E_SUCCESS) {
311
309
fprintf (stderr, "Error in prime generation: %s\n",
312
310
safer_gnutls_strerror(ret));
405
403
fprintf(stderr, "Connection to: %s, port %d\n", ip, 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));
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)); */
418
414
ret = connect(tcp_sd, (struct sockaddr *) &to, sizeof(to));
497
493
decrypted_buffer_size = pgp_packet_decrypt(buffer,
499
495
&decrypted_buffer,
501
497
if (decrypted_buffer_size >= 0){
502
498
while(written < (size_t) decrypted_buffer_size){
503
499
ret = (int)fwrite (decrypted_buffer + written, 1,
658
654
AvahiSServiceBrowser *sb = NULL;
662
657
int returncode = EXIT_SUCCESS;
663
658
const char *interface = NULL;
664
659
AvahiIfIndex if_index = AVAHI_IF_UNSPEC;
665
660
char *connect_to = NULL;
667
debug_int = debug ? 1 : 0;
669
663
static struct option long_options[] = {
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'},
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'},
679
672
int option_index = 0;