summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py
diff options
context:
space:
mode:
authorDan Klein <danklei@csi-kiwi-03.cisco.com>2015-09-20 15:53:42 +0300
committerDan Klein <danklei@csi-kiwi-03.cisco.com>2015-09-20 15:53:42 +0300
commit28fef018f75b5a54ac69ac7c919127bf47f5b61f (patch)
treec21c2af8dfe7c05bee170e96fc923458b8894be6 /scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py
parenta78680a896f65dd6733d27d99e9cd8440eb185e9 (diff)
parent56dbd342eb97fc087611157ce8e965088b7f9bf8 (diff)
Pushed Stateless progress (along with Packet Builder module)
Diffstat (limited to 'scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py')
-rw-r--r--scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py b/scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py
new file mode 100644
index 00000000..49148a34
--- /dev/null
+++ b/scripts/external_libs/dpkt-1.8.6/dpkt/ssl_ciphersuites.py
@@ -0,0 +1,76 @@
+# Copyright 2012 Google Inc. All rights reserved.
+
+"""
+Nicely formatted cipher suite definitions for TLS
+
+A list of cipher suites in the form of CipherSuite objects.
+These are supposed to be immutable; don't mess with them.
+"""
+
+
+class CipherSuite(object):
+ """
+ Encapsulates a cipher suite.
+
+ Members/args:
+ * code: two-byte ID code, as int
+ * name: as in 'TLS_RSA_WITH_RC4_40_MD5'
+ * kx: key exchange algorithm, string
+ * auth: authentication algorithm, string
+ * encoding: encoding algorithm
+ * mac: message authentication code algorithm
+ """
+
+ def __init__(self, code, name, kx, auth, encoding, mac):
+ self.code = code
+ self.name = name
+ self.kx = kx
+ self.auth = auth
+ self.encoding = encoding
+ self.mac = mac
+
+ def __repr__(self):
+ return 'CipherSuite(%s)' % self.name
+
+ MAC_SIZES = {
+ 'MD5': 16,
+ 'SHA': 20,
+ 'SHA256': 32, # I guess
+ }
+
+ BLOCK_SIZES = {
+ 'AES_256_CBC': 16,
+ }
+
+ @property
+ def mac_size(self):
+ """In bytes. Default to 0."""
+ return self.MAC_SIZES.get(self.mac, 0)
+
+ @property
+ def block_size(self):
+ """In bytes. Default to 1."""
+ return self.BLOCK_SIZES.get(self.encoding, 1)
+
+
+# master list of CipherSuite Objects
+CIPHERSUITES = [
+ # not a real cipher suite, can be ignored, see RFC5746
+ CipherSuite(0xff, 'TLS_EMPTY_RENEGOTIATION_INFO',
+ 'NULL', 'NULL', 'NULL', 'NULL'),
+ CipherSuite(0x00, 'TLS_NULL_WITH_NULL_NULL',
+ 'NULL', 'NULL', 'NULL', 'NULL'),
+ CipherSuite(0x01, 'TLS_RSA_WITH_NULL_MD5', 'RSA', 'RSA', 'NULL', 'MD5'),
+ CipherSuite(0x02, 'TLS_RSA_WITH_NULL_SHA', 'RSA', 'RSA', 'NULL', 'SHA'),
+ CipherSuite(0x0039, 'TLS_DHE_RSA_WITH_AES_256_CBC_SHA',
+ 'DHE', 'RSA', 'AES_256_CBC', 'SHA'), # not sure I got the kx/auth thing right.
+ CipherSuite(0xffff, 'UNKNOWN_CIPHER', '', '', '', '')
+]
+
+BY_CODE = dict(
+ (cipher.code, cipher) for cipher in CIPHERSUITES)
+
+BY_NAME = dict(
+ (suite.name, suite) for suite in CIPHERSUITES)
+
+NULL_SUITE = BY_CODE[0x00]