summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_lib.c
diff options
context:
space:
mode:
authorPhus Lu <phus.lu@gmail.com>2021-10-25 18:47:00 +0800
committerTomas Mraz <tomas@openssl.org>2022-02-03 13:45:41 +0100
commit13a53fbf13bc6fa09c95ad4bdc6ec70fa15aa16d (patch)
tree34c712b39eae57857d9b3b60abd7d8f59c9cdca5 /ssl/ssl_lib.c
parent27aca04e13ca8a9bead49de7bc380110ecb7064e (diff)
add SSL_get0_iana_groups() & SSL_client_hello_get_extension_order()
The function/macro allow user get groups/extensions without memory allcations. So we could calculate the ssl fignerprint(ja3) in low cost. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16910)
Diffstat (limited to 'ssl/ssl_lib.c')
-rw-r--r--ssl/ssl_lib.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 655eac0b7c..cb7a52ab7e 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -5424,6 +5424,40 @@ int SSL_client_hello_get1_extensions_present(SSL *s, int **out, size_t *outlen)
return 0;
}
+int SSL_client_hello_get_extension_order(SSL *s, uint16_t *exts, size_t *num_exts)
+{
+ RAW_EXTENSION *ext;
+ size_t num = 0, i;
+
+ if (s->clienthello == NULL || num_exts == NULL)
+ return 0;
+ for (i = 0; i < s->clienthello->pre_proc_exts_len; i++) {
+ ext = s->clienthello->pre_proc_exts + i;
+ if (ext->present)
+ num++;
+ }
+ if (num == 0) {
+ *num_exts = 0;
+ return 1;
+ }
+ if (exts == NULL) {
+ *num_exts = num;
+ return 1;
+ }
+ if (*num_exts < num)
+ return 0;
+ for (i = 0; i < s->clienthello->pre_proc_exts_len; i++) {
+ ext = s->clienthello->pre_proc_exts + i;
+ if (ext->present) {
+ if (ext->received_order >= num)
+ return 0;
+ exts[ext->received_order] = ext->type;
+ }
+ }
+ *num_exts = num;
+ return 1;
+}
+
int SSL_client_hello_get0_ext(SSL *s, unsigned int type, const unsigned char **out,
size_t *outlen)
{