SSL programs: group options processing in 1 place

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2023-06-26 11:28:00 +02:00
parent 3048c8c906
commit 0b74434e2a
2 changed files with 50 additions and 50 deletions

View file

@ -867,31 +867,6 @@ int main(int argc, char *argv[])
mbedtls_test_enable_insecure_external_rng(); mbedtls_test_enable_insecure_external_rng();
#endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */ #endif /* MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG */
if (argc < 2) {
usage:
if (ret == 0) {
ret = 1;
}
mbedtls_printf(USAGE1);
mbedtls_printf(USAGE2);
mbedtls_printf(USAGE3);
mbedtls_printf(USAGE4);
list = mbedtls_ssl_list_ciphersuites();
while (*list) {
mbedtls_printf(" %-42s", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
if (!*list) {
break;
}
mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
}
mbedtls_printf("\n");
goto exit;
}
opt.server_name = DFL_SERVER_NAME; opt.server_name = DFL_SERVER_NAME;
opt.server_addr = DFL_SERVER_ADDR; opt.server_addr = DFL_SERVER_ADDR;
opt.server_port = DFL_SERVER_PORT; opt.server_port = DFL_SERVER_PORT;
@ -976,6 +951,31 @@ usage:
opt.key_opaque_alg1 = DFL_KEY_OPAQUE_ALG; opt.key_opaque_alg1 = DFL_KEY_OPAQUE_ALG;
opt.key_opaque_alg2 = DFL_KEY_OPAQUE_ALG; opt.key_opaque_alg2 = DFL_KEY_OPAQUE_ALG;
if (argc < 2) {
usage:
if (ret == 0) {
ret = 1;
}
mbedtls_printf(USAGE1);
mbedtls_printf(USAGE2);
mbedtls_printf(USAGE3);
mbedtls_printf(USAGE4);
list = mbedtls_ssl_list_ciphersuites();
while (*list) {
mbedtls_printf(" %-42s", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
if (!*list) {
break;
}
mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
}
mbedtls_printf("\n");
goto exit;
}
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
p = argv[i]; p = argv[i];
if ((q = strchr(p, '=')) == NULL) { if ((q = strchr(p, '=')) == NULL) {

View file

@ -1643,31 +1643,6 @@ int main(int argc, char *argv[])
signal(SIGINT, term_handler); signal(SIGINT, term_handler);
#endif #endif
if (argc < 2) {
usage:
if (ret == 0) {
ret = 1;
}
mbedtls_printf(USAGE1);
mbedtls_printf(USAGE2);
mbedtls_printf(USAGE3);
mbedtls_printf(USAGE4);
list = mbedtls_ssl_list_ciphersuites();
while (*list) {
mbedtls_printf(" %-42s", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
if (!*list) {
break;
}
mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
}
mbedtls_printf("\n");
goto exit;
}
opt.buffer_size = DFL_IO_BUF_LEN; opt.buffer_size = DFL_IO_BUF_LEN;
opt.server_addr = DFL_SERVER_ADDR; opt.server_addr = DFL_SERVER_ADDR;
opt.server_port = DFL_SERVER_PORT; opt.server_port = DFL_SERVER_PORT;
@ -1766,6 +1741,31 @@ usage:
opt.key2_opaque_alg1 = DFL_KEY_OPAQUE_ALG; opt.key2_opaque_alg1 = DFL_KEY_OPAQUE_ALG;
opt.key2_opaque_alg2 = DFL_KEY_OPAQUE_ALG; opt.key2_opaque_alg2 = DFL_KEY_OPAQUE_ALG;
if (argc < 2) {
usage:
if (ret == 0) {
ret = 1;
}
mbedtls_printf(USAGE1);
mbedtls_printf(USAGE2);
mbedtls_printf(USAGE3);
mbedtls_printf(USAGE4);
list = mbedtls_ssl_list_ciphersuites();
while (*list) {
mbedtls_printf(" %-42s", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
if (!*list) {
break;
}
mbedtls_printf(" %s\n", mbedtls_ssl_get_ciphersuite_name(*list));
list++;
}
mbedtls_printf("\n");
goto exit;
}
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
p = argv[i]; p = argv[i];
if ((q = strchr(p, '=')) == NULL) { if ((q = strchr(p, '=')) == NULL) {