Skip to content

Commit

Permalink
PR feedback; Cleanup wrapper header
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Apr 22, 2024
1 parent ad180b9 commit 40e1456
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
4 changes: 4 additions & 0 deletions aws-lc-fips-sys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ endif()

add_subdirectory(aws-lc aws-lc EXCLUDE_FROM_ALL)

if(BUILD_SHARED_LIBS)
add_definitions(-DBORINGSSL_SHARED_LIBRARY)
endif()

if (BUILD_LIBSSL)
add_definitions(-DAWS_LC_RUST_INCLUDE_SSL)
endif()
Expand Down
51 changes: 23 additions & 28 deletions aws-lc-fips-sys/include/rust_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,7 @@
#ifndef OPENSSL_HEADER_RUST_WRAPPER_H
#define OPENSSL_HEADER_RUST_WRAPPER_H

#include <openssl/err.h>

#define AWS_LC_WRAPPER_ADD_PREFIX(a, b) AWS_LC_WRAPPER_ADD_PREFIX_INNER(a, b)
#define AWS_LC_WRAPPER_ADD_PREFIX_INNER(a, b) a ## _ ## b

#if defined(BORINGSSL_PREFIX)

#define ERR_GET_LIB_RUST AWS_LC_WRAPPER_ADD_PREFIX(BORINGSSL_PREFIX, ERR_GET_LIB_RUST)
#define ERR_GET_REASON_RUST AWS_LC_WRAPPER_ADD_PREFIX(BORINGSSL_PREFIX, ERR_GET_REASON_RUST)
#define ERR_GET_FUNC_RUST AWS_LC_WRAPPER_ADD_PREFIX(BORINGSSL_PREFIX, ERR_GET_FUNC_RUST)

#endif // BORINGSSL_PREFIX

#if defined(__cplusplus)
extern "C" {
#endif

// The following functions are wrappers over inline functions and macros in
// BoringSSL, which bindgen cannot currently correctly bind. These wrappers
// ensure changes to the functions remain in lockstep with the Rust versions.
OPENSSL_EXPORT int ERR_GET_LIB_RUST(uint32_t packed_error);
OPENSSL_EXPORT int ERR_GET_REASON_RUST(uint32_t packed_error);
OPENSSL_EXPORT int ERR_GET_FUNC_RUST(uint32_t packed_error);


#if defined(__cplusplus)
} // extern C
#endif
#define BORINGSSL_IMPLEMENTATION 1

#include "openssl/is_awslc.h"
#include "openssl/aes.h"
Expand Down Expand Up @@ -120,4 +93,26 @@ extern int CRYPTO_tls1_prf(const EVP_MD *digest,
const uint8_t *seed1, size_t seed1_len,
const uint8_t *seed2, size_t seed2_len);


#if defined(BORINGSSL_PREFIX)
#define ERR_GET_LIB_RUST BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_GET_LIB_RUST)
#define ERR_GET_REASON_RUST BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_GET_REASON_RUST)
#define ERR_GET_FUNC_RUST BORINGSSL_ADD_PREFIX(BORINGSSL_PREFIX, ERR_GET_FUNC_RUST)
#endif // BORINGSSL_PREFIX

#if defined(__cplusplus)
extern "C" {
#endif

// The following functions are wrappers over inline functions and macros in
// BoringSSL, which bindgen cannot currently correctly bind. These wrappers
// ensure changes to the functions remain in lockstep with the Rust versions.
OPENSSL_EXPORT int ERR_GET_LIB_RUST(uint32_t packed_error);
OPENSSL_EXPORT int ERR_GET_REASON_RUST(uint32_t packed_error);
OPENSSL_EXPORT int ERR_GET_FUNC_RUST(uint32_t packed_error);

#if defined(__cplusplus)
} // extern C
#endif

#endif // OPENSSL_HEADER_RUST_WRAPPER_H

0 comments on commit 40e1456

Please sign in to comment.