byte[] sharedSecret = getSharedSecret(outgoingPublicKey, keyAgreement);
// create output cipher
byte[] digestOut = calculateHMAC_SHA256(outgoingPublicKey, sharedSecret);
try {
cipherOut = Cipher.getInstance("RC4");
cipherOut.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(digestOut, 0, 16, "RC4"));
} catch (Exception e) {
JFLog.log("Encryption cipher creation failed" + e);
}
// create input cipher
byte[] digestIn = calculateHMAC_SHA256(incomingPublicKey, sharedSecret);
try {
cipherIn = Cipher.getInstance("RC4");
cipherIn.init(Cipher.DECRYPT_MODE, new SecretKeySpec(digestIn, 0, 16, "RC4"));
} catch (Exception e) {
JFLog.log("Decryption cipher creation failed" + e);
}
// update 'encoder / decoder state' for the RC4 keys
// both parties *pretend* as if handshake part 2 (1536 bytes) was encrypted