Submitted by: Adam Langley <agl@google.com>

Fix handling of exporter return value and use OpenSSL indentation in
s_client, s_server.
This commit is contained in:
Dr. Stephen Henson 2012-02-11 23:21:09 +00:00
parent cc4b48c27c
commit cdf9d6f6ed
2 changed files with 44 additions and 38 deletions

View file

@ -362,7 +362,7 @@ static void sc_usage(void)
# endif # endif
#endif #endif
BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n"); BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list"); BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
BIO_printf(bio_err," -keymatexport label - Export keying material using label\n"); BIO_printf(bio_err," -keymatexport label - Export keying material using label\n");
BIO_printf(bio_err," -keymatexportlen len - Export len bytes of keying material (default 20)\n"); BIO_printf(bio_err," -keymatexportlen len - Export len bytes of keying material (default 20)\n");
} }
@ -2077,21 +2077,24 @@ static void print_stuff(BIO *bio, SSL *s, int full)
} }
SSL_SESSION_print(bio,SSL_get_session(s)); SSL_SESSION_print(bio,SSL_get_session(s));
if (keymatexportlabel != NULL) { if (keymatexportlabel != NULL)
{
BIO_printf(bio, "Keying material exporter:\n"); BIO_printf(bio, "Keying material exporter:\n");
BIO_printf(bio, " Label: '%s'\n", keymatexportlabel); BIO_printf(bio, " Label: '%s'\n", keymatexportlabel);
BIO_printf(bio, " Length: %i bytes\n", keymatexportlen); BIO_printf(bio, " Length: %i bytes\n", keymatexportlen);
exportedkeymat = OPENSSL_malloc(keymatexportlen); exportedkeymat = OPENSSL_malloc(keymatexportlen);
if (exportedkeymat != NULL) { if (exportedkeymat != NULL)
i = SSL_export_keying_material(s, exportedkeymat, {
if (!SSL_export_keying_material(s, exportedkeymat,
keymatexportlen, keymatexportlen,
keymatexportlabel, keymatexportlabel,
strlen(keymatexportlabel), strlen(keymatexportlabel),
NULL, 0, 0); NULL, 0, 0))
if (i != keymatexportlen) { {
BIO_printf(bio, BIO_printf(bio, " Error\n");
" Error: return value %i\n", i); }
} else { else
{
BIO_printf(bio, " Keying material: "); BIO_printf(bio, " Keying material: ");
for (i=0; i<keymatexportlen; i++) for (i=0; i<keymatexportlen; i++)
BIO_printf(bio, "%02X", BIO_printf(bio, "%02X",

View file

@ -556,7 +556,7 @@ static void sv_usage(void)
# ifndef OPENSSL_NO_NEXTPROTONEG # ifndef OPENSSL_NO_NEXTPROTONEG
BIO_printf(bio_err," -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n"); BIO_printf(bio_err," -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n");
# endif # endif
BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list"); BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n");
#endif #endif
BIO_printf(bio_err," -keymatexport label - Export keying material using label\n"); BIO_printf(bio_err," -keymatexport label - Export keying material using label\n");
BIO_printf(bio_err," -keymatexportlen len - Export len bytes of keying material (default 20)\n"); BIO_printf(bio_err," -keymatexportlen len - Export len bytes of keying material (default 20)\n");
@ -2475,22 +2475,25 @@ static int init_ssl_connection(SSL *con)
#endif /* OPENSSL_NO_KRB5 */ #endif /* OPENSSL_NO_KRB5 */
BIO_printf(bio_s_out, "Secure Renegotiation IS%s supported\n", BIO_printf(bio_s_out, "Secure Renegotiation IS%s supported\n",
SSL_get_secure_renegotiation_support(con) ? "" : " NOT"); SSL_get_secure_renegotiation_support(con) ? "" : " NOT");
if (keymatexportlabel != NULL) { if (keymatexportlabel != NULL)
{
BIO_printf(bio_s_out, "Keying material exporter:\n"); BIO_printf(bio_s_out, "Keying material exporter:\n");
BIO_printf(bio_s_out, " Label: '%s'\n", keymatexportlabel); BIO_printf(bio_s_out, " Label: '%s'\n", keymatexportlabel);
BIO_printf(bio_s_out, " Length: %i bytes\n", BIO_printf(bio_s_out, " Length: %i bytes\n",
keymatexportlen); keymatexportlen);
exportedkeymat = OPENSSL_malloc(keymatexportlen); exportedkeymat = OPENSSL_malloc(keymatexportlen);
if (exportedkeymat != NULL) { if (exportedkeymat != NULL)
i = SSL_export_keying_material(con, exportedkeymat, {
if (!SSL_export_keying_material(con, exportedkeymat,
keymatexportlen, keymatexportlen,
keymatexportlabel, keymatexportlabel,
strlen(keymatexportlabel), strlen(keymatexportlabel),
NULL, 0, 0); NULL, 0, 0))
if (i != keymatexportlen) { {
BIO_printf(bio_s_out, BIO_printf(bio_s_out, " Error\n");
" Error: return value %i\n", i); }
} else { else
{
BIO_printf(bio_s_out, " Keying material: "); BIO_printf(bio_s_out, " Keying material: ");
for (i=0; i<keymatexportlen; i++) for (i=0; i<keymatexportlen; i++)
BIO_printf(bio_s_out, "%02X", BIO_printf(bio_s_out, "%02X",