diff options
author | Jack Lloyd <[email protected]> | 2016-01-06 13:40:23 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-01-06 13:40:23 -0500 |
commit | 805c391817f22681ca9f09d7b04475f7cd9d34e7 (patch) | |
tree | b28acc55a3c8689430a1acc273e0889385b99935 /src/scripts/tls_suite_info.py | |
parent | ac5ae9a7a28b664d86b79cf85a6708c9f8b9a0fd (diff) |
Precompile the list of TLS ciphersuites
This avoids a scan over the entire 0 - 0xFFFF space which is mostly
empty, by instead keeping a second list in tls_suite_info which is
exactly the keys for which the switch statement has values.
This scan is only ever done once (when first needed) but removing it
is sufficient to increase AFL's throuhput by 4x since it goes through
a full startup on each test.
Diffstat (limited to 'src/scripts/tls_suite_info.py')
-rwxr-xr-x | src/scripts/tls_suite_info.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/scripts/tls_suite_info.py b/src/scripts/tls_suite_info.py index dc0468c88..6ba807d68 100755 --- a/src/scripts/tls_suite_info.py +++ b/src/scripts/tls_suite_info.py @@ -311,15 +311,33 @@ namespace Botan { namespace TLS { +std::vector<u16bit> Ciphersuite::all_known_ciphersuite_ids() + { + return std::vector<u16bit>{ +""" + + csuite_ids = {} + + for (k,v) in suites.items(): + csuite_ids[v[0]] = (k, v[1]) + + for i in sorted(csuite_ids.keys()): + suite_info += " 0x%s,\n" % (i) + + suite_info += """ }; +} + Ciphersuite Ciphersuite::by_id(u16bit suite) { switch(suite) { """ - for k in sorted(suites.keys()): - suite_info += " case 0x%s: // %s\n" % (suites[k][0], k) - suite_info += " return %s;\n\n" % (suites[k][1]) + for i in sorted(csuite_ids.keys()): + suite_name = csuite_ids[i][0] + suite_expr = csuite_ids[i][1] + suite_info += " case 0x%s: // %s\n" % (i, suite_name) + suite_info += " return %s;\n\n" % (suite_expr) suite_info += """ } |