PR: 2716
authorDr. Stephen Henson <steve@openssl.org>
Sat, 11 Feb 2012 23:21:09 +0000 (23:21 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sat, 11 Feb 2012 23:21:09 +0000 (23:21 +0000)
Submitted by: Adam Langley <agl@google.com>

Fix handling of exporter return value and use OpenSSL indentation in
s_client, s_server.

apps/s_client.c
apps/s_server.c

index 22e676283885391e23d58fca5f0959975a4234f6..20f661ec5010a20592de7b7a8119745225d62f87 100644 (file)
@@ -362,7 +362,7 @@ static void sc_usage(void)
 # endif
 #endif
        BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n");
 # endif
 #endif
        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," -keymatexportlen len  - Export len bytes of keying material (default 20)\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");
        }
@@ -2077,30 +2077,33 @@ 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, "    Label: '%s'\n", keymatexportlabel);
                BIO_printf(bio, "    Length: %i bytes\n", keymatexportlen);
                exportedkeymat = OPENSSL_malloc(keymatexportlen);
                BIO_printf(bio, "Keying material exporter:\n");
                BIO_printf(bio, "    Label: '%s'\n", keymatexportlabel);
                BIO_printf(bio, "    Length: %i bytes\n", keymatexportlen);
                exportedkeymat = OPENSSL_malloc(keymatexportlen);
-               if (exportedkeymat != NULL) {
-                       i = SSL_export_keying_material(s, exportedkeymat,
-                                                      keymatexportlen,
-                                                      keymatexportlabel,
-                                                    strlen(keymatexportlabel),
-                                                      NULL, 0, 0);
-                       if (i != keymatexportlen) {
-                               BIO_printf(bio,
-                                          "    Error: return value %i\n", i);
-                       } else {
+               if (exportedkeymat != NULL)
+                       {
+                       if (!SSL_export_keying_material(s, exportedkeymat,
+                                                       keymatexportlen,
+                                                       keymatexportlabel,
+                                                       strlen(keymatexportlabel),
+                                                       NULL, 0, 0))
+                               {
+                               BIO_printf(bio, "    Error\n");
+                               }
+                       else
+                               {
                                BIO_printf(bio, "    Keying material: ");
                                for (i=0; i<keymatexportlen; i++)
                                        BIO_printf(bio, "%02X",
                                                   exportedkeymat[i]);
                                BIO_printf(bio, "\n");
                                BIO_printf(bio, "    Keying material: ");
                                for (i=0; i<keymatexportlen; i++)
                                        BIO_printf(bio, "%02X",
                                                   exportedkeymat[i]);
                                BIO_printf(bio, "\n");
-                       }
+                               }
                        OPENSSL_free(exportedkeymat);
                        OPENSSL_free(exportedkeymat);
+                       }
                }
                }
-       }
        BIO_printf(bio,"---\n");
        if (peer != NULL)
                X509_free(peer);
        BIO_printf(bio,"---\n");
        if (peer != NULL)
                X509_free(peer);
index 5e3e4ac27ad3e9f34b5a79fd552c609c9156b3a3..fe29b4cae7acf2a026bde310166aaff355825056 100644 (file)
@@ -556,7 +556,7 @@ static void sv_usage(void)
 # ifndef OPENSSL_NO_NEXTPROTONEG
        BIO_printf(bio_err," -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n");
 # endif
 # ifndef OPENSSL_NO_NEXTPROTONEG
        BIO_printf(bio_err," -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)\n");
 # 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
        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");
 #endif
        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");
@@ -2475,31 +2475,34 @@ static int init_ssl_connection(SSL *con)
 #endif /* OPENSSL_NO_KRB5 */
        BIO_printf(bio_s_out, "Secure Renegotiation IS%s supported\n",
                      SSL_get_secure_renegotiation_support(con) ? "" : " NOT");
 #endif /* OPENSSL_NO_KRB5 */
        BIO_printf(bio_s_out, "Secure Renegotiation IS%s supported\n",
                      SSL_get_secure_renegotiation_support(con) ? "" : " NOT");
-       if (keymatexportlabel != NULL) {
-               BIO_printf(bio_s_out, "Keying material exporter:\n");
-               BIO_printf(bio_s_out, "    Label: '%s'\n", keymatexportlabel);
-               BIO_printf(bio_s_out, "    Length: %i bytes\n",
+       if (keymatexportlabel != NULL)
+               {
+               BIO_printf(bio_s_out, "Keying material exporter:\n");
+               BIO_printf(bio_s_out, "    Label: '%s'\n", keymatexportlabel);
+               BIO_printf(bio_s_out, "    Length: %i bytes\n",
                           keymatexportlen);
                           keymatexportlen);
-               exportedkeymat = OPENSSL_malloc(keymatexportlen);
-               if (exportedkeymat != NULL) {
-                       i = SSL_export_keying_material(con, exportedkeymat,
-                                                      keymatexportlen,
-                                                      keymatexportlabel,
-                                                    strlen(keymatexportlabel),
-                                                      NULL, 0, 0);
-                       if (i != keymatexportlen) {
-                               BIO_printf(bio_s_out,
-                                          "    Error: return value %i\n", i);
-                       } else {
-                               BIO_printf(bio_s_out, "    Keying material: ");
-                               for (i=0; i<keymatexportlen; i++)
-                                       BIO_printf(bio_s_out, "%02X",
+               exportedkeymat = OPENSSL_malloc(keymatexportlen);
+               if (exportedkeymat != NULL)
+                       {
+                       if (!SSL_export_keying_material(con, exportedkeymat,
+                                                       keymatexportlen,
+                                                       keymatexportlabel,
+                                                       strlen(keymatexportlabel),
+                                                       NULL, 0, 0))
+                               {
+                               BIO_printf(bio_s_out, "    Error\n");
+                               }
+                       else
+                               {
+                               BIO_printf(bio_s_out, "    Keying material: ");
+                               for (i=0; i<keymatexportlen; i++)
+                                       BIO_printf(bio_s_out, "%02X",
                                                   exportedkeymat[i]);
                                                   exportedkeymat[i]);
-                               BIO_printf(bio_s_out, "\n");
-                       }
-                       OPENSSL_free(exportedkeymat);
-               }
-       }
+                               BIO_printf(bio_s_out, "\n");
+                               }
+                       OPENSSL_free(exportedkeymat);
+                       }
+               }
 
        return(1);
        }
 
        return(1);
        }