Fix FFI slice usage

Use CSlice instead of a regular Rust slice when passing pointers to C
FFI.

Change-Id: Iccd827f4c6f005d860993e97fef5e9caf514885b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60525
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
diff --git a/rust/bssl-crypto/src/digest.rs b/rust/bssl-crypto/src/digest.rs
index 35b6534..aa6355d 100644
--- a/rust/bssl-crypto/src/digest.rs
+++ b/rust/bssl-crypto/src/digest.rs
@@ -15,7 +15,7 @@
 
 use core::marker::PhantomData;
 
-use crate::ForeignTypeRef;
+use crate::{ForeignTypeRef, CSlice};
 
 /// The SHA-256 digest algorithm.
 #[derive(Clone)]
@@ -110,10 +110,11 @@
 
     /// Hashes the provided input into the current digest operation.
     pub fn update(&mut self, data: &[u8]) {
+        let data_ffi = CSlice(data);
         // Safety:
-        // - `data` is a slice from safe Rust.
+        // - `data` is a CSlice from safe Rust.
         let result = unsafe {
-            bssl_sys::EVP_DigestUpdate(&mut self.0, data.as_ptr() as *const _, data.len())
+            bssl_sys::EVP_DigestUpdate(&mut self.0, data_ffi.as_ptr() as *const _, data_ffi.len())
         };
         assert_eq!(result, 1, "bssl_sys::EVP_DigestUpdate failed");
     }
diff --git a/rust/bssl-crypto/src/ed25519.rs b/rust/bssl-crypto/src/ed25519.rs
index df36507..f4ab5be 100644
--- a/rust/bssl-crypto/src/ed25519.rs
+++ b/rust/bssl-crypto/src/ed25519.rs
@@ -89,14 +89,15 @@
     pub fn sign(&self, msg: &[u8]) -> Signature {
         let mut sig_bytes = [0u8; SIGNATURE_LENGTH];
 
+        let msg_ffi = CSlice(msg);
         // Safety:
         // - On allocation failure we panic.
         // - Signature and private keys are always the correct length.
         let result = unsafe {
             bssl_sys::ED25519_sign(
                 sig_bytes.as_mut_ptr(),
-                msg.as_ptr(),
-                msg.len(),
+                msg_ffi.as_ptr(),
+                msg_ffi.len(),
                 self.0.as_ptr(),
             )
         };