Skip to content

Commit

Permalink
select security policy based on fips or tls13
Browse files Browse the repository at this point in the history
  • Loading branch information
toidiu committed Sep 17, 2024
1 parent e4b845c commit 60f4ba4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion implicit_default_detection/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn main() {

let auto_gen = format!(
"/* AUTO-GENERATED */
EXPECT_SUCCESS(s2n_config_set_cipher_preferences({}, \"20240501\"));
EXPECT_SUCCESS(s2n_config_set_cipher_preferences({}, s2n_testing_old_default_security_policy()));
/* AUTO-GENERATED */",
config_name
);
Expand Down
14 changes: 13 additions & 1 deletion tests/testlib/s2n_security_policy_testlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
* permissions and limitations under the License.
*/

#include "crypto/s2n_fips.h"
#include "s2n_testlib.h"
#include "utils/s2n_safety.h"

extern const struct s2n_ecc_named_curve s2n_unsupported_curve;

const struct s2n_ecc_named_curve *const ecc_pref_list_for_retry[] = {
const struct s2n_ecc_named_curve* const ecc_pref_list_for_retry[] = {
&s2n_unsupported_curve,
#if EVP_APIS_SUPPORTED
&s2n_ecc_curve_x25519,
Expand All @@ -40,3 +41,14 @@ const struct s2n_security_policy security_policy_test_tls13_retry = {
.certificate_signature_preferences = &s2n_certificate_signature_preferences_20201110,
.ecc_preferences = &ecc_preferences_for_retry,
};

const char* s2n_testing_old_default_security_policy()
{
if (s2n_use_default_tls13_config()) {
return "20240503";
} else if (s2n_is_in_fips_mode()) {
return "20240502";
} else {
return "20240501";
}
}
1 change: 1 addition & 0 deletions tests/testlib/s2n_testlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

extern const struct s2n_ecc_preferences ecc_preferences_for_retry;
extern const struct s2n_security_policy security_policy_test_tls13_retry;
extern const char *s2n_testing_old_default_security_policy();

/* Hex methods for testing */
S2N_RESULT s2n_stuffer_alloc_from_hex(struct s2n_stuffer *stuffer, const char *str);
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/s2n_timer_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

#include "utils/s2n_timer.h"

#include "s2n_test.h"
#include "testlib/s2n_testlib.h"
#include "tls/s2n_config.h"

int mock_clock(void *in, uint64_t *out)
Expand Down

0 comments on commit 60f4ba4

Please sign in to comment.