Add padding when encrypt and remove padding when decrypt#1545
Add padding when encrypt and remove padding when decrypt#1545Rob-Hague merged 16 commits intosshnet:developfrom
Conversation
…` passed to `EncryptBlock` if padding is specified, no matter input is divisible or not.
…padding is specified.
…putBuffer` passed to `DecryptBlock` and unpadding for the final output if padding is not specified and mode is CFB or OFB.
…putBuffer` passed to `EncryptBlock` and unpadding for the final output if padding is not specified and mode is CFB or OFB.
| /// </summary> | ||
| /// <param name="input">The input.</param> | ||
| /// <returns>The padd count.</returns> | ||
| public abstract int PadCount(byte[] input); |
There was a problem hiding this comment.
We can consider replacing CipherPadding and PKCS7Padding with BouncyCastle's Pkcs7Padding
There was a problem hiding this comment.
yes, I think we should take this opportunity to delete the useless CipherPadding and replace it with BC IBlockCipherPadding, and delete PKCS7Padding and replace it with BC Pkcs7Padding, if possible
There was a problem hiding this comment.
Let me have a try
There was a problem hiding this comment.
Just had a quick look. It would be easier to remove it in my next PR #1546.
|
There would be pros and cons about different ways to fix the issue, but anyway, I think we all agree that it is an issue and should be fixed. @Rob-Hague @zybexXL |
|
I have started reviewing this, but I need more time to refamiliarise myself in this area. I have been a bit busy lately |
|
Thanks! Reviewing is usually more difficult than DIY. No hurry, take your time. |
| /// </summary> | ||
| /// <param name="input">The input.</param> | ||
| /// <returns>The padd count.</returns> | ||
| public abstract int PadCount(byte[] input); |
There was a problem hiding this comment.
yes, I think we should take this opportunity to delete the useless CipherPadding and replace it with BC IBlockCipherPadding, and delete PKCS7Padding and replace it with BC Pkcs7Padding, if possible
test/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.Gen.cs.txt
Outdated
Show resolved
Hide resolved
…AesCipherTest.Gen.cs.txt Co-authored-by: Rob Hague <[email protected]>
Originally I was to use BCL TripleDES/DES to replace managed implementation. Then I found the padding is wrong and was going to make a fix. During the fix, I noticed that I'm on the same path with @Rob-Hague and @zybexXL 😄 See #1238 and https://github.com/zybexXL/SSH.NET/compare/feature_AES_CSP...zybexXL:SSH.NET:fix_padding?diff=split