List of usage examples for org.bouncycastle.crypto.generators Poly1305KeyGenerator clamp
public static void clamp(byte[] key)
r
(second 16 bytes) portion of the key.From source file:ch.lamacrypt.internal.crypto.CPCipher.java
License:Open Source License
/** * Initializes Poly1305 with the given instance of ChaCha20Engine * * @param cipher//from w w w.j a va2s . c o m */ private void initMAC(ChaChaEngine cipher) { byte[] firstBlock = new byte[64]; cipher.processBytes(firstBlock, 0, firstBlock.length, firstBlock, 0); // NOTE: The BC implementation puts 'r' after 'k' System.arraycopy(firstBlock, 0, firstBlock, 32, 16); KeyParameter macKey = new KeyParameter(firstBlock, 16, 32); Poly1305KeyGenerator.clamp(macKey.getKey()); mac.init(macKey); }