List of usage examples for org.bouncycastle.crypto.engines RFC3394WrapEngine unwrap
public byte[] unwrap(byte[] in, int inOff, int inLen) throws InvalidCipherTextException
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 ww . j a v a 2s . 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.RFC3394Wrap.java
License:Open Source License
public static Optional<byte[]> unwrapAES(byte[] keyEncryptionKey, byte[] wrappedKey) { try {//from w ww. 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(); } }