Search in sources :

Example 6 with ECDHBasicAgreement

use of org.bouncycastle.crypto.agreement.ECDHBasicAgreement in project rskj by rsksmart.

the class ECIESTest method makeIESEngine.

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
    AESEngine aesEngine = new AESEngine();
    EthereumIESEngine iesEngine = new EthereumIESEngine(new ECDHBasicAgreement(), new ConcatKDFBytesGenerator(new SHA256Digest()), new HMac(new SHA256Digest()), new SHA256Digest(), new BufferedBlockCipher(new SICBlockCipher(aesEngine)));
    byte[] d = new byte[] {};
    byte[] e = new byte[] {};
    IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
    ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
    iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, curve), new ECPublicKeyParameters(pub, curve), parametersWithIV);
    return iesEngine;
}
Also used : AESEngine(org.bouncycastle.crypto.engines.AESEngine) HMac(org.bouncycastle.crypto.macs.HMac) SICBlockCipher(org.bouncycastle.crypto.modes.SICBlockCipher) ECDHBasicAgreement(org.bouncycastle.crypto.agreement.ECDHBasicAgreement) ConcatKDFBytesGenerator(org.ethereum.ConcatKDFBytesGenerator) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest)

Aggregations

ECDHBasicAgreement (org.bouncycastle.crypto.agreement.ECDHBasicAgreement)6 HMac (org.bouncycastle.crypto.macs.HMac)6 SHA256Digest (org.bouncycastle.crypto.digests.SHA256Digest)5 AESEngine (org.bouncycastle.crypto.engines.AESEngine)5 SICBlockCipher (org.bouncycastle.crypto.modes.SICBlockCipher)5 BufferedBlockCipher (org.bouncycastle.crypto.BufferedBlockCipher)4 ConcatKDFBytesGenerator (org.ethereum.ConcatKDFBytesGenerator)3 SecureRandom (java.security.SecureRandom)2 AsymmetricCipherKeyPair (org.bouncycastle.crypto.AsymmetricCipherKeyPair)2 KeyGenerationParameters (org.bouncycastle.crypto.KeyGenerationParameters)2 IESEngine (org.bouncycastle.crypto.engines.IESEngine)2 ECKeyPairGenerator (org.bouncycastle.crypto.generators.ECKeyPairGenerator)2 KDF2BytesGenerator (org.bouncycastle.crypto.generators.KDF2BytesGenerator)2 ECIESPublicKeyParser (org.bouncycastle.crypto.parsers.ECIESPublicKeyParser)2 Test (org.junit.Test)2 KeyEncoder (org.bouncycastle.crypto.KeyEncoder)1 SHA1Digest (org.bouncycastle.crypto.digests.SHA1Digest)1 EphemeralKeyPairGenerator (org.bouncycastle.crypto.generators.EphemeralKeyPairGenerator)1