summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/usr.bin/openssl/apps.c5
-rw-r--r--src/usr.bin/openssl/s_cb.c8
-rw-r--r--src/usr.bin/openssl/s_client.c61
-rw-r--r--src/usr.bin/openssl/s_server.c52
4 files changed, 13 insertions, 113 deletions
diff --git a/src/usr.bin/openssl/apps.c b/src/usr.bin/openssl/apps.c
index 7594e77c19..a63bbf9c13 100644
--- a/src/usr.bin/openssl/apps.c
+++ b/src/usr.bin/openssl/apps.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: apps.c,v 1.43 2017/04/18 02:15:50 deraadt Exp $ */ 1/* $OpenBSD: apps.c,v 1.44 2017/08/12 21:04:33 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -2079,7 +2079,8 @@ policies_print(BIO *out, X509_STORE_CTX *ctx)
2079 BIO_free(out); 2079 BIO_free(out);
2080} 2080}
2081 2081
2082/* next_protos_parse parses a comma separated list of strings into a string 2082/*
2083 * next_protos_parse parses a comma separated list of strings into a string
2083 * in a format suitable for passing to SSL_CTX_set_next_protos_advertised. 2084 * in a format suitable for passing to SSL_CTX_set_next_protos_advertised.
2084 * outlen: (output) set to the length of the resulting buffer on success. 2085 * outlen: (output) set to the length of the resulting buffer on success.
2085 * err: (maybe NULL) on failure, an error message line is written to this BIO. 2086 * err: (maybe NULL) on failure, an error message line is written to this BIO.
diff --git a/src/usr.bin/openssl/s_cb.c b/src/usr.bin/openssl/s_cb.c
index d8ab83fb01..73c4953c62 100644
--- a/src/usr.bin/openssl/s_cb.c
+++ b/src/usr.bin/openssl/s_cb.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_cb.c,v 1.7 2016/12/30 17:25:48 jsing Exp $ */ 1/* $OpenBSD: s_cb.c,v 1.8 2017/08/12 21:04:33 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -732,12 +732,6 @@ tlsext_cb(SSL * s, int client_server, int type, unsigned char *data, int len,
732 extname = "renegotiation info"; 732 extname = "renegotiation info";
733 break; 733 break;
734 734
735#ifdef TLSEXT_TYPE_next_proto_neg
736 case TLSEXT_TYPE_next_proto_neg:
737 extname = "next protocol";
738 break;
739#endif
740
741 default: 735 default:
742 extname = "unknown"; 736 extname = "unknown";
743 break; 737 break;
diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c
index aa1c5764bd..f81d1a61bb 100644
--- a/src/usr.bin/openssl/s_client.c
+++ b/src/usr.bin/openssl/s_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_client.c,v 1.32 2017/04/18 02:15:50 deraadt Exp $ */ 1/* $OpenBSD: s_client.c,v 1.33 2017/08/12 21:04:33 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -243,7 +243,6 @@ sc_usage(void)
243 BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n"); 243 BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n");
244 BIO_printf(bio_err, " -status - request certificate status from server\n"); 244 BIO_printf(bio_err, " -status - request certificate status from server\n");
245 BIO_printf(bio_err, " -no_ticket - disable use of RFC4507bis session tickets\n"); 245 BIO_printf(bio_err, " -no_ticket - disable use of RFC4507bis session tickets\n");
246 BIO_printf(bio_err, " -nextprotoneg arg - enable NPN extension, considering named protocols supported (comma-separated list)\n");
247 BIO_printf(bio_err, " -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n"); 246 BIO_printf(bio_err, " -alpn arg - enable ALPN extension, considering named protocols supported (comma-separated list)\n");
248 BIO_printf(bio_err, " -groups arg - specify EC curve groups (colon-separated list)\n"); 247 BIO_printf(bio_err, " -groups arg - specify EC curve groups (colon-separated list)\n");
249#ifndef OPENSSL_NO_SRTP 248#ifndef OPENSSL_NO_SRTP
@@ -278,36 +277,6 @@ ssl_servername_cb(SSL * s, int *ad, void *arg)
278char *srtp_profiles = NULL; 277char *srtp_profiles = NULL;
279#endif 278#endif
280 279
281/* This the context that we pass to next_proto_cb */
282typedef struct tlsextnextprotoctx_st {
283 unsigned char *data;
284 unsigned short len;
285 int status;
286} tlsextnextprotoctx;
287
288static tlsextnextprotoctx next_proto;
289
290static int
291next_proto_cb(SSL * s, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
292{
293 tlsextnextprotoctx *ctx = arg;
294
295 if (!c_quiet) {
296 /* We can assume that |in| is syntactically valid. */
297 unsigned i;
298 BIO_printf(bio_c_out, "Protocols advertised by server: ");
299 for (i = 0; i < inlen;) {
300 if (i)
301 BIO_write(bio_c_out, ", ", 2);
302 BIO_write(bio_c_out, &in[i + 1], in[i]);
303 i += in[i] + 1;
304 }
305 BIO_write(bio_c_out, "\n", 1);
306 }
307 ctx->status = SSL_select_next_proto(out, outlen, in, inlen, ctx->data, ctx->len);
308 return SSL_TLSEXT_ERR_OK;
309}
310
311enum { 280enum {
312 PROTO_OFF = 0, 281 PROTO_OFF = 0,
313 PROTO_SMTP, 282 PROTO_SMTP,
@@ -354,9 +323,7 @@ s_client_main(int argc, char **argv)
354 struct timeval timeout; 323 struct timeval timeout;
355 const char *errstr = NULL; 324 const char *errstr = NULL;
356 char *servername = NULL; 325 char *servername = NULL;
357 tlsextctx tlsextcbp = 326 tlsextctx tlsextcbp = {NULL, 0};
358 {NULL, 0};
359 const char *next_proto_neg_in = NULL;
360 const char *alpn_in = NULL; 327 const char *alpn_in = NULL;
361 const char *groups_in = NULL; 328 const char *groups_in = NULL;
362 char *sess_in = NULL; 329 char *sess_in = NULL;
@@ -532,9 +499,10 @@ s_client_main(int argc, char **argv)
532 } else if (strcmp(*argv, "-no_ticket") == 0) { 499 } else if (strcmp(*argv, "-no_ticket") == 0) {
533 off |= SSL_OP_NO_TICKET; 500 off |= SSL_OP_NO_TICKET;
534 } else if (strcmp(*argv, "-nextprotoneg") == 0) { 501 } else if (strcmp(*argv, "-nextprotoneg") == 0) {
502 /* Ignored. */
535 if (--argc < 1) 503 if (--argc < 1)
536 goto bad; 504 goto bad;
537 next_proto_neg_in = *(++argv); 505 ++argv;
538 } else if (strcmp(*argv, "-alpn") == 0) { 506 } else if (strcmp(*argv, "-alpn") == 0) {
539 if (--argc < 1) 507 if (--argc < 1)
540 goto bad; 508 goto bad;
@@ -633,16 +601,6 @@ bad:
633 goto end; 601 goto end;
634 } 602 }
635 603
636 next_proto.status = -1;
637 if (next_proto_neg_in) {
638 next_proto.data = next_protos_parse(&next_proto.len, next_proto_neg_in);
639 if (next_proto.data == NULL) {
640 BIO_printf(bio_err, "Error parsing -nextprotoneg argument\n");
641 goto end;
642 }
643 } else
644 next_proto.data = NULL;
645
646 if (!app_passwd(bio_err, passarg, NULL, &pass, NULL)) { 604 if (!app_passwd(bio_err, passarg, NULL, &pass, NULL)) {
647 BIO_printf(bio_err, "Error getting password\n"); 605 BIO_printf(bio_err, "Error getting password\n");
648 goto end; 606 goto end;
@@ -704,8 +662,6 @@ bad:
704 if (socket_type == SOCK_DGRAM) 662 if (socket_type == SOCK_DGRAM)
705 SSL_CTX_set_read_ahead(ctx, 1); 663 SSL_CTX_set_read_ahead(ctx, 1);
706 664
707 if (next_proto.data)
708 SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &next_proto);
709 if (alpn_in) { 665 if (alpn_in) {
710 unsigned short alpn_len; 666 unsigned short alpn_len;
711 unsigned char *alpn = next_protos_parse(&alpn_len, alpn_in); 667 unsigned char *alpn = next_protos_parse(&alpn_len, alpn_in);
@@ -1256,7 +1212,6 @@ end:
1256 print_stuff(bio_c_out, con, 1); 1212 print_stuff(bio_c_out, con, 1);
1257 SSL_free(con); 1213 SSL_free(con);
1258 } 1214 }
1259 free(next_proto.data);
1260 if (ctx != NULL) 1215 if (ctx != NULL)
1261 SSL_CTX_free(ctx); 1216 SSL_CTX_free(ctx);
1262 if (cert) 1217 if (cert)
@@ -1404,14 +1359,6 @@ print_stuff(BIO * bio, SSL * s, int full)
1404 } 1359 }
1405#endif 1360#endif
1406 1361
1407 if (next_proto.status != -1) {
1408 const unsigned char *proto;
1409 unsigned int proto_len;
1410 SSL_get0_next_proto_negotiated(s, &proto, &proto_len);
1411 BIO_printf(bio, "Next protocol: (%d) ", next_proto.status);
1412 BIO_write(bio, proto, proto_len);
1413 BIO_write(bio, "\n", 1);
1414 }
1415 { 1362 {
1416 const unsigned char *proto; 1363 const unsigned char *proto;
1417 unsigned int proto_len; 1364 unsigned int proto_len;
diff --git a/src/usr.bin/openssl/s_server.c b/src/usr.bin/openssl/s_server.c
index 493dc26264..7254109fba 100644
--- a/src/usr.bin/openssl/s_server.c
+++ b/src/usr.bin/openssl/s_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s_server.c,v 1.26 2017/04/18 02:15:50 deraadt Exp $ */ 1/* $OpenBSD: s_server.c,v 1.27 2017/08/12 21:04:33 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -333,7 +333,6 @@ sv_usage(void)
333 BIO_printf(bio_err, " not specified (default is %s)\n", TEST_CERT2); 333 BIO_printf(bio_err, " not specified (default is %s)\n", TEST_CERT2);
334 BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n"); 334 BIO_printf(bio_err, " -tlsextdebug - hex dump of all TLS extensions received\n");
335 BIO_printf(bio_err, " -no_ticket - disable use of RFC4507bis session tickets\n"); 335 BIO_printf(bio_err, " -no_ticket - disable use of RFC4507bis session tickets\n");
336 BIO_printf(bio_err, " -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n");
337 BIO_printf(bio_err," -alpn arg - set the advertised protocols for the ALPN extension (comma-separated list)\n"); 336 BIO_printf(bio_err," -alpn arg - set the advertised protocols for the ALPN extension (comma-separated list)\n");
338#ifndef OPENSSL_NO_SRTP 337#ifndef OPENSSL_NO_SRTP
339 BIO_printf(bio_err, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n"); 338 BIO_printf(bio_err, " -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
@@ -509,24 +508,6 @@ err:
509 goto done; 508 goto done;
510} 509}
511 510
512/* This is the context that we pass to next_proto_cb */
513typedef struct tlsextnextprotoctx_st {
514 unsigned char *data;
515 unsigned int len;
516} tlsextnextprotoctx;
517
518static int
519next_proto_cb(SSL * s, const unsigned char **data, unsigned int *len, void *arg)
520{
521 tlsextnextprotoctx *next_proto = arg;
522
523 *data = next_proto->data;
524 *len = next_proto->len;
525
526 return SSL_TLSEXT_ERR_OK;
527}
528
529
530/* This the context that we pass to alpn_cb */ 511/* This the context that we pass to alpn_cb */
531typedef struct tlsextalpnctx_st { 512typedef struct tlsextalpnctx_st {
532 unsigned char *data; 513 unsigned char *data;
@@ -599,8 +580,6 @@ s_server_main(int argc, char *argv[])
599 EVP_PKEY *s_key2 = NULL; 580 EVP_PKEY *s_key2 = NULL;
600 X509 *s_cert2 = NULL; 581 X509 *s_cert2 = NULL;
601 tlsextctx tlsextcbp = {NULL, NULL, SSL_TLSEXT_ERR_ALERT_WARNING}; 582 tlsextctx tlsextcbp = {NULL, NULL, SSL_TLSEXT_ERR_ALERT_WARNING};
602 const char *next_proto_neg_in = NULL;
603 tlsextnextprotoctx next_proto = { NULL, 0 };
604 const char *alpn_in = NULL; 583 const char *alpn_in = NULL;
605 tlsextalpnctx alpn_ctx = { NULL, 0 }; 584 tlsextalpnctx alpn_ctx = { NULL, 0 };
606 585
@@ -843,13 +822,12 @@ s_server_main(int argc, char *argv[])
843 if (--argc < 1) 822 if (--argc < 1)
844 goto bad; 823 goto bad;
845 s_key_file2 = *(++argv); 824 s_key_file2 = *(++argv);
846 } 825 } else if (strcmp(*argv, "-nextprotoneg") == 0) {
847 else if (strcmp(*argv, "-nextprotoneg") == 0) { 826 /* Ignored. */
848 if (--argc < 1) 827 if (--argc < 1)
849 goto bad; 828 goto bad;
850 next_proto_neg_in = *(++argv); 829 ++argv;
851 } 830 } else if (strcmp(*argv,"-alpn") == 0) {
852 else if (strcmp(*argv,"-alpn") == 0) {
853 if (--argc < 1) 831 if (--argc < 1)
854 goto bad; 832 goto bad;
855 alpn_in = *(++argv); 833 alpn_in = *(++argv);
@@ -928,15 +906,6 @@ bad:
928 } 906 }
929 } 907 }
930 } 908 }
931 if (next_proto_neg_in) {
932 unsigned short len;
933 next_proto.data = next_protos_parse(&len, next_proto_neg_in);
934 if (next_proto.data == NULL)
935 goto end;
936 next_proto.len = len;
937 } else {
938 next_proto.data = NULL;
939 }
940 alpn_ctx.data = NULL; 909 alpn_ctx.data = NULL;
941 if (alpn_in) { 910 if (alpn_in) {
942 unsigned short len; 911 unsigned short len;
@@ -1083,8 +1052,6 @@ bad:
1083 if (vpm) 1052 if (vpm)
1084 SSL_CTX_set1_param(ctx2, vpm); 1053 SSL_CTX_set1_param(ctx2, vpm);
1085 } 1054 }
1086 if (next_proto.data)
1087 SSL_CTX_set_next_protos_advertised_cb(ctx, next_proto_cb, &next_proto);
1088 if (alpn_ctx.data) 1055 if (alpn_ctx.data)
1089 SSL_CTX_set_alpn_select_cb(ctx, alpn_cb, &alpn_ctx); 1056 SSL_CTX_set_alpn_select_cb(ctx, alpn_cb, &alpn_ctx);
1090 1057
@@ -1255,7 +1222,6 @@ end:
1255 X509_free(s_cert2); 1222 X509_free(s_cert2);
1256 if (s_key2) 1223 if (s_key2)
1257 EVP_PKEY_free(s_key2); 1224 EVP_PKEY_free(s_key2);
1258 free(next_proto.data);
1259 free(alpn_ctx.data); 1225 free(alpn_ctx.data);
1260 if (bio_s_out != NULL) { 1226 if (bio_s_out != NULL) {
1261 BIO_free(bio_s_out); 1227 BIO_free(bio_s_out);
@@ -1614,8 +1580,6 @@ init_ssl_connection(SSL * con)
1614 X509 *peer; 1580 X509 *peer;
1615 long verify_error; 1581 long verify_error;
1616 char buf[BUFSIZ]; 1582 char buf[BUFSIZ];
1617 const unsigned char *next_proto_neg;
1618 unsigned next_proto_neg_len;
1619 unsigned char *exportedkeymat; 1583 unsigned char *exportedkeymat;
1620 1584
1621 i = SSL_accept(con); 1585 i = SSL_accept(con);
@@ -1650,12 +1614,6 @@ init_ssl_connection(SSL * con)
1650 str = SSL_CIPHER_get_name(SSL_get_current_cipher(con)); 1614 str = SSL_CIPHER_get_name(SSL_get_current_cipher(con));
1651 BIO_printf(bio_s_out, "CIPHER is %s\n", (str != NULL) ? str : "(NONE)"); 1615 BIO_printf(bio_s_out, "CIPHER is %s\n", (str != NULL) ? str : "(NONE)");
1652 1616
1653 SSL_get0_next_proto_negotiated(con, &next_proto_neg, &next_proto_neg_len);
1654 if (next_proto_neg) {
1655 BIO_printf(bio_s_out, "NEXTPROTO is ");
1656 BIO_write(bio_s_out, next_proto_neg, next_proto_neg_len);
1657 BIO_printf(bio_s_out, "\n");
1658 }
1659#ifndef OPENSSL_NO_SRTP 1617#ifndef OPENSSL_NO_SRTP
1660 { 1618 {
1661 SRTP_PROTECTION_PROFILE *srtp_profile 1619 SRTP_PROTECTION_PROFILE *srtp_profile