Skip to content

Commit 40a91c8

Browse files
authored
Cap cipher suite and extension count (#187)
* Cap cipher count at 99 * Cap extension count at 99
1 parent 594b219 commit 40a91c8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

python/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def get_hex_sorted(entry, field, sort=True):
102102

103103
# remove GREASE and calculate length
104104
c = [ x[2:] for x in values if x not in GREASE_TABLE ]
105-
actual_length = len(c)
105+
actual_length = min(len(c), 99)
106106

107107
# now remove SNI and ALPN values
108108
if field == 'extensions' and sort:

python/ja4.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def to_ja4s(x, debug_stream):
173173

174174
# get extensions in hex in the order they are present (include grease values)
175175
x['extensions'] = [ '{:04x}'.format(int(k)) for k in x['extensions'] ]
176-
ext_len = '{:02d}'.format(len(x['extensions']))
176+
ext_len = '{:02d}'.format(min(len(x['extensions']), 99))
177177
extensions = sha_encode(x['extensions'])
178178

179179
# only one cipher for ja4s
@@ -209,7 +209,7 @@ def to_ja4(x, debug_stream):
209209
ptype = 'q' if x['quic'] else 't'
210210

211211
x['extensions'] = [ '0x{:04x}'.format(int(k)) for k in x['extensions'] ]
212-
ext_len = '{:02d}'.format(len([ x for x in x['extensions'] if x not in GREASE_TABLE]))
212+
ext_len = '{:02d}'.format(min(len([ x for x in x['extensions'] if x not in GREASE_TABLE]), 99))
213213
cache_update(x, 'client_ciphers', x['ciphers'], debug_stream)
214214

215215
if ('0x000d' in x['extensions']):

0 commit comments

Comments
 (0)