@@ -56,17 +56,19 @@ public void EncryptShouldTakeIntoAccountPaddingForLengthOfInputBufferPassedToEnc
5656 }
5757
5858 [ TestMethod ]
59- public void DecryptShouldTakeIntoAccountPaddingForLengthOfOutputBufferPassedToDecryptBlock ( )
59+ public void DecryptShouldTakeIntoAccountUnPaddingForTheFinalOutput ( )
6060 {
61- var input = new byte [ ] { 0x2c , 0x1a , 0x05 , 0x00 , 0x68 } ;
62- var output = new byte [ ] { 0x0a , 0x00 , 0x03 , 0x02 , 0x06 , 0x08 , 0x07 , 0x05 } ;
61+ var input = new byte [ ] { 0x0a , 0x00 , 0x03 , 0x02 , 0x06 , 0x08 , 0x07 , 0x05 } ;
62+ var output = new byte [ ] { 0x2c , 0x1a , 0x05 , 0x00 , 0x68 } ;
63+ var padding = new byte [ ] { 0x03 , 0x03 , 0x03 } ;
6364 var key = new byte [ ] { 0x17 , 0x78 , 0x56 , 0xe1 , 0x3e , 0xbd , 0x3e , 0x50 , 0x1d , 0x79 , 0x3f , 0x0f , 0x55 , 0x37 , 0x45 , 0x54 } ;
6465 var blockCipher = new BlockCipherStub ( key , 8 , null , new PKCS7Padding ( ) )
6566 {
6667 DecryptBlockDelegate = ( inputBuffer , inputOffset , inputCount , outputBuffer , outputOffset ) =>
6768 {
6869 Assert . AreEqual ( 8 , outputBuffer . Length ) ;
6970 Buffer . BlockCopy ( output , 0 , outputBuffer , 0 , output . Length ) ;
71+ Buffer . BlockCopy ( padding , 0 , outputBuffer , output . Length , padding . Length ) ;
7072 return inputBuffer . Length ;
7173 }
7274 } ;
0 commit comments