Skip to content

Using SHA256 and PSS padding#722

Merged
rayluo merged 1 commit intodevfrom
sha256
Jul 16, 2024
Merged

Using SHA256 and PSS padding#722
rayluo merged 1 commit intodevfrom
sha256

Conversation

@rayluo
Copy link
Contributor

@rayluo rayluo commented Jul 16, 2024

No new API is added in this PR. The SHA256 behavior will automatically kick in when using the recent .pfx support AND when the authority is not ADFS.

Manually tested and saw the x5t#S256 and the "alg": "PS256" visible in the header. All the existing E2E test cases are now using this new SHA256 behavior, and they still pass.

Also manually tested the SHA1 code path and it still works. (Did not add it as automated test case because currently there is no public API to control the opt-in and opt-out.)

@rayluo rayluo marked this pull request as ready for review July 16, 2024 09:27
@rayluo rayluo requested a review from a team as a code owner July 16, 2024 09:27
x5c = [
'\n'.join(cert_pem.splitlines()[1:-1]) # Strip the "--- header ---" and "--- footer ---"
]
sha256_thumbprint = cert.fingerprint(hashes.SHA256()).hex() # cryptography 0.7+
Copy link

@Robbie-Microsoft Robbie-Microsoft Jul 16, 2024

Choose a reason for hiding this comment

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

Can you add the below checks to this function so that you're only returning one thumbprint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean a test case? We do not currently have such a test case, but its utilization is in this part of the PR. You can see that we pass in only one of the thumbprints, not both.

}
else: # Fall back
if not sha1_thumbprint:
raise ValueError("You shall provide a thumbprint in SHA1.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the SHA thumbprints something that the developer is meant to provide, and would they see this error message if something went wrong? If so, you may want something more informative like "A SHA1 thumbprint is needed for ADFS" or similar to let them know which SHA version is needed for each flow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When an app developer encounters this error message, he or she is already in the ADFS code path, so the "you shall provide a thumbprint in SHA1" is good enough as an actionable item.

I incline to avoid mentioning too-specific info such as "ADFS" in this case, because that kind of wording tends to become outdated when/if we will add or remove some scenarios into this SHA1 group.

@rayluo rayluo merged commit 57dce47 into dev Jul 16, 2024
@rayluo rayluo deleted the sha256 branch July 16, 2024 19:48
@rayluo rayluo mentioned this pull request Jul 17, 2024
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.

[Feature Request] AAD client assertions should be computed using SHA 256 and an approved padding scheme

4 participants