OLD | NEW |
1 # Authors: | 1 # Authors: |
2 # Trevor Perrin | 2 # Trevor Perrin |
3 # Dave Baggett (Arcode Corporation) - cleanup handling of constants | 3 # Dave Baggett (Arcode Corporation) - cleanup handling of constants |
4 # Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2 | 4 # Yngve Pettersen (ported by Paul Sokolovsky) - TLS 1.2 |
5 # | 5 # |
6 # See the LICENSE file for legal information regarding use of this file. | 6 # See the LICENSE file for legal information regarding use of this file. |
7 | 7 |
8 """Class for setting handshake parameters.""" | 8 """Class for setting handshake parameters.""" |
9 | 9 |
10 from .constants import CertificateType | 10 from .constants import CertificateType |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 @type tlsIntoleranceType: str | 101 @type tlsIntoleranceType: str |
102 @ivar tlsIntoleranceType: How the server should react when simulating TLS | 102 @ivar tlsIntoleranceType: How the server should react when simulating TLS |
103 intolerance. | 103 intolerance. |
104 | 104 |
105 The allowed values are "alert" (return a fatal handshake_failure alert), | 105 The allowed values are "alert" (return a fatal handshake_failure alert), |
106 "close" (abruptly close the connection), and "reset" (send a TCP reset). | 106 "close" (abruptly close the connection), and "reset" (send a TCP reset). |
107 | 107 |
108 @type useExperimentalTackExtension: bool | 108 @type useExperimentalTackExtension: bool |
109 @ivar useExperimentalTackExtension: Whether to enabled TACK support. | 109 @ivar useExperimentalTackExtension: Whether to enabled TACK support. |
| 110 |
| 111 @type alertAfterHandshake: bool |
| 112 @ivar alertAfterHandshake: If true, the server will send a fatal |
| 113 alert immediately after the handshake completes. |
110 | 114 |
111 Note that TACK support is not standardized by IETF and uses a temporary | 115 Note that TACK support is not standardized by IETF and uses a temporary |
112 TLS Extension number, so should NOT be used in production software. | 116 TLS Extension number, so should NOT be used in production software. |
113 """ | 117 """ |
114 def __init__(self): | 118 def __init__(self): |
115 self.minKeySize = 1023 | 119 self.minKeySize = 1023 |
116 self.maxKeySize = 8193 | 120 self.maxKeySize = 8193 |
117 self.cipherNames = CIPHER_NAMES | 121 self.cipherNames = CIPHER_NAMES |
118 self.macNames = MAC_NAMES | 122 self.macNames = MAC_NAMES |
119 self.keyExchangeNames = KEY_EXCHANGE_NAMES | 123 self.keyExchangeNames = KEY_EXCHANGE_NAMES |
120 self.cipherImplementations = CIPHER_IMPLEMENTATIONS | 124 self.cipherImplementations = CIPHER_IMPLEMENTATIONS |
121 self.certificateTypes = CERTIFICATE_TYPES | 125 self.certificateTypes = CERTIFICATE_TYPES |
122 self.minVersion = (3,1) | 126 self.minVersion = (3,1) |
123 self.maxVersion = (3,3) | 127 self.maxVersion = (3,3) |
124 self.tlsIntolerant = None | 128 self.tlsIntolerant = None |
125 self.tlsIntoleranceType = 'alert' | 129 self.tlsIntoleranceType = 'alert' |
126 self.useExperimentalTackExtension = False | 130 self.useExperimentalTackExtension = False |
| 131 self.alertAfterHandshake = False |
127 | 132 |
128 # Validates the min/max fields, and certificateTypes | 133 # Validates the min/max fields, and certificateTypes |
129 # Filters out unsupported cipherNames and cipherImplementations | 134 # Filters out unsupported cipherNames and cipherImplementations |
130 def _filter(self): | 135 def _filter(self): |
131 other = HandshakeSettings() | 136 other = HandshakeSettings() |
132 other.minKeySize = self.minKeySize | 137 other.minKeySize = self.minKeySize |
133 other.maxKeySize = self.maxKeySize | 138 other.maxKeySize = self.maxKeySize |
134 other.cipherNames = self.cipherNames | 139 other.cipherNames = self.cipherNames |
135 other.macNames = self.macNames | 140 other.macNames = self.macNames |
136 other.keyExchangeNames = self.keyExchangeNames | 141 other.keyExchangeNames = self.keyExchangeNames |
137 other.cipherImplementations = self.cipherImplementations | 142 other.cipherImplementations = self.cipherImplementations |
138 other.certificateTypes = self.certificateTypes | 143 other.certificateTypes = self.certificateTypes |
139 other.minVersion = self.minVersion | 144 other.minVersion = self.minVersion |
140 other.maxVersion = self.maxVersion | 145 other.maxVersion = self.maxVersion |
141 other.tlsIntolerant = self.tlsIntolerant | 146 other.tlsIntolerant = self.tlsIntolerant |
142 other.tlsIntoleranceType = self.tlsIntoleranceType | 147 other.tlsIntoleranceType = self.tlsIntoleranceType |
| 148 other.alertAfterHandshake = self.alertAfterHandshake |
143 | 149 |
144 if not cipherfactory.tripleDESPresent: | 150 if not cipherfactory.tripleDESPresent: |
145 other.cipherNames = [e for e in self.cipherNames if e != "3des"] | 151 other.cipherNames = [e for e in self.cipherNames if e != "3des"] |
146 if len(other.cipherNames)==0: | 152 if len(other.cipherNames)==0: |
147 raise ValueError("No supported ciphers") | 153 raise ValueError("No supported ciphers") |
148 if len(other.certificateTypes)==0: | 154 if len(other.certificateTypes)==0: |
149 raise ValueError("No supported certificate types") | 155 raise ValueError("No supported certificate types") |
150 | 156 |
151 if not cryptomath.m2cryptoLoaded: | 157 if not cryptomath.m2cryptoLoaded: |
152 other.cipherImplementations = \ | 158 other.cipherImplementations = \ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 return other | 203 return other |
198 | 204 |
199 def _getCertificateTypes(self): | 205 def _getCertificateTypes(self): |
200 l = [] | 206 l = [] |
201 for ct in self.certificateTypes: | 207 for ct in self.certificateTypes: |
202 if ct == "x509": | 208 if ct == "x509": |
203 l.append(CertificateType.x509) | 209 l.append(CertificateType.x509) |
204 else: | 210 else: |
205 raise AssertionError() | 211 raise AssertionError() |
206 return l | 212 return l |
OLD | NEW |