List of usage examples for org.bouncycastle.crypto.engines RFC3394WrapEngine RFC3394WrapEngine
public RFC3394WrapEngine(BlockCipher engine)
From source file:com.github.horrorho.inflatabledonkey.crypto.AESWrap.java
License:Open Source License
public static Optional<byte[]> unwrap(byte[] keyEncryptionKey, byte[] wrappedKey) { try {/*from w w w.j a v a 2 s .c o m*/ RFC3394WrapEngine engine = new RFC3394WrapEngine(new AESFastEngine()); engine.init(false, new KeyParameter(keyEncryptionKey)); return Optional.of(engine.unwrap(wrappedKey, 0, wrappedKey.length)); } catch (InvalidCipherTextException ex) { logger.warn("-- unwrap() - InvalidCipherTextException: {}", ex); return Optional.empty(); } }
From source file:com.github.horrorho.inflatabledonkey.crypto.AESWrap.java
License:Open Source License
public static byte[] wrap(byte[] keyEncryptionKey, byte[] unwrappedKey) { RFC3394WrapEngine engine = new RFC3394WrapEngine(new AESFastEngine()); engine.init(true, new KeyParameter(keyEncryptionKey)); return engine.wrap(unwrappedKey, 0, unwrappedKey.length); }
From source file:com.github.horrorho.inflatabledonkey.crypto.RFC3394Wrap.java
License:Open Source License
public static Optional<byte[]> unwrapAES(byte[] keyEncryptionKey, byte[] wrappedKey) { try {/* w w w. j a v a2 s . c o m*/ RFC3394WrapEngine engine = new RFC3394WrapEngine(new AESFastEngine()); engine.init(false, new KeyParameter(keyEncryptionKey)); return Optional.of(engine.unwrap(wrappedKey, 0, wrappedKey.length)); } catch (InvalidCipherTextException ex) { logger.debug("-- unwrap() - InvalidCipherTextException: {}", ex.getMessage()); return Optional.empty(); } }
From source file:com.github.horrorho.inflatabledonkey.crypto.RFC3394Wrap.java
License:Open Source License
public static byte[] wrapAES(byte[] keyEncryptionKey, byte[] unwrappedKey) { RFC3394WrapEngine engine = new RFC3394WrapEngine(new AESFastEngine()); engine.init(true, new KeyParameter(keyEncryptionKey)); return engine.wrap(unwrappedKey, 0, unwrappedKey.length); }
From source file:com.github.horrorho.inflatabledonkey.crypto.rfc6637.RFC6637Factory.java
License:Open Source License
public static synchronized RFC6637 secp521r1() { if (SECP521R1 == null) { SECP521R1 = create("secp521r1", SHA512Digest::new, () -> new RFC3394WrapEngine(new AESFastEngine()), RFC6637Constants.ECDH, RFC6637Constants.AES_256, 0x20, RFC6637Constants.SHA512); }//from w w w . j a v a 2 s .c o m return SECP521R1; }
From source file:com.github.horrorho.inflatabledonkey.crypto.rfc6637.RFC6637Factory.java
License:Open Source License
public static synchronized RFC6637 secp256r1() { if (SECP256R1 == null) { SECP256R1 = create("secp256r1", SHA256Digest::new, () -> new RFC3394WrapEngine(new AESFastEngine()), RFC6637Constants.ECDH, RFC6637Constants.AES_128, 0x10, RFC6637Constants.SHA256); }/* www . j a v a 2 s. c om*/ return SECP256R1; }