/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This is the client key exchange message (CLIENT --> SERVER) used with
* all RSA key exchanges; it holds the RSA-encrypted pre-master secret.
*
* The message is encrypted using PKCS #1 block type 02 encryption with the
* server's public key. The padding and resulting message size is a function
* of this server's public key modulus size, but the pre-master secret is
* always exactly 48 bytes.
*
*/
/**
* The TLS spec says that the version in the RSA premaster secret must
* be the maximum version supported by the client (i.e. the version it
* requested in its client hello version). However, we (and other
* implementations) used to send the active negotiated version. The
* system property below allows to toggle the behavior.
*/
"com.sun.net.ssl.rsaPreMasterSecretFix";
/*
* Default is "false" (old behavior) for compatibility reasons in
*/
private final static boolean rsaPreMasterSecretFix =
/*
* The following field values were encrypted with the server's public
* key (or temp key from server key exchange msg) and are presented
* here in DECRYPTED form.
*/
/*
* Client randomly creates a pre-master secret and encrypts it
* using the server's RSA public key; only the server can decrypt
* it, using its RSA private key. Result is the same size as the
* server's public key, and uses PKCS #1 block format 02.
*/
throw new SSLKeyException("Public key not of type RSA");
}
this.protocolVersion = protocolVersion;
} else {
}
try {
"SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
} catch (GeneralSecurityException e) {
throw (SSLKeyException)new SSLKeyException
("RSA premaster secret error").initCause(e);
}
}
/*
* Server gets the PKCS #1 (block format 02) data, decrypts
* it with its private key.
*/
throw new SSLKeyException("Private key not of type RSA");
}
} else {
encrypted = new byte [messageSize];
throw new SSLProtocolException
("SSL: read PreMasterSecret: short read");
}
}
try {
// polish the premaster secret
} catch (Exception e) {
// polish the premaster secret
}
}
/**
* To avoid vulnerabilities described by section 7.4.7.1, RFC 5246,
* version numbers in a manner indistinguishable from correctly
* formatted RSA blocks.
*
* RFC 5246 describes the approach as :
*
* 1. Generate a string R of 46 random bytes
*
* 2. Decrypt the message to recover the plaintext M
*
* 3. If the PKCS#1 padding is not correct, or the length of message
* M is not exactly 48 bytes:
* pre_master_secret = ClientHello.client_version || R
* else If ClientHello.client_version <= TLS 1.0, and version
* number check is explicitly disabled:
* pre_master_secret = M
* else:
* pre_master_secret = ClientHello.client_version || M[2..47]
*/
this.protocolVersion = clientHelloVersion;
// check the length
"unable to get the plaintext of the premaster secret");
}
"incorrect length of premaster secret: " +
(keySize/8));
}
return generateDummySecret(clientHelloVersion);
}
// The key size is exactly 48 bytes or not accessible.
//
// Conservatively, pass the checking to master secret
// calculation.
return secretKey;
// check the version
return secretKey;
/*
* For compatibility, we maintain the behavior that the
* version in pre_master_secret can be the negotiated
* version for TLS v1.0 and SSL v3.0.
*/
this.protocolVersion = currentVersion;
return secretKey;
}
"ClientHello.client_version is " + clientHelloVersion +
", while PreMasterSecret.client_version is " +
}
return generateDummySecret(clientHelloVersion);
} else {
"incorrect length of premaster secret: " +
}
return generateDummySecret(clientHelloVersion);
}
}
failoverException != null) {
}
return generateDummySecret(clientHelloVersion);
}
// generate a premaster secret with the specified version number
}
try {
"SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
return kg.generateKey();
} catch (GeneralSecurityException e) {
throw new RuntimeException("Could not generate dummy secret", e);
}
}
int messageType() {
return ht_client_key_exchange;
}
int messageLength() {
} else {
}
}
s.putBytes16(encrypted);
} else {
}
}
s.println("*** ClientKeyExchange, RSA PreMasterSecret, " +
}
}