OLD | NEW |
---|---|
1 # Authors: | 1 # Authors: |
2 # Trevor Perrin | 2 # Trevor Perrin |
3 # Dave Baggett (Arcode Corporation) - canonicalCipherName | 3 # Dave Baggett (Arcode Corporation) - canonicalCipherName |
4 # | 4 # |
5 # See the LICENSE file for legal information regarding use of this file. | 5 # See the LICENSE file for legal information regarding use of this file. |
6 | 6 |
7 """Class representing a TLS session.""" | 7 """Class representing a TLS session.""" |
8 | 8 |
9 from .utils.compat import * | 9 from .utils.compat import * |
10 from .mathtls import * | 10 from .mathtls import * |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 def __init__(self): | 47 def __init__(self): |
48 self.masterSecret = bytearray(0) | 48 self.masterSecret = bytearray(0) |
49 self.sessionID = bytearray(0) | 49 self.sessionID = bytearray(0) |
50 self.cipherSuite = 0 | 50 self.cipherSuite = 0 |
51 self.srpUsername = "" | 51 self.srpUsername = "" |
52 self.clientCertChain = None | 52 self.clientCertChain = None |
53 self.serverCertChain = None | 53 self.serverCertChain = None |
54 self.tackExt = None | 54 self.tackExt = None |
55 self.tackInHelloExt = False | 55 self.tackInHelloExt = False |
56 self.serverName = "" | 56 self.serverName = "" |
57 self.alpn_proto_selected = None | |
davidben
2016/08/04 22:29:26
ALPN protocols are not remembered across session r
Bence
2016/08/05 14:27:55
Done.
| |
57 self.resumable = False | 58 self.resumable = False |
58 | 59 |
59 def create(self, masterSecret, sessionID, cipherSuite, | 60 def create(self, masterSecret, sessionID, cipherSuite, |
60 srpUsername, clientCertChain, serverCertChain, | 61 srpUsername, clientCertChain, serverCertChain, |
61 tackExt, tackInHelloExt, serverName, resumable=True): | 62 tackExt, tackInHelloExt, alpn_proto_selected, serverName, |
63 resumable=True): | |
62 self.masterSecret = masterSecret | 64 self.masterSecret = masterSecret |
63 self.sessionID = sessionID | 65 self.sessionID = sessionID |
64 self.cipherSuite = cipherSuite | 66 self.cipherSuite = cipherSuite |
65 self.srpUsername = srpUsername | 67 self.srpUsername = srpUsername |
66 self.clientCertChain = clientCertChain | 68 self.clientCertChain = clientCertChain |
67 self.serverCertChain = serverCertChain | 69 self.serverCertChain = serverCertChain |
68 self.tackExt = tackExt | 70 self.tackExt = tackExt |
69 self.tackInHelloExt = tackInHelloExt | 71 self.tackInHelloExt = tackInHelloExt |
70 self.serverName = serverName | 72 self.serverName = serverName |
73 self.alpn_proto_selected = alpn_proto_selected | |
71 self.resumable = resumable | 74 self.resumable = resumable |
72 | 75 |
73 def _clone(self): | 76 def _clone(self): |
74 other = Session() | 77 other = Session() |
75 other.masterSecret = self.masterSecret | 78 other.masterSecret = self.masterSecret |
76 other.sessionID = self.sessionID | 79 other.sessionID = self.sessionID |
77 other.cipherSuite = self.cipherSuite | 80 other.cipherSuite = self.cipherSuite |
78 other.srpUsername = self.srpUsername | 81 other.srpUsername = self.srpUsername |
79 other.clientCertChain = self.clientCertChain | 82 other.clientCertChain = self.clientCertChain |
80 other.serverCertChain = self.serverCertChain | 83 other.serverCertChain = self.serverCertChain |
81 other.tackExt = self.tackExt | 84 other.tackExt = self.tackExt |
82 other.tackInHelloExt = self.tackInHelloExt | 85 other.tackInHelloExt = self.tackInHelloExt |
83 other.serverName = self.serverName | 86 other.serverName = self.serverName |
87 other.alpn_proto_selected = self.alpn_proto_selected | |
84 other.resumable = self.resumable | 88 other.resumable = self.resumable |
85 return other | 89 return other |
86 | 90 |
87 def valid(self): | 91 def valid(self): |
88 """If this session can be used for session resumption. | 92 """If this session can be used for session resumption. |
89 | 93 |
90 @rtype: bool | 94 @rtype: bool |
91 @return: If this session can be used for session resumption. | 95 @return: If this session can be used for session resumption. |
92 """ | 96 """ |
93 return self.resumable and self.sessionID | 97 return self.resumable and self.sessionID |
(...skipping 23 matching lines...) Expand all Loading... | |
117 """ | 121 """ |
118 return CipherSuite.canonicalCipherName(self.cipherSuite) | 122 return CipherSuite.canonicalCipherName(self.cipherSuite) |
119 | 123 |
120 def getMacName(self): | 124 def getMacName(self): |
121 """Get the name of the HMAC hash algo used with this connection. | 125 """Get the name of the HMAC hash algo used with this connection. |
122 | 126 |
123 @rtype: str | 127 @rtype: str |
124 @return: The name of the HMAC hash algo used with this connection. | 128 @return: The name of the HMAC hash algo used with this connection. |
125 """ | 129 """ |
126 return CipherSuite.canonicalMacName(self.cipherSuite) | 130 return CipherSuite.canonicalMacName(self.cipherSuite) |
OLD | NEW |