Add crypto libraries

Add C++ versions of the BoringSSL crypto functions we need (copied
from keystore) and create Rust wrappers for them.

Test: atest keystore2_test
Change-Id: I21ff8630df26ca73ae36395c5303270e96a6deb6
diff --git a/keystore2/Android.bp b/keystore2/Android.bp
index a1ee969..526fd86 100644
--- a/keystore2/Android.bp
+++ b/keystore2/Android.bp
@@ -44,6 +44,7 @@
         "libandroid_hardware_keymint",
         "libanyhow",
         "libbinder_rs",
+        "libkeystore2_crypto_bindgen",
         "libkeystore2_selinux",
         "liblazy_static",
         "liblibsqlite3_sys",
@@ -51,6 +52,24 @@
         "librusqlite",
         "libthiserror",
     ],
+    shared_libs: ["libkeystore2_crypto"],
+}
+
+cc_library {
+    name: "libkeystore2_crypto",
+    srcs: ["src/crypto.cpp"],
+    shared_libs: [
+        "libcrypto",
+        "liblog",
+    ],
+}
+
+rust_bindgen {
+    name: "libkeystore2_crypto_bindgen",
+    wrapper_src: "src/crypto.hpp",
+    crate_name: "keystore2_crypto_bindgen",
+    source_stem: "bindings",
+    host_supported: true,
 }
 
 rust_binary {