Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: separate out ja3 specific logic #4578

Merged
merged 9 commits into from
Jun 25, 2024
Merged

Conversation

lrstewart
Copy link
Contributor

Description of changes:

Moving towards adding JA4 support.

I split the JA3-specific logic into a separate file. As part of that, I also better encapsulated the logic that calculates either a digest or a full string for a given hash, because JA4 will need to reuse that logic (JA4 includes two different digests, concatenated).

Other than the hashing, JA3 and JA4 share very little. JA3 uses decimal, JA4 uses hex. The separators are also different.

This is an example JA3 fingerprint:

769,47-53-5-10-49161-49162-49171-49172-50-56-19-4,0-10-11,23-24-25,0

While this is an example JA4 fingerprint:

t13d1516h2_002f,0035,009c,009d,1301,1302,1303_0005,000a,000b,000d,0012,0015,0017_0403,0804,0401,0503,0805,0501

Callouts

The diff is really not good, but I can't figure out how to improve it. If it's completely unreadable, I could just rename "s2n_fingerprint.c" to "s2n_fingerprint_common.c" to avoid the messy diff. I could then rename it back in a later PR.

Testing:

The existing "s2n_fingerprint_ja3_test" tests continue to pass with the refactor. I also added some "s2n_fingerprint_test" tests for the hashing + grease value detection.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Jun 3, 2024
@lrstewart lrstewart force-pushed the ja4_1 branch 3 times, most recently from 9cb5a88 to c79dc43 Compare June 3, 2024 05:48
@lrstewart lrstewart marked this pull request as ready for review June 3, 2024 07:32
@lrstewart lrstewart requested review from goatgoose and maddeleine June 3, 2024 07:32
POSIX_GUARD_RESULT(s2n_fingerprint_hash_flush(&md5_hash, &string_stuffer));
DEFER_CLEANUP(struct s2n_hash_state hash_state = { 0 }, s2n_hash_free);
POSIX_GUARD(s2n_hash_new(&hash_state));
s2n_hash_allow_md5_for_fips(&hash_state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the error being intentionally ignored here to avoid the s2n_is_in_fips_mode() check? Would it be better to just have s2n_digest_allow_md5_for_fips() no-op when s2n-tls isn't in FIPS mode?

tls/s2n_fingerprint_ja3.c Outdated Show resolved Hide resolved
tls/s2n_fingerprint.c Outdated Show resolved Hide resolved
@lrstewart lrstewart requested a review from goatgoose June 10, 2024 21:24
tls/s2n_fingerprint.c Show resolved Hide resolved
tls/s2n_fingerprint.c Outdated Show resolved Hide resolved
tls/s2n_fingerprint.c Outdated Show resolved Hide resolved
tls/s2n_fingerprint.c Show resolved Hide resolved
tls/s2n_fingerprint_ja3.c Outdated Show resolved Hide resolved
tls/s2n_fingerprint.c Show resolved Hide resolved
tls/s2n_fingerprint.c Show resolved Hide resolved
@lrstewart lrstewart enabled auto-merge (squash) June 24, 2024 19:11
@lrstewart lrstewart merged commit 023f788 into aws:main Jun 25, 2024
34 checks passed
@lrstewart lrstewart deleted the ja4_1 branch June 25, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants