@@ -14,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes.Security.Cryptography
14
14
public class BlockCipherTest : TestBase
15
15
{
16
16
[ TestMethod ]
17
- public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEncryptBlock ( )
17
+ public void EncryptShouldTakeIntoAccountPaddingForLengthOfInputBufferPassedToEncryptBlock_InputNotDivisible ( )
18
18
{
19
19
var input = new byte [ ] { 0x2c , 0x1a , 0x05 , 0x00 , 0x68 } ;
20
20
var output = new byte [ ] { 0x0a , 0x00 , 0x03 , 0x02 , 0x06 , 0x08 , 0x07 , 0x05 } ;
@@ -23,7 +23,7 @@ public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEn
23
23
{
24
24
EncryptBlockDelegate = ( inputBuffer , inputOffset , inputCount , outputBuffer , outputOffset ) =>
25
25
{
26
- Assert . AreEqual ( 8 , outputBuffer . Length ) ;
26
+ Assert . AreEqual ( 8 , inputBuffer . Length ) ;
27
27
Buffer . BlockCopy ( output , 0 , outputBuffer , 0 , output . Length ) ;
28
28
return inputBuffer . Length ;
29
29
}
@@ -34,6 +34,27 @@ public void EncryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToEn
34
34
Assert . IsTrue ( output . SequenceEqual ( actual ) ) ;
35
35
}
36
36
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
+
37
58
[ TestMethod ]
38
59
public void DecryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToDecryptBlock ( )
39
60
{
0 commit comments