diff options
| author | jsing <> | 2016-12-30 17:25:48 +0000 |
|---|---|---|
| committer | jsing <> | 2016-12-30 17:25:48 +0000 |
| commit | b6a4a6abadee9e623e9b7e8f318e25c5681e2dc3 (patch) | |
| tree | 60cfd9ecaf49a5109e5cbbe2facdf318f5110875 /src/usr.bin/openssl/s_cb.c | |
| parent | 1cc76fd07be78b0b955623d8e844d5345cae0cd1 (diff) | |
| download | openbsd-b6a4a6abadee9e623e9b7e8f318e25c5681e2dc3.tar.gz openbsd-b6a4a6abadee9e623e9b7e8f318e25c5681e2dc3.tar.bz2 openbsd-b6a4a6abadee9e623e9b7e8f318e25c5681e2dc3.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.c | 39 |
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 | ||
| 288 | int | ||
| 289 | ssl_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 | |||
| 288 | long | 325 | long |
| 289 | bio_dump_callback(BIO * bio, int cmd, const char *argp, | 326 | bio_dump_callback(BIO * bio, int cmd, const char *argp, |
| 290 | int argi, long argl, long ret) | 327 | int argi, long argl, long ret) |
