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

Add check for matching group in CertificateSelection #218

Open
tatianab opened this issue Jun 12, 2020 · 0 comments
Open

Add check for matching group in CertificateSelection #218

tatianab opened this issue Jun 12, 2020 · 0 comments

Comments

@tatianab
Copy link

Currently, the CertificateSelection function calls the schemeValidForKey function, which checks if the signature type (RSA_PKCS1, RSA_PSS, or ECDSA) is correct for the given key, but does not check if the underlying group is correct for the signature algorithm in the ECDSA case. This causes the function to sometimes output a signature algorithm incompatible with the chosen certificate.

I propose to add the following check inside schemeValidForKey:

func schemeValidForKey(alg SignatureScheme, key crypto.Signer) bool {
        ...
	case *ecdsa.PrivateKey:
		// proposed check
		if curveFromNamedGroup(curveMap[alg]) != key.Public().(*ecdsa.PublicKey).Curve {
			return false
		}
       ...

If you agree, I will submit a PR with this change.

@chris-wood

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

No branches or pull requests

1 participant