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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 121 |
122 @type supportedTokenBindingParams: list | 122 @type supportedTokenBindingParams: list |
123 @ivar supportedTokenBindingParams: A list of token binding parameters that | 123 @ivar supportedTokenBindingParams: A list of token binding parameters that |
124 the server supports when negotiating token binding. List values are integers | 124 the server supports when negotiating token binding. List values are integers |
125 corresponding to the TokenBindingKeyParameters enum in the Token Binding | 125 corresponding to the TokenBindingKeyParameters enum in the Token Binding |
126 Negotiation spec (draft-ietf-tokbind-negotiation-00). Values are in server's | 126 Negotiation spec (draft-ietf-tokbind-negotiation-00). Values are in server's |
127 preference order, with most preferred params first. | 127 preference order, with most preferred params first. |
128 | 128 |
129 Note that TACK support is not standardized by IETF and uses a temporary | 129 Note that TACK support is not standardized by IETF and uses a temporary |
130 TLS Extension number, so should NOT be used in production software. | 130 TLS Extension number, so should NOT be used in production software. |
| 131 |
| 132 @type alpnProtos: list of strings. |
| 133 @param alpnProtos: A list of supported upper layer protocols to use in the |
| 134 Application-Layer Protocol Negotiation Extension (RFC 7301). For the |
| 135 client, the order does not matter. For the server, the list is in |
| 136 decreasing order of preference. |
131 """ | 137 """ |
132 def __init__(self): | 138 def __init__(self): |
133 self.minKeySize = 1023 | 139 self.minKeySize = 1023 |
134 self.maxKeySize = 8193 | 140 self.maxKeySize = 8193 |
135 self.cipherNames = CIPHER_NAMES | 141 self.cipherNames = CIPHER_NAMES |
136 self.macNames = MAC_NAMES | 142 self.macNames = MAC_NAMES |
137 self.keyExchangeNames = KEY_EXCHANGE_NAMES | 143 self.keyExchangeNames = KEY_EXCHANGE_NAMES |
138 self.cipherImplementations = CIPHER_IMPLEMENTATIONS | 144 self.cipherImplementations = CIPHER_IMPLEMENTATIONS |
139 self.certificateTypes = CERTIFICATE_TYPES | 145 self.certificateTypes = CERTIFICATE_TYPES |
140 self.minVersion = (3,1) | 146 self.minVersion = (3,1) |
141 self.maxVersion = (3,3) | 147 self.maxVersion = (3,3) |
142 self.tlsIntolerant = None | 148 self.tlsIntolerant = None |
143 self.tlsIntoleranceType = 'alert' | 149 self.tlsIntoleranceType = 'alert' |
144 self.useExperimentalTackExtension = False | 150 self.useExperimentalTackExtension = False |
145 self.alertAfterHandshake = False | 151 self.alertAfterHandshake = False |
146 self.enableChannelID = True | 152 self.enableChannelID = True |
147 self.enableExtendedMasterSecret = True | 153 self.enableExtendedMasterSecret = True |
148 self.supportedTokenBindingParams = [] | 154 self.supportedTokenBindingParams = [] |
| 155 self.alpnProtos = None |
149 | 156 |
150 # Validates the min/max fields, and certificateTypes | 157 # Validates the min/max fields, and certificateTypes |
151 # Filters out unsupported cipherNames and cipherImplementations | 158 # Filters out unsupported cipherNames and cipherImplementations |
152 def _filter(self): | 159 def _filter(self): |
153 other = HandshakeSettings() | 160 other = HandshakeSettings() |
154 other.minKeySize = self.minKeySize | 161 other.minKeySize = self.minKeySize |
155 other.maxKeySize = self.maxKeySize | 162 other.maxKeySize = self.maxKeySize |
156 other.cipherNames = self.cipherNames | 163 other.cipherNames = self.cipherNames |
157 other.macNames = self.macNames | 164 other.macNames = self.macNames |
158 other.keyExchangeNames = self.keyExchangeNames | 165 other.keyExchangeNames = self.keyExchangeNames |
159 other.cipherImplementations = self.cipherImplementations | 166 other.cipherImplementations = self.cipherImplementations |
160 other.certificateTypes = self.certificateTypes | 167 other.certificateTypes = self.certificateTypes |
161 other.minVersion = self.minVersion | 168 other.minVersion = self.minVersion |
162 other.maxVersion = self.maxVersion | 169 other.maxVersion = self.maxVersion |
163 other.tlsIntolerant = self.tlsIntolerant | 170 other.tlsIntolerant = self.tlsIntolerant |
164 other.tlsIntoleranceType = self.tlsIntoleranceType | 171 other.tlsIntoleranceType = self.tlsIntoleranceType |
165 other.alertAfterHandshake = self.alertAfterHandshake | 172 other.alertAfterHandshake = self.alertAfterHandshake |
166 other.enableChannelID = self.enableChannelID | 173 other.enableChannelID = self.enableChannelID |
167 other.enableExtendedMasterSecret = self.enableExtendedMasterSecret | 174 other.enableExtendedMasterSecret = self.enableExtendedMasterSecret |
168 other.supportedTokenBindingParams = self.supportedTokenBindingParams | 175 other.supportedTokenBindingParams = self.supportedTokenBindingParams |
| 176 other.alpnProtos = self.alpnProtos; |
169 | 177 |
170 if not cipherfactory.tripleDESPresent: | 178 if not cipherfactory.tripleDESPresent: |
171 other.cipherNames = [e for e in self.cipherNames if e != "3des"] | 179 other.cipherNames = [e for e in self.cipherNames if e != "3des"] |
172 if len(other.cipherNames)==0: | 180 if len(other.cipherNames)==0: |
173 raise ValueError("No supported ciphers") | 181 raise ValueError("No supported ciphers") |
174 if len(other.certificateTypes)==0: | 182 if len(other.certificateTypes)==0: |
175 raise ValueError("No supported certificate types") | 183 raise ValueError("No supported certificate types") |
176 | 184 |
177 if not cryptomath.m2cryptoLoaded: | 185 if not cryptomath.m2cryptoLoaded: |
178 other.cipherImplementations = \ | 186 other.cipherImplementations = \ |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return other | 231 return other |
224 | 232 |
225 def _getCertificateTypes(self): | 233 def _getCertificateTypes(self): |
226 l = [] | 234 l = [] |
227 for ct in self.certificateTypes: | 235 for ct in self.certificateTypes: |
228 if ct == "x509": | 236 if ct == "x509": |
229 l.append(CertificateType.x509) | 237 l.append(CertificateType.x509) |
230 else: | 238 else: |
231 raise AssertionError() | 239 raise AssertionError() |
232 return l | 240 return l |
OLD | NEW |