Skip to content

Commit aa5a4df

Browse files
committed
Add support for TLS curves in TLSProfile
Signed-off-by: Davide Salerno <dsalerno@redhat.com> # Conflicts: # config/v1/zz_generated.swagger_doc_generated.go
1 parent a0ffeb3 commit aa5a4df

28 files changed

Lines changed: 20839 additions & 2 deletions

File tree

config/v1/types_tlssecurityprofile.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,31 @@ const (
157157
TLSProfileCustomType TLSProfileType = "Custom"
158158
)
159159

160+
// TLSCurve is a named curve identifier that can be used in TLSProfile.Curves.
161+
// There is a one-to-one mapping between these names and the curve IDs defined
162+
// in crypto/tls package based on IANA's "TLS Supported Groups" registry:
163+
// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8
164+
//
165+
// +kubebuilder:validation:Enum=X25519;P-256;P-384;P-521;X25519MLKEM768
166+
type TLSCurve string
167+
168+
const (
169+
// TLSCurveX25519 represents X25519.
170+
TLSCurveX25519 TLSCurve = "X25519"
171+
// TLSCurveP256 represents P-256 (secp256r1).
172+
TLSCurveP256 TLSCurve = "P-256"
173+
// TLSCurveP384 represents P-384 (secp384r1).
174+
TLSCurveP384 TLSCurve = "P-384"
175+
// TLSCurveP521 represents P-521 (secp521r1).
176+
TLSCurveP521 TLSCurve = "P-521"
177+
// TLSCurveX25519MLKEM768 represents X25519MLKEM768.
178+
TLSCurveX25519MLKEM768 TLSCurve = "X25519MLKEM768"
179+
// TLSCurveP256r1MLKEM1024 represents P256r1MLKEM1024 (secp256r1MLKEM1024).
180+
TLSCurveP256r1MLKEM768 TLSCurve = "P256r1MLKEM768"
181+
// TLSCurveP384r1MLKEM1024 represents P384r1MLKEM1024 (secp384r1MLKEM1024).
182+
TLSCurveP384r1MLKEM1024 TLSCurve = "P384r1MLKEM1024"
183+
)
184+
160185
// TLSProfileSpec is the desired behavior of a TLSSecurityProfile.
161186
type TLSProfileSpec struct {
162187
// ciphers is used to specify the cipher algorithms that are negotiated
@@ -168,6 +193,38 @@ type TLSProfileSpec struct {
168193
//
169194
// +listType=atomic
170195
Ciphers []string `json:"ciphers"`
196+
// curves is used to specify the elliptic curves that are used during
197+
// the TLS handshake. Operators may remove entries their operands do
198+
// not support.
199+
//
200+
// TLSProfiles Old, Intermediate, Modern are including by default the following
201+
// curves: X25519, P-256, P-384, P-521, X25519MLKEM768, SecP256r1MLKEM1024, SecP384r1MLKEM1024.
202+
// TLSProfiles Custom do not include any curves by default.
203+
// NOTE: since this field is optional, if no curves are specified, the default curves
204+
// used by the underlying TLS library will be used.
205+
//
206+
// For example, to use X25519 and P-256 (yaml):
207+
//
208+
// # Example: Force PQC-only encryption
209+
// apiVersion: config.openshift.io/v1
210+
// kind: APIServer
211+
// spec:
212+
// tlsSecurityProfile:
213+
// type: Custom
214+
// custom:
215+
// ciphers:
216+
// - TLS_AES_128_GCM_SHA256
217+
// - TLS_AES_256_GCM_SHA384
218+
// - TLS_CHACHA20_POLY1305_SHA256
219+
// curves:
220+
// - X25519MLKEM768 # PQC-only: only hybrid quantum-resistant curve
221+
// minTLSVersion: VersionTLS13
222+
//
223+
// +optional
224+
// +listType=set
225+
// +kubebuilder:validation:MaxItems=5
226+
// +openshift:enable:FeatureGate=TLSCurvesConfiguration
227+
Curves []TLSCurve `json:"curves,omitempty"`
171228
// minTLSVersion is used to specify the minimal version of the TLS protocol
172229
// that is negotiated during the TLS handshake. For example, to use TLS
173230
// versions 1.1, 1.2 and 1.3 (yaml):
@@ -241,6 +298,12 @@ var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
241298
"AES256-SHA",
242299
"DES-CBC3-SHA",
243300
},
301+
Curves: []TLSCurve{
302+
TLSCurveX25519,
303+
TLSCurveP256,
304+
TLSCurveP384,
305+
TLSCurveX25519MLKEM768,
306+
},
244307
MinTLSVersion: VersionTLS10,
245308
},
246309
TLSProfileIntermediateType: {
@@ -257,6 +320,12 @@ var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
257320
"DHE-RSA-AES128-GCM-SHA256",
258321
"DHE-RSA-AES256-GCM-SHA384",
259322
},
323+
Curves: []TLSCurve{
324+
TLSCurveX25519,
325+
TLSCurveP256,
326+
TLSCurveP384,
327+
TLSCurveX25519MLKEM768,
328+
},
260329
MinTLSVersion: VersionTLS12,
261330
},
262331
TLSProfileModernType: {
@@ -265,6 +334,12 @@ var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
265334
"TLS_AES_256_GCM_SHA384",
266335
"TLS_CHACHA20_POLY1305_SHA256",
267336
},
337+
Curves: []TLSCurve{
338+
TLSCurveX25519,
339+
TLSCurveP256,
340+
TLSCurveP384,
341+
TLSCurveX25519MLKEM768,
342+
},
268343
MinTLSVersion: VersionTLS13,
269344
},
270345
}

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_apiservers-CustomNoUpgrade.crd.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,39 @@ spec:
325325
type: string
326326
type: array
327327
x-kubernetes-list-type: atomic
328+
curves:
329+
description: "curves is used to specify the elliptic curves
330+
that are used during\nthe TLS handshake. Operators may
331+
remove entries their operands do\nnot support.\n\nTLSProfiles
332+
Old, Intermediate, Modern are including by default the following\ncurves:
333+
X25519, P-256, P-384, P-521, X25519MLKEM768, SecP256r1MLKEM1024,
334+
SecP384r1MLKEM1024.\nTLSProfiles Custom do not include any
335+
curves by default.\nNOTE: since this field is optional,
336+
if no curves are specified, the default curves\nused by
337+
the underlying TLS library will be used.\n\nFor example,
338+
to use X25519 and P-256 (yaml):\n\n# Example: Force PQC-only
339+
encryption\napiVersion: config.openshift.io/v1\nkind: APIServer\nspec:\n
340+
\ tlsSecurityProfile:\n type: Custom\n custom:\n ciphers:\n\t
341+
\ - TLS_AES_128_GCM_SHA256\n - TLS_AES_256_GCM_SHA384\n
342+
\ - TLS_CHACHA20_POLY1305_SHA256\n curves:\n
343+
\ - X25519MLKEM768 # PQC-only: only hybrid quantum-resistant
344+
curve\n minTLSVersion: VersionTLS13"
345+
items:
346+
description: |-
347+
TLSCurve is a named curve identifier that can be used in TLSProfile.Curves.
348+
There is a one-to-one mapping between these names and the curve IDs defined
349+
in crypto/tls package based on IANA's "TLS Supported Groups" registry:
350+
https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8
351+
enum:
352+
- X25519
353+
- P-256
354+
- P-384
355+
- P-521
356+
- X25519MLKEM768
357+
type: string
358+
maxItems: 5
359+
type: array
360+
x-kubernetes-list-type: set
328361
minTLSVersion:
329362
description: |-
330363
minTLSVersion is used to specify the minimal version of the TLS protocol

config/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/v1/zz_generated.featuregated-crd-manifests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ apiservers.config.openshift.io:
77
Category: ""
88
FeatureGates:
99
- KMSEncryptionProvider
10+
- TLSCurvesConfiguration
1011
FilenameOperatorName: config-operator
1112
FilenameOperatorOrdering: "01"
1213
FilenameRunLevel: "0000_10"

0 commit comments

Comments
 (0)