boring-sys 5.2.0

FFI bindings to BoringSSL
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
From fc01a66ac146778c4e6651d6fc6d62c7e12bfb32 Mon Sep 17 00:00:00 2001
From: Christopher Patton <cpatton@cloudflare.com>
Date: Wed, 27 May 2026 09:55:52 -0700
Subject: [PATCH] Add additional post-quantum key agreement

This patch adds:

1. Enable X25519MLKEM768 by default.

2. Supports for P256Kyber768Draft00 under 0xfe32, which we temporarily
   need for compliance reasons.  (Note that this is not the codepoint
   allocated for that exchange in the IANA table.)
   Enables by default and in FIPS mode.

3. Add SSL(_CTX)_use_second_keyshare.  By default BoringSSL will send a
   non post-quantum and a post-quantum keyshare if available.  These
   functions allow one to change the behaviour to only send a single
   keyshare.
---
 crypto/obj/obj_dat.h                |   6 +-
 crypto/obj/obj_mac.num              |   1 +
 crypto/obj/objects.txt              |   1 +
 include/openssl/nid.h               |   3 +
 include/openssl/ssl.h               |  15 ++++
 ssl/extensions.cc                   |  26 ++++---
 ssl/internal.h                      |  12 ++-
 ssl/ssl_key_share.cc                | 111 +++++++++++++++++++++++++++-
 ssl/ssl_lib.cc                      |  16 +++-
 ssl/ssl_test.cc                     |  24 +++++-
 ssl/test/runner/basic_tests.go      |   2 +
 ssl/test/runner/cbc_tests.go        |   3 +
 ssl/test/runner/common.go           |   2 +-
 ssl/test/runner/curve_tests.go      |  28 +++----
 ssl/test/runner/ech_tests.go        |  24 +++++-
 ssl/test/runner/extension_tests.go  |   3 +-
 ssl/test/runner/key_update_tests.go |   6 +-
 tool/client.cc                      |   9 +++
 18 files changed, 249 insertions(+), 43 deletions(-)

diff --git a/crypto/obj/obj_dat.h b/crypto/obj/obj_dat.h
index feb8f2d1e..7ca28d9f5 100644
--- a/crypto/obj/obj_dat.h
+++ b/crypto/obj/obj_dat.h
@@ -16,7 +16,7 @@
 
 
 BSSL_NAMESPACE_BEGIN
-#define NUM_NID 973
+#define NUM_NID 974
 
 static const uint8_t kObjectData[] = {
     /* NID_rsadsi */
@@ -8802,6 +8802,8 @@ static const ASN1_OBJECT kObjects[NUM_NID] = {
      0},
     {NULL, NULL, NID_undef, 0, NULL, 0},
     {"X-Wing", "X-Wing", NID_X_Wing, 0, NULL, 0},
+    {"P256Kyber768Draft00", "P256Kyber768Draft00", NID_P256Kyber768Draft00, 0,
+     NULL, 0},
 };
 
 static const uint16_t kNIDsInShortNameOrder[] = {
@@ -8934,6 +8936,7 @@ static const uint16_t kNIDsInShortNameOrder[] = {
     18 /* OU */,
     749 /* Oakley-EC2N-3 */,
     750 /* Oakley-EC2N-4 */,
+    973 /* P256Kyber768Draft00 */,
     9 /* PBE-MD2-DES */,
     168 /* PBE-MD2-RC2-64 */,
     10 /* PBE-MD5-DES */,
@@ -9858,6 +9861,7 @@ static const uint16_t kNIDsInLongNameOrder[] = {
     366 /* OCSP Nonce */,
     371 /* OCSP Service Locator */,
     180 /* OCSP Signing */,
+    973 /* P256Kyber768Draft00 */,
     161 /* PBES2 */,
     69 /* PBKDF2 */,
     162 /* PBMAC1 */,
diff --git a/crypto/obj/obj_mac.num b/crypto/obj/obj_mac.num
index 7b8bd2ead..dc7b2878f 100644
--- a/crypto/obj/obj_mac.num
+++ b/crypto/obj/obj_mac.num
@@ -959,3 +959,4 @@ ML_DSA_65		968
 ML_DSA_87		969
 ML_KEM_768		970
 X_Wing		972
+P256Kyber768Draft00		973
diff --git a/crypto/obj/objects.txt b/crypto/obj/objects.txt
index 67b9ade43..384b25753 100644
--- a/crypto/obj/objects.txt
+++ b/crypto/obj/objects.txt
@@ -1340,6 +1340,7 @@ secg-scheme 14 3 : dhSinglePass-cofactorDH-sha512kdf-scheme
 
 # NIDs for post quantum hybrid KEMs in TLS (no corresponding OIDs).
  : X25519Kyber768Draft00
+ : P256Kyber768Draft00
  : X25519MLKEM768
 
 # NIDs for PQ/T hybrid KEMs (no corresponding OIDs).
diff --git a/include/openssl/nid.h b/include/openssl/nid.h
index 6b3bb4506..068fc5977 100644
--- a/include/openssl/nid.h
+++ b/include/openssl/nid.h
@@ -5511,6 +5511,9 @@ extern "C" {
 #define SN_X_Wing "X-Wing"
 #define NID_X_Wing 972
 
+#define SN_P256Kyber768Draft00 "P256Kyber768Draft00"
+#define NID_P256Kyber768Draft00 973
+
 
 #if defined(__cplusplus)
 } /* extern C */
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 055b3e025..09d6508f4 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -2586,6 +2586,7 @@ OPENSSL_EXPORT size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx);
 #define SSL_GROUP_X25519_MLKEM768 0x11ec
 #define SSL_GROUP_X25519_KYBER768_DRAFT00 0x6399
 #define SSL_GROUP_MLKEM1024 0x0202
+#define SSL_GROUP_P256_KYBER768_DRAFT00 0xfe32
 
 // SSL_CTX_set1_group_ids sets the preferred groups for |ctx| to |group_ids|.
 // Each element of |group_ids| should be a unique one of the |SSL_GROUP_*|
@@ -6241,6 +6242,20 @@ OPENSSL_EXPORT int SSL_CTX_set1_curves_list(SSL_CTX *ctx, const char *curves);
 // SSL_set1_curves_list calls |SSL_set1_groups_list|.
 OPENSSL_EXPORT int SSL_set1_curves_list(SSL *ssl, const char *curves);
 
+// By default, a client will send both a non post-quantum and a post-quantum
+// keyshare if available.
+//
+// SSL_use_second_keyshare controls this behaviour. If |enabled| is 0, then
+// a client using |ssl| will only send one keyshare.
+OPENSSL_EXPORT void SSL_use_second_keyshare(SSL *ssl, int enabled);
+
+// By default, a client will send both a non post-quantum and a post-quantum
+// keyshare if available.
+//
+// SSL_CTX_use_second_keyshare controls this behaviour. If |enabled| is 0, then
+// a client using |ctx| will only send one keyshare.
+OPENSSL_EXPORT void SSL_CTX_use_second_keyshare(SSL_CTX *ctx, int enabled);
+
 // TLSEXT_nid_unknown is a constant used in OpenSSL for
 // |SSL_get_negotiated_group| to return an unrecognized group. BoringSSL never
 // returns this value, but we define this constant for compatibility.
diff --git a/ssl/extensions.cc b/ssl/extensions.cc
index db1a29139..05c8c1e16 100644
--- a/ssl/extensions.cc
+++ b/ssl/extensions.cc
@@ -107,6 +107,7 @@ static bool tls1_check_duplicate_extensions(const CBS *cbs) {
 static bool is_post_quantum_group(uint16_t id) {
   switch (id) {
     case SSL_GROUP_X25519_KYBER768_DRAFT00:
+    case SSL_GROUP_P256_KYBER768_DRAFT00:
     case SSL_GROUP_X25519_MLKEM768:
     case SSL_GROUP_MLKEM1024:
       return true;
@@ -2418,18 +2419,21 @@ bool ssl_setup_key_shares(SSL_HANDSHAKE *hs, uint16_t override_group_id) {
     if (!default_key_shares.TryPushBack(supported_group_list[0])) {
       return false;
     }
-    // We'll try to include one post-quantum and one classical initial key
-    // share.
-    for (size_t i = 1; i < supported_group_list.size(); i++) {
-      if (is_post_quantum_group(default_key_shares[0]) ==
-          is_post_quantum_group(supported_group_list[i])) {
-        continue;
-      }
-      if (!default_key_shares.TryPushBack(supported_group_list[i])) {
-        return false;
+
+    if (!ssl->config->disable_second_keyshare) {
+      // We'll try to include one post-quantum and one classical initial key
+      // share.
+      for (size_t i = 1; i < supported_group_list.size(); i++) {
+        if (is_post_quantum_group(default_key_shares[0]) ==
+            is_post_quantum_group(supported_group_list[i])) {
+          continue;
+        }
+        if (!default_key_shares.TryPushBack(supported_group_list[i])) {
+          return false;
+        }
+        assert(default_key_shares[1] != default_key_shares[0]);
+        break;
       }
-      assert(default_key_shares[1] != default_key_shares[0]);
-      break;
     }
     selected_key_shares.emplace(default_key_shares);
   }
diff --git a/ssl/internal.h b/ssl/internal.h
index 2bea8f62d..47b688bf4 100644
--- a/ssl/internal.h
+++ b/ssl/internal.h
@@ -913,7 +913,7 @@ struct NamedGroup {
 Span<const NamedGroup> NamedGroups();
 
 // kNumNamedGroups is the number of supported groups.
-constexpr size_t kNumNamedGroups = 7u;
+constexpr size_t kNumNamedGroups = 8u;
 
 // DefaultSupportedGroupIds returns the list of IDs for the default groups that
 // are supported when the caller hasn't explicitly configured supported groups.
@@ -3531,6 +3531,11 @@ struct SSL_CONFIG {
   // permute_extensions is whether to permute extensions when sending messages.
   bool permute_extensions : 1;
 
+  // As a client by default we will send a non post-quantum share and
+  // a post-quantum share if available. If disable_second_keyshare is set,
+  // we will only send the most preferred keyshare.
+  bool disable_second_keyshare : 1;
+
   // aes_hw_override if set indicates we should override checking for aes
   // hardware support, and use the value in aes_hw_override_value instead.
   bool aes_hw_override : 1;
@@ -4172,6 +4177,11 @@ struct ssl_ctx_st : public bssl::RefCounted<ssl_ctx_st> {
   // permute_extensions is whether to permute extensions when sending messages.
   bool permute_extensions : 1;
 
+  // As a client by default we will send a non post-quantum share and
+  // a post-quantum share if available. If disable_second_keyshare is set,
+  // we will only send the most preferred keyshare.
+  bool disable_second_keyshare : 1;
+
   // allow_unknown_alpn_protos is whether the client allows unsolicited ALPN
   // protocols from the peer.
   bool allow_unknown_alpn_protos : 1;
diff --git a/ssl/ssl_key_share.cc b/ssl/ssl_key_share.cc
index d155b5527..4fb08906b 100644
--- a/ssl/ssl_key_share.cc
+++ b/ssl/ssl_key_share.cc
@@ -193,6 +193,109 @@ class X25519KeyShare : public SSLKeyShare {
   uint8_t private_key_[32];
 };
 
+class P256Kyber768Draft00KeyShare : public SSLKeyShare {
+ public:
+  P256Kyber768Draft00KeyShare()
+    : ecks_(EC_group_p256(), SSL_GROUP_SECP256R1) {}
+
+  uint16_t GroupID() const override {
+    return SSL_GROUP_P256_KYBER768_DRAFT00;
+  }
+
+  bool Generate(CBB *out) override {
+    uint8_t kyber_public_key[KYBER_PUBLIC_KEY_BYTES];
+    KYBER_generate_key(kyber_public_key, &kyber_private_key_);
+
+    if(!ecks_.Generate(out) ||
+       !CBB_add_bytes(out, kyber_public_key, sizeof(kyber_public_key))) {
+      return false;
+    }
+
+    return true;
+  }
+
+  bool Encap(CBB *out_ciphertext, Array<uint8_t> *out_secret,
+             uint8_t *out_alert, Span<const uint8_t> peer_key) override {
+    Array<uint8_t> ec_secret;
+
+    *out_alert = SSL_AD_INTERNAL_ERROR;
+
+    if(peer_key.size() != p256_share_size + KYBER_PUBLIC_KEY_BYTES) {
+      *out_alert = SSL_AD_ILLEGAL_PARAMETER;
+      OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_ECPOINT);
+      return false;
+    }
+
+    if (!ecks_.Encap(out_ciphertext, &ec_secret, out_alert,
+                    peer_key.subspan(0, p256_share_size))) {
+      return false;
+    }
+
+    KYBER_public_key peer_kyber_pub;
+    CBS peer_kyber_cbs;
+    CBS_init(&peer_kyber_cbs, peer_key.data() + p256_share_size,
+             KYBER_PUBLIC_KEY_BYTES);
+
+    if (!KYBER_parse_public_key(&peer_kyber_pub, &peer_kyber_cbs)) {
+      *out_alert = SSL_AD_ILLEGAL_PARAMETER;
+      OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_ECPOINT);
+      return false;
+    }
+
+    uint8_t kyber_ciphertext[KYBER_CIPHERTEXT_BYTES];
+    Array<uint8_t> secret;
+    if (!secret.InitForOverwrite(p256_secret_size + KYBER_SHARED_SECRET_BYTES)) {
+      return false;
+    }
+    OPENSSL_memcpy(secret.data(), ec_secret.data(), ec_secret.size());
+    KYBER_encap(kyber_ciphertext, secret.data() + p256_secret_size,
+                &peer_kyber_pub);
+
+    if(!CBB_add_bytes(out_ciphertext, kyber_ciphertext,
+                       sizeof(kyber_ciphertext))) {
+      return false;
+    }
+
+    *out_secret = std::move(secret);
+    return true;
+  }
+
+  bool Decap(Array<uint8_t> *out_secret, uint8_t *out_alert,
+             Span<const uint8_t> ciphertext) override {
+    *out_alert = SSL_AD_INTERNAL_ERROR;
+
+    Array<uint8_t> ec_secret;
+
+    if (ciphertext.size() != p256_share_size + KYBER_CIPHERTEXT_BYTES) {
+      *out_alert = SSL_AD_ILLEGAL_PARAMETER;
+      OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_ECPOINT);
+      return false;
+    }
+
+    if (!ecks_.Decap(&ec_secret, out_alert,
+                     ciphertext.subspan(0, p256_share_size))) {
+      return false;
+    }
+
+    Array<uint8_t> secret;
+    if (!secret.InitForOverwrite(p256_secret_size + KYBER_SHARED_SECRET_BYTES)) {
+      return false;
+    }
+    OPENSSL_memcpy(secret.data(), ec_secret.data(), ec_secret.size());
+    KYBER_decap(secret.data() + p256_secret_size,
+                ciphertext.data() + p256_share_size, &kyber_private_key_);
+    *out_secret = std::move(secret);
+    return true;
+  }
+
+ private:
+  ECKeyShare ecks_;
+  KYBER_private_key kyber_private_key_;
+
+  static constexpr size_t p256_share_size = 65;
+  static constexpr size_t p256_secret_size = 32;
+};
+
 // draft-tls-westerbaan-xyber768d00-03
 class X25519Kyber768KeyShare : public SSLKeyShare {
  public:
@@ -441,9 +544,11 @@ constexpr NamedGroup kNamedGroups[] = {
     {NID_secp521r1, SSL_GROUP_SECP521R1, "P-521", "secp521r1"},
     {NID_X25519, SSL_GROUP_X25519, "X25519", "x25519"},
     {NID_X25519Kyber768Draft00, SSL_GROUP_X25519_KYBER768_DRAFT00,
-     "X25519Kyber768Draft00", ""},
+     "X25519Kyber768Draft00", "Xyber768D00"},
     {NID_X25519MLKEM768, SSL_GROUP_X25519_MLKEM768, "X25519MLKEM768", ""},
     {NID_ML_KEM_1024, SSL_GROUP_MLKEM1024, "MLKEM1024", ""},
+    {NID_P256Kyber768Draft00, SSL_GROUP_P256_KYBER768_DRAFT00,
+     "P256Kyber768Draft00", "P256Kyber768D00"},
 };
 
 static_assert(std::size(kNamedGroups) == kNumNamedGroups,
@@ -455,6 +560,8 @@ Span<const NamedGroup> NamedGroups() { return kNamedGroups; }
 
 Span<const uint16_t> DefaultSupportedGroupIds() {
   static const uint16_t kDefaultSupportedGroupIds[] = {
+      SSL_GROUP_X25519_MLKEM768,
+      SSL_GROUP_P256_KYBER768_DRAFT00,
       SSL_GROUP_X25519,
       SSL_GROUP_SECP256R1,
       SSL_GROUP_SECP384R1,
@@ -478,6 +585,8 @@ UniquePtr<SSLKeyShare> SSLKeyShare::Create(uint16_t group_id) {
       return MakeUnique<X25519MLKEM768KeyShare>();
     case SSL_GROUP_MLKEM1024:
       return MakeUnique<MLKEM1024KeyShare>();
+    case SSL_GROUP_P256_KYBER768_DRAFT00:
+      return MakeUnique<P256Kyber768Draft00KeyShare>();
     default:
       return nullptr;
   }
diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc
index 89702eaaf..a7505841c 100644
--- a/ssl/ssl_lib.cc
+++ b/ssl/ssl_lib.cc
@@ -385,6 +385,7 @@ ssl_ctx_st::ssl_ctx_st(const SSL_METHOD *ssl_method)
       channel_id_enabled(false),
       grease_enabled(false),
       permute_extensions(false),
+      disable_second_keyshare(false),
       allow_unknown_alpn_protos(false),
       false_start_allowed_without_alpn(false),
       handoff(false),
@@ -517,6 +518,7 @@ SSL *SSL_new(SSL_CTX *ctx) {
   ssl->config->retain_only_sha256_of_client_certs =
       ctx->retain_only_sha256_of_client_certs;
   ssl->config->permute_extensions = ctx->permute_extensions;
+  ssl->config->disable_second_keyshare = ctx->disable_second_keyshare;
   ssl->config->aes_hw_override = ctx->aes_hw_override;
   ssl->config->aes_hw_override_value = ctx->aes_hw_override_value;
   ssl->config->compliance_policy = ctx->compliance_policy;
@@ -582,6 +584,7 @@ SSL_CONFIG::SSL_CONFIG(SSL *ssl_arg)
       jdk11_workaround(false),
       quic_use_legacy_codepoint(false),
       permute_extensions(false),
+      disable_second_keyshare(false),
       alps_use_new_codepoint(true),
       server_padding_enabled(false) {
   assert(ssl);
@@ -3390,6 +3393,15 @@ int SSL_set1_curves_list(SSL *ssl, const char *curves) {
   return SSL_set1_groups_list(ssl, curves);
 }
 
+void SSL_use_second_keyshare(SSL *ssl, int enabled) {
+  ssl->config->disable_second_keyshare = !enabled;
+}
+
+void SSL_CTX_use_second_keyshare(SSL_CTX *ctx, int enabled) {
+  ctx->disable_second_keyshare = !enabled;
+}
+
+
 namespace fips202205 {
 
 // (References are to SP 800-52r2):
@@ -3401,7 +3413,9 @@ namespace fips202205 {
 // Section 3.3.1
 // "The server shall be configured to only use cipher suites that are
 // composed entirely of NIST approved algorithms"
-static const uint16_t kGroups[] = {SSL_GROUP_SECP256R1, SSL_GROUP_SECP384R1};
+static const uint16_t kGroups[] = {
+    SSL_GROUP_P256_KYBER768_DRAFT00,
+    SSL_GROUP_SECP256R1, SSL_GROUP_SECP384R1};
 
 static const uint16_t kSigAlgs[] = {
     SSL_SIGN_RSA_PKCS1_SHA256,
diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc
index a91a6268c..3999ad61b 100644
--- a/ssl/ssl_test.cc
+++ b/ssl/ssl_test.cc
@@ -522,6 +522,14 @@ static const CurveTest kCurveTests[] = {
         "MLKEM1024:X25519MLKEM768",
         {SSL_GROUP_MLKEM1024, SSL_GROUP_X25519_MLKEM768},
     },
+    {
+        "P256Kyber768Draft00",
+        {SSL_GROUP_P256_KYBER768_DRAFT00},
+    },
+    {
+        "P-256:P256Kyber768Draft00",
+        {SSL_GROUP_SECP256R1, SSL_GROUP_P256_KYBER768_DRAFT00},
+    },
 
     {
         "P-256:P-384:P-521:X25519",
@@ -683,7 +691,9 @@ TEST(SSLTest, CurveRules) {
 }
 
 TEST(SSLTest, DefaultCurves) {
-  const uint16_t kDefaults[] = {SSL_GROUP_X25519, SSL_GROUP_SECP256R1,
+  const uint16_t kDefaults[] = {SSL_GROUP_X25519_MLKEM768,
+                                SSL_GROUP_P256_KYBER768_DRAFT00,
+                                SSL_GROUP_X25519, SSL_GROUP_SECP256R1,
                                 SSL_GROUP_SECP384R1};
 
   // Test the group ID APIs.
@@ -1643,6 +1653,9 @@ static bool GetClientHello(SSL *ssl, std::vector<uint8_t> *out) {
 static size_t GetClientHelloLen(uint16_t max_version, uint16_t session_version,
                                 size_t ticket_len) {
   bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(TLS_method()));
+  // RTG-3417 bas: we need to disable PQ here so that the small ClientHello
+  // padding tests properly tests things.
+  SSL_CTX_set1_curves_list(ctx.get(), "X25519");
   bssl::UniquePtr<SSL_SESSION> session =
       CreateSessionWithTicket(session_version, ticket_len);
   if (!ctx || !session) {
@@ -2317,7 +2330,10 @@ TEST(SSLTest, SetGroupIdsWithEqualPreference) {
 // Test that the SSL group flags are defaulted to zero when zero groups are set
 // (i.e. using the default groups).
 TEST(SSLTest, SetGroupIdsWithFlags_DefaultGroups) {
-  const uint16_t kDefaultGroups[] = {SSL_GROUP_X25519, SSL_GROUP_SECP256R1,
+  const uint16_t kDefaultGroups[] = {SSL_GROUP_X25519_MLKEM768,
+                                     SSL_GROUP_P256_KYBER768_DRAFT00,
+                                     SSL_GROUP_X25519,
+                                     SSL_GROUP_SECP256R1,
                                      SSL_GROUP_SECP384R1};
   const uint32_t kBogusFlags[] = {SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT,
                                   SSL_GROUP_FLAG_EQUAL_PREFERENCE_WITH_NEXT, 0};
@@ -7112,7 +7128,9 @@ TEST(SSLTest, ApplyHandoffRemovesUnsupportedCurves) {
 
   // The default list of groups is used before applying the handoff.
   EXPECT_THAT(server->config->supported_group_list,
-              ElementsAreArray({SSL_GROUP_X25519, SSL_GROUP_SECP256R1,
+              ElementsAreArray({SSL_GROUP_X25519_MLKEM768,
+                                SSL_GROUP_P256_KYBER768_DRAFT00,
+                                SSL_GROUP_X25519, SSL_GROUP_SECP256R1,
                                 SSL_GROUP_SECP384R1}));
   ASSERT_TRUE(SSL_apply_handoff(server.get(), handoff));
   EXPECT_EQ(1u, server->config->supported_group_list.size());
diff --git a/ssl/test/runner/basic_tests.go b/ssl/test/runner/basic_tests.go
index 54d49637b..5887c715a 100644
--- a/ssl/test/runner/basic_tests.go
+++ b/ssl/test/runner/basic_tests.go
@@ -132,6 +132,7 @@ read alert 1 0
 				`write hs 1
 read hs 3
 write hs 1
+write hs 1
 read hs 2
 read hs 11
 read hs 12
@@ -2003,6 +2004,7 @@ read alert 1 0
 write hs 2
 write hs 8
 write hs 11
+write hs 11
 write hs 15
 write hs 20
 read hs 20
diff --git a/ssl/test/runner/cbc_tests.go b/ssl/test/runner/cbc_tests.go
index 6f49d12af..5e970b2b5 100644
--- a/ssl/test/runner/cbc_tests.go
+++ b/ssl/test/runner/cbc_tests.go
@@ -14,6 +14,8 @@
 
 package runner
 
+import "strconv"
+
 func addCBCPaddingTests() {
 	testCases = append(testCases, testCase{
 		name: "MaxCBCPadding",
@@ -104,6 +106,7 @@ func addCBCSplittingTests() {
 				"-partial-write",
 				// BoringSSL disables 3DES by default.
 				"-cipher", "ALL:3DES",
+				 "-curves", strconv.Itoa(int(CurveX25519)),
 			},
 		})
 	}
diff --git a/ssl/test/runner/common.go b/ssl/test/runner/common.go
index c241c418e..9ffafa248 100644
--- a/ssl/test/runner/common.go
+++ b/ssl/test/runner/common.go
@@ -2186,7 +2186,7 @@ type ProtocolBugs struct {
 	FailIfHelloRetryRequested bool
 
 	// FailIfPostQuantumOffered will cause a server to reject a ClientHello if
-	// post-quantum curves are supported.
+	// post-quantum curves are not supported.
 	FailIfPostQuantumOffered bool
 
 	// ExpectKeyShares, if not nil, lists (in order) the curves that a ClientHello
diff --git a/ssl/test/runner/curve_tests.go b/ssl/test/runner/curve_tests.go
index 956a73203..d04a1531d 100644
--- a/ssl/test/runner/curve_tests.go
+++ b/ssl/test/runner/curve_tests.go
@@ -582,17 +582,6 @@ func addCurveTests() {
 		})
 	}
 
-	// ML-KEM and Kyber should not be offered by default as a client.
-	testCases = append(testCases, testCase{
-		name: "PostQuantumNotEnabledByDefaultInClients",
-		config: Config{
-			MinVersion: VersionTLS13,
-			Bugs: ProtocolBugs{
-				FailIfPostQuantumOffered: true,
-			},
-		},
-	})
-
 	for _, curve := range testCurves {
 		if !isMLKEMGroup(curve.id) {
 			continue
@@ -682,18 +671,19 @@ func addCurveTests() {
 		})
 	}
 
-	// As a server, ML-KEMs and Kyber are not yet supported by default.
+	// If ML-KEM is offered, both X25519 and ML-KEM should have a key-share.
 	testCases = append(testCases, testCase{
-		testType: serverTest,
-		name:     "PostQuantumNotEnabledByDefaultForAServer",
+		name: "NotJustMLKEMKeyShare",
 		config: Config{
-			MinVersion:       VersionTLS13,
-			CurvePreferences: []CurveID{CurveX25519MLKEM768, CurveMLKEM1024, CurveX25519Kyber768, CurveX25519},
-			DefaultCurves:    []CurveID{CurveX25519MLKEM768, CurveMLKEM1024, CurveX25519Kyber768},
+			MinVersion: VersionTLS13,
+			Bugs: ProtocolBugs{
+				ExpectedKeyShares: []CurveID{CurveX25519MLKEM768, CurveX25519},
+			},
 		},
 		flags: []string{
-			"-server-preference",
-			"-expect-curve-id", strconv.Itoa(int(CurveX25519)),
+			"-curves", strconv.Itoa(int(CurveX25519MLKEM768)),
+			"-curves", strconv.Itoa(int(CurveX25519)),
+			"-expect-curve-id", strconv.Itoa(int(CurveX25519MLKEM768)),
 		},
 	})
 
diff --git a/ssl/test/runner/ech_tests.go b/ssl/test/runner/ech_tests.go
index 2cd3c10d3..f19d8d20a 100644
--- a/ssl/test/runner/ech_tests.go
+++ b/ssl/test/runner/ech_tests.go
@@ -451,7 +451,8 @@ func addEncryptedClientHelloTests() {
 				expectMsgCallback += clientAndServerHello
 			}
 			// EncryptedExtensions onwards.
-			expectMsgCallback += `write hs 8
+			if protocol != dtls {
+				expectMsgCallback += `write hs 8
 write hs 11
 write hs 15
 write hs 20
@@ -462,6 +463,20 @@ write hs 4
 read ack
 read ack
 `
+			} else {
+				expectMsgCallback += `write hs 8
+write hs 11
+write hs 11
+write hs 15
+write hs 20
+read hs 20
+write ack
+write hs 4
+write hs 4
+read ack
+read ack
+`
+			}
 			if protocol != dtls {
 				expectMsgCallback = strings.ReplaceAll(expectMsgCallback, "write ack\n", "")
 				expectMsgCallback = strings.ReplaceAll(expectMsgCallback, "read ack\n", "")
@@ -2349,8 +2364,11 @@ read ack
 
 		// Test the message callback is correctly reported, with and without
 		// HelloRetryRequest.
-		clientAndServerHello := "write clienthelloinner\nwrite hs 1\nread hs 2\n"
-		clientAndServerHelloInitial := clientAndServerHello
+		clientAndServerHelloInitial := "write clienthelloinner\nwrite hs 1\nwrite hs 1\nread hs 2\n"
+		clientAndServerHello  := "write clienthelloinner\nwrite hs 1\nread hs 2\n"
+		if protocol != dtls {
+			clientAndServerHelloInitial = clientAndServerHello
+		}
 		if protocol == tls {
 			clientAndServerHelloInitial += "write ccs\n"
 		}
diff --git a/ssl/test/runner/extension_tests.go b/ssl/test/runner/extension_tests.go
index ab9b0b02d..834da257f 100644
--- a/ssl/test/runner/extension_tests.go
+++ b/ssl/test/runner/extension_tests.go
@@ -16,6 +16,7 @@ package runner
 
 import (
 	"fmt"
+	"strconv"
 )
 
 func addExtensionTests() {
@@ -2001,7 +2002,7 @@ func addExtensionTests() {
 		// This hostname just needs to be long enough to push the
 		// ClientHello into F5's danger zone between 256 and 511 bytes
 		// long.
-		flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com"},
+		flags: []string{"-host-name", "01234567890123456789012345678901234567890123456789012345678901234567890123456789.com", "-curves", strconv.Itoa(int(CurveX25519))},
 	})
 
 	// Test that illegal extensions in TLS 1.3 are rejected by the client if
diff --git a/ssl/test/runner/key_update_tests.go b/ssl/test/runner/key_update_tests.go
index f98528265..2068b1102 100644
--- a/ssl/test/runner/key_update_tests.go
+++ b/ssl/test/runner/key_update_tests.go
@@ -14,7 +14,10 @@
 
 package runner
 
-import "slices"
+import (
+	"slices"
+	"strconv"
+)
 
 func addKeyUpdateTests() {
 	// TLS tests.
@@ -295,6 +298,7 @@ func addKeyUpdateTests() {
 			},
 		},
 		shimSendsKeyUpdateBeforeRead: true,
+		flags:            []string{"-curves", strconv.Itoa(int(CurveX25519))},
 	})
 
 	// Test that shim responds to KeyUpdate requests.
diff --git a/tool/client.cc b/tool/client.cc
index 1653af8da..cab725d40 100644
--- a/tool/client.cc
+++ b/tool/client.cc
@@ -156,6 +156,11 @@ static const struct argument kArguments[] = {
         kBooleanArgument,
         "Permute extensions in handshake messages",
     },
+    {
+        "-disable-second-keyshare",
+        kBooleanArgument,
+        "Do not send a second keyshare",
+    },
     {
         "-test-resumption",
         kBooleanArgument,
@@ -637,6 +642,10 @@ bool Client(const std::vector<std::string> &args) {
     SSL_CTX_set_permute_extensions(ctx.get(), 1);
   }
 
+  if (args_map.count("-disable-second-keyshare") != 0) {
+    SSL_CTX_use_second_keyshare(ctx.get(), 0);
+  }
+
   // Configure accepted roots.
   if (args_map.count("-root-certs") != 0) {
     if (!SSL_CTX_load_verify_locations(
-- 
2.50.1 (Apple Git-155)