summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2019-10-21 12:49:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-10-21 12:49:33 +0000
commitbfc55bd05b4f71713a0e7ecf46ddf76ba90b01d2 (patch)
tree674d759d76017ce859c30f0a31de84382697ed7a
parent65d184c9f337bb7f461060e3808e07164cb0d236 (diff)
parent7ea5d8b7b12fb0e36b386604182799df9d88a176 (diff)
downloadboringssl-bfc55bd05b4f71713a0e7ecf46ddf76ba90b01d2.tar.gz
Merge "Move BoringSSL self test binaries to external/boringssl."
-rw-r--r--selftest/Android.bp50
-rw-r--r--selftest/boringssl_self_test.cpp27
-rw-r--r--selftest/boringssl_self_test.rc15
3 files changed, 92 insertions, 0 deletions
diff --git a/selftest/Android.bp b/selftest/Android.bp
new file mode 100644
index 00000000..5e92441b
--- /dev/null
+++ b/selftest/Android.bp
@@ -0,0 +1,50 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+ name: "boringssl_self_test_defaults",
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+ shared_libs: [
+ "libcrypto",
+ ],
+ srcs: [
+ "boringssl_self_test.cpp",
+ ],
+}
+
+cc_binary {
+ name: "boringssl_self_test",
+ visibility: [
+ "//external/conscrypt/apex",
+ "//external/conscrypt/apex/testing",
+ ],
+ defaults: ["boringssl_self_test_defaults"],
+}
+
+cc_binary {
+ name: "boringssl_self_test_vendor",
+ defaults: ["boringssl_self_test_defaults"],
+ stem: "boringssl_self_test",
+ vendor: true,
+ init_rc: ["boringssl_self_test.rc"],
+}
diff --git a/selftest/boringssl_self_test.cpp b/selftest/boringssl_self_test.cpp
new file mode 100644
index 00000000..3d2d5209
--- /dev/null
+++ b/selftest/boringssl_self_test.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <openssl/crypto.h>
+
+int main(int, char**) {
+ // If we get here, then libcrypto is either in FIPS mode (in which case
+ // it doesn't run the self test), or the self test has passed. If the
+ // self test ran and failed, then libcrypto will already have abort()ed.
+ if (!FIPS_mode()) {
+ return 1; // failure
+ }
+ return 0; // success
+}
diff --git a/selftest/boringssl_self_test.rc b/selftest/boringssl_self_test.rc
new file mode 100644
index 00000000..dc08111e
--- /dev/null
+++ b/selftest/boringssl_self_test.rc
@@ -0,0 +1,15 @@
+# Run boringssl self test for each ABI so that later processes can skip it. http://b/139348610
+on early-init && property:ro.product.cpu.abilist32=*
+ exec_start boringssl_self_test32_vendor
+on early-init && property:ro.product.cpu.abilist64=*
+ exec_start boringssl_self_test64_vendor
+
+service boringssl_self_test32_vendor /vendor/bin/boringssl_self_test32
+ setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true
+ reboot_on_failure reboot,boringssl-self-check-failed
+ stdio_to_kmsg
+
+service boringssl_self_test64_vendor /vendor/bin/boringssl_self_test64
+ setenv BORINGSSL_SELF_TEST_CREATE_FLAG true # Any nonempty value counts as true
+ reboot_on_failure reboot,boringssl-self-check-failed
+ stdio_to_kmsg