Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions src/main/java/com/trilead/ssh2/crypto/cipher/AES.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public void transformBlock(byte[] src, int srcoff, byte[] dst, int dstoff) {
}
}

@Override
public void transformBlocks(byte[] src, int srcoff, byte[] dst, int dstoff, int numBlocks) {
try {
cipher.update(src, srcoff, numBlocks * AES_BLOCK_SIZE, dst, dstoff);
} catch (ShortBufferException e) {
throw new AssertionError(e);
}
}

/**
* AES in CBC (Cipher Block Chaining) mode for SSH.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/trilead/ssh2/crypto/cipher/BlockCipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ public interface BlockCipher
int getBlockSize();

void transformBlock(byte[] src, int srcoff, byte[] dst, int dstoff);

default void transformBlocks(byte[] src, int srcoff, byte[] dst, int dstoff, int numBlocks) {
int blockSize = getBlockSize();
for (int i = 0; i < numBlocks; i++) {
transformBlock(src, srcoff + i * blockSize, dst, dstoff + i * blockSize);
}
}
}
Loading