mac.doFinal(T, 0);
mac.doFinal(T2, 0);
private void calculateMac() { byte[] outC = new byte[blockSize]; mac.doFinal(outC, 0); for (int i = 0; i < macBlock.length; i++) { macBlock[i] = (byte)(nonceMac[i] ^ associatedTextMac[i] ^ outC[i]); } }
private void calculateMac() { byte[] outC = new byte[blockSize]; mac.doFinal(outC, 0); for (int i = 0; i < macBlock.length; i++) { macBlock[i] = (byte)(nonceMac[i] ^ associatedTextMac[i] ^ outC[i]); } }
public byte[] getMac() { byte[] res = new byte[mac.getMacSize()]; mac.doFinal(res, 0); return res; } }
private void initCipher() { if (cipherInitialized) { return; } cipherInitialized = true; mac.doFinal(associatedTextMac, 0); byte[] tag = new byte[blockSize]; tag[blockSize - 1] = cTAG; mac.update(tag, 0, blockSize); }
protected byte[] engineDoFinal() { byte[] out = new byte[engineGetMacLength()]; macEngine.doFinal(out, 0); return out; }
protected byte[] engineDoFinal() { byte[] out = new byte[engineGetMacLength()]; macEngine.doFinal(out, 0); return out; }
protected byte[] engineDoFinal() { byte[] out = new byte[engineGetMacLength()]; macEngine.doFinal(out, 0); return out; }
public byte[] getMac() { byte[] res = new byte[mac.getMacSize()]; mac.doFinal(res, 0); return res; } }
private void F( byte[] S, int c, byte[] iBuf, byte[] out, int outOff) { if (c == 0) { throw new IllegalArgumentException("iteration count must be at least 1."); } if (S != null) { hMac.update(S, 0, S.length); } hMac.update(iBuf, 0, iBuf.length); hMac.doFinal(state, 0); System.arraycopy(state, 0, out, outOff, state.length); for (int count = 1; count < c; count++) { hMac.update(state, 0, state.length); hMac.doFinal(state, 0); for (int j = 0; j != state.length; j++) { out[outOff + j] ^= state[j]; } } }
prf.update(ios, 0, ios.length); prf.update(fixedInputData_afterCtr, 0, fixedInputData_afterCtr.length); prf.doFinal(k, 0);
@Override public byte[] getMAC(final byte[] data) { byte[] n = new byte[this.sscBytes.length + data.length]; System.arraycopy(this.sscBytes, 0, n, 0, this.sscBytes.length); System.arraycopy(data, 0, n, this.sscBytes.length, data.length); n = addPadding(n); final BlockCipher cipher = new AESEngine(); final Mac mac = new CMac(cipher, 64); mac.init(this.keyP); mac.update(n, 0, n.length); final byte[] out = new byte[mac.getMacSize()]; mac.doFinal(out, 0); return out; }
private static void hmac_hash(Mac mac, byte[] secret, byte[] seed, byte[] out) { mac.init(new KeyParameter(secret)); byte[] a = seed; int size = mac.getMacSize(); int iterations = (out.length + size - 1) / size; byte[] buf = new byte[mac.getMacSize()]; byte[] buf2 = new byte[mac.getMacSize()]; for (int i = 0; i < iterations; i++) { mac.update(a, 0, a.length); mac.doFinal(buf, 0); a = buf; mac.update(a, 0, a.length); mac.update(seed, 0, seed.length); mac.doFinal(buf2, 0); System.arraycopy(buf2, 0, out, (size * i), Math.min(size, out.length - (size * i))); } }
public TlsSRPLoginParameters getLoginParameters(byte[] identity) { mac.update(PREFIX_SALT, 0, PREFIX_SALT.length); mac.update(identity, 0, identity.length); byte[] salt = new byte[mac.getMacSize()]; mac.doFinal(salt, 0); mac.update(PREFIX_PASSWORD, 0, PREFIX_PASSWORD.length); mac.update(identity, 0, identity.length); byte[] password = new byte[mac.getMacSize()]; mac.doFinal(password, 0); BigInteger verifier = verifierGenerator.generateVerifier(salt, identity, password); return new TlsSRPLoginParameters(group, verifier, salt); } }
private void hmac_DRBG_Update_Func(byte[] seedMaterial, byte vValue) { _hMac.init(new KeyParameter(_K)); _hMac.update(_V, 0, _V.length); _hMac.update(vValue); if (seedMaterial != null) { _hMac.update(seedMaterial, 0, seedMaterial.length); } _hMac.doFinal(_K, 0); _hMac.init(new KeyParameter(_K)); _hMac.update(_V, 0, _V.length); _hMac.doFinal(_V, 0); }
@Override public byte[] doAesCmac(final byte[] data, final byte[] key) { final BlockCipher cipher = new AESEngine(); final org.spongycastle.crypto.Mac mac = new CMac(cipher, 64); final KeyParameter keyP = new KeyParameter(key); mac.init(keyP); mac.update(data, 0, data.length); final byte[] out = new byte[8]; mac.doFinal(out, 0); return out; }
protected byte[] calculateRecordMAC(KeyParameter macKey, byte[] additionalData, byte[] buf, int off, int len) { Mac mac = new Poly1305(); mac.init(macKey); updateRecordMACText(mac, additionalData, 0, additionalData.length); updateRecordMACText(mac, buf, off, len); updateRecordMACLength(mac, additionalData.length); updateRecordMACLength(mac, len); byte[] output = new byte[mac.getMacSize()]; mac.doFinal(output, 0); return output; }
/** * Calculate the MAC for some given data. * * @param type The message type of the message. * @param message A byte-buffer containing the message. * @param offset The number of bytes to skip, before the message starts. * @param length The length of the message. * @return A new byte-buffer containing the MAC value. */ public byte[] calculateMac(long seqNo, short type, byte[] message, int offset, int length) { ProtocolVersion serverVersion = context.getServerVersion(); boolean isSSL = serverVersion.isSSL(); byte[] macHeader = new byte[isSSL ? 11 : 13]; TlsUtils.writeUint64(seqNo, macHeader, 0); TlsUtils.writeUint8(type, macHeader, 8); if (!isSSL) { TlsUtils.writeVersion(serverVersion, macHeader, 9); } TlsUtils.writeUint16(length, macHeader, macHeader.length - 2); mac.update(macHeader, 0, macHeader.length); mac.update(message, offset, length); byte[] result = new byte[mac.getMacSize()]; mac.doFinal(result, 0); return truncate(result); }