Skip to content

Commit

Permalink
Add re-exports for making inline functions available
Browse files Browse the repository at this point in the history
This CL adds a re-export for `CBS_init` and
`CBS_len`, since these are declared as `OPENSSL_INLINE` and are
thus unavailable currently since inline support is not yet merged.
It also changes the existing wrappers for inline functions
to re-exports too.

Note: this is required to land the boringssl update in AOSP.

Test: m checkbuild
Change-Id: Ic6e2927d7a79b788a4ed0380cf27b3557b6f6f64
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/68327
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Matthew Maurer <mmaurer@google.com>
Commit-Queue: Ellen Arteca <emarteca@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
  • Loading branch information
Ellen Arteca authored and Boringssl LUCI CQ committed May 9, 2024
1 parent d34f540 commit 4d50a59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
8 changes: 8 additions & 0 deletions rust/bssl-sys/rust_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ int ERR_GET_REASON_RUST(uint32_t packed_error) {
int ERR_GET_FUNC_RUST(uint32_t packed_error) {
return ERR_GET_FUNC(packed_error);
}

void CBS_init_RUST(CBS *cbs, const uint8_t *data, size_t len) {
CBS_init(cbs, data, len);
}

size_t CBS_len_RUST(const CBS *cbs) {
return CBS_len(cbs);
}
4 changes: 3 additions & 1 deletion rust/bssl-sys/rust_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define OPENSSL_HEADER_RUST_WRAPPER_H

#include <openssl/err.h>
#include <openssl/bytestring.h>

#if defined(__cplusplus)
extern "C" {
Expand All @@ -30,7 +31,8 @@ extern "C" {
int ERR_GET_LIB_RUST(uint32_t packed_error);
int ERR_GET_REASON_RUST(uint32_t packed_error);
int ERR_GET_FUNC_RUST(uint32_t packed_error);

void CBS_init_RUST(CBS *cbs, const uint8_t *data, size_t len);
size_t CBS_len_RUST(const CBS *cbs);

#if defined(__cplusplus)
} // extern C
Expand Down
21 changes: 5 additions & 16 deletions rust/bssl-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,11 @@ pub const XN_FLAG_ONELINE: c_ulong = bindgen::XN_FLAG_ONELINE as c_ulong;

// TODO(crbug.com/boringssl/596): Remove these wrappers.
#[cfg(unsupported_inline_wrappers)]
pub fn ERR_GET_LIB(packed_error: u32) -> i32 {
// Safety: This is safe for all inputs. bindgen conservatively marks everything unsafe.
unsafe { ERR_GET_LIB_RUST(packed_error) }
}

#[cfg(unsupported_inline_wrappers)]
pub fn ERR_GET_REASON(packed_error: u32) -> i32 {
// Safety: This is safe for all inputs. bindgen conservatively marks everything unsafe.
unsafe { ERR_GET_REASON_RUST(packed_error) }
}

#[cfg(unsupported_inline_wrappers)]
pub fn ERR_GET_FUNC(packed_error: u32) -> i32 {
// Safety: This is safe for all inputs. bindgen conservatively marks everything unsafe.
unsafe { ERR_GET_FUNC_RUST(packed_error) }
}
pub use { ERR_GET_LIB_RUST as ERR_GET_LIB,
ERR_GET_REASON_RUST as ERR_GET_REASON,
ERR_GET_FUNC_RUST as ERR_GET_FUNC,
CBS_init_RUST as CBS_init,
CBS_len_RUST as CBS_len };

pub fn init() {
// Safety: `CRYPTO_library_init` may be called multiple times and concurrently.
Expand Down

0 comments on commit 4d50a59

Please sign in to comment.