1919#include <string.h>
2020
2121#include "crypto/s2n_ecc_evp.h"
22- #include "crypto/s2n_fips .h"
22+ #include "pq- crypto/s2n_pq .h"
2323#include "tls/s2n_cipher_suites.h"
2424#include "tls/s2n_connection.h"
2525#include "tls/s2n_security_policies.h"
@@ -226,7 +226,7 @@ int main(int argc, char **argv)
226226 TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 ,
227227 TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 ,
228228 TLS_ECDHE_BIKE_RSA_WITH_AES_256_GCM_SHA384 ,
229- TLS_ECDHE_BIKE_RSA_WITH_AES_256_GCM_SHA384 ,
229+ TLS_ECDHE_SIKE_RSA_WITH_AES_256_GCM_SHA384 ,
230230 TLS_ECDHE_KYBER_RSA_WITH_AES_256_GCM_SHA384 ,
231231 };
232232 const uint8_t cipher_count = sizeof (wire_ciphers ) / S2N_TLS_CIPHER_SUITE_LEN ;
@@ -359,11 +359,27 @@ int main(int argc, char **argv)
359359 EXPECT_EQUAL (conn -> secure .cipher_suite , s2n_cipher_suite_from_wire (expected_rsa_wire_choice ));
360360 EXPECT_SUCCESS (s2n_connection_wipe (conn ));
361361
362- #if !defined(S2N_NO_PQ )
363- if (!s2n_is_in_fips_mode ()) {
364- /* There is no support for PQ KEMs while in FIPS mode */
365- /* Test that clients that support PQ ciphers can negotiate them. */
366- const uint8_t expected_pq_wire_choice [] = {TLS_ECDHE_BIKE_RSA_WITH_AES_256_GCM_SHA384 };
362+ /* Test that PQ cipher suites are marked available/unavailable appropriately in s2n_cipher_suites_init() */
363+ {
364+ const struct s2n_cipher_suite * pq_suites [] = {
365+ & s2n_ecdhe_sike_rsa_with_aes_256_gcm_sha384 ,
366+ & s2n_ecdhe_bike_rsa_with_aes_256_gcm_sha384 ,
367+ & s2n_ecdhe_kyber_rsa_with_aes_256_gcm_sha384 ,
368+ };
369+
370+ for (size_t i = 0 ; i < s2n_array_len (pq_suites ); i ++ ) {
371+ if (s2n_pq_is_enabled ()) {
372+ EXPECT_EQUAL (pq_suites [i ]-> available , 1 );
373+ EXPECT_NOT_NULL (pq_suites [i ]-> record_alg );
374+ } else {
375+ EXPECT_EQUAL (pq_suites [i ]-> available , 0 );
376+ EXPECT_NULL (pq_suites [i ]-> record_alg );
377+ }
378+ }
379+ }
380+
381+ /* Test that clients that support PQ ciphers can negotiate them. */
382+ {
367383 uint8_t client_extensions_data [] = {
368384 0xFE , 0x01 , /* PQ KEM extension ID */
369385 0x00 , 0x04 , /* Total extension length in bytes */
@@ -377,7 +393,14 @@ int main(int argc, char **argv)
377393 conn -> secure .client_pq_kem_extension .data = client_extensions_data ;
378394 conn -> secure .client_pq_kem_extension .size = client_extensions_len ;
379395 EXPECT_SUCCESS (s2n_set_cipher_as_tls_server (conn , wire_ciphers , cipher_count ));
380- EXPECT_EQUAL (conn -> secure .cipher_suite , s2n_cipher_suite_from_wire (expected_pq_wire_choice ));
396+ const uint8_t bike_cipher [] = {TLS_ECDHE_BIKE_RSA_WITH_AES_256_GCM_SHA384 };
397+ const uint8_t ecc_cipher [] = {TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 };
398+ if (s2n_pq_is_enabled ()) {
399+ EXPECT_EQUAL (conn -> secure .cipher_suite , s2n_cipher_suite_from_wire (bike_cipher ));
400+ } else {
401+ EXPECT_EQUAL (conn -> secure .cipher_suite , s2n_cipher_suite_from_wire (ecc_cipher ));
402+ }
403+
381404 EXPECT_SUCCESS (s2n_connection_wipe (conn ));
382405
383406 /* Test cipher preferences that use PQ cipher suites that require TLS 1.2 fall back to classic ciphers if a client
@@ -395,7 +418,6 @@ int main(int argc, char **argv)
395418 EXPECT_SUCCESS (s2n_connection_wipe (conn ));
396419 }
397420 }
398- #endif
399421
400422 /* Clean+free to setup for ECDSA tests */
401423 EXPECT_SUCCESS (s2n_config_free (server_config ));
0 commit comments