X-Git-Url: https://www.bearssl.org/gitweb//home/git/?p=BearSSL;a=blobdiff_plain;f=tools%2Fnames.c;h=e7d2403f3f39bd8bd5386409f71654689dc5b4dd;hp=b34354e188208e232326963de8ef9f366793e4cb;hb=72d33930b2e477434e91ff37a89b3e99265f338f;hpb=f56b0baab3625e3cb31a8b48c7c0a7995de42ac6 diff --git a/tools/names.c b/tools/names.c index b34354e..e7d2403 100644 --- a/tools/names.c +++ b/tools/names.c @@ -46,6 +46,18 @@ const hash_function hash_functions[] = { /* see brssl.h */ const cipher_suite cipher_suites[] = { + { + "ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", + BR_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + REQ_ECDHE_ECDSA | REQ_CHAPOL | REQ_SHA256 | REQ_TLS12, + "ECDHE with ECDSA, ChaCha20+Poly1305 encryption (TLS 1.2+)" + }, + { + "ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", + BR_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + REQ_ECDHE_RSA | REQ_CHAPOL | REQ_SHA256 | REQ_TLS12, + "ECDHE with RSA, ChaCha20+Poly1305 encryption (TLS 1.2+)" + }, { "ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", BR_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, @@ -396,6 +408,60 @@ eqstr(const char *s1, const char *s2) return eqstr_chunk(s1, strlen(s1), s2, strlen(s2)); } +static int +hexval(int c) +{ + if (c >= '0' && c <= '9') { + return c - '0'; + } else if (c >= 'A' && c <= 'F') { + return c - 'A' + 10; + } else if (c >= 'a' && c <= 'f') { + return c - 'a' + 10; + } else { + return -1; + } +} + +/* see brssl.h */ +size_t +parse_size(const char *s) +{ + int radix; + size_t acc; + const char *t; + + t = s; + if (t[0] == '0' && (t[1] == 'x' || t[1] == 'X')) { + radix = 16; + t += 2; + } else { + radix = 10; + } + acc = 0; + for (;;) { + int c, d; + size_t z; + + c = *t ++; + if (c == 0) { + return acc; + } + d = hexval(c); + if (d < 0 || d >= radix) { + fprintf(stderr, "ERROR: not a valid digit: '%c'\n", c); + return (size_t)-1; + } + z = acc * (size_t)radix + (size_t)d; + if (z < (size_t)d || (z / (size_t)radix) != acc + || z == (size_t)-1) + { + fprintf(stderr, "ERROR: value too large: %s\n", s); + return (size_t)-1; + } + acc = z; + } +} + /* * Comma-separated list enumeration. This returns a pointer to the first * word in the string, skipping leading ignored characters. '*len' is @@ -597,3 +663,20 @@ ec_curve_name(int curve) return "unknown"; } } + +/* see brssl.h */ +const char * +hash_function_name(int id) +{ + switch (id) { + case br_md5sha1_ID: return "MD5+SHA-1"; + case br_md5_ID: return "MD5"; + case br_sha1_ID: return "SHA-1"; + case br_sha224_ID: return "SHA-224"; + case br_sha256_ID: return "SHA-256"; + case br_sha384_ID: return "SHA-384"; + case br_sha512_ID: return "SHA-512"; + default: + return "unknown"; + } +}