Added support for TLS_FALLBACK_SCSV.

This commit is contained in:
Thomas Pornin 2016-11-20 16:14:48 +01:00
parent 6cc90dad21
commit 7561e7d6c8
8 changed files with 457 additions and 412 deletions

View file

@ -149,6 +149,8 @@ usage_client(void)
" -hf names add support for some hash functions (comma-separated)\n");
fprintf(stderr,
" -minhello len set minimum ClientHello length (in bytes)\n");
fprintf(stderr,
" -fallback send the TLS_FALLBACK_SCSV (i.e. claim a downgrade)\n");
}
/* see brssl.h */
@ -177,6 +179,7 @@ do_client(int argc, char *argv[])
unsigned char *iobuf;
size_t iobuf_len;
size_t minhello_len;
int fallback;
int fd;
retcode = 0;
@ -196,6 +199,7 @@ do_client(int argc, char *argv[])
iobuf = NULL;
iobuf_len = 0;
minhello_len = (size_t)-1;
fallback = 0;
fd = -1;
for (i = 0; i < argc; i ++) {
const char *arg;
@ -376,6 +380,8 @@ do_client(int argc, char *argv[])
usage_client();
goto client_exit_error;
}
} else if (eqstr(arg, "-fallback")) {
fallback = 1;
} else {
fprintf(stderr, "ERROR: unknown option: '%s'\n", arg);
usage_client();
@ -457,7 +463,7 @@ do_client(int argc, char *argv[])
/*
* Compute implementation requirements and inject implementations.
*/
suite_ids = xmalloc(num_suites * sizeof *suite_ids);
suite_ids = xmalloc((num_suites + 1) * sizeof *suite_ids);
br_ssl_client_zero(&cc);
br_ssl_engine_set_versions(&cc.eng, vmin, vmax);
dnhash = NULL;
@ -557,6 +563,9 @@ do_client(int argc, char *argv[])
br_ssl_engine_set_ec(&cc.eng, &br_ec_prime_i31);
}
}
if (fallback) {
suite_ids[num_suites ++] = 0x5600;
}
br_ssl_engine_set_suites(&cc.eng, suite_ids, num_suites);
for (u = 0; hash_functions[u].name; u ++) {

View file

@ -333,6 +333,9 @@ sp_choose(const br_ssl_server_policy_class **pctx,
case BR_SSLKEYX_ECDHE_RSA:
if (pc->sk->key_type == BR_KEYTYPE_RSA) {
choices->cipher_suite = st[u][0];
if (cc->eng.session.version < BR_TLS12) {
hash_id = 0;
}
choices->hash_id = hash_id;
goto choose_ok;
}
@ -340,6 +343,9 @@ sp_choose(const br_ssl_server_policy_class **pctx,
case BR_SSLKEYX_ECDHE_ECDSA:
if (pc->sk->key_type == BR_KEYTYPE_EC) {
choices->cipher_suite = st[u][0];
if (cc->eng.session.version < BR_TLS12) {
hash_id = br_sha1_ID;
}
choices->hash_id = hash_id;
goto choose_ok;
}