-
-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add padding when encrypt and remove padding when decrypt #1545
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can consider replacing CipherPadding
and PKCS7Padding
with BouncyCastle's Pkcs7Padding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me have a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
/// </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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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