[bssl] Retrieve error code from BoringSSL

This cl retrieves the error code from BoringSSL when an operation
fails and returns it to the users.

Test: atest rialto_test
Bug: 302527194
Change-Id: I36da67c2ff9e7f45aea8db659d400c347d9705ca
diff --git a/libs/bssl/src/util.rs b/libs/bssl/src/util.rs
index cb5e368..880c85b 100644
--- a/libs/bssl/src/util.rs
+++ b/libs/bssl/src/util.rs
@@ -14,13 +14,14 @@
 
 //! Utility functions.
 
+use crate::err::get_error_reason_code;
 use bssl_avf_error::{ApiName, Error, Result};
 use log::error;
 
 pub(crate) fn check_int_result(ret: i32, api_name: ApiName) -> Result<()> {
     match ret {
         1 => Ok(()),
-        0 => Err(Error::CallFailed(api_name)),
+        0 => Err(Error::CallFailed(api_name, get_error_reason_code())),
         _ => {
             error!(
                 "Received a return value ({}) other than 0 or 1 from the BoringSSL API: {:?}",
@@ -30,3 +31,7 @@
         }
     }
 }
+
+pub(crate) fn to_call_failed_error(api_name: ApiName) -> Error {
+    Error::CallFailed(api_name, get_error_reason_code())
+}