FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

JCL-385: Improve PKCE verifier to always produce spec conforming values by acoburn · Pull Request #517 · inrupt/solid-client-java · GitHub

Repository navigation

JCL-385: Improve PKCE verifier to always produce spec conforming values - #517

Merged
acoburn merged 1 commit into
mainfrom
JCL-385-pkce-verifier-length
Jun 9, 2023
Merged

acoburn merged 1 commit into
mainfrom
JCL-385-pkce-verifier-length

Conversation

acoburn commented Jun 8, 2023

Copy link
Copy Markdown
Contributor

Occasionally the CI/CD workflows will fail because the PKCE verifier is less than 43 characters (required by the spec). This can happen if the random number selected is too low, resulting in an encoded byte array that has too few characters.

This is fixed here by ensuring a minimum value for the BigInteger.

Effectively it changes the range from [0 - 2^256) to [2^256 - 2^257) so the generated byte array is always sufficiently long.

Imagine that the random number generator selects the number 250 -- this will be packed into a single octet and the entropy of the validator will be too low. This way, there will always be at least 32 octets.

acoburn requested a review from a team June 8, 2023 18:38
acoburn force-pushed the JCL-385-pkce-verifier-length branch from a86257e to 2f301e0 Compare June 8, 2023 18:46
Comment on lines -36 to +32
assertTrue(PKCE.createChallenge("", "SHA-256").getBytes(UTF_8).length <= 128);
assertTrue(PKCE.createChallenge("🐶🐶🐶", "SHA-256").length() >= 43);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For my own understanding, was the .getBytes(UTF_8) useful in the first place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No, the getBytes test was unnecessary. The spec requires checking the character length of the resulting string, not the size of the byte array. Admittedly, for ASCII strings, the two will be equivalent, but it is unnecessary

acoburn merged commit 7226e75 into main Jun 9, 2023
acoburn deleted the JCL-385-pkce-verifier-length branch June 9, 2023 10:36
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL