Skip to content

Commit

Permalink
refactor: move "s2n_libcrypto_is" methods into s2n_libcrypto.h (#5117)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart authored Feb 18, 2025
1 parent f2e9181 commit dcbec3e
Show file tree
Hide file tree
Showing 32 changed files with 30 additions and 25 deletions.
1 change: 1 addition & 0 deletions crypto/s2n_drbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <openssl/evp.h>
#include <sys/param.h>

#include "crypto/s2n_openssl.h"
#include "utils/s2n_blob.h"
#include "utils/s2n_random.h"
#include "utils/s2n_safety.h"
Expand Down
1 change: 0 additions & 1 deletion crypto/s2n_ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "crypto/s2n_ecc_evp.h"
#include "crypto/s2n_evp_signing.h"
#include "crypto/s2n_hash.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_pkey.h"
#include "error/s2n_errno.h"
#include "stuffer/s2n_stuffer.h"
Expand Down
2 changes: 2 additions & 0 deletions crypto/s2n_fips.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <openssl/crypto.h>

#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_openssl.h"
#include "utils/s2n_init.h"
#include "utils/s2n_safety.h"

Expand Down
1 change: 0 additions & 1 deletion crypto/s2n_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "crypto/s2n_fips.h"
#include "crypto/s2n_hmac.h"
#include "crypto/s2n_openssl.h"
#include "error/s2n_errno.h"
#include "utils/s2n_safety.h"

Expand Down
9 changes: 8 additions & 1 deletion crypto/s2n_libcrypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@

#include "utils/s2n_result.h"

bool s2n_libcrypto_is_openssl(void);
bool s2n_libcrypto_is_openssl_fips(void);
bool s2n_libcrypto_is_awslc(void);
bool s2n_libcrypto_is_awslc_fips(void);
bool s2n_libcrypto_is_boringssl(void);
bool s2n_libcrypto_is_libressl(void);

uint64_t s2n_libcrypto_awslc_api_version(void);
S2N_RESULT s2n_libcrypto_validate_runtime(void);
const char *s2n_libcrypto_get_version_name(void);
bool s2n_libcrypto_supports_flag_no_check_time();
bool s2n_libcrypto_supports_flag_no_check_time(void);
9 changes: 0 additions & 9 deletions crypto/s2n_openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#pragma once

#include <stdbool.h>

/**
* openssl with OPENSSL_VERSION_NUMBER < 0x10100003L made data type details unavailable
* libressl use openssl with data type details available, but mandatorily set
Expand Down Expand Up @@ -49,10 +47,3 @@
#define s2n_evp_ctx_init(ctx) EVP_CIPHER_CTX_init(ctx)
#define RESULT_EVP_CTX_INIT(ctx) EVP_CIPHER_CTX_init(ctx)
#endif

bool s2n_libcrypto_is_openssl(void);
bool s2n_libcrypto_is_openssl_fips(void);
bool s2n_libcrypto_is_awslc();
bool s2n_libcrypto_is_awslc_fips(void);
bool s2n_libcrypto_is_boringssl();
bool s2n_libcrypto_is_libressl();
2 changes: 0 additions & 2 deletions crypto/s2n_pq.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

#include "s2n_pq.h"

#include "crypto/s2n_openssl.h"

bool s2n_libcrypto_supports_evp_kem()
{
/* S2N_LIBCRYPTO_SUPPORTS_EVP_KEM will be auto-detected and #defined if
Expand Down
1 change: 1 addition & 0 deletions crypto/s2n_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "crypto/s2n_drbg.h"
#include "crypto/s2n_evp_signing.h"
#include "crypto/s2n_hash.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_pkey.h"
#include "crypto/s2n_rsa_signing.h"
#include "error/s2n_errno.h"
Expand Down
1 change: 0 additions & 1 deletion crypto/s2n_rsa_pss.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include "crypto/s2n_evp_signing.h"
#include "crypto/s2n_hash.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_pkey.h"
#include "crypto/s2n_rsa.h"
#include "crypto/s2n_rsa_signing.h"
Expand Down
1 change: 0 additions & 1 deletion crypto/s2n_rsa_signing.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#pragma once

#include "api/s2n.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_rsa.h"
#include "utils/s2n_blob.h"

Expand Down
1 change: 1 addition & 0 deletions tests/cbmc/include/cbmc_proof/make_common_datastructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "crypto/s2n_evp.h"
#include "crypto/s2n_hash.h"
#include "crypto/s2n_hmac.h"
#include "crypto/s2n_libcrypto.h"
#include "stuffer/s2n_stuffer.h"
#include "tls/s2n_config.h"
#include "tls/s2n_connection.h"
Expand Down
1 change: 0 additions & 1 deletion tests/cbmc/stubs/s2n_libcrypto_is_awslc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <cbmc_proof/nondet.h>

#include <stdbool.h>
#include "crypto/s2n_openssl.h"

static int flag = 0;
static bool s2n_awslc_flag = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/s2n_build_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>

#include "crypto/s2n_openssl.h"
#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"

#define MAX_LIBCRYPTO_NAME_LEN 100
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_cert_authorities_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "tls/extensions/s2n_cert_authorities.h"

#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_rsa_pss.h"
#include "s2n_test.h"
#include "testlib/s2n_testlib.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/s2n_config_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "api/s2n.h"
#include "crypto/s2n_fips.h"
#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_pq.h"
#include "s2n_test.h"
#include "testlib/s2n_testlib.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_evp_signing_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "crypto/s2n_ecdsa.h"
#include "crypto/s2n_fips.h"
#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_rsa_pss.h"
#include "crypto/s2n_rsa_signing.h"
#include "s2n_test.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_fips_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "crypto/s2n_fips.h"

#include "api/s2n.h"
#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"

int main()
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_hash_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <string.h>

#include "crypto/s2n_fips.h"
#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"
#include "stuffer/s2n_stuffer.h"
#include "testlib/s2n_testlib.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_hkdf_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "crypto/s2n_fips.h"
#include "crypto/s2n_hmac.h"
#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"
#include "stuffer/s2n_stuffer.h"
#include "testlib/s2n_testlib.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

#include "crypto/s2n_openssl.h"
#include "crypto/s2n_libcrypto.h"

#include "s2n_test.h"
#include "utils/s2n_random.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_locking_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <pthread.h>

#include "crypto/s2n_openssl.h"
#include "s2n_test.h"

#define LOCK_N 1
Expand Down
1 change: 0 additions & 1 deletion tests/unit/s2n_pq_mlkem_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "api/s2n.h"
#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_pq.h"
#include "s2n_test.h"
#include "testlib/s2n_testlib.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_random_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include "api/s2n.h"
#include "crypto/s2n_fips.h"
#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"
#include "utils/s2n_fork_detection.h"

Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_tls13_secrets_rfc8448_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/* Needed to set up X25519 key shares */
#include <openssl/evp.h>

#include "crypto/s2n_openssl.h"
#include "s2n_test.h"
#include "testlib/s2n_testlib.h"
#include "tls/s2n_cipher_suites.h"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/s2n_tls_prf_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <string.h>

#include "api/s2n.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"
#include "stuffer/s2n_stuffer.h"
#include "testlib/s2n_testlib.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <string.h>

#include "api/s2n.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_openssl_x509.h"
#include "error/s2n_errno.h"
#include "s2n_test.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/s2n_x509_validator_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* permissions and limitations under the License.
*/

#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_openssl_x509.h"
#include "s2n_test.h"
#include "testlib/s2n_testlib.h"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/s2n_x509_validator_time_verification_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* permissions and limitations under the License.
*/

#include "crypto/s2n_libcrypto.h"
#include "s2n_test.h"
#include "testlib/s2n_testlib.h"

Expand Down
1 change: 0 additions & 1 deletion tls/s2n_prf.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "crypto/s2n_fips.h"
#include "crypto/s2n_hash.h"
#include "crypto/s2n_hmac.h"
#include "crypto/s2n_openssl.h"
#include "error/s2n_errno.h"
#include "stuffer/s2n_stuffer.h"
#include "tls/s2n_cipher_suites.h"
Expand Down
1 change: 0 additions & 1 deletion tls/s2n_prf.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "crypto/s2n_hash.h"
#include "crypto/s2n_hmac.h"
#include "crypto/s2n_openssl.h"
#include "utils/s2n_blob.h"

/* Enough to support TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, 2*SHA384_DIGEST_LEN + 2*AES256_KEY_SIZE */
Expand Down
1 change: 0 additions & 1 deletion tls/s2n_x509_validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <sys/socket.h>

#include "crypto/s2n_libcrypto.h"
#include "crypto/s2n_openssl.h"
#include "crypto/s2n_openssl_x509.h"
#include "crypto/s2n_pkey.h"
#include "tls/extensions/s2n_extension_list.h"
Expand Down
1 change: 1 addition & 0 deletions utils/s2n_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "api/s2n.h"
#include "crypto/s2n_drbg.h"
#include "crypto/s2n_fips.h"
#include "crypto/s2n_libcrypto.h"
#include "error/s2n_errno.h"
#include "s2n_io.h"
#include "stuffer/s2n_stuffer.h"
Expand Down

0 comments on commit dcbec3e

Please sign in to comment.