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 bb72075
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions aws-lc-fips-sys/include/rust_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,6 @@
#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

#include "openssl/is_awslc.h"
#include "openssl/aes.h"
#include "openssl/asn1.h"
Expand Down Expand Up @@ -112,12 +83,42 @@ OPENSSL_EXPORT int ERR_GET_FUNC_RUST(uint32_t packed_error);
#include "openssl/ssl3.h"
#endif

#ifdef _WIN32
#define AWS_LC_FIPS_SYS_EXPORT __declspec(dllexport)
#else
#define AWS_LC_FIPS_SYS_EXPORT __attribute__((visibility("default")))
#endif

// The TLS PRF API is exported in AWS-LC main branch, but in the current FIPS branch, this API is defined in a private header.
extern int CRYPTO_tls1_prf(const EVP_MD *digest,
AWS_LC_FIPS_SYS_EXPORT int CRYPTO_tls1_prf(const EVP_MD *digest,
uint8_t *out, size_t out_len,
const uint8_t *secret, size_t secret_len,
const char *label, size_t label_len,
const uint8_t *seed1, size_t seed1_len,
const uint8_t *seed2, size_t seed2_len);

#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.
AWS_LC_FIPS_SYS_EXPORT int ERR_GET_LIB_RUST(uint32_t packed_error);
AWS_LC_FIPS_SYS_EXPORT int ERR_GET_REASON_RUST(uint32_t packed_error);
AWS_LC_FIPS_SYS_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 bb72075

Please sign in to comment.