tizen 2.4 release
[external/nghttp2.git] / mkcipherlist.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # This script read cipher suite list csv file [1] and prints out ECDHE
5 # or DHE with AEAD ciphers only.  The output is used by
6 # src/shrpx_ssl.cc.
7 #
8 # [1] http://www.iana.org/assignments/tls-parameters/tls-parameters-4.csv
9 # [2] http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
10
11 from __future__ import unicode_literals
12 import re
13 import sys
14 import csv
15
16 pat = re.compile(r'\ATLS_(?:ECDHE|DHE)_.*_GCM')
17
18 ciphers = []
19 for hl, name, _, _ in csv.reader(sys.stdin):
20     if not pat.match(name):
21         continue
22
23     high, low = hl.split(',')
24
25     id = high + low[2:] + 'u'
26     ciphers.append((id, name))
27
28 print '''\
29 enum {'''
30
31 for id, name in ciphers:
32     print '{} = {},'.format(name, id)
33
34 print '''\
35 };
36 '''
37
38 for id, name in ciphers:
39     print '''\
40 case {}:'''.format(name)