Skip to content

Conversation

@vitormattos
Copy link
Contributor

At my environment, when the saltLength already is an integer value, throw an error because integer isn't object.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@terrafrost
Copy link
Member

Looking at RSASSA_PSS_params.php it looks like this is chiefly an issue if saltLength isn't explicitly defined.

A unit test for this would be good.

I should be able to generate a key that reproduces the problem but to save time could you provide the key you're using?

This is probably an issue in the 3.0 branch as well. I want to say that the 2.0 branch doesn't support PSS keys but I could be wrong. But, also, a unit test would enable us to see if it's even still an issue after #2105 is merged.

Thanks!

@vitormattos
Copy link
Contributor Author

I ran some tests on my side and found that the issue was not related to phpseclib itself. I was using the Scoper package, and it applied changes beyond just namespace rewriting. When I tested the same scenario with the same certificate without Scoper, everything worked correctly.

@terrafrost
Copy link
Member

I was able to create a key that manifests the problem in phpseclib v3:

-----BEGIN PRIVATE KEY-----
MIIE6AIBADA4BgkqhkiG9w0BAQowK6ANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3
DQEBCDALBglghkgBZQMEAgMEggSnMIIEowIBAAKCAQEA+i92dl1Dx+70VNV5eWi6
Vtox/7oajorUVdv9UABEJOlWrCNk4yXnz+kpi/rXu9YBOD1UzKZtC6JbkSM70GIH
i8AxVMy7J9q/x95SpUvytCi/PdGjT0jbh8ClWELAXdjrkkEGdOMTNRNFTcRC3FuF
XOtxU8hs0eKJENjBh0H8T/xaDTX2iMY8m+5cvX3hjUd6SEXC9ghDH8mZKqxBN0sT
aBkxzE2yITBnIVk619VflcpEoMvfipg9AA/EsD95xR9wTS3qCw4ZFNi+i6fV2Io8
d0QLz3mEZTAMjqcpUcVzOWdaAZs2gpQ1RPJrSZDD6WbIRm1cMW866YfFQBQX9xc2
BQIDAQABAoIBADLtyIKt16dyiEBguHqzjAM0Jat2GgPcVP8pajaH51dQPLmL9vSa
eccEItYA+Tueg98L9SA33MjagyNXdcykt/6F4ETv7EVfrVylcFN/02dDSDLwYvs3
zKCk4cPGytwP1VyPah4PP5C1XI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U++SxNcox
-----END PRIVATE KEY-----

It's not an issue in the master branch of phpseclib, presumably because every time you try to access an element, if an encoding doesn't exist, it'll encode / decode it so that an encoding does exist.

@terrafrost terrafrost reopened this Nov 21, 2025
@terrafrost
Copy link
Member

I cherry-picked this commit to the 3.0 branch and added a unit test.

It's not an issue in the 1.0 / 2.0 branch because those branches don't decode the parameters of PSS keys.

@terrafrost terrafrost closed this Nov 21, 2025
terrafrost referenced this pull request Nov 21, 2025
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
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