Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated S2N to add support for sharing openssl/libcrypto #35

Merged
merged 27 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion aws-crt-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
/* automatically generated by rust-bindgen 0.59.0 */
/* automatically generated by rust-bindgen 0.59.1 */

#![allow(dead_code)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deref_nullptr)]

pub type __uint8_t = ::std::os::raw::c_uchar;
pub type __uint16_t = ::std::os::raw::c_ushort;
pub type __uint32_t = ::std::os::raw::c_uint;
pub type __int64_t = ::std::os::raw::c_long;
pub type __uint64_t = ::std::os::raw::c_ulong;
extern "C" {
pub fn aws_crt_init();
}
Expand All @@ -15,6 +20,9 @@ extern "C" {
extern "C" {
pub fn aws_crt_test_error(arg1: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
}
extern "C" {
pub fn aws_crt_crypto_share();
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct aws_allocator {
Expand Down
2 changes: 1 addition & 1 deletion crt/aws-c-common
Submodule aws-c-common updated 392 files
2 changes: 1 addition & 1 deletion crt/s2n
Submodule s2n updated from 663457 to 578da0
1 change: 1 addition & 0 deletions src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
AWS_CRT_API void aws_crt_init(void);
AWS_CRT_API void aws_crt_clean_up(void);
AWS_CRT_API int aws_crt_test_error(int);
AWS_CRT_API void aws_crt_crypto_share(void);

typedef struct aws_allocator aws_crt_allocator;

Expand Down
22 changes: 22 additions & 0 deletions src/crypto.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#include "crt.h"

#if defined(AWS_OS_POSIX) && !defined(AWS_OS_APPLE)
# include <openssl/crypto.h>
# include <s2n.h>

void aws_crt_crypto_share(void) {
/* Prevent s2n from initializing or de-initializing crypto */
s2n_crypto_disable_init();

# if !S2N_OPENSSL_VERSION_AT_LEAST(1, 1, 0)
OPENSSL_add_all_algorithms();
# else
OPENSSL_init_crypto(
OPENSSL_INIT_LOAD_CRYPTO_STRINGS | OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL);
# endif
}

#else
void aws_crt_crypto_share(void) {}
#endif