Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/src/ssh_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ class SSHTransport {

final _remotePacketSN = SSHPacketSN.fromZero();

int _localAeadPacketCount = 0;

int _remoteAeadPacketCount = 0;

final _paddingRandom = Random.secure();

/// Whether a key exchange is currently in progress (initial or re-key).
Expand Down Expand Up @@ -372,7 +376,7 @@ class SSHTransport {
final encrypted = _processAead(
key: _localCipherKey!,
iv: _localIV!,
sequence: _localPacketSN.value,
sequence: _localAeadPacketCount++,
aad: aad,
input: plaintext,
forEncryption: true,
Expand Down Expand Up @@ -743,7 +747,7 @@ class SSHTransport {
plaintext = _processAead(
key: _remoteAeadKey!,
iv: _remoteAeadFixedNonce!,
sequence: _remotePacketSN.value,
sequence: _remoteAeadPacketCount++,
aad: aad,
input: encryptedInput,
forEncryption: false,
Expand Down Expand Up @@ -1035,6 +1039,7 @@ class SSHTransport {
}
_encryptCipher = null;
_localMac = null; // AEAD provides integrity
_localAeadPacketCount = 0;
} else {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
_encryptCipher = cipherType.createCipher(
_deriveKey(
Expand Down Expand Up @@ -1104,6 +1109,7 @@ class SSHTransport {
}
_decryptCipher = null;
_remoteMac = null; // AEAD provides integrity
_remoteAeadPacketCount = 0;
} else {
_decryptCipher = cipherType.createCipher(
_deriveKey(
Expand Down