/** * Creates a Salsa20 engine * * @param key the key to use * @return an initialized Salsa20 engine */ @SuppressWarnings("WeakerAccess") public static Salsa20Engine createSalsa20(byte[] key) { MessageDigest md = Encryption.getMessageDigestInstance(); KeyParameter keyParameter = new KeyParameter(md.digest(key)); ParametersWithIV ivParameter = new ParametersWithIV(keyParameter, SALSA20_IV); Salsa20Engine engine = new Salsa20Engine(); engine.init(true, ivParameter); return engine; }
private void initialize(byte[] protectedStreamKey) { byte[] salsaKey = Sha256.hash(protectedStreamKey); try { salsa20Engine = new Salsa20Engine(); salsa20Engine.init(true, new ParametersWithIV(new KeyParameter(salsaKey), Hex.decode(SALSA20IV))); } catch (Exception e) { throw new UnsupportedOperationException("Could not find provider '" + SALSA20_ALGORITHM + "'", e); } }