Skip to content

Commit 2ed6523

Browse files
committed
Add support for TLS curves in TLSProfile
Signed-off-by: Davide Salerno <dsalerno@redhat.com>
1 parent d4b2fef commit 2ed6523

File tree

28 files changed

+20840
-3
lines changed

28 files changed

+20840
-3
lines changed

config/v1/types_tlssecurityprofile.go

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,31 @@ const (
202202
TLSProfileCustomType TLSProfileType = "Custom"
203203
)
204204

205+
// TLSCurve is a named curve identifier that can be used in TLSProfile.Curves.
206+
// There is a one-to-one mapping between these names and the curve IDs defined
207+
// in crypto/tls package based on IANA's "TLS Supported Groups" registry:
208+
// https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8
209+
//
210+
// +kubebuilder:validation:Enum=X25519;P-256;P-384;P-521;X25519MLKEM768
211+
type TLSCurve string
212+
213+
const (
214+
// TLSCurveX25519 represents X25519.
215+
TLSCurveX25519 TLSCurve = "X25519"
216+
// TLSCurveP256 represents P-256 (secp256r1).
217+
TLSCurveP256 TLSCurve = "P-256"
218+
// TLSCurveP384 represents P-384 (secp384r1).
219+
TLSCurveP384 TLSCurve = "P-384"
220+
// TLSCurveP521 represents P-521 (secp521r1).
221+
TLSCurveP521 TLSCurve = "P-521"
222+
// TLSCurveX25519MLKEM768 represents X25519MLKEM768.
223+
TLSCurveX25519MLKEM768 TLSCurve = "X25519MLKEM768"
224+
// TLSCurveP256r1MLKEM1024 represents P256r1MLKEM1024 (secp256r1MLKEM1024).
225+
TLSCurveP256r1MLKEM768 TLSCurve = "P256r1MLKEM768"
226+
// TLSCurveP384r1MLKEM1024 represents P384r1MLKEM1024 (secp384r1MLKEM1024).
227+
TLSCurveP384r1MLKEM1024 TLSCurve = "P384r1MLKEM1024"
228+
)
229+
205230
// TLSProfileSpec is the desired behavior of a TLSSecurityProfile.
206231
type TLSProfileSpec struct {
207232
// ciphers is used to specify the cipher algorithms that are negotiated
@@ -213,6 +238,38 @@ type TLSProfileSpec struct {
213238
//
214239
// +listType=atomic
215240
Ciphers []string `json:"ciphers"`
241+
// curves is used to specify the elliptic curves that are used during
242+
// the TLS handshake. Operators may remove entries their operands do
243+
// not support.
244+
//
245+
// TLSProfiles Old, Intermediate, Modern are including by default the following
246+
// curves: X25519, P-256, P-384, P-521, X25519MLKEM768, SecP256r1MLKEM1024, SecP384r1MLKEM1024.
247+
// TLSProfiles Custom do not include any curves by default.
248+
// NOTE: since this field is optional, if no curves are specified, the default curves
249+
// used by the underlying TLS library will be used.
250+
//
251+
// For example, to use X25519 and P-256 (yaml):
252+
//
253+
// # Example: Force PQC-only encryption
254+
// apiVersion: config.openshift.io/v1
255+
// kind: APIServer
256+
// spec:
257+
// tlsSecurityProfile:
258+
// type: Custom
259+
// custom:
260+
// ciphers:
261+
// - TLS_AES_128_GCM_SHA256
262+
// - TLS_AES_256_GCM_SHA384
263+
// - TLS_CHACHA20_POLY1305_SHA256
264+
// curves:
265+
// - X25519MLKEM768 # PQC-only: only hybrid quantum-resistant curve
266+
// minTLSVersion: VersionTLS13
267+
//
268+
// +optional
269+
// +listType=set
270+
// +kubebuilder:validation:MaxItems=5
271+
// +openshift:enable:FeatureGate=TLSCurvesConfiguration
272+
Curves []TLSCurve `json:"curves,omitempty"`
216273
// minTLSVersion is used to specify the minimal version of the TLS protocol
217274
// that is negotiated during the TLS handshake. For example, to use TLS
218275
// versions 1.1, 1.2 and 1.3 (yaml):
@@ -283,6 +340,12 @@ var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
283340
"AES256-SHA",
284341
"DES-CBC3-SHA",
285342
},
343+
Curves: []TLSCurve{
344+
TLSCurveX25519,
345+
TLSCurveP256,
346+
TLSCurveP384,
347+
TLSCurveX25519MLKEM768,
348+
},
286349
MinTLSVersion: VersionTLS10,
287350
},
288351
TLSProfileIntermediateType: {
@@ -299,6 +362,12 @@ var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
299362
"DHE-RSA-AES128-GCM-SHA256",
300363
"DHE-RSA-AES256-GCM-SHA384",
301364
},
365+
Curves: []TLSCurve{
366+
TLSCurveX25519,
367+
TLSCurveP256,
368+
TLSCurveP384,
369+
TLSCurveX25519MLKEM768,
370+
},
302371
MinTLSVersion: VersionTLS12,
303372
},
304373
TLSProfileModernType: {
@@ -307,6 +376,12 @@ var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
307376
"TLS_AES_256_GCM_SHA384",
308377
"TLS_CHACHA20_POLY1305_SHA256",
309378
},
379+
Curves: []TLSCurve{
380+
TLSCurveX25519,
381+
TLSCurveP256,
382+
TLSCurveP384,
383+
TLSCurveX25519MLKEM768,
384+
},
310385
MinTLSVersion: VersionTLS13,
311386
},
312387
}

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