/** * set up for use with stream mode, where the key derivation function * is used to provide a stream of bytes to xor with the message. * @param agree the key agreement used as the basis for the encryption * @param kdf the key derivation function used for byte generation * @param mac the message authentication code generator for the message * @param hash hash ing function * @param cipher the actual cipher */ public EthereumIESEngine( BasicAgreement agree, DerivationFunction kdf, Mac mac, Digest hash, BufferedBlockCipher cipher) { this.agree = agree; this.kdf = kdf; this.mac = mac; this.hash = hash; this.macBuf = new byte[mac.getMacSize()]; this.cipher = cipher; }
K1 = new byte[inLen - V.length - mac.getMacSize()]; K2 = new byte[param.getMacKeySize() / 8]; K = new byte[K1.length + K2.length]; M = new byte[cipher.getOutputSize(inLen - V.length - mac.getMacSize())]; len = cipher.processBytes(in_enc, inOff + V.length, inLen - V.length - mac.getMacSize(), M, 0); len += cipher.doFinal(M, len); byte[] T1 = Arrays.copyOfRange(in_enc, end - mac.getMacSize(), end);
byte[] T = new byte[mac.getMacSize()];
public KDFDoublePipelineIterationBytesGenerator(Mac prf) { this.prf = prf; this.h = prf.getMacSize(); this.a = new byte[h]; this.k = new byte[h]; }
public KDFFeedbackBytesGenerator(Mac prf) { this.prf = prf; this.h = prf.getMacSize(); this.k = new byte[h]; }
public KDFCounterBytesGenerator(Mac prf) { this.prf = prf; this.h = prf.getMacSize(); this.k = new byte[h]; }
/** * @return The Keysize of the mac. */ public int getSize() { return mac.getMacSize(); }
protected int engineGetMacLength() { return macEngine.getMacSize(); }
protected int engineGetMacLength() { return macEngine.getMacSize(); }
protected int engineGetMacLength() { return macEngine.getMacSize(); }
/** * set up for use with stream mode, where the key derivation function * is used to provide a stream of bytes to xor with the message. * * @param agree the key agreement used as the basis for the encryption * @param kdf the key derivation function used for byte generation * @param mac the message authentication code generator for the message */ public IESEngine( BasicAgreement agree, DerivationFunction kdf, Mac mac) { this.agree = agree; this.kdf = kdf; this.mac = mac; this.macBuf = new byte[mac.getMacSize()]; this.cipher = null; }
public byte[] getMac() { byte[] res = new byte[mac.getMacSize()]; mac.doFinal(res, 0); return res; } }
public PKCS5S2ParametersGenerator(Digest digest) { hMac = new HMac(digest); state = new byte[hMac.getMacSize()]; }
public byte[] getMac() { byte[] res = new byte[mac.getMacSize()]; mac.doFinal(res, 0); return res; } }
/** * Constructor that accepts an instance of a block cipher engine. * * @param cipher the engine to use */ public EAXBlockCipher(BlockCipher cipher) { blockSize = cipher.getBlockSize(); mac = new CMac(cipher); macBlock = new byte[blockSize]; associatedTextMac = new byte[mac.getMacSize()]; nonceMac = new byte[mac.getMacSize()]; this.cipher = new SICBlockCipher(cipher); }
/** * Constructor that accepts an instance of a block cipher engine. * * @param cipher the engine to use */ public EAXBlockCipher(BlockCipher cipher) { blockSize = cipher.getBlockSize(); mac = new CMac(cipher); macBlock = new byte[blockSize]; bufBlock = new byte[blockSize * 2]; associatedTextMac = new byte[mac.getMacSize()]; nonceMac = new byte[mac.getMacSize()]; this.cipher = new SICBlockCipher(cipher); }
private byte[] generateDerivedKey( int dkLen) { int hLen = hMac.getMacSize(); int l = (dkLen + hLen - 1) / hLen; byte[] iBuf = new byte[4]; byte[] out = new byte[l * hLen]; for (int i = 1; i <= l; i++) { intToOctet(iBuf, i); F(password, salt, iterationCount, iBuf, out, (i - 1) * hLen); } return out; }
@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; }
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); } }
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; }