Skip to content

Conversation

@shengjiang3
Copy link

GDC (Google Distributed Cloud) needs to support ECDSA-P384 keys for compliance. This change creates an EsSigner and EsVerifier class that is capable of supporting both ECDSA-P256 and ECDSA-P384 keys for backwards compatibility. The EsSigner and EsVerifier classes are plumbed through to the GDC service accounts and are used to both sign and verify JWTs.

This implementation was successfully tested against a GDC instance using both ECDSA-P256 and ECDSA-P384 keys.

GDC (Google Distributed Cloud) needs to support ECDSA-P384 keys for
compliance. This change creates an EsSigner and EsVerifier class that is
capable of supporting both ECDSA-P256 and ECDSA-P384 keys for backwards
compatibility. The EsSigner and EsVerifier classes are plumbed through
to the GDC service accounts and are used to both sign and verify JWTs.

This implementation was successfully tested against a GDC instance using
both ECDSA-P256 and ECDSA-P384 keys.
@shengjiang3 shengjiang3 requested review from a team as code owners November 11, 2025 07:05
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 11, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 11, 2025
ES256Verifier = es256.ES256Verifier
if es is not None: # pragma: NO COVER
ES256Signer = es.EsSigner
ES256Verifier = es.EsVerifier
Copy link
Contributor

@daniel-sanche daniel-sanche Nov 11, 2025

Choose a reason for hiding this comment

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

We have ES256Verifier/ES256Signer as separate classes in the the es256 module, but the import file is shadowing them with a EsSigner/EsVerifier aliases

I understand they are both set up as aliases, so this is essentially equivalent for now. But I could see it getting very confusing in the future, if we try to make changes to the classes

Copy link
Author

Choose a reason for hiding this comment

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

I kept these as aliases in case there are users that import ES256Signer/ES256Verifier to not break them. What is the deprecation policy for this library?

I agree that it is confusing though. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we need to keep them around to avoid breaking existing code. Can we replace these with imports from the es256.py file, so we are defining the alias in one place?

try:
from google.auth.crypt import es256
from google.auth.crypt import es
except ImportError: # pragma: NO COVER
Copy link
Contributor

@daniel-sanche daniel-sanche Nov 11, 2025

Choose a reason for hiding this comment

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

  • In what case would the import fail (I assume importing cryptography?)? That should probably be documented as a comment
  • this is marked as NO COVER. But it seems like we should have some coverage for this scenerio. Thoughts?

Copy link
Author

Choose a reason for hiding this comment

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

Added a comment.

I tried to add a unit test to test this, but found that it is not trivial to simulate an import error. The logic here is straight forward enough that it might be ok not to have code coverage for this part. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, you can unimport a package using something like del cryptography. That should let you define a test method that doesn't have cryptography active. Did you try doing something like that?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I tried using monkey patch to remove the library and then to reload imports but it wasn't working. I think spending additional time to figure out how to simulate an import error just to check that the ES* types are not defined has low ROI.

@@ -0,0 +1,208 @@
# Copyright 2017 Google Inc.
Copy link
Contributor

@daniel-sanche daniel-sanche Nov 11, 2025

Choose a reason for hiding this comment

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

Note to self (and other reviewers): most of this file is copied over from es256.py, so I only focused on diff for this review

Sheng Jiang added 2 commits November 18, 2025 18:21
- Changed ESAttributes to _ESAttributes.
- Merged from_private_key and from_public_key to from_key.
daniel-sanche
daniel-sanche previously approved these changes Nov 19, 2025
Copy link
Contributor

@daniel-sanche daniel-sanche left a comment

Choose a reason for hiding this comment

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

LGTM

Linchin
Linchin previously approved these changes Nov 19, 2025
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@daniel-sanche daniel-sanche enabled auto-merge (squash) November 20, 2025 18:34
auto-merge was automatically disabled November 20, 2025 19:07

Head branch was pushed to by a user without write access

@shengjiang3 shengjiang3 dismissed stale reviews from Linchin and daniel-sanche via 1090a46 November 20, 2025 19:07
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 20, 2025
@daniel-sanche daniel-sanche added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 21, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 21, 2025
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.

4 participants