protected void prepareSerializedPublicKeyLength(T msg) { msg.setPublicKeyLength(msg.getPublicKey().getValue().length); LOGGER.debug("SerializedPublicKeyLength: " + msg.getPublicKeyLength().getValue()); }
/** * Writes the SerializedPublicKey of the RSAClientKeyExchangeMessage into * the final byte[] */ private void writeSerializedPublickey(T msg) { appendBytes(msg.getPublicKey().getValue()); LOGGER.debug("SerializedPublicKey: " + ArrayConverter.bytesToHexString(msg.getPublicKey().getValue())); } }
/** * Reads the next bytes as the SerializedPublicKey and writes them in the * message * * @param msg * Message to write in */ private void parseSerializedPublicKey(T msg) { msg.setPublicKey(parseByteArrayField(msg.getPublicKeyLength().getValue())); LOGGER.debug("SerializedPublicKey: " + ArrayConverter.bytesToHexString(msg.getPublicKey().getValue())); }
protected byte[] decryptPremasterSecret() { BigInteger bigIntegerEncryptedPremasterSecret = new BigInteger(1, msg.getPublicKey().getValue()); BigInteger serverPrivateKey = chooser.getServerRSAPrivateKey(); if (chooser.getServerRsaModulus().equals(BigInteger.ZERO)) { LOGGER.warn("RSA Modulus is Zero, returning new byte[0] as decryptedPremasterSecret"); return new byte[0]; } BigInteger decrypted = bigIntegerEncryptedPremasterSecret.modPow(serverPrivateKey, chooser .getServerRsaModulus().abs()); return decrypted.toByteArray(); }
protected void prepareSerializedPublicKey(T msg) { msg.setPublicKey(encrypted); LOGGER.debug("SerializedPublicKey: " + ArrayConverter.bytesToHexString(msg.getPublicKey().getValue())); }
prepareClientServerRandom(msg); int keyByteLength = chooser.getServerRsaModulus().bitLength() / 8; if (clientMode && (msg.getPublicKey() == null || msg.getPublicKey().getValue() == null)) { int randomByteLength = keyByteLength - HandshakeByteLength.PREMASTER_SECRET - 3; padding = new byte[randomByteLength];