aboutsummaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2024-01-18 12:43:33 -0800
committerAdam Langley <agl@google.com>2024-01-19 18:24:23 +0000
commit0eac34864c7f2ee611bf3ee4c2b9d4470f2285f3 (patch)
tree4d08f406f390644a186661f61e67e5480c0c95c0 /rust
parent470b9cbd626b7ca079a192b5198be81912f5a837 (diff)
downloadboringssl-0eac34864c7f2ee611bf3ee4c2b9d4470f2285f3.zip
boringssl-0eac34864c7f2ee611bf3ee4c2b9d4470f2285f3.tar.gz
boringssl-0eac34864c7f2ee611bf3ee4c2b9d4470f2285f3.tar.bz2
Reworking bssl_crypto: make with_output_array_fallible use a bool.
This function took a `c_int` and checked that it was 1. But since `initialized_struct_fallible` now expects a bool, this should too. Change-Id: Ice7997c0847299f42fbc71fcc7b29acb66014bde Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65547 Reviewed-by: Bob Beck <bbe@google.com>
Diffstat (limited to 'rust')
-rw-r--r--rust/bssl-crypto/src/lib.rs4
-rw-r--r--rust/bssl-crypto/src/x25519.rs2
2 files changed, 3 insertions, 3 deletions
diff --git a/rust/bssl-crypto/src/lib.rs b/rust/bssl-crypto/src/lib.rs
index 21a2725..38096c3 100644
--- a/rust/bssl-crypto/src/lib.rs
+++ b/rust/bssl-crypto/src/lib.rs
@@ -311,7 +311,7 @@ where
/// Safety: the closure must fully initialize the array if it returns one.
unsafe fn with_output_array_fallible<const N: usize, F>(func: F) -> Option<[u8; N]>
where
- F: FnOnce(*mut u8, usize) -> core::ffi::c_int,
+ F: FnOnce(*mut u8, usize) -> bool,
{
let mut out_uninit = core::mem::MaybeUninit::<[u8; N]>::uninit();
let out_ptr = if N != 0 {
@@ -319,7 +319,7 @@ where
} else {
core::ptr::null_mut()
};
- if func(out_ptr, N) == 1 {
+ if func(out_ptr, N) {
// Safety: `func` promises to fill all of `out_uninit` if it returns one.
unsafe { Some(out_uninit.assume_init()) }
} else {
diff --git a/rust/bssl-crypto/src/x25519.rs b/rust/bssl-crypto/src/x25519.rs
index b91af54..26030b1 100644
--- a/rust/bssl-crypto/src/x25519.rs
+++ b/rust/bssl-crypto/src/x25519.rs
@@ -76,7 +76,7 @@ impl PrivateKey {
// Safety: `X25519` indeed writes `SHARED_KEY_LEN` bytes.
unsafe {
with_output_array_fallible(|out, _| {
- bssl_sys::X25519(out, self.0.as_ffi_ptr(), other_public_key.as_ffi_ptr())
+ bssl_sys::X25519(out, self.0.as_ffi_ptr(), other_public_key.as_ffi_ptr()) == 1
})
}
}