summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/s_cb.c
diff options
context:
space:
mode:
authorjsing <>2016-12-30 17:25:48 +0000
committerjsing <>2016-12-30 17:25:48 +0000
commita8b45803d3fb6170b4567bc459cc88846d7d09ee (patch)
tree60cfd9ecaf49a5109e5cbbe2facdf318f5110875 /src/usr.bin/openssl/s_cb.c
parentc6852449efeadbfc5a05c733da7136ce72a68a35 (diff)
downloadopenbsd-a8b45803d3fb6170b4567bc459cc88846d7d09ee.tar.gz
openbsd-a8b45803d3fb6170b4567bc459cc88846d7d09ee.tar.bz2
openbsd-a8b45803d3fb6170b4567bc459cc88846d7d09ee.zip
Display details of the server ephemeral key, based on OpenSSL.
ok doug@
Diffstat (limited to 'src/usr.bin/openssl/s_cb.c')
-rw-r--r--src/usr.bin/openssl/s_cb.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/usr.bin/openssl/s_cb.c b/src/usr.bin/openssl/s_cb.c
index ac3a0076bd..d8ab83fb01 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.6 2015/09/10 19:08:46 jsing Exp $ */ 1/* $OpenBSD: s_cb.c,v 1.7 2016/12/30 17:25:48 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 *
@@ -285,6 +285,43 @@ set_cert_key_stuff(SSL_CTX * ctx, X509 * cert, EVP_PKEY * key)
285 return 1; 285 return 1;
286} 286}
287 287
288int
289ssl_print_tmp_key(BIO *out, SSL *s)
290{
291 const char *cname;
292 EVP_PKEY *pkey;
293 EC_KEY *ec;
294 int nid;
295
296 if (!SSL_get_server_tmp_key(s, &pkey))
297 return 0;
298
299 BIO_puts(out, "Server Temp Key: ");
300 switch (EVP_PKEY_id(pkey)) {
301 case EVP_PKEY_DH:
302 BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(pkey));
303 break;
304
305 case EVP_PKEY_EC:
306 ec = EVP_PKEY_get1_EC_KEY(pkey);
307 nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
308 EC_KEY_free(ec);
309
310 if ((cname = EC_curve_nid2nist(nid)) == NULL)
311 cname = OBJ_nid2sn(nid);
312
313 BIO_printf(out, "ECDH, %s, %d bits\n", cname, EVP_PKEY_bits(pkey));
314 break;
315
316 default:
317 BIO_printf(out, "%s, %d bits\n", OBJ_nid2sn(EVP_PKEY_id(pkey)),
318 EVP_PKEY_bits(pkey));
319 }
320
321 EVP_PKEY_free(pkey);
322 return 1;
323}
324
288long 325long
289bio_dump_callback(BIO * bio, int cmd, const char *argp, 326bio_dump_callback(BIO * bio, int cmd, const char *argp,
290 int argi, long argl, long ret) 327 int argi, long argl, long ret)