Skip to content

Add legacy support for encryption and decryption methods in AES CyriptoService provider #30

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

Merged
merged 6 commits into from
Jun 4, 2025

Conversation

MayMeow
Copy link
Owner

@MayMeow MayMeow commented Jun 4, 2025

closes #29

This pull request add better compatibilty with javascript encrypted data.

@MayMeow MayMeow changed the title Add legacy support for encryption and decryption methods in AESC Add legacy support for encryption and decryption methods in AES Jun 4, 2025
@MayMeow MayMeow changed the title Add legacy support for encryption and decryption methods in AES Add legacy support for encryption and decryption methods in AES CyriptoService provider Jun 4, 2025
@MayMeow MayMeow requested a review from Copilot June 4, 2025 09:56
Copilot

This comment was marked as outdated.

@MayMeow MayMeow requested a review from Copilot June 4, 2025 10:02
Copilot

This comment was marked as outdated.

@MayMeow MayMeow requested a review from Copilot June 4, 2025 10:50
Copilot

This comment was marked as outdated.

@MayMeow MayMeow requested a review from Copilot June 4, 2025 11:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a legacy flag to the AES CryptoService provider to support JavaScript–compatible payload formats.

  • Extended encrypt and decrypt methods with a bool $legacy parameter to switch IV/TAG ordering.
  • Factored payload construction into buildPayload and parsing into parsePayload.
  • Updated tests to verify both default and legacy encryption/decryption flows.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/AESCryptoServiceProvider.php Added legacy parameter, buildPayload/parsePayload methods, and updated docblocks
tests/AESCryptoServiceProviderTest.php Added legacy-encryption test cases and decrypt(..., legacy: true) assertion
Comments suppressed due to low confidence (3)

src/AESCryptoServiceProvider.php:161

  • [nitpick] The single-letter variable $c is not descriptive. Rename it to $cipherText for clarity.
$c = base64_decode($encryptedData);

tests/AESCryptoServiceProviderTest.php:19

  • [nitpick] Add spaces around the = operator to match coding style ($encryptedText = ...).
$encryptedText= $csp->encrypt($plainText, legacy: true);

src/AESCryptoServiceProvider.php:152

  • [nitpick] Merge the $legacy param description onto the same line (e.g. @param bool $legacy True = IV-TAG-EncryptedData; false = IV-EncryptedData-TAG).
@param bool $legacy

@MayMeow MayMeow merged commit 0b8816d into main Jun 4, 2025
2 of 3 checks passed
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.

Make AES export format compatible with JavaScript Web Crypto (TAG as last element)
1 participant