public Mac() { super(new org.bouncycastle.crypto.macs.Poly1305()); } }
public static byte[] create(KeyParameter macKey, byte[] additionalData, byte[] ciphertext) { Poly1305 poly = new Poly1305(); poly.init(macKey); poly.update(additionalData, 0, additionalData.length); if (additionalData.length % 16 != 0) { int round = 16-(additionalData.length%16); poly.update(new byte[round], 0, round); poly.update(ciphertext, 0, ciphertext.length); if (ciphertext.length % 16 != 0) { int round = 16-(ciphertext.length%16); poly.update(new byte[round], 0, round); additionalDataLength = new byte[8]; poly.update(additionalDataLength, 0, 8); byte[] ciphertextLength = Pack.longToLittleEndian(ciphertext.length); poly.update(ciphertextLength, 0, 8); byte[] calculatedMAC = new byte[poly.getMacSize()]; poly.doFinal(calculatedMAC, 0); return calculatedMAC;
long tp0 = mul32x32_64(h0,r0) + mul32x32_64(h1,s4) + mul32x32_64(h2,s3) + mul32x32_64(h3,s2) + mul32x32_64(h4,s1); long tp1 = mul32x32_64(h0,r1) + mul32x32_64(h1,r0) + mul32x32_64(h2,s4) + mul32x32_64(h3,s3) + mul32x32_64(h4,s2); long tp2 = mul32x32_64(h0,r2) + mul32x32_64(h1,r1) + mul32x32_64(h2,r0) + mul32x32_64(h3,s4) + mul32x32_64(h4,s3); long tp3 = mul32x32_64(h0,r3) + mul32x32_64(h1,r2) + mul32x32_64(h2,r1) + mul32x32_64(h3,r0) + mul32x32_64(h4,s4); long tp4 = mul32x32_64(h0,r4) + mul32x32_64(h1,r3) + mul32x32_64(h2,r2) + mul32x32_64(h3,r1) + mul32x32_64(h4,r0);
processBlock(); Pack.intToLittleEndian((int)f3, out, outOff + 12); reset(); return BLOCK_SIZE;
public void update(final byte in) throws IllegalStateException { singleByte[0] = in; update(singleByte, 0, 1); }
public void update(final byte[] in, final int inOff, final int len) throws DataLengthException, IllegalStateException { int copied = 0; while (len > copied) { if (currentBlockOffset == BLOCK_SIZE) { processBlock(); currentBlockOffset = 0; } int toCopy = Math.min((len - copied), BLOCK_SIZE - currentBlockOffset); System.arraycopy(in, copied + inOff, currentBlock, currentBlockOffset, toCopy); copied += toCopy; currentBlockOffset += toCopy; } }
processBlock(); Pack.intToLittleEndian((int)f3, out, outOff + 12); reset(); return BLOCK_SIZE;
public void update(final byte in) throws IllegalStateException { singleByte[0] = in; update(singleByte, 0, 1); }
public void update(final byte[] in, final int inOff, final int len) throws DataLengthException, IllegalStateException { int copied = 0; while (len > copied) { if (currentBlockOffset == BLOCK_SIZE) { processBlock(); currentBlockOffset = 0; } int toCopy = Math.min((len - copied), BLOCK_SIZE - currentBlockOffset); System.arraycopy(in, copied + inOff, currentBlock, currentBlockOffset, toCopy); copied += toCopy; currentBlockOffset += toCopy; } }
/** * Constructor * * @throws NoSuchAlgorithmException thrown if the given algorithm is not supported */ public BCPoly1305MacHelper() throws NoSuchAlgorithmException { this.mac = new Poly1305(); }
long tp0 = mul32x32_64(h0,r0) + mul32x32_64(h1,s4) + mul32x32_64(h2,s3) + mul32x32_64(h3,s2) + mul32x32_64(h4,s1); long tp1 = mul32x32_64(h0,r1) + mul32x32_64(h1,r0) + mul32x32_64(h2,s4) + mul32x32_64(h3,s3) + mul32x32_64(h4,s2); long tp2 = mul32x32_64(h0,r2) + mul32x32_64(h1,r1) + mul32x32_64(h2,r0) + mul32x32_64(h3,s4) + mul32x32_64(h4,s3); long tp3 = mul32x32_64(h0,r3) + mul32x32_64(h1,r2) + mul32x32_64(h2,r1) + mul32x32_64(h3,r0) + mul32x32_64(h4,s4); long tp4 = mul32x32_64(h0,r4) + mul32x32_64(h1,r3) + mul32x32_64(h2,r2) + mul32x32_64(h3,r1) + mul32x32_64(h4,r0);
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new TwofishEngine())); } }
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new CamelliaEngine())); } }
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new CAST6Engine())); } }
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new RC6Engine())); } }
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new ARIAEngine())); } }
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new SM4Engine())); } }
public Poly1305() { super(new org.bouncycastle.crypto.macs.Poly1305(new SEEDEngine())); } }