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 # | 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 for setting handshake parameters.""" | 7 """Class for setting handshake parameters.""" |
8 | 8 |
9 from .constants import CertificateType | 9 from .constants import CertificateType |
10 from .utils import cryptomath | 10 from .utils import cryptomath |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 @type maxVersion: tuple | 86 @type maxVersion: tuple |
87 @ivar maxVersion: The maximum allowed SSL/TLS version. | 87 @ivar maxVersion: The maximum allowed SSL/TLS version. |
88 | 88 |
89 This variable can be set to (3,0) for SSL 3.0, (3,1) for | 89 This variable can be set to (3,0) for SSL 3.0, (3,1) for |
90 TLS 1.0, or (3,2) for TLS 1.1. If the other party wishes to | 90 TLS 1.0, or (3,2) for TLS 1.1. If the other party wishes to |
91 use a higher version, a protocol_version alert will be signalled. | 91 use a higher version, a protocol_version alert will be signalled. |
92 The default is (3,2). (WARNING: Some servers may (improperly) | 92 The default is (3,2). (WARNING: Some servers may (improperly) |
93 reject clients which offer support for TLS 1.1. In this case, | 93 reject clients which offer support for TLS 1.1. In this case, |
94 try lowering maxVersion to (3,1)). | 94 try lowering maxVersion to (3,1)). |
| 95 |
| 96 @type tlsIntolerant: tuple |
| 97 @ivar tlsIntolerant: TLS version intolerance for servers. |
| 98 |
| 99 If tlsIntolerant is not None, the server will simulate TLS version |
| 100 intolerance by returning a fatal handshake_failure alert or a TCP reset to |
| 101 all TLS versions tlsIntolerant or higher. |
| 102 |
| 103 @type resetOnIntolerance: bool |
| 104 @ivar resetOnIntolerance: Whether to send a TCP reset on TLS intolerance. |
| 105 |
| 106 If resetOnIntolerance is True, the server will simulate TLS version |
| 107 intolerance with a TCP reset rather than with a fatal handshake_failuer |
| 108 alert. |
95 | 109 |
96 @type useExperimentalTackExtension: bool | 110 @type useExperimentalTackExtension: bool |
97 @ivar useExperimentalTackExtension: Whether to enabled TACK support. | 111 @ivar useExperimentalTackExtension: Whether to enabled TACK support. |
98 | 112 |
99 Note that TACK support is not standardized by IETF and uses a temporary | 113 Note that TACK support is not standardized by IETF and uses a temporary |
100 TLS Extension number, so should NOT be used in production software. | 114 TLS Extension number, so should NOT be used in production software. |
101 """ | 115 """ |
102 def __init__(self): | 116 def __init__(self): |
103 self.minKeySize = 1023 | 117 self.minKeySize = 1023 |
104 self.maxKeySize = 8193 | 118 self.maxKeySize = 8193 |
105 self.cipherNames = CIPHER_NAMES | 119 self.cipherNames = CIPHER_NAMES |
106 self.macNames = MAC_NAMES | 120 self.macNames = MAC_NAMES |
107 self.keyExchangeNames = KEY_EXCHANGE_NAMES | 121 self.keyExchangeNames = KEY_EXCHANGE_NAMES |
108 self.cipherImplementations = CIPHER_IMPLEMENTATIONS | 122 self.cipherImplementations = CIPHER_IMPLEMENTATIONS |
109 self.certificateTypes = CERTIFICATE_TYPES | 123 self.certificateTypes = CERTIFICATE_TYPES |
110 self.minVersion = (3,0) | 124 self.minVersion = (3,0) |
111 self.maxVersion = (3,2) | 125 self.maxVersion = (3,2) |
| 126 self.tlsIntolerant = None |
| 127 self.resetOnIntolerance = False |
112 self.useExperimentalTackExtension = False | 128 self.useExperimentalTackExtension = False |
113 | 129 |
114 # Validates the min/max fields, and certificateTypes | 130 # Validates the min/max fields, and certificateTypes |
115 # Filters out unsupported cipherNames and cipherImplementations | 131 # Filters out unsupported cipherNames and cipherImplementations |
116 def _filter(self): | 132 def _filter(self): |
117 other = HandshakeSettings() | 133 other = HandshakeSettings() |
118 other.minKeySize = self.minKeySize | 134 other.minKeySize = self.minKeySize |
119 other.maxKeySize = self.maxKeySize | 135 other.maxKeySize = self.maxKeySize |
120 other.cipherNames = self.cipherNames | 136 other.cipherNames = self.cipherNames |
121 other.macNames = self.macNames | 137 other.macNames = self.macNames |
122 other.keyExchangeNames = self.keyExchangeNames | 138 other.keyExchangeNames = self.keyExchangeNames |
123 other.cipherImplementations = self.cipherImplementations | 139 other.cipherImplementations = self.cipherImplementations |
124 other.certificateTypes = self.certificateTypes | 140 other.certificateTypes = self.certificateTypes |
125 other.minVersion = self.minVersion | 141 other.minVersion = self.minVersion |
126 other.maxVersion = self.maxVersion | 142 other.maxVersion = self.maxVersion |
| 143 other.tlsIntolerant = self.tlsIntolerant |
| 144 other.resetOnIntolerance = self.resetOnIntolerance |
127 | 145 |
128 if not cipherfactory.tripleDESPresent: | 146 if not cipherfactory.tripleDESPresent: |
129 other.cipherNames = [e for e in self.cipherNames if e != "3des"] | 147 other.cipherNames = [e for e in self.cipherNames if e != "3des"] |
130 if len(other.cipherNames)==0: | 148 if len(other.cipherNames)==0: |
131 raise ValueError("No supported ciphers") | 149 raise ValueError("No supported ciphers") |
132 if len(other.certificateTypes)==0: | 150 if len(other.certificateTypes)==0: |
133 raise ValueError("No supported certificate types") | 151 raise ValueError("No supported certificate types") |
134 | 152 |
135 if not cryptomath.m2cryptoLoaded: | 153 if not cryptomath.m2cryptoLoaded: |
136 other.cipherImplementations = \ | 154 other.cipherImplementations = \ |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return other | 195 return other |
178 | 196 |
179 def _getCertificateTypes(self): | 197 def _getCertificateTypes(self): |
180 l = [] | 198 l = [] |
181 for ct in self.certificateTypes: | 199 for ct in self.certificateTypes: |
182 if ct == "x509": | 200 if ct == "x509": |
183 l.append(CertificateType.x509) | 201 l.append(CertificateType.x509) |
184 else: | 202 else: |
185 raise AssertionError() | 203 raise AssertionError() |
186 return l | 204 return l |
OLD | NEW |