Skip to content
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

Feature/pkcs7 padding #406

Merged
merged 7 commits into from
Oct 6, 2023
Merged

Conversation

Kalkwst
Copy link
Contributor

@Kalkwst Kalkwst commented Oct 6, 2023

This pull request introduces a new class that implements the PKCS7 padding algorithm. The class provides three main methods: AddPadding, RemovePadding, and GetPaddingSize.

  • AddPadding: This method adds padding to the end of a byte array according to the PKCS#7 standard.
  • RemovePadding: This method removes the PKCS7 padding from the given input data.
  • GetPaddingSize: This method gets the number of padding bytes in the given input data according to the PKCS7 padding scheme.

The implementation uses bitwise operations to avoid branching, which can lead to more efficient code execution,and avoid timing attacks.

In addition, a new folder structure Crypto/Padding has been created for this implementation, as the current structure didn’t have any relevant folder for this implementation.

  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

@Kalkwst Kalkwst requested a review from siriak as a code owner October 6, 2023 09:47
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (5d9c5fe) 95.90% compared to head (5e815e2) 95.90%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #406   +/-   ##
=======================================
  Coverage   95.90%   95.90%           
=======================================
  Files         221      222    +1     
  Lines        9200     9258   +58     
=======================================
+ Hits         8823     8879   +56     
- Misses        377      379    +2     
Files Coverage Δ
Algorithms/Crypto/Paddings/PKCS7Padding.cs 96.55% <96.55%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kalkwst
Copy link
Contributor Author

Kalkwst commented Oct 6, 2023

the naming convention change to Pkcs7Padding to me seems less readable than the PKCS7Padding, but I will change it to appease codacy

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! As for the naming convention, it's a common convention to only capitalize the first letter of an acronym (e.g., https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=net-7.0)

@siriak siriak merged commit 38a0922 into TheAlgorithms:master Oct 6, 2023
4 checks passed
@Kalkwst Kalkwst deleted the feature/PKCS7Padding branch October 6, 2023 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants