protected static byte[] getSharedSecret(byte[] otherPublicKeyBytes, KeyAgreement agreement) {
BigInteger otherPublicKeyInt = new BigInteger(1, otherPublicKeyBytes);
try {
KeyFactory keyFactory = KeyFactory.getInstance("DH");
KeySpec otherPublicKeySpec = new DHPublicKeySpec(otherPublicKeyInt, RTMPHandshake.DH_MODULUS, RTMPHandshake.DH_BASE);
PublicKey otherPublicKey = keyFactory.generatePublic(otherPublicKeySpec);
agreement.doPhase(otherPublicKey, true);
} catch (Exception e) {
JFLog.log("Exception getting the shared secret", e);
}
byte[] sharedSecret = agreement.generateSecret();