8214321: Misleading code in SSLCipher

Reviewed-by: ascarpino
This commit is contained in:
Xue-Lei Andrew Fan 2018-11-26 20:50:21 -08:00
parent b1c4b461f1
commit 23ecdbbc1d

View file

@ -530,22 +530,22 @@ enum SSLCipher {
ProtocolVersion protocolVersion, ProtocolVersion protocolVersion,
SecretKey key, IvParameterSpec iv, SecretKey key, IvParameterSpec iv,
SecureRandom random) throws GeneralSecurityException { SecureRandom random) throws GeneralSecurityException {
if (readCipherGenerators.length == 0) { if (writeCipherGenerators.length == 0) {
return null; return null;
} }
WriteCipherGenerator rcg = null; WriteCipherGenerator wcg = null;
for (Map.Entry<WriteCipherGenerator, for (Map.Entry<WriteCipherGenerator,
ProtocolVersion[]> me : writeCipherGenerators) { ProtocolVersion[]> me : writeCipherGenerators) {
for (ProtocolVersion pv : me.getValue()) { for (ProtocolVersion pv : me.getValue()) {
if (protocolVersion == pv) { if (protocolVersion == pv) {
rcg = me.getKey(); wcg = me.getKey();
} }
} }
} }
if (rcg != null) { if (wcg != null) {
return rcg.createCipher(this, authenticator, return wcg.createCipher(this, authenticator,
protocolVersion, transformation, key, iv, random); protocolVersion, transformation, key, iv, random);
} }
return null; return null;