private void checkMAC(final byte[] data) throws TransportException { mac.update(seq); // seq num mac.update(data, 0, packetLength + 4); // packetLength+4 = entire packet w/o mac mac.doFinal(macResult, 0); // compute // Check against the received MAC if (!ByteArrayUtils.equals(macResult, 0, data, packetLength + 4, mac.getBlockSize())) { throw new TransportException(DisconnectReason.MAC_ERROR, "MAC Error"); } }
void setAlgorithms(Cipher cipher, MAC mac, Compression compression) { this.cipher = cipher; this.mac = mac; this.compression = compression; if (compression != null) compression.init(getCompressionType()); this.cipherSize = cipher.getIVSize(); this.etm = mac.isEtm(); }
@Override void setAlgorithms(Cipher cipher, MAC mac, Compression compression) { super.setAlgorithms(cipher, mac, compression); macResult = new byte[mac.getBlockSize()]; }
mac_C2S.init(resizedKey(integrityKey_C2S, mac_C2S.getBlockSize(), hash, kex.getK(), kex.getH())); mac_S2C.init(resizedKey(integrityKey_S2C, mac_S2C.getBlockSize(), hash, kex.getK(), kex.getH()));
bytesNeeded = packetLength + mac.getBlockSize() - inputBuffer.available(); if (bytesNeeded <= 0) { seq = seq + 1 & 0xffffffffL;
mac_C2S.init(resizedKey(integrityKey_C2S, mac_C2S.getBlockSize(), hash, kex.getK(), kex.getH())); mac_S2C.init(resizedKey(integrityKey_S2C, mac_S2C.getBlockSize(), hash, kex.getK(), kex.getH()));
private void putMAC(SSHPacket buffer, int startOfPacket, int endOfPadding) { buffer.wpos(endOfPadding + mac.getBlockSize()); mac.update(seq); mac.update(buffer.array(), startOfPacket, endOfPadding); mac.doFinal(buffer.array(), endOfPadding); }
need = packetLength + (mac != null ? mac.getBlockSize() : 0) - inputBuffer.available(); if (need <= 0) { decryptBuffer(cipherSize, packetLength + 4 - cipherSize); // Decrypt the rest of the payload
void setAlgorithms(Cipher cipher, MAC mac, Compression compression) { this.cipher = cipher; this.mac = mac; this.compression = compression; if (compression != null) compression.init(getCompressionType()); this.cipherSize = cipher.getIVSize(); this.etm = mac.isEtm(); }
private void checkMAC(final byte[] data) throws TransportException { mac.update(seq); // seq num mac.update(data, 0, packetLength + 4); // packetLength+4 = entire packet w/o mac mac.doFinal(macResult, 0); // compute // Check against the received MAC if (!ByteArrayUtils.equals(macResult, 0, data, packetLength + 4, mac.getBlockSize())) { throw new TransportException(DisconnectReason.MAC_ERROR, "MAC Error"); } }
@Override void setAlgorithms(Cipher cipher, MAC mac, Compression compression) { super.setAlgorithms(cipher, mac, compression); macResult = new byte[mac.getBlockSize()]; }
private void checkMAC(final byte[] data) throws TransportException { mac.update(seq); // seq num mac.update(data, 0, packetLength + 4); // packetLength+4 = entire packet w/o mac mac.doFinal(macResult, 0); // compute // Check against the received MAC if (!ByteArrayUtils.equals(macResult, 0, data, packetLength + 4, mac.getBlockSize())) throw new TransportException(DisconnectReason.MAC_ERROR, "MAC Error"); }
@Override void setAlgorithms(Cipher cipher, MAC mac, Compression compression) { super.setAlgorithms(cipher, mac, compression); macResult = new byte[mac.getBlockSize()]; }
private void putMAC(SSHPacket buffer, int startOfPacket, int endOfPadding) { buffer.wpos(endOfPadding + mac.getBlockSize()); mac.update(seq); mac.update(buffer.array(), startOfPacket, endOfPadding); mac.doFinal(buffer.array(), endOfPadding); }
need = packetLength + (mac != null ? mac.getBlockSize() : 0) - inputBuffer.available(); if (need <= 0) { decryptBuffer(cipherSize, packetLength + 4 - cipherSize); // Decrypt the rest of the payload
private void putMAC(SSHPacket buffer, int startOfPacket, int endOfPadding) { buffer.wpos(endOfPadding + mac.getBlockSize()); mac.update(seq); mac.update(buffer.array(), startOfPacket, endOfPadding); mac.doFinal(buffer.array(), endOfPadding); }