diff --git a/python/common.py b/python/common.py index eb4342d..ddd2dab 100644 --- a/python/common.py +++ b/python/common.py @@ -102,7 +102,7 @@ def get_hex_sorted(entry, field, sort=True): # remove GREASE and calculate length c = [ x[2:] for x in values if x not in GREASE_TABLE ] - actual_length = len(c) + actual_length = min(len(c), 99) # now remove SNI and ALPN values if field == 'extensions' and sort: diff --git a/python/ja4.py b/python/ja4.py index 0ce1ce9..95fb158 100644 --- a/python/ja4.py +++ b/python/ja4.py @@ -173,7 +173,7 @@ def to_ja4s(x, debug_stream): # get extensions in hex in the order they are present (include grease values) x['extensions'] = [ '{:04x}'.format(int(k)) for k in x['extensions'] ] - ext_len = '{:02d}'.format(len(x['extensions'])) + ext_len = '{:02d}'.format(min(len(x['extensions']), 99)) extensions = sha_encode(x['extensions']) # only one cipher for ja4s @@ -209,7 +209,7 @@ def to_ja4(x, debug_stream): ptype = 'q' if x['quic'] else 't' x['extensions'] = [ '0x{:04x}'.format(int(k)) for k in x['extensions'] ] - ext_len = '{:02d}'.format(len([ x for x in x['extensions'] if x not in GREASE_TABLE])) + ext_len = '{:02d}'.format(min(len([ x for x in x['extensions'] if x not in GREASE_TABLE]), 99)) cache_update(x, 'client_ciphers', x['ciphers'], debug_stream) if ('0x000d' in x['extensions']):