1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
| private void clientHello(ClientHello var1) throws IOException {
ServerNameExtension var2 = (ServerNameExtension)var1.extensions.get(ExtensionType.EXT_SERVER_NAME); if(!this.sniMatchers.isEmpty() && var2 != null && !var2.isMatched(this.sniMatchers)) { this.fatalSE(112, "Unrecognized server name indication"); }
boolean var3 = false; CipherSuiteList var4 = var1.getCipherSuites(); if(var4.contains(CipherSuite.C_SCSV)) { var3 = true; if(this.isInitialHandshake) { this.secureRenegotiation = true; } else if(this.secureRenegotiation) { this.fatalSE(40, "The SCSV is present in a secure renegotiation"); } else { this.fatalSE(40, "The SCSV is present in a insecure renegotiation"); } }
RenegotiationInfoExtension var5 = (RenegotiationInfoExtension)var1.extensions.get(ExtensionType.EXT_RENEGOTIATION_INFO); if(var5 != null) { var3 = true; if(this.isInitialHandshake) { if(!var5.isEmpty()) { this.fatalSE(40, "The renegotiation_info field is not empty"); }
this.secureRenegotiation = true; } else { if(!this.secureRenegotiation) { this.fatalSE(40, "The renegotiation_info is present in a insecure renegotiation"); }
if(!MessageDigest.isEqual(this.clientVerifyData, var5.getRenegotiatedConnection())) { this.fatalSE(40, "Incorrect verify data in ClientHello renegotiation_info message"); } } } else if(!this.isInitialHandshake && this.secureRenegotiation) { this.fatalSE(40, "Inconsistent secure renegotiation indication"); }
if(!var3 || !this.secureRenegotiation) { if(this.isInitialHandshake) { if(!allowLegacyHelloMessages) { this.fatalSE(40, "Failed to negotiate the use of secure renegotiation"); }
if(debug != null && Debug.isOn("handshake")) { System.out.println("Warning: No renegotiation indication in ClientHello, allow legacy ClientHello"); } } else if(!allowUnsafeRenegotiation) { if(this.activeProtocolVersion.v >= ProtocolVersion.TLS10.v) { this.warningSE(100); this.invalidated = true; if(this.input.available() > 0) { this.fatalSE(10, "ClientHello followed by an unexpected handshake message"); }
return; }
this.fatalSE(40, "Renegotiation is not allowed"); } else if(debug != null && Debug.isOn("handshake")) { System.out.println("Warning: continue with insecure renegotiation"); } }
this.input.digestNow(); ServerHello var6 = new ServerHello(); this.clientRequestedVersion = var1.protocolVersion; ProtocolVersion var7 = this.selectProtocolVersion(this.clientRequestedVersion); if(var7 == null || var7.v == ProtocolVersion.SSL20Hello.v) { this.fatalSE(40, "Client requested protocol " + this.clientRequestedVersion + " not enabled or not supported"); }
this.handshakeHash.protocolDetermined(var7); this.setVersion(var7); var6.protocolVersion = this.protocolVersion; this.clnt_random = var1.clnt_random; this.svr_random = new RandomCookie(this.sslContext.getSecureRandom()); var6.svr_random = this.svr_random; this.session = null; if(this.session == null) {
this.supportedCurves = (SupportedEllipticCurvesExtension)var1.extensions.get(ExtensionType.EXT_ELLIPTIC_CURVES); if(this.protocolVersion.v >= ProtocolVersion.TLS12.v) { SignatureAlgorithmsExtension var18 = (SignatureAlgorithmsExtension)var1.extensions.get(ExtensionType.EXT_SIGNATURE_ALGORITHMS); if(var18 != null) { Collection var24 = var18.getSignAlgorithms(); if(var24 == null || var24.isEmpty()) { throw new SSLHandshakeException("No peer supported signature algorithms"); }
Collection var25 = SignatureAndHashAlgorithm.getSupportedAlgorithms(this.algorithmConstraints, var24); if(var25.isEmpty()) { throw new SSLHandshakeException("No signature and hash algorithm in common"); }
this.setPeerSupportedSignAlgs(var25); } }
this.session = new SSLSessionImpl(this.protocolVersion, CipherSuite.C_NULL, this.getLocalSupportedSignAlgs(), this.sslContext.getSecureRandom(), this.getHostAddressSE(), this.getPortSE()); if(this.protocolVersion.v >= ProtocolVersion.TLS12.v && this.peerSupportedSignAlgs != null) { this.session.setPeerSupportedSignatureAlgorithms(this.peerSupportedSignAlgs); }
List var19 = Collections.emptyList(); if(var2 != null) { var19 = var2.getServerNames(); }
this.session.setRequestedServerNames(var19); this.setHandshakeSessionSE(this.session); this.chooseCipherSuite(var1); this.session.setSuite(this.cipherSuite); this.session.setLocalPrivateKey(this.privateKey); } else { this.setHandshakeSessionSE(this.session); }
var6.cipherSuite = this.cipherSuite; var6.sessionId = this.session.getSessionId(); var6.compression_method = this.session.getCompression();
var6.write(this.output); if(this.resumingSession) { this.calculateConnectionKeys(this.session.getMasterSecret()); this.sendChangeCipherAndFinish(false); } else { if(this.keyExchange != KeyExchange.K_KRB5 && this.keyExchange != KeyExchange.K_KRB5_EXPORT) { if(this.keyExchange != KeyExchange.K_DH_ANON && this.keyExchange != KeyExchange.K_ECDH_ANON) { if(this.certs == null) { throw new RuntimeException("no certificates"); }
CertificateMsg var26 = new CertificateMsg(this.certs); this.session.setLocalCertificates(this.certs); if(debug != null && Debug.isOn("handshake")) { var26.print(System.out); }
var26.write(this.output); } else if(this.certs != null) { throw new RuntimeException("anonymous keyexchange with certs"); } }
Object var27; switch(null.$SwitchMap$sun$security$ssl$CipherSuite$KeyExchange[this.keyExchange.ordinal()]) { case 1: case 3: case 4: var27 = null; break; case 2: if(JsseJce.getRSAKeyLength(this.certs[0].getPublicKey()) > 512) { try { var27 = new RSA_ServerKeyExchange(this.tempPublicKey, this.privateKey, this.clnt_random, this.svr_random, this.sslContext.getSecureRandom()); this.privateKey = this.tempPrivateKey; } catch (GeneralSecurityException var15) { throwSSLException("Error generating RSA server key exchange", var15); var27 = null; } } else { var27 = null; } break; case 5: case 6: try { var27 = new DH_ServerKeyExchange(this.dh, this.privateKey, this.clnt_random.random_bytes, this.svr_random.random_bytes, this.sslContext.getSecureRandom(), this.preferableSignatureAlgorithm, this.protocolVersion); } catch (GeneralSecurityException var14) { throwSSLException("Error generating DH server key exchange", var14); var27 = null; } break; case 7: var27 = new DH_ServerKeyExchange(this.dh, this.protocolVersion); break; case 8: case 9: var27 = null; break; case 10: case 11: case 12: try { var27 = new ECDH_ServerKeyExchange(this.ecdh, this.privateKey, this.clnt_random.random_bytes, this.svr_random.random_bytes, this.sslContext.getSecureRandom(), this.preferableSignatureAlgorithm, this.protocolVersion); } catch (GeneralSecurityException var13) { throwSSLException("Error generating ECDH server key exchange", var13); var27 = null; } break; default: throw new RuntimeException("internal error: " + this.keyExchange); }
if(var27 != null) { if(debug != null && Debug.isOn("handshake")) { ((ServerKeyExchange)var27).print(System.out); }
((ServerKeyExchange)var27).write(this.output); }
if(this.doClientAuth != 0 && this.keyExchange != KeyExchange.K_DH_ANON && this.keyExchange != KeyExchange.K_ECDH_ANON && this.keyExchange != KeyExchange.K_KRB5 && this.keyExchange != KeyExchange.K_KRB5_EXPORT) { Collection var31 = null; if(this.protocolVersion.v >= ProtocolVersion.TLS12.v) { var31 = this.getLocalSupportedSignAlgs(); if(var31.isEmpty()) { throw new SSLHandshakeException("No supported signature algorithm"); }
Set var12 = SignatureAndHashAlgorithm.getHashAlgorithmNames(var31); if(var12.isEmpty()) { throw new SSLHandshakeException("No supported signature algorithm"); } }
X509Certificate[] var28 = this.sslContext.getX509TrustManager().getAcceptedIssuers(); CertificateRequest var29 = new CertificateRequest(var28, this.keyExchange, var31, this.protocolVersion); if(debug != null && Debug.isOn("handshake")) { var29.print(System.out); }
var29.write(this.output); }
ServerHelloDone var30 = new ServerHelloDone(); var30.write(this.output); this.output.flush(); } }
|