summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vchat-client.c7
-rw-r--r--vchat-connection.c2
-rw-r--r--vchat-connection.h2
-rwxr-xr-xvchat-keygen7
-rw-r--r--vchat-protocol.c1
-rw-r--r--vchat-tls.c6
-rw-r--r--vchat-tls.h4
-rw-r--r--vchat-ui.c44
-rw-r--r--vchat.h3
-rw-r--r--[-rwxr-xr-x]vchatrc.ex0
10 files changed, 57 insertions, 19 deletions
diff --git a/vchat-client.c b/vchat-client.c
index a22df94..92d1905 100644
--- a/vchat-client.c
+++ b/vchat-client.c
@@ -343,8 +343,13 @@ void cleanup(int signal) {
343 /* inform user if we where killed by signal */ 343 /* inform user if we where killed by signal */
344 if (signal > 1) { 344 if (signal > 1) {
345 fprintf(stderr, "vchat-client: terminated with signal %d.\n", signal); 345 fprintf(stderr, "vchat-client: terminated with signal %d.\n", signal);
346 } else if (errstr[0]) 346 if (!loggedin)
347 dumpconnect();
348 } else if (errstr[0]) {
347 fputs(errstr, stderr); 349 fputs(errstr, stderr);
350 if (!loggedin)
351 dumpconnect();
352 }
348 /* end of story */ 353 /* end of story */
349 exit(0); 354 exit(0);
350} 355}
diff --git a/vchat-connection.c b/vchat-connection.c
index dea69d0..d0abc0d 100644
--- a/vchat-connection.c
+++ b/vchat-connection.c
@@ -166,7 +166,7 @@ int vc_connect(const char *server, const char *port) {
166#endif 166#endif
167#ifdef TLS_LIB_MBEDTLS 167#ifdef TLS_LIB_MBEDTLS
168 if (_engine == TLS_ENGINE_MBEDTLS) 168 if (_engine == TLS_ENGINE_MBEDTLS)
169 result = vc_mbedtls_connect(serverfd, &vc_store); 169 result = vc_mbedtls_connect(server, serverfd, &vc_store);
170#endif 170#endif
171 vc_cleanup_x509store(&vc_store); 171 vc_cleanup_x509store(&vc_store);
172 172
diff --git a/vchat-connection.h b/vchat-connection.h
index 766dc0a..84294f6 100644
--- a/vchat-connection.h
+++ b/vchat-connection.h
@@ -5,7 +5,7 @@
5int vc_connect(const char *host, const char *port); 5int vc_connect(const char *host, const char *port);
6void vc_sendmessage(const char *message); 6void vc_sendmessage(const char *message);
7int vc_receive(); 7int vc_receive();
8int vc_poll(); 8int vc_poll(int);
9void vc_disconnect(); 9void vc_disconnect();
10 10
11const char *vchat_tls_version_external(); 11const char *vchat_tls_version_external();
diff --git a/vchat-keygen b/vchat-keygen
index 91fcbba..4163838 100755
--- a/vchat-keygen
+++ b/vchat-keygen
@@ -29,7 +29,8 @@ if [ ! -e $KEYBASE.key ]; then
29 echo "vchat-keygen: generating RSA key $KEYBASE.key" 29 echo "vchat-keygen: generating RSA key $KEYBASE.key"
30 echo "vchat-keygen: please set passphrase for local security" 30 echo "vchat-keygen: please set passphrase for local security"
31 umask 0077 31 umask 0077
32 openssl genrsa -des3 -out $KEYBASE.key 4096 32 openssl ecparam -genkey -name secp384r1 | \
33 openssl ec -out $KEYBASE.key -aes256
33else 34else
34 echo "vchat-keygen: private key $KEYBASE.key exists" 35 echo "vchat-keygen: private key $KEYBASE.key exists"
35fi 36fi
@@ -40,11 +41,11 @@ fi
40 echo "vchat-keygen: generating config-file for self-signing $KEYBASE.ca.keyconf" 41 echo "vchat-keygen: generating config-file for self-signing $KEYBASE.ca.keyconf"
41 cat >$KEYBASE.ca.keyconf <<EOT 42 cat >$KEYBASE.ca.keyconf <<EOT
42[ req ] 43[ req ]
43default_bits = 4096
44default_keyfile = user.key 44default_keyfile = user.key
45distinguished_name = req_distinguished_name 45distinguished_name = req_distinguished_name
46string_mask = nombstr 46string_mask = nombstr
47req_extensions = v3_req 47req_extensions = v3_req
48default_md = sha384
48[ req_distinguished_name ] 49[ req_distinguished_name ]
49commonName = Name 50commonName = Name
50commonName_max = 64 51commonName_max = 64
@@ -57,7 +58,7 @@ EOT
57 fi 58 fi
58 echo "vchat-keygen: generating Certificate Signing Request $KEYBASE.csr" 59 echo "vchat-keygen: generating Certificate Signing Request $KEYBASE.csr"
59 echo "vchat-keygen: please enter your nickname at the 'Name []:' prompt" 60 echo "vchat-keygen: please enter your nickname at the 'Name []:' prompt"
60 openssl req -new -sha1 -config $KEYBASE.ca.keyconf -key $KEYBASE.key -out $KEYBASE.csr 61 openssl req -new -sha256 -config $KEYBASE.ca.keyconf -key $KEYBASE.key -out $KEYBASE.csr
61 echo "vchat-keygen: send this ($KEYBASE.csr) Certificate Signing Request to 62 echo "vchat-keygen: send this ($KEYBASE.csr) Certificate Signing Request to
62 vchat@vchat.berlin.ccc.de to get it signed by the vchat-CA. You will 63 vchat@vchat.berlin.ccc.de to get it signed by the vchat-CA. You will
63 receive your signed Certificate shortly." 64 receive your signed Certificate shortly."
diff --git a/vchat-protocol.c b/vchat-protocol.c
index ac65639..c5021e4 100644
--- a/vchat-protocol.c
+++ b/vchat-protocol.c
@@ -235,6 +235,7 @@ static void justloggedin(char *message) {
235 loadcfg(getstroption(CF_LOGINSCRIPT), 0, handleline); 235 loadcfg(getstroption(CF_LOGINSCRIPT), 0, handleline);
236 handleline(".S"); 236 handleline(".S");
237 loggedin = 1; 237 loggedin = 1;
238 flushconnect();
238 } 239 }
239} 240}
240 241
diff --git a/vchat-tls.c b/vchat-tls.c
index eaa12f4..e230487 100644
--- a/vchat-tls.c
+++ b/vchat-tls.c
@@ -475,7 +475,7 @@ static void vc_tls_report_error(int error, char *message) {
475 writecf(FS_ERR, tmpstr); 475 writecf(FS_ERR, tmpstr);
476} 476}
477 477
478int vc_mbedtls_connect(int serverfd, vc_x509store_t *vc_store) { 478int vc_mbedtls_connect(const char *servername, int serverfd, vc_x509store_t *vc_store) {
479 /* Some aliases for shorter references */ 479 /* Some aliases for shorter references */
480 mbedstate *s = &_mbedtls_state; 480 mbedstate *s = &_mbedtls_state;
481 mbedtls_ssl_config *conf = &_mbedtls_state._conf; 481 mbedtls_ssl_config *conf = &_mbedtls_state._conf;
@@ -510,7 +510,7 @@ int vc_mbedtls_connect(int serverfd, vc_x509store_t *vc_store) {
510 510
511 char *ciphers = getstroption(CF_CIPHERSUITE); 511 char *ciphers = getstroption(CF_CIPHERSUITE);
512 if (!ciphers) 512 if (!ciphers)
513 ciphers = "ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA"; 513 ciphers = "TLS1-3-AES-256-GCM-SHA384:TLS1-3-AES-128-GCM-SHA256:TLS1-3-AES-128-CCM-SHA256:TLS1-3-AES-128-CCM-8-SHA256:TLS1-3-CHACHA20-POLY1305-SHA256:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA";
514 ciphers = strdup(ciphers); 514 ciphers = strdup(ciphers);
515 for (token = strtok(ciphers, ":"); token && suitecount < MAX_SUITES - 1; 515 for (token = strtok(ciphers, ":"); token && suitecount < MAX_SUITES - 1;
516 token = strtok(NULL, ":")) { 516 token = strtok(NULL, ":")) {
@@ -601,7 +601,7 @@ int vc_mbedtls_connect(int serverfd, vc_x509store_t *vc_store) {
601 ret, "Can not configure parameters on tls context, mbedtls reports: "); 601 ret, "Can not configure parameters on tls context, mbedtls reports: ");
602 return -1; 602 return -1;
603 } 603 }
604 /* TODO: mbedtls_ssl_set_hostname(&ssl, SERVER_NAME) */ 604 mbedtls_ssl_set_hostname(ssl, strdup(servername));
605 605
606 mbedtls_ssl_set_bio(ssl, (void *)(intptr_t)serverfd, static_tcp_send, 606 mbedtls_ssl_set_bio(ssl, (void *)(intptr_t)serverfd, static_tcp_send,
607 static_tcp_recv, NULL); 607 static_tcp_recv, NULL);
diff --git a/vchat-tls.h b/vchat-tls.h
index 5399820..60856e2 100644
--- a/vchat-tls.h
+++ b/vchat-tls.h
@@ -26,7 +26,7 @@ void vc_cleanup_x509store(vc_x509store_t *s);
26 26
27#if !defined(TLS_LIB_OPENSSL) && !defined(TLS_LIB_MBEDTLS) 27#if !defined(TLS_LIB_OPENSSL) && !defined(TLS_LIB_MBEDTLS)
28#error \ 28#error \
29 "Neither TLS_LIB_OPENSSL nor TLS_LIB_MBEDTLS are defined. Please select exactly one." 29 "Neither TLS_LIB_OPENSSL nor TLS_LIB_MBEDTLS are defined. Please select at least one."
30#endif 30#endif
31 31
32#ifdef TLS_LIB_OPENSSL 32#ifdef TLS_LIB_OPENSSL
@@ -40,7 +40,7 @@ char *vc_openssl_version();
40 40
41#ifdef TLS_LIB_MBEDTLS 41#ifdef TLS_LIB_MBEDTLS
42void vc_mbedtls_init_x509store(vc_x509store_t *); 42void vc_mbedtls_init_x509store(vc_x509store_t *);
43int vc_mbedtls_connect(int serverfd, vc_x509store_t *); 43int vc_mbedtls_connect(const char* servername, int serverfd, vc_x509store_t *);
44ssize_t vc_mbedtls_sendmessage(const void *buf, size_t size); 44ssize_t vc_mbedtls_sendmessage(const void *buf, size_t size);
45ssize_t vc_mbedtls_receivemessage(void *buf, size_t size); 45ssize_t vc_mbedtls_receivemessage(void *buf, size_t size);
46void vc_mbedtls_cleanup(); 46void vc_mbedtls_cleanup();
diff --git a/vchat-ui.c b/vchat-ui.c
index bb33287..90c7e9a 100644
--- a/vchat-ui.c
+++ b/vchat-ui.c
@@ -91,6 +91,7 @@ struct sb_data {
91static struct sb_data *sb_pub = NULL; 91static struct sb_data *sb_pub = NULL;
92static struct sb_data *sb_priv = NULL; 92static struct sb_data *sb_priv = NULL;
93static struct sb_data *sb_out = NULL; 93static struct sb_data *sb_out = NULL;
94static struct sb_data *sb_connect = NULL;
94 95
95/* Tells, which window is active */ 96/* Tells, which window is active */
96static int sb_win = 0; /* 0 for pub, 1 for priv */ 97static int sb_win = 0; /* 0 for pub, 1 for priv */
@@ -304,20 +305,24 @@ static void sb_flush(struct sb_data *sb) {
304 struct sb_entry *now = sb->entries, *prev = NULL, *tmp; 305 struct sb_entry *now = sb->entries, *prev = NULL, *tmp;
305 while (now) { 306 while (now) {
306 tmp = (struct sb_entry *)((unsigned long)prev ^ (unsigned long)now->link); 307 tmp = (struct sb_entry *)((unsigned long)prev ^ (unsigned long)now->link);
308 prev = now;
307 free(now->what); 309 free(now->what);
308 free(now); 310 free(now);
309 prev = now;
310 now = tmp; 311 now = tmp;
311 } 312 }
312 sb->entries = NULL; 313 sb->entries = NULL;
314 sb->last = NULL;
315 sb->count = 0;
316 sb->scroll = 0;
313} 317}
314 318
315/*static void 319/*
316sb_clear ( struct sb_data **sb ) { 320static void sb_clear ( struct sb_data **sb ) {
317 sb_flush(*sb); 321 sb_flush(*sb);
318 free( *sb ); 322 free( *sb );
319 *sb = NULL; 323 *sb = NULL;
320}*/ 324}
325*/
321 326
322static struct sb_entry *sb_add(struct sb_data *sb, const char *line, 327static struct sb_entry *sb_add(struct sb_data *sb, const char *line,
323 time_t when) { 328 time_t when) {
@@ -393,7 +398,8 @@ int writecf(formtstr id, char *str) {
393 struct sb_entry *tmp; 398 struct sb_entry *tmp;
394 int i = 0; 399 int i = 0;
395 time_t now = time(NULL); 400 time_t now = time(NULL);
396 snprintf(tmpstr, TMPSTRSIZE, getformatstr(id), str); 401 if (snprintf(tmpstr, TMPSTRSIZE, getformatstr(id), str) < 0)
402 return 0;
397 tmp = sb_add(sb_pub, tmpstr, now); 403 tmp = sb_add(sb_pub, tmpstr, now);
398 404
399 if ((sb_pub->scroll == sb_pub->count) && 405 if ((sb_pub->scroll == sb_pub->count) &&
@@ -407,9 +413,27 @@ int writecf(formtstr id, char *str) {
407 else 413 else
408 consoleline(NULL); 414 consoleline(NULL);
409 415
416 if (!loggedin)
417 sb_add(sb_connect, str, now);
418
410 return i; 419 return i;
411} 420}
412 421
422void dumpconnect() {
423 struct sb_entry *now = sb_connect->entries, *prev = NULL, *tmp;
424 while (now) {
425 tmp = (struct sb_entry *)((unsigned long)prev ^ (unsigned long)now->link);
426 fputs(now->what, stderr);
427 fputc(10, stderr);
428 prev = now;
429 now = tmp;
430 }
431}
432
433void flushconnect() {
434 sb_flush(sb_connect);
435}
436
413int writepriv(char *str, int maybeep) { 437int writepriv(char *str, int maybeep) {
414 int i = 0; 438 int i = 0;
415 if (private) { 439 if (private) {
@@ -1222,6 +1246,7 @@ void initui(void) {
1222 /* Prepare our scrollback buffers */ 1246 /* Prepare our scrollback buffers */
1223 sb_pub = (struct sb_data *)malloc(sizeof(struct sb_data)); 1247 sb_pub = (struct sb_data *)malloc(sizeof(struct sb_data));
1224 sb_out = (struct sb_data *)malloc(sizeof(struct sb_data)); 1248 sb_out = (struct sb_data *)malloc(sizeof(struct sb_data));
1249 sb_connect = (struct sb_data *)malloc(sizeof(struct sb_data));
1225 if (privheight) 1250 if (privheight)
1226 sb_priv = (struct sb_data *)malloc(sizeof(struct sb_data)); 1251 sb_priv = (struct sb_data *)malloc(sizeof(struct sb_data));
1227 else 1252 else
@@ -1230,6 +1255,7 @@ void initui(void) {
1230 memset(sb_pub, 0, sizeof(struct sb_data)); 1255 memset(sb_pub, 0, sizeof(struct sb_data));
1231 memset(sb_priv, 0, sizeof(struct sb_data)); 1256 memset(sb_priv, 0, sizeof(struct sb_data));
1232 memset(sb_out, 0, sizeof(struct sb_data)); 1257 memset(sb_out, 0, sizeof(struct sb_data));
1258 memset(sb_connect, 0, sizeof(struct sb_data));
1233 1259
1234 /* set colors for windows */ 1260 /* set colors for windows */
1235 if (has_colors()) { 1261 if (has_colors()) {
@@ -1344,15 +1370,17 @@ void consoleline(char *message) {
1344 char date[10]; 1370 char date[10];
1345 time_t now = time(NULL); 1371 time_t now = time(NULL);
1346 strftime(date, sizeof(date), getformatstr(FS_CONSOLETIME), localtime(&now)); 1372 strftime(date, sizeof(date), getformatstr(FS_CONSOLETIME), localtime(&now));
1347 snprintf(tmpstr, TMPSTRSIZE, "%s%s", date, consolestr); 1373 if (snprintf(tmpstr, TMPSTRSIZE, "%s%s", date, consolestr) < 0)
1374 return;
1348 mvwaddnstr(console, 0, 0, tmpstr, getmaxx(console) - 1); 1375 mvwaddnstr(console, 0, 0, tmpstr, getmaxx(console) - 1);
1349 } else { 1376 } else {
1350 mvwaddnstr(console, 0, 0, message ? message : consolestr, 1377 mvwaddnstr(console, 0, 0, message ? message : consolestr,
1351 getmaxx(console) - 1); 1378 getmaxx(console) - 1);
1352 } 1379 }
1353 1380
1354 snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_SBINF), sb_pub->scroll, 1381 if (snprintf(tmpstr, TMPSTRSIZE, getformatstr(FS_SBINF), sb_pub->scroll,
1355 sb_pub->count); 1382 sb_pub->count) < 0)
1383 return;
1356 mvwaddstr(console, 0, getmaxx(console) - 1 - (strlen(tmpstr) - 1), tmpstr); 1384 mvwaddstr(console, 0, getmaxx(console) - 1 - (strlen(tmpstr) - 1), tmpstr);
1357 if (sb_win == 0) 1385 if (sb_win == 0)
1358 mvwaddch(console, 0, getmaxx(console) - 1, '*'); 1386 mvwaddch(console, 0, getmaxx(console) - 1, '*');
diff --git a/vchat.h b/vchat.h
index 412566a..3fdbb37 100644
--- a/vchat.h
+++ b/vchat.h
@@ -195,6 +195,9 @@ void flushout(void);
195 } 195 }
196void hideout(void); 196void hideout(void);
197int writecf(formtstr id, char *str); 197int writecf(formtstr id, char *str);
198/* dumps aggregated connect output in case of a connection error */
199void dumpconnect();
200void flushconnect();
198 201
199extern int outputcountdown; 202extern int outputcountdown;
200 203
diff --git a/vchatrc.ex b/vchatrc.ex
index c66d1f9..c66d1f9 100755..100644
--- a/vchatrc.ex
+++ b/vchatrc.ex