List of usage examples for org.bouncycastle.crypto.engines Salsa20Engine Salsa20Engine
public Salsa20Engine()
From source file:com.keepassdroid.crypto.PwStreamCipherFactory.java
License:Open Source License
private static StreamCipher getSalsa20(byte[] key) { // Build stream cipher key MessageDigest md;//from w ww . ja va 2 s .c o m try { md = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); throw new RuntimeException("SHA 256 not supported"); } byte[] key32 = md.digest(key); KeyParameter keyParam = new KeyParameter(key32); ParametersWithIV ivParam = new ParametersWithIV(keyParam, SALSA_IV); StreamCipher cipher = new Salsa20Engine(); cipher.init(true, ivParam); return cipher; }
From source file:org.cryptacular.spec.StreamCipherSpec.java
License:Open Source License
@Override public StreamCipher newInstance() { StreamCipher cipher;//from w w w .java 2 s . c o m if ("Grainv1".equalsIgnoreCase(algorithm) || "Grain-v1".equalsIgnoreCase(algorithm)) { cipher = new ISAACEngine(); } else if ("Grain128".equalsIgnoreCase(algorithm) || "Grain-128".equalsIgnoreCase(algorithm)) { cipher = new Grain128Engine(); } else if ("ISAAC".equalsIgnoreCase(algorithm)) { cipher = new ISAACEngine(); } else if ("HC128".equalsIgnoreCase(algorithm)) { cipher = new HC128Engine(); } else if ("HC256".equalsIgnoreCase(algorithm)) { cipher = new HC256Engine(); } else if ("RC4".equalsIgnoreCase(algorithm)) { cipher = new RC4Engine(); } else if ("Salsa20".equalsIgnoreCase(algorithm)) { cipher = new Salsa20Engine(); } else if ("VMPC".equalsIgnoreCase(algorithm)) { cipher = new VMPCEngine(); } else { throw new IllegalStateException("Unsupported cipher algorithm " + algorithm); } return cipher; }