Debian Codegraph @

crt/s2n/tls/s2n_fingerprint.h

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #pragma once
17
18 #include "api/s2n.h"
19 #include "api/unstable/fingerprint.h"
20 #include "crypto/s2n_hash.h"
21 #include "stuffer/s2n_stuffer.h"
22 #include "tls/s2n_client_hello.h"
23 #include "utils/s2n_result.h"
24
25 #define S2N_JA3_HASH_STR_SIZE (MD5_DIGEST_LENGTH * 2)
26
27 struct s2n_fingerprint {
28 size_t raw_size;
29 const struct s2n_fingerprint_method *method;
30 struct s2n_client_hello *client_hello;
31 struct s2n_hash_state hash;
32 struct s2n_stuffer workspace;
33 };
34
35 struct s2n_fingerprint_hash {
36 uint32_t bytes_digested;
37 struct s2n_stuffer *buffer;
38 struct s2n_hash_state *hash;
39 };
40 S2N_RESULT s2n_fingerprint_hash_add_char(struct s2n_fingerprint_hash *hash, char c);
41 S2N_RESULT s2n_fingerprint_hash_add_str(struct s2n_fingerprint_hash *hash, const char *str, size_t str_size);
42 S2N_RESULT s2n_fingerprint_hash_add_bytes(struct s2n_fingerprint_hash *hash, const uint8_t *b, size_t size);
43 S2N_RESULT s2n_fingerprint_hash_digest(struct s2n_fingerprint_hash *hash, struct s2n_blob *out);
44 bool s2n_fingerprint_hash_do_digest(struct s2n_fingerprint_hash *hash);
45
46 struct s2n_fingerprint_method {
47 s2n_hash_algorithm hash;
48 uint32_t hash_str_size;
49 S2N_RESULT (*fingerprint)(struct s2n_fingerprint *fingerprint,
50 struct s2n_fingerprint_hash *hash, struct s2n_stuffer *output);
51 };
52 extern struct s2n_fingerprint_method ja3_fingerprint;
53 extern struct s2n_fingerprint_method ja4_fingerprint;
54
55 bool s2n_fingerprint_is_grease_value(uint16_t val);
56 S2N_RESULT s2n_fingerprint_parse_extension(struct s2n_stuffer *input, uint16_t *iana);
57 S2N_RESULT s2n_fingerprint_get_legacy_version(struct s2n_client_hello *ch, uint16_t *version);