Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): Use (legacy) deterministic ECDSA key generation #38

Closed
wants to merge 3 commits into from

Conversation

thomas-fossati
Copy link
Contributor

Fix #37

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

See my comment!

In general as a fix LGTM!

@@ -19,7 +20,7 @@ func TestAppraisalExtensions_SetGetKeyAttestation_ok(t *testing.T) {
},
}

kp, err := ecdsa.GenerateKey(elliptic.P256(), new(zeroSource))
kp, err := keygen.ECDSALegacy(elliptic.P256(), new(zeroSource))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not against the fix as such:

However, is it really needed ? Should we not seek feedback on the issue with ECDSA Library maintainers! Then we should not rely on third party library as a workaround?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to make the case for reverting a change in the Go standard library I am certainly not stopping you :-D

From a personal/pragmatic point of view, I am content with this minimal-impact fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, raised an issue:
golang/go#69248

Please review, if you want to add anything on it!

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande Sep 4, 2024

Choose a reason for hiding this comment

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

Also if the new change is by design should we not use a Non-Zero Reader in our code to avoid crash, instead of fundamentally by-pass the core golang module ??

We will soon become stale using the library, which we are un-aware of?

I mean filippo.io/keygen here:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test needs to construct a key deterministically.

Copy link
Contributor

Choose a reason for hiding this comment

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

The test needs to construct a key deterministically.

yes, what I meant was we can supply a constant deterministic byte array to the input rather than always zero

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will soon become stale using the library, which we are un-aware of?

I mean filippo.io/keygen here:

No, filippo.io/keygen is forever stable - that's the promise.

Instead, if we use GenerateKey(), golang makes no promises about the stability of the output. From the ecdsa package documentation:

"Note that the returned key does not depend deterministically on the bytes read from rand, and may change between calls and/or between versions."

Copy link
Contributor

@yogeshbdeshpande yogeshbdeshpande left a comment

Choose a reason for hiding this comment

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

LGTM!

@thomas-fossati
Copy link
Contributor Author

As discussed f2f, the simpler and most effective change is to hardcode a valid ECDSA key in the test.

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.

BUG: SetGetKeyAttestation test is stuck
2 participants