diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2012-09-08 13:59:51 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2012-09-08 13:59:51 +0000 |
commit | 33a8de69dc092285fce9a3db4aae2b0df8852427 (patch) | |
tree | 8aecae0e19eac9a95adbcc2e146b36d7655a5c9f /apps | |
parent | 319354eb6c6cac74213d754dad105f71abc72547 (diff) |
new ctrl to retrive value of received temporary key in server key exchange message, print out details in s_client
Diffstat (limited to 'apps')
-rw-r--r-- | apps/s_apps.h | 1 | ||||
-rw-r--r-- | apps/s_cb.c | 34 | ||||
-rw-r--r-- | apps/s_client.c | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/apps/s_apps.h b/apps/s_apps.h index c7e6926a27..b45c1b9a56 100644 --- a/apps/s_apps.h +++ b/apps/s_apps.h @@ -163,6 +163,7 @@ int set_cert_key_and_authz(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key, int ssl_print_sigalgs(BIO *out, SSL *s); int ssl_print_curves(BIO *out, SSL *s); #endif +int ssl_print_tmp_key(BIO *out, SSL *s); int init_client(int *sock, char *server, int port, int type); int should_retry(int i); int extract_port(char *str, short *port_ptr); diff --git a/apps/s_cb.c b/apps/s_cb.c index b592870f96..fc40f391e3 100644 --- a/apps/s_cb.c +++ b/apps/s_cb.c @@ -466,6 +466,40 @@ int ssl_print_curves(BIO *out, SSL *s) return 1; } +int ssl_print_tmp_key(BIO *out, SSL *s) + { + EVP_PKEY *key; + if (!SSL_get_server_tmp_key(s, &key)) + return 1; + BIO_puts(out, "Server Temp Key: "); + switch (EVP_PKEY_id(key)) + { + case EVP_PKEY_RSA: + BIO_printf(out, "RSA, %d bits\n", EVP_PKEY_bits(key)); + break; + + case EVP_PKEY_DH: + BIO_printf(out, "DH, %d bits\n", EVP_PKEY_bits(key)); + break; + + case EVP_PKEY_EC: + { + EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key); + int nid; + const char *cname; + nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec)); + EC_KEY_free(ec); + cname = EC_curve_nid2nist(nid); + if (!cname) + cname = OBJ_nid2sn(nid); + BIO_printf(out, "ECDH, %s, %d bits\n", + cname, EVP_PKEY_bits(key)); + } + } + EVP_PKEY_free(key); + return 1; + } + long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp, int argi, long argl, long ret) diff --git a/apps/s_client.c b/apps/s_client.c index 0591adde24..ea0a3216a9 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -2105,6 +2105,7 @@ static void print_stuff(BIO *bio, SSL *s, int full) } ssl_print_sigalgs(bio, s); + ssl_print_tmp_key(bio, s); BIO_printf(bio,"---\nSSL handshake has read %ld bytes and written %ld bytes\n", BIO_number_read(SSL_get_rbio(s)), |