List of usage examples for org.bouncycastle.crypto.engines NoekeonEngine NoekeonEngine
public NoekeonEngine()
From source file:NoekeonVects.java
License:Creative Commons License
public void eax_vectors() throws Exception { System.out.println("EAX-noekeon (16 byte key)"); EAXBlockCipher eax = new EAXBlockCipher(new NoekeonEngine()); byte[] output = new byte[48]; byte[] tag = new byte[16]; for (int j = 0; j < 16; j++) tag[j] = (byte) j; for (int i = 0; i <= 32; i++) { byte[] header_nonce_plaintext = new byte[i]; for (int j = 0; j < i; j++) header_nonce_plaintext[j] = (byte) j; AEADParameters params = new AEADParameters(maybe_schedule_key(tag), 128, header_nonce_plaintext, header_nonce_plaintext); eax.init(true, params);// w ww.j a v a 2s. c o m int off = eax.processBytes(header_nonce_plaintext, 0, i, output, 0); off += eax.doFinal(output, off); if (off != i + 16) throw new RuntimeException("didn't expect that"); byte[] ciphertext = new byte[i]; for (int j = 0; j < i; j++) ciphertext[j] = output[j]; for (int j = 0; j < 16; j++) tag[j] = output[i + j]; System.out.print(i < 10 ? " " : " "); System.out.print(i); System.out.print(": "); hexOut(ciphertext); System.out.print(", "); hexOut(tag); System.out.println(); } }
From source file:org.cryptacular.spec.BlockCipherSpec.java
License:Open Source License
@Override public BlockCipher newInstance() { BlockCipher cipher;/*ww w. jav a2s .c o m*/ if ("AES".equalsIgnoreCase(algorithm)) { cipher = new AESFastEngine(); } else if ("Blowfish".equalsIgnoreCase(algorithm)) { cipher = new BlowfishEngine(); } else if ("Camellia".equalsIgnoreCase(algorithm)) { cipher = new CamelliaEngine(); } else if ("CAST5".equalsIgnoreCase(algorithm)) { cipher = new CAST5Engine(); } else if ("CAST6".equalsIgnoreCase(algorithm)) { cipher = new CAST6Engine(); } else if ("DES".equalsIgnoreCase(algorithm)) { cipher = new DESEngine(); } else if ("DESede".equalsIgnoreCase(algorithm) || "DES3".equalsIgnoreCase(algorithm)) { cipher = new DESedeEngine(); } else if ("GOST".equalsIgnoreCase(algorithm) || "GOST28147".equals(algorithm)) { cipher = new GOST28147Engine(); } else if ("Noekeon".equalsIgnoreCase(algorithm)) { cipher = new NoekeonEngine(); } else if ("RC2".equalsIgnoreCase(algorithm)) { cipher = new RC2Engine(); } else if ("RC5".equalsIgnoreCase(algorithm)) { cipher = new RC564Engine(); } else if ("RC6".equalsIgnoreCase(algorithm)) { cipher = new RC6Engine(); } else if ("SEED".equalsIgnoreCase(algorithm)) { cipher = new SEEDEngine(); } else if ("Serpent".equalsIgnoreCase(algorithm)) { cipher = new SerpentEngine(); } else if ("Skipjack".equalsIgnoreCase(algorithm)) { cipher = new SkipjackEngine(); } else if ("TEA".equalsIgnoreCase(algorithm)) { cipher = new TEAEngine(); } else if ("Twofish".equalsIgnoreCase(algorithm)) { cipher = new TwofishEngine(); } else if ("XTEA".equalsIgnoreCase(algorithm)) { cipher = new XTEAEngine(); } else { throw new IllegalStateException("Unsupported cipher algorithm " + algorithm); } return cipher; }