List of usage examples for org.bouncycastle.crypto.modes OCBBlockCipher OCBBlockCipher
public OCBBlockCipher(BlockCipher hashCipher, BlockCipher mainCipher)
From source file:org.cryptacular.spec.AEADBlockCipherSpec.java
License:Open Source License
/** * Creates a new AEAD block cipher from the specification in this instance. * * @return New AEAD block cipher instance. *//*from www . j a va 2 s . c o m*/ @Override public AEADBlockCipher newInstance() { final BlockCipher blockCipher = new BlockCipherSpec(algorithm).newInstance(); AEADBlockCipher aeadBlockCipher; switch (mode) { case "GCM": aeadBlockCipher = new GCMBlockCipher(blockCipher); break; case "CCM": aeadBlockCipher = new CCMBlockCipher(blockCipher); break; case "OCB": aeadBlockCipher = new OCBBlockCipher(blockCipher, new BlockCipherSpec(algorithm).newInstance()); break; case "EAX": aeadBlockCipher = new EAXBlockCipher(blockCipher); break; default: throw new IllegalStateException("Unsupported mode " + mode); } return aeadBlockCipher; }
From source file:org.cryptacular.util.CipherUtilTest.java
License:Open Source License
@DataProvider(name = "aead-block-cipher") public Object[][] getAeadBlockCipherData() { return new Object[][] { new Object[] { // Plaintext is NOT multiple of block size "I never picked cotton like my mother did", new GCMBlockCipher(new AESEngine()), }, new Object[] { // Plaintext is multiple of block size "Cogito ergo sum.", new GCMBlockCipher(new AESEngine()), }, // CCM new Object[] { "Thousands of candles can be lit from a single candle and the life " + "of the candle will not be shortened.", new CCMBlockCipher(new TwofishEngine()), }, // OCB new Object[] { "I slept and dreamt life was joy. I awoke and saw that life was " + "service. I acted and behold: service was joy.", new OCBBlockCipher(new AESEngine(), new AESEngine()), }, }; }