70-test_tls13kexmodes.t 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. #! /usr/bin/env perl
  2. # Copyright 2017-2023 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (the "License"). You may not use
  5. # this file except in compliance with the License. You can obtain a copy
  6. # in the file LICENSE in the source distribution or at
  7. # https://www.openssl.org/source/license.html
  8. use strict;
  9. use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file srctop_dir bldtop_dir/;
  10. use OpenSSL::Test::Utils;
  11. use File::Temp qw(tempfile);
  12. use TLSProxy::Proxy;
  13. use checkhandshake qw(checkhandshake @handmessages @extensions);
  14. my $test_name = "test_tls13kexmodes";
  15. setup($test_name);
  16. plan skip_all => "TLSProxy isn't usable on $^O"
  17. if $^O =~ /^(VMS)$/;
  18. plan skip_all => "$test_name needs the dynamic engine feature enabled"
  19. if disabled("engine") || disabled("dynamic-engine");
  20. plan skip_all => "$test_name needs the sock feature enabled"
  21. if disabled("sock");
  22. plan skip_all => "$test_name needs TLSv1.3 enabled"
  23. if disabled("tls1_3") || (disabled("ec") && disabled("dh"));
  24. plan skip_all => "$test_name needs EC enabled"
  25. if disabled("ec");
  26. @handmessages = (
  27. [TLSProxy::Message::MT_CLIENT_HELLO,
  28. checkhandshake::ALL_HANDSHAKES],
  29. [TLSProxy::Message::MT_SERVER_HELLO,
  30. checkhandshake::HRR_HANDSHAKE | checkhandshake::HRR_RESUME_HANDSHAKE],
  31. [TLSProxy::Message::MT_CLIENT_HELLO,
  32. checkhandshake::HRR_HANDSHAKE | checkhandshake::HRR_RESUME_HANDSHAKE],
  33. [TLSProxy::Message::MT_SERVER_HELLO,
  34. checkhandshake::ALL_HANDSHAKES],
  35. [TLSProxy::Message::MT_ENCRYPTED_EXTENSIONS,
  36. checkhandshake::ALL_HANDSHAKES],
  37. [TLSProxy::Message::MT_CERTIFICATE_REQUEST,
  38. checkhandshake::CLIENT_AUTH_HANDSHAKE],
  39. [TLSProxy::Message::MT_CERTIFICATE,
  40. checkhandshake::ALL_HANDSHAKES & ~(checkhandshake::RESUME_HANDSHAKE | checkhandshake::HRR_RESUME_HANDSHAKE)],
  41. [TLSProxy::Message::MT_CERTIFICATE_VERIFY,
  42. checkhandshake::ALL_HANDSHAKES & ~(checkhandshake::RESUME_HANDSHAKE | checkhandshake::HRR_RESUME_HANDSHAKE)],
  43. [TLSProxy::Message::MT_FINISHED,
  44. checkhandshake::ALL_HANDSHAKES],
  45. [TLSProxy::Message::MT_CERTIFICATE,
  46. checkhandshake::CLIENT_AUTH_HANDSHAKE],
  47. [TLSProxy::Message::MT_CERTIFICATE_VERIFY,
  48. checkhandshake::CLIENT_AUTH_HANDSHAKE],
  49. [TLSProxy::Message::MT_FINISHED,
  50. checkhandshake::ALL_HANDSHAKES],
  51. [0, 0]
  52. );
  53. @extensions = (
  54. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SERVER_NAME,
  55. TLSProxy::Message::CLIENT,
  56. checkhandshake::SERVER_NAME_CLI_EXTENSION],
  57. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_STATUS_REQUEST,
  58. TLSProxy::Message::CLIENT,
  59. checkhandshake::STATUS_REQUEST_CLI_EXTENSION],
  60. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SUPPORTED_GROUPS,
  61. TLSProxy::Message::CLIENT,
  62. checkhandshake::DEFAULT_EXTENSIONS],
  63. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_EC_POINT_FORMATS,
  64. TLSProxy::Message::CLIENT,
  65. checkhandshake::DEFAULT_EXTENSIONS],
  66. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SIG_ALGS,
  67. TLSProxy::Message::CLIENT,
  68. checkhandshake::DEFAULT_EXTENSIONS],
  69. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_ALPN,
  70. TLSProxy::Message::CLIENT,
  71. checkhandshake::ALPN_CLI_EXTENSION],
  72. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SCT,
  73. TLSProxy::Message::CLIENT,
  74. checkhandshake::SCT_CLI_EXTENSION],
  75. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_ENCRYPT_THEN_MAC,
  76. TLSProxy::Message::CLIENT,
  77. checkhandshake::DEFAULT_EXTENSIONS],
  78. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_EXTENDED_MASTER_SECRET,
  79. TLSProxy::Message::CLIENT,
  80. checkhandshake::DEFAULT_EXTENSIONS],
  81. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SESSION_TICKET,
  82. TLSProxy::Message::CLIENT,
  83. checkhandshake::DEFAULT_EXTENSIONS],
  84. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_KEY_SHARE,
  85. TLSProxy::Message::CLIENT,
  86. checkhandshake::DEFAULT_EXTENSIONS],
  87. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SUPPORTED_VERSIONS,
  88. TLSProxy::Message::CLIENT,
  89. checkhandshake::DEFAULT_EXTENSIONS],
  90. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_PSK_KEX_MODES,
  91. TLSProxy::Message::CLIENT,
  92. checkhandshake::PSK_KEX_MODES_EXTENSION],
  93. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_PSK,
  94. TLSProxy::Message::CLIENT,
  95. checkhandshake::PSK_CLI_EXTENSION],
  96. [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_SUPPORTED_VERSIONS,
  97. TLSProxy::Message::SERVER,
  98. checkhandshake::DEFAULT_EXTENSIONS],
  99. [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_KEY_SHARE,
  100. TLSProxy::Message::SERVER,
  101. checkhandshake::KEY_SHARE_HRR_EXTENSION],
  102. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SERVER_NAME,
  103. TLSProxy::Message::CLIENT,
  104. checkhandshake::SERVER_NAME_CLI_EXTENSION],
  105. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_STATUS_REQUEST,
  106. TLSProxy::Message::CLIENT,
  107. checkhandshake::STATUS_REQUEST_CLI_EXTENSION],
  108. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SUPPORTED_GROUPS,
  109. TLSProxy::Message::CLIENT,
  110. checkhandshake::DEFAULT_EXTENSIONS],
  111. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_EC_POINT_FORMATS,
  112. TLSProxy::Message::CLIENT,
  113. checkhandshake::DEFAULT_EXTENSIONS],
  114. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SIG_ALGS,
  115. TLSProxy::Message::CLIENT,
  116. checkhandshake::DEFAULT_EXTENSIONS],
  117. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_ALPN,
  118. TLSProxy::Message::CLIENT,
  119. checkhandshake::ALPN_CLI_EXTENSION],
  120. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SCT,
  121. TLSProxy::Message::CLIENT,
  122. checkhandshake::SCT_CLI_EXTENSION],
  123. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_ENCRYPT_THEN_MAC,
  124. TLSProxy::Message::CLIENT,
  125. checkhandshake::DEFAULT_EXTENSIONS],
  126. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_EXTENDED_MASTER_SECRET,
  127. TLSProxy::Message::CLIENT,
  128. checkhandshake::DEFAULT_EXTENSIONS],
  129. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SESSION_TICKET,
  130. TLSProxy::Message::CLIENT,
  131. checkhandshake::DEFAULT_EXTENSIONS],
  132. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_KEY_SHARE,
  133. TLSProxy::Message::CLIENT,
  134. checkhandshake::DEFAULT_EXTENSIONS],
  135. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_SUPPORTED_VERSIONS,
  136. TLSProxy::Message::CLIENT,
  137. checkhandshake::DEFAULT_EXTENSIONS],
  138. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_PSK_KEX_MODES,
  139. TLSProxy::Message::CLIENT,
  140. checkhandshake::PSK_KEX_MODES_EXTENSION],
  141. [TLSProxy::Message::MT_CLIENT_HELLO, TLSProxy::Message::EXT_PSK,
  142. TLSProxy::Message::CLIENT,
  143. checkhandshake::PSK_CLI_EXTENSION],
  144. [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_SUPPORTED_VERSIONS,
  145. TLSProxy::Message::SERVER,
  146. checkhandshake::DEFAULT_EXTENSIONS],
  147. [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_KEY_SHARE,
  148. TLSProxy::Message::SERVER,
  149. checkhandshake::KEY_SHARE_SRV_EXTENSION],
  150. [TLSProxy::Message::MT_SERVER_HELLO, TLSProxy::Message::EXT_PSK,
  151. TLSProxy::Message::SERVER,
  152. checkhandshake::PSK_SRV_EXTENSION],
  153. [TLSProxy::Message::MT_CERTIFICATE, TLSProxy::Message::EXT_STATUS_REQUEST,
  154. TLSProxy::Message::SERVER,
  155. checkhandshake::STATUS_REQUEST_SRV_EXTENSION],
  156. [0,0,0,0]
  157. );
  158. use constant {
  159. DELETE_EXTENSION => 0,
  160. EMPTY_EXTENSION => 1,
  161. NON_DHE_KEX_MODE_ONLY => 2,
  162. DHE_KEX_MODE_ONLY => 3,
  163. UNKNOWN_KEX_MODES => 4,
  164. BOTH_KEX_MODES => 5
  165. };
  166. my $proxy = TLSProxy::Proxy->new(
  167. undef,
  168. cmdstr(app(["openssl"]), display => 1),
  169. srctop_file("apps", "server.pem"),
  170. (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
  171. );
  172. #Test 1: First get a session
  173. (undef, my $session) = tempfile();
  174. $proxy->clientflags("-no_rx_cert_comp -sess_out ".$session);
  175. $proxy->serverflags("-no_rx_cert_comp -servername localhost");
  176. $proxy->sessionfile($session);
  177. $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
  178. plan tests => 13;
  179. ok(TLSProxy::Message->success(), "Initial connection");
  180. #Test 2: Attempt a resume with no kex modes extension. Should fail (server
  181. # MUST abort handshake with pre_shared key and no psk_kex_modes)
  182. $proxy->clear();
  183. $proxy->clientflags("-no_rx_cert_comp -sess_in ".$session);
  184. my $testtype = DELETE_EXTENSION;
  185. $proxy->filter(\&modify_kex_modes_filter);
  186. $proxy->start();
  187. ok(TLSProxy::Message->fail(), "Resume with no kex modes");
  188. #Test 3: Attempt a resume with empty kex modes extension. Should fail (empty
  189. # extension is invalid)
  190. $proxy->clear();
  191. $proxy->clientflags("-no_rx_cert_comp -sess_in ".$session);
  192. $testtype = EMPTY_EXTENSION;
  193. $proxy->start();
  194. ok(TLSProxy::Message->fail(), "Resume with empty kex modes");
  195. #Test 4: Attempt a resume with non-dhe kex mode only. Should resume without a
  196. # key_share
  197. $proxy->clear();
  198. $proxy->clientflags("-no_rx_cert_comp -allow_no_dhe_kex -sess_in ".$session);
  199. $proxy->serverflags("-no_rx_cert_comp -allow_no_dhe_kex");
  200. $testtype = NON_DHE_KEX_MODE_ONLY;
  201. $proxy->start();
  202. checkhandshake($proxy, checkhandshake::RESUME_HANDSHAKE,
  203. checkhandshake::DEFAULT_EXTENSIONS
  204. | checkhandshake::PSK_KEX_MODES_EXTENSION
  205. | checkhandshake::PSK_CLI_EXTENSION
  206. | checkhandshake::PSK_SRV_EXTENSION,
  207. "Resume with non-dhe kex mode");
  208. #Test 5: Attempt a resume with dhe kex mode only. Should resume with a key_share
  209. $proxy->clear();
  210. $proxy->clientflags("-no_rx_cert_comp -sess_in ".$session);
  211. $testtype = DHE_KEX_MODE_ONLY;
  212. $proxy->start();
  213. checkhandshake($proxy, checkhandshake::RESUME_HANDSHAKE,
  214. checkhandshake::DEFAULT_EXTENSIONS
  215. | checkhandshake::PSK_KEX_MODES_EXTENSION
  216. | checkhandshake::KEY_SHARE_SRV_EXTENSION
  217. | checkhandshake::PSK_CLI_EXTENSION
  218. | checkhandshake::PSK_SRV_EXTENSION,
  219. "Resume with non-dhe kex mode");
  220. #Test 6: Attempt a resume with only unrecognised kex modes. Should not resume
  221. # but rather fall back to full handshake
  222. $proxy->clear();
  223. $proxy->clientflags("-no_rx_cert_comp -sess_in ".$session);
  224. $testtype = UNKNOWN_KEX_MODES;
  225. $proxy->start();
  226. checkhandshake($proxy, checkhandshake::DEFAULT_HANDSHAKE,
  227. checkhandshake::DEFAULT_EXTENSIONS
  228. | checkhandshake::PSK_KEX_MODES_EXTENSION
  229. | checkhandshake::KEY_SHARE_SRV_EXTENSION
  230. | checkhandshake::PSK_CLI_EXTENSION,
  231. "Resume with unrecognized kex mode");
  232. #Test 7: Attempt a resume with both, non-dhe and dhe kex mode. Should resume with
  233. # a key_share, even though non-dhe is allowed, but not explicitly preferred.
  234. $proxy->clear();
  235. $proxy->clientflags("-no_rx_cert_comp -allow_no_dhe_kex -sess_in ".$session);
  236. $proxy->serverflags("-allow_no_dhe_kex");
  237. $testtype = BOTH_KEX_MODES;
  238. $proxy->start();
  239. checkhandshake($proxy, checkhandshake::RESUME_HANDSHAKE,
  240. checkhandshake::DEFAULT_EXTENSIONS
  241. | checkhandshake::PSK_KEX_MODES_EXTENSION
  242. | checkhandshake::KEY_SHARE_SRV_EXTENSION
  243. | checkhandshake::PSK_CLI_EXTENSION
  244. | checkhandshake::PSK_SRV_EXTENSION,
  245. "Resume with both kex modes");
  246. #Test 8: Attempt a resume with both, non-dhe and dhe kex mode, but with server-side
  247. # preference for non-dhe. Should resume without a key_share.
  248. $proxy->clear();
  249. $proxy->clientflags("-no_rx_cert_comp -allow_no_dhe_kex -sess_in ".$session);
  250. $proxy->serverflags("-allow_no_dhe_kex -prefer_no_dhe_kex");
  251. $testtype = BOTH_KEX_MODES;
  252. $proxy->start();
  253. checkhandshake($proxy, checkhandshake::RESUME_HANDSHAKE,
  254. checkhandshake::DEFAULT_EXTENSIONS
  255. | checkhandshake::PSK_KEX_MODES_EXTENSION
  256. | checkhandshake::PSK_CLI_EXTENSION
  257. | checkhandshake::PSK_SRV_EXTENSION,
  258. "Resume with both kex modes, preference for non-dhe");
  259. #Test 9: Attempt a resume with both, non-dhe and dhe kex mode, with server-side
  260. # preference for non-dhe, but non-dhe not allowed. Should resume with a key_share.
  261. $proxy->clear();
  262. $proxy->clientflags("-no_rx_cert_comp -allow_no_dhe_kex -sess_in ".$session);
  263. $proxy->serverflags("-prefer_no_dhe_kex");
  264. $testtype = BOTH_KEX_MODES;
  265. $proxy->start();
  266. checkhandshake($proxy, checkhandshake::RESUME_HANDSHAKE,
  267. checkhandshake::DEFAULT_EXTENSIONS
  268. | checkhandshake::PSK_KEX_MODES_EXTENSION
  269. | checkhandshake::KEY_SHARE_SRV_EXTENSION
  270. | checkhandshake::PSK_CLI_EXTENSION
  271. | checkhandshake::PSK_SRV_EXTENSION,
  272. "Resume with both kex modes, preference for but disabled non-dhe");
  273. #Test 10: Attempt a resume with both non-dhe and dhe kex mode, but unacceptable
  274. # initial key_share. Should resume with a key_share following an HRR
  275. $proxy->clear();
  276. $proxy->clientflags("-no_rx_cert_comp -sess_in ".$session);
  277. $proxy->serverflags("-no_rx_cert_comp -curves P-384");
  278. $testtype = BOTH_KEX_MODES;
  279. $proxy->start();
  280. checkhandshake($proxy, checkhandshake::HRR_RESUME_HANDSHAKE,
  281. checkhandshake::DEFAULT_EXTENSIONS
  282. | checkhandshake::PSK_KEX_MODES_EXTENSION
  283. | checkhandshake::KEY_SHARE_SRV_EXTENSION
  284. | checkhandshake::KEY_SHARE_HRR_EXTENSION
  285. | checkhandshake::PSK_CLI_EXTENSION
  286. | checkhandshake::PSK_SRV_EXTENSION,
  287. "Resume with both kex modes and HRR");
  288. #Test 11: Attempt a resume with dhe kex mode only and an unacceptable initial
  289. # key_share. Should resume with a key_share following an HRR
  290. $proxy->clear();
  291. $proxy->clientflags("-no_rx_cert_comp -sess_in ".$session);
  292. $proxy->serverflags("-no_rx_cert_comp -curves P-384");
  293. $testtype = DHE_KEX_MODE_ONLY;
  294. $proxy->start();
  295. checkhandshake($proxy, checkhandshake::HRR_RESUME_HANDSHAKE,
  296. checkhandshake::DEFAULT_EXTENSIONS
  297. | checkhandshake::PSK_KEX_MODES_EXTENSION
  298. | checkhandshake::KEY_SHARE_SRV_EXTENSION
  299. | checkhandshake::KEY_SHARE_HRR_EXTENSION
  300. | checkhandshake::PSK_CLI_EXTENSION
  301. | checkhandshake::PSK_SRV_EXTENSION,
  302. "Resume with dhe kex mode and HRR");
  303. #Test 12: Attempt a resume with both non-dhe and dhe kex mode, unacceptable
  304. # initial key_share and no overlapping groups. Should resume without a
  305. # key_share
  306. $proxy->clear();
  307. $proxy->clientflags("-no_rx_cert_comp -allow_no_dhe_kex -curves P-384 -sess_in ".$session);
  308. $proxy->serverflags("-no_rx_cert_comp -allow_no_dhe_kex -curves P-256");
  309. $testtype = BOTH_KEX_MODES;
  310. $proxy->start();
  311. checkhandshake($proxy, checkhandshake::RESUME_HANDSHAKE,
  312. checkhandshake::DEFAULT_EXTENSIONS
  313. | checkhandshake::PSK_KEX_MODES_EXTENSION
  314. | checkhandshake::PSK_CLI_EXTENSION
  315. | checkhandshake::PSK_SRV_EXTENSION,
  316. "Resume with both kex modes, no overlapping groups");
  317. #Test 13: Attempt a resume with dhe kex mode only, unacceptable
  318. # initial key_share and no overlapping groups. Should fail
  319. $proxy->clear();
  320. $proxy->clientflags("-no_rx_cert_comp -curves P-384 -sess_in ".$session);
  321. $proxy->serverflags("-no_rx_cert_comp -curves P-256");
  322. $testtype = DHE_KEX_MODE_ONLY;
  323. $proxy->start();
  324. ok(TLSProxy::Message->fail(), "Resume with dhe kex mode, no overlapping groups");
  325. unlink $session;
  326. sub modify_kex_modes_filter
  327. {
  328. my $proxy = shift;
  329. # We're only interested in the initial ClientHello
  330. return if ($proxy->flight != 0);
  331. foreach my $message (@{$proxy->message_list}) {
  332. if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
  333. my $ext;
  334. if ($testtype == EMPTY_EXTENSION) {
  335. $ext = pack "C",
  336. 0x00; #List length
  337. } elsif ($testtype == NON_DHE_KEX_MODE_ONLY) {
  338. $ext = pack "C2",
  339. 0x01, #List length
  340. 0x00; #psk_ke
  341. } elsif ($testtype == DHE_KEX_MODE_ONLY) {
  342. $ext = pack "C2",
  343. 0x01, #List length
  344. 0x01; #psk_dhe_ke
  345. } elsif ($testtype == UNKNOWN_KEX_MODES) {
  346. $ext = pack "C3",
  347. 0x02, #List length
  348. 0xfe, #unknown
  349. 0xff; #unknown
  350. } elsif ($testtype == BOTH_KEX_MODES) {
  351. #We deliberately list psk_ke first...should still use psk_dhe_ke, except if the server is configured otherwise.
  352. $ext = pack "C3",
  353. 0x02, #List length
  354. 0x00, #psk_ke
  355. 0x01; #psk_dhe_ke
  356. }
  357. if ($testtype == DELETE_EXTENSION) {
  358. $message->delete_extension(
  359. TLSProxy::Message::EXT_PSK_KEX_MODES);
  360. } else {
  361. $message->set_extension(
  362. TLSProxy::Message::EXT_PSK_KEX_MODES, $ext);
  363. }
  364. $message->repack();
  365. }
  366. }
  367. }