@@ -14,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
1414 public class BlockCipherTest : TestBase
1515 {
1616 [ TestMethod ]
17- public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEncryptBlock ( )
17+ public void EncryptShouldTakeIntoAccountPaddingForLengthOfInputBufferPassedToEncryptBlock_InputNotDivisible ( )
1818 {
1919 var input = new byte [ ] { 0x2c , 0x1a , 0x05 , 0x00 , 0x68 } ;
2020 var output = new byte [ ] { 0x0a , 0x00 , 0x03 , 0x02 , 0x06 , 0x08 , 0x07 , 0x05 } ;
@@ -23,7 +23,7 @@ public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEn
2323 {
2424 EncryptBlockDelegate = ( inputBuffer , inputOffset , inputCount , outputBuffer , outputOffset ) =>
2525 {
26- Assert . AreEqual ( 8 , outputBuffer . Length ) ;
26+ Assert . AreEqual ( 8 , inputBuffer . Length ) ;
2727 Buffer . BlockCopy ( output , 0 , outputBuffer , 0 , output . Length ) ;
2828 return inputBuffer . Length ;
2929 }
@@ -34,6 +34,27 @@ public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEn
3434 Assert . IsTrue ( output . SequenceEqual ( actual ) ) ;
3535 }
3636
37+ [ TestMethod ]
38+ public void EncryptShouldTakeIntoAccountPaddingForLengthOfInputBufferPassedToEncryptBlock_InputDivisible ( )
39+ {
40+ var input = new byte [ 0 ] ;
41+ var output = new byte [ ] { 0x0a , 0x00 , 0x03 , 0x02 , 0x06 , 0x08 , 0x07 , 0x05 } ;
42+ var key = new byte [ ] { 0x17 , 0x78 , 0x56 , 0xe1 , 0x3e , 0xbd , 0x3e , 0x50 , 0x1d , 0x79 , 0x3f , 0x0f , 0x55 , 0x37 , 0x45 , 0x54 } ;
43+ var blockCipher = new BlockCipherStub ( key , 8 , null , new PKCS7Padding ( ) )
44+ {
45+ EncryptBlockDelegate = ( inputBuffer , inputOffset , inputCount , outputBuffer , outputOffset ) =>
46+ {
47+ Assert . AreEqual ( 8 , inputBuffer . Length ) ;
48+ Buffer . BlockCopy ( output , 0 , outputBuffer , 0 , output . Length ) ;
49+ return inputBuffer . Length ;
50+ }
51+ } ;
52+
53+ var actual = blockCipher . Encrypt ( input ) ;
54+
55+ Assert . IsTrue ( output . SequenceEqual ( actual ) ) ;
56+ }
57+
3758 [ TestMethod ]
3859 public void DecryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToDecryptBlock ( )
3960 {
0 commit comments