question: public static byte [ ] checkTlsPreMasterSecretKey ( int clientVersion , int serverVersion , SecureRandom random , byte [ ] encoded , boolean isFailOver ) { if ( random == null ) { random = JCAUtil . getSecureRandom ( ) ; } byte [ ] replacer = new byte [ 48 ] ; random . nextBytes ( replacer ) ; if ( ! isFailOver && ( encoded != null ) ) { if ( encoded . length != 48 ) { return replacer ; } int encodedVersion = ( ( encoded [ 0 ] & 0xFF ) << 8 ) | ( encoded [ 1 ] & 0xFF ) ; if ( clientVersion != encodedVersion ) { if ( clientVersion > 0x0301 || serverVersion != encodedVersion ) { encoded = replacer ; } } return encoded ; } return replacer ; }
target:  Check the format of TLS PreMasterSecret. <P> To avoid vulnerabilities described by section 7.4.7.1, RFC 5246, treating incorrectly formatted message blocks and/or mismatched version numbers in a manner indistinguishable from correctly formatted RSA blocks. RFC 5246 describes the approach as : 1. Generate a string R of 48 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 = R else If ClientHello.client_version <= TLS 1.0, and version number check is explicitly disabled: premaster secret = M else If M[0..1] != ClientHello.client_version: premaster secret = R else: premaster secret = M Note that #2 should have completed before the call to this method.