Search in sources :

Example 1 with ChaChaEngine

use of com.github.zhenwei.core.crypto.engines.ChaChaEngine in project LinLong-Java by zhenwei1108.

the class ChaCha20 method process.

static void process(byte[] key, byte[] nonce, byte[] buf, int off, int len) {
    ChaChaEngine e = new ChaChaEngine(20);
    e.init(true, new ParametersWithIV(new KeyParameter(key), nonce));
    e.processBytes(buf, off, len, buf, off);
}
Also used : ParametersWithIV(com.github.zhenwei.core.crypto.params.ParametersWithIV) ChaChaEngine(com.github.zhenwei.core.crypto.engines.ChaChaEngine) KeyParameter(com.github.zhenwei.core.crypto.params.KeyParameter)

Example 2 with ChaChaEngine

use of com.github.zhenwei.core.crypto.engines.ChaChaEngine in project LinLong-Java by zhenwei1108.

the class Seed method prg.

static void prg(byte[] r, int rOff, long rlen, byte[] key, int keyOff) {
    byte[] nonce = new byte[8];
    StreamCipher cipher = new ChaChaEngine(12);
    cipher.init(true, new ParametersWithIV(new KeyParameter(key, keyOff, 32), nonce));
    cipher.processBytes(r, rOff, (int) rlen, r, rOff);
// crypto_stream_chacha12(r, rlen, nonce, key);
}
Also used : ParametersWithIV(com.github.zhenwei.core.crypto.params.ParametersWithIV) ChaChaEngine(com.github.zhenwei.core.crypto.engines.ChaChaEngine) KeyParameter(com.github.zhenwei.core.crypto.params.KeyParameter) StreamCipher(com.github.zhenwei.core.crypto.StreamCipher)

Aggregations

ChaChaEngine (com.github.zhenwei.core.crypto.engines.ChaChaEngine)2 KeyParameter (com.github.zhenwei.core.crypto.params.KeyParameter)2 ParametersWithIV (com.github.zhenwei.core.crypto.params.ParametersWithIV)2 StreamCipher (com.github.zhenwei.core.crypto.StreamCipher)1