Example usage for org.bouncycastle.crypto.engines RFC3394WrapEngine init

List of usage examples for org.bouncycastle.crypto.engines RFC3394WrapEngine init

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.engines RFC3394WrapEngine init.

Prototype

public void init(boolean forWrapping, CipherParameters param) 

Source Link

Usage

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. ja 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 {//from w ww  .j  av a 2s . co 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);
}