Skip to content

Conversation

@fabiendupont
Copy link

Extends the crypto package to generate ECDSA P-256 key pairs in addition to existing RSA support, enabling OpenShift components to use modern elliptic curve cryptography.

Adds:

  • KeyAlgorithm type for algorithm selection (RSA, ECDSA)
  • newECDSAKeyPair() and newECDSAKeyPairWithHash() functions using P-256 curve
  • newKeyPairWithAlgorithm() for unified key generation
  • signatureAlgorithmForKey() for automatic algorithm detection
  • CA.MakeServerCertWithAlgorithm() and CA.MakeServerCertForDurationWithAlgorithm()

All existing APIs remain unchanged, preserving 100% backwards compatibility. New functionality is opt-in through *WithAlgorithm functions.

ECDSA P-256 provides equivalent security to 3072-bit RSA with smaller keys (~87% smaller), faster operations, and better performance. This prepares OpenShift for modern TLS deployments and aligns with industry best practices.

Test coverage includes:

  • Unit tests for key generation, signature algorithm detection, and encoding
  • Integration tests for RSA CA + ECDSA server and vice versa
  • Backwards compatibility tests verifying existing RSA functionality

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 4, 2026
@openshift-ci-robot
Copy link

@fabiendupont: This pull request explicitly references no jira issue.

Details

In response to this:

Extends the crypto package to generate ECDSA P-256 key pairs in addition to existing RSA support, enabling OpenShift components to use modern elliptic curve cryptography.

Adds:

  • KeyAlgorithm type for algorithm selection (RSA, ECDSA)
  • newECDSAKeyPair() and newECDSAKeyPairWithHash() functions using P-256 curve
  • newKeyPairWithAlgorithm() for unified key generation
  • signatureAlgorithmForKey() for automatic algorithm detection
  • CA.MakeServerCertWithAlgorithm() and CA.MakeServerCertForDurationWithAlgorithm()

All existing APIs remain unchanged, preserving 100% backwards compatibility. New functionality is opt-in through *WithAlgorithm functions.

ECDSA P-256 provides equivalent security to 3072-bit RSA with smaller keys (~87% smaller), faster operations, and better performance. This prepares OpenShift for modern TLS deployments and aligns with industry best practices.

Test coverage includes:

  • Unit tests for key generation, signature algorithm detection, and encoding
  • Integration tests for RSA CA + ECDSA server and vice versa
  • Backwards compatibility tests verifying existing RSA functionality

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from deads2k and p0lyn0mial February 4, 2026 17:26
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 4, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fabiendupont
Once this PR has been reviewed and has the lgtm label, please assign p0lyn0mial for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

fabiendupont added a commit to fabiendupont/openshift-service-ca-operator that referenced this pull request Feb 4, 2026
Adds support for generating ECDSA P-256 certificates by specifying the
key algorithm via the new service annotation:
  service.beta.openshift.io/serving-cert-key-algorithm: ecdsa

When the annotation is not specified or set to "rsa", the operator
generates RSA certificates for full backwards compatibility.

This enables services to opt into modern elliptic curve cryptography,
which provides equivalent security to 3072-bit RSA with significantly
smaller keys (~87% smaller) and better performance.

Implementation:
- Added ServingCertKeyAlgorithmAnnotation constant in api.go
- Modified MakeServingCert() to check annotation and select algorithm
- Uses library-go's new MakeServerCertWithAlgorithm() API
- Validates annotation values (rsa, ecdsa) with helpful error messages
- Case-insensitive algorithm matching

Testing:
- Added TestECDSACertificateGeneration with 5 test cases
- Verifies RSA (default and explicit), ECDSA, and invalid inputs
- All existing tests pass with no regressions

Depends on: openshift/library-go#2116

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Fabien Dupont <fdupont@redhat.com>
}

// MakeServerCertWithAlgorithm creates a server certificate with the specified key algorithm
func (ca *CA) MakeServerCertWithAlgorithm(hostnames sets.Set[string], lifetime time.Duration, algorithm KeyAlgorithm, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I might be wrong, but it looks like MakeServerCert and MakeServerCertWithAlgorithm are very similar. There are two differences. The first is the key algorithm, and the second is that MakeServerCertWithAlgorithm sets the signature algorithm.

I’m wondering if it would make sense to create a private common function for both. I think something like the following could work:

func (ca *CA) MakeServerCertWithAlgorithm(hostnames sets.Set[string], lifetime time.Duration, algorithm KeyAlgorithm, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error) {
	sigFn := func(template *x509.Certificate) error {
		template.SignatureAlgorithm = signatureAlgorithmForKey(ca.Config.Key)
		return nil
	}
	fns = append([]CertificateExtensionFunc{sigFn}, fns...)
	return ca.makeServerCertWithAlgorithm(hostnames, lifetime, algorithm, fns...)
}

and

func (ca *CA) MakeServerCert(hostnames sets.Set[string], lifetime time.Duration, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error) {
	return ca.makeServerCertWithAlgorithm(hostnames, lifetime, AlgorithmRSA, fns...)
}

case AlgorithmRSA:
return newKeyPairWithHash()
default:
return newKeyPairWithHash() // Default to RSA for backwards compatibility
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a private method I think we could return an error for unsupported algorithms.

}

// MakeServerCertForDurationWithAlgorithm creates a server certificate with specified duration and algorithm
func (ca *CA) MakeServerCertForDurationWithAlgorithm(hostnames sets.Set[string], lifetime time.Duration, algorithm KeyAlgorithm, fns ...CertificateExtensionFunc) (*TLSCertificateConfig, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

am I right that the differences between MakeServerCertForDuration and MakeServerCertForDurationWithAlgorithm mirror those between MakeServerCert and MakeServerCertWithAlgorithm (key algorithm and signature algorithm)? If so, could we refactor them in the same way?

Copy link
Author

Choose a reason for hiding this comment

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

Good feedback. Makes sense.

Extends the crypto package to generate ECDSA P-256 key pairs in addition
to existing RSA support, enabling OpenShift components to use modern
elliptic curve cryptography.

Adds:
- KeyAlgorithm type for algorithm selection (RSA, ECDSA)
- newECDSAKeyPair() and newECDSAKeyPairWithHash() functions using P-256 curve
- newKeyPairWithAlgorithm() for unified key generation
- signatureAlgorithmForKey() for automatic algorithm detection
- CA.MakeServerCertWithAlgorithm() and CA.MakeServerCertForDurationWithAlgorithm()

All existing APIs remain unchanged, preserving 100% backwards compatibility.
New functionality is opt-in through *WithAlgorithm functions.

ECDSA P-256 provides equivalent security to 3072-bit RSA with smaller keys
(~87% smaller), faster operations, and better performance. This prepares
OpenShift for modern TLS deployments and aligns with industry best practices.

Test coverage includes:
- Unit tests for key generation, signature algorithm detection, and encoding
- Integration tests for RSA CA + ECDSA server and vice versa
- Backwards compatibility tests verifying existing RSA functionality

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Fabien Dupont <fdupont@redhat.com>
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 11, 2026

@fabiendupont: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants