Register the experimental algorithms again - #668
Merged
Conversation
The configuration files of the jose-experimental algorithms still referred to the classes by their pre-4.0 names, under Jose\Component. Because SignatureSource and EncryptionSource decide whether to load those files with a class_exists() check on the very same stale names, the files were never loaded: not a single experimental algorithm was reachable through the bundle since the namespaces were renamed. Loading them uncovered a second defect: A256CCM_64_128 and A256CCM_64_64 returned the name of their "16" counterparts, so they replaced them in the AlgorithmManager and were themselves unreachable. Only the names were wrong, the parameters of both classes already were the expected ones. The twenty-two baseline entries that hid the problem, all of the form "Class Jose\Component\Signature\Algorithm\HS1 not found", are dropped.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Target branch: 4.1.x
Includes:
Since the folder rename (#510), the experimental algorithms live under
Jose\Experimental\{Signature,KeyEncryption,ContentEncryption}, but the bundle was left behind: the three configuration files still imported them fromJose\Component.That alone would have been noisy, but
SignatureSourceandEncryptionSourcedecide whether to load those files with aclass_exists()check against the very same stale names:The check always returned
false, so the files were never loaded and the failure stayed silent. No experimental algorithm was reachable through the bundle at all:RS1,HS1,HS256/64,ES256K,BLAKE2B,A128CTR,A192CTR,A256CTR,RSA-OAEP-384,RSA-OAEP-512, the eightA*CCM-*andchacha20-poly1305.A second defect
Loading them uncovered a copy-paste error:
A256CCM_64_128andA256CCM_64_64returned the name of their16counterparts.AlgorithmManageris keyed byname(), not by the DI alias, so these two replacedA256CCM-16-128andA256CCM-16-64in the manager and were themselves unreachable. A JWE built with them would also have carried the wrongencheader value. Only the names were wrong: IV size and tag length were already the expected ones in both classes.Note on the baseline
Here too PHPStan had reported it, and twenty-two entries had been baselined:
This PR drops all twenty-two.
Tests
tests/Bundle/JoseFramework/Functional/ExperimentalAlgorithmsTest.phpasserts that every experimental alias is registered in theAlgorithmManagerFactoryand resolvable, and that eachA*CCM-*class reports its own name. Fifteen of its twenty-two tests fail without this fix.PHPStan reports the same 30 errors as
4.1.xdoes today, Deptrac is clean, and the test suite fails on exactly the same tests as before.Worth knowing when reviewing: the test kernel container is cached in
var/cache/test. After touching anything undersrc/Bundle/Resources/config/,rm -rf var/cacheis needed or the bundle tests keep asserting against the old container.