Java Code Examples for org.bouncycastle.crypto.engines.AESEngine#init()

The following examples show how to use org.bouncycastle.crypto.engines.AESEngine#init() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Framer.java    From besu with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new framer out of the handshake secrets derived during the cryptographic handshake.
 *
 * @param secrets The handshake secrets.
 */
public Framer(final HandshakeSecrets secrets) {
  this.secrets = secrets;

  final KeyParameter aesKey = new KeyParameter(secrets.getAesSecret());
  final KeyParameter macKey = new KeyParameter(secrets.getMacSecret());

  encryptor = new SICBlockCipher(new AESEngine());
  encryptor.init(true, new ParametersWithIV(aesKey, IV));

  decryptor = new SICBlockCipher(new AESEngine());
  decryptor.init(false, new ParametersWithIV(aesKey, IV));

  macEncryptor = new AESEngine();
  macEncryptor.init(true, macKey);
}
 
Example 2
Source File: RLPxConnection.java    From cava with Apache License 2.0 6 votes vote down vote up
RLPxConnection(
    Bytes32 aesSecret,
    Bytes32 macSecret,
    Bytes32 token,
    Bytes egressMac,
    Bytes ingressMac,
    SECP256K1.PublicKey publicKey,
    SECP256K1.PublicKey peerPublicKey) {
  this.aesSecret = aesSecret;
  this.macSecret = macSecret;
  this.token = token;

  KeyParameter macKey = new KeyParameter(macSecret.toArrayUnsafe());
  macEncryptionEngine = new AESEngine();
  macEncryptionEngine.init(true, macKey);

  updateEgress(egressMac);
  updateIngress(ingressMac);
  this.publicKey = publicKey;
  this.peerPublicKey = peerPublicKey;
}
 
Example 3
Source File: RLPxConnection.java    From incubator-tuweni with Apache License 2.0 5 votes vote down vote up
RLPxConnection(
    Bytes32 aesSecret,
    Bytes32 macSecret,
    Bytes32 token,
    Bytes egressMac,
    Bytes ingressMac,
    SECP256K1.PublicKey publicKey,
    SECP256K1.PublicKey peerPublicKey) {
  this.aesSecret = aesSecret;
  this.macSecret = macSecret;
  this.token = token;

  KeyParameter macKey = new KeyParameter(macSecret.toArrayUnsafe());
  macEncryptionEngine = new AESEngine();
  macEncryptionEngine.init(true, macKey);

  updateEgress(egressMac);
  updateIngress(ingressMac);
  this.publicKey = publicKey;
  this.peerPublicKey = peerPublicKey;

  KeyParameter aesKey = new KeyParameter(aesSecret.toArrayUnsafe());

  byte[] IV = new byte[16];
  Arrays.fill(IV, (byte) 0);

  decryptionCipher = new SICBlockCipher(new AESEngine());
  decryptionCipher.init(false, new ParametersWithIV(aesKey, IV));

  encryptionCipher = new SICBlockCipher(new AESEngine());
  encryptionCipher.init(true, new ParametersWithIV(aesKey, IV));
}