Teach the get_mozilla_ciphers.py script to parse recent firefoxen

This commit is contained in:
Nick Mathewson 2014-04-08 03:19:38 -04:00
parent 48578e1512
commit d00dc9f7d1

View File

@ -41,12 +41,12 @@ fileA = open(ff('security/manager/ssl/src/nsNSSComponent.cpp'),'r')
inCipherSection = False inCipherSection = False
cipherLines = [] cipherLines = []
for line in fileA: for line in fileA:
if line.startswith('static CipherPref CipherPrefs'): if line.startswith('static const CipherPref sCipherPrefs[]'):
# Get the starting boundary of the Cipher Preferences # Get the starting boundary of the Cipher Preferences
inCipherSection = True inCipherSection = True
elif inCipherSection: elif inCipherSection:
line = line.strip() line = line.strip()
if line.startswith('{NULL, 0}'): if line.startswith('{ nullptr, 0}'):
# At the ending boundary of the Cipher Prefs # At the ending boundary of the Cipher Prefs
break break
else: else:
@ -56,12 +56,30 @@ fileA.close()
# Parse the lines and put them into a dict # Parse the lines and put them into a dict
ciphers = {} ciphers = {}
cipher_pref = {} cipher_pref = {}
key_pending = None
for line in cipherLines: for line in cipherLines:
m = re.search(r'^{\s*\"([^\"]+)\",\s*(\S*)\s*}', line) m = re.search(r'^{\s*\"([^\"]+)\",\s*(\S+)\s*(?:,\s*(true|false))?\s*}', line)
if m: if m:
key,value = m.groups() assert not key_pending
ciphers[key] = value key,value,enabled = m.groups()
cipher_pref[value] = key if enabled == 'true':
ciphers[key] = value
cipher_pref[value] = key
continue
m = re.search(r'^{\s*\"([^\"]+)\",', line)
if m:
assert not key_pending
key_pending = m.group(1)
continue
m = re.search(r'^\s*(\S+)(?:,\s*(true|false))?\s*}', line)
if m:
assert key_pending
key = key_pending
value,enabled = m.groups()
key_pending = None
if enabled == 'true':
ciphers[key] = value
cipher_pref[value] = key
#### ####
# Now find the correct order for the ciphers # Now find the correct order for the ciphers