seleniumbase_rs_codec::ja4 computes JA4 and JA4_r from a ClientHello,
following FoxIO’s TLS-client definition. Only JA4 itself is implemented (the TLS
client method, BSD-3-Clause); JA4H, JA4S, JA4X and the other JA4+ methods carry a
different licence and are not part of the crate.
A JA4 string is a_b_c:
aholds the transport (t), the highest TLS version (13), whether SNI is present (d, oriwithoutserver_name), the cipher and extension counts (two digits each, at most 99), and the first and last character of the first ALPN value (00without one);bis the first 12 hex digits of the SHA-256 of the sorted cipher suites;cis the same hash over the sorted extensions (without SNI and ALPN) followed by_and the signature algorithms in wire order.
The variants are JA4_o (original order, SNI and ALPN kept in the extension list),
JA4_r (sorted, unhashed) and JA4_ro (original order, unhashed). GREASE values
are ignored everywhere. JA4 sorts the extensions first, so it stays stable while
Chrome shuffles them on every connection.
The first pair is the published example vector the crate’s tests pin. The second compares the JA4 recorded for Chrome 155 on macOS with that example.
Ja4#
struct
A hashed JA4 fingerprint, a_b_c. It implements Display and FromStr.
The a section, ten characters, such as t13d1517h2.
Twelve hex digits over the cipher suites (000000000000 for an empty list).
Twelve hex digits over the extensions and signature algorithms.
Ja4 methods#
method
of: theJA4of a hello, sorted ciphers and extensions, hashed.of_original_order: theJA4_o, wire order, hashed.raw: theJA4_rstring, sorted and unhashed.raw_original_order: theJA4_rostring, wire order and unhashed.parse: readsa_b_c(trimmed);amust have the documented ten-character shape andbandcmust be twelve lowercase hex digits.diff: which parts differ fromother.
Ja4Raw#
struct
An unhashed fingerprint (JA4_r or JA4_ro): the a section and the id lists
behind b and c. Its Display writes the ids as four lowercase hex digits
joined by commas, and adds _ and the signature algorithms only when there are
any.
The a section.
Cipher suites, GREASE removed.
Extensions, GREASE removed; sorted and without SNI and ALPN in the JA4_r form.
Signature algorithms in wire order.
Ja4Raw::parse reads a_ciphers_extensions[_signature_algorithms] with ids as
four hex digits, at most MAX_JA4_LEN (16 KiB). The string does not say whether
it is sorted; the caller knows which variant it holds. hashed gives the JA4 of
these lists, as JA4 defines b and c.
Ja4Facts#
struct
The facts of a hello that JA4 reads, independent of how the hello was obtained.
TlsSpec::ja4_facts builds one from a spec instead of a hello.
The handshake client_version, used when no supported_versions is present.
The supported_versions list; empty when the extension is absent. The highest
non-GREASE value is the version in a.
Cipher suites and every extension id, in wire order (SNI and ALPN included).
The first ALPN protocol name, when the hello offers ALPN.
Signature algorithms in wire order; empty when the extension is absent.
a() is the a section; raw(order) is JA4_r for Ja4Order::Sorted and
JA4_ro for Ja4Order::Original; ja4(order) is JA4 or JA4_o.
Ja4Order#
enum
Ja4Diff#
struct
The difference between two fingerprints, part by part: the fields of a that
differ, and whether the cipher hash and the extension hash differ. is_empty is
true when the fingerprints are equal.
Ja4AField#
enum
A field of the a section: the transport letter (character 1), the TLS version
code (2 to 3), the SNI letter (4), the cipher count (5 to 6), the extension count
(7 to 8) and the ALPN characters (9 to 10).
Ja4Section#
enum
A section of a fingerprint, named in errors and mismatches (TlsSpec overlays
report SpecError::Ja4Mismatch(Ja4Section)). Its Display is a, ciphers,
extensions and signature algorithms.
Ja4Error#
enum
version_code, version_from_code, alpn_code#
fn
version_code: the two-character code of a TLS version (13for0x0304,12,11,10,s3,s2, andd1tod3for DTLS), or00when unknown.version_from_code: the version a code stands for,Nonefor00and unknown codes.alpn_code: the ALPN field ofafor the first ALPN value: the first and last character when both are ASCII alphanumeric, else the first and last hex digit of the whole value, and00without a value.
Constants#
constThe longest raw fingerprint string Ja4Raw::parse reads, and the ALPN field of a
hello with no usable ALPN value.