xref: /aosp_15_r20/external/boringssl/selftest/boringssl_self_test.cpp (revision 8fb009dc861624b67b6cdb62ea21f0f22d0c584b)
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <openssl/crypto.h>
18 
19 // This program is run early during boot and if it exits with a
20 // failure status then the device will reboot to the bootloader.
21 // See init.rc for details.
22 // It may also exit before reaching main() if BoringSSL fast tests fail.
main(int,char **)23 int main(int, char**) {
24     if (!FIPS_mode()) {
25         return 1;  // Fail: BoringSSL not built in FIPS mode.
26     }
27     if (!BORINGSSL_self_test()) {
28         return 1;  // Fail: One or more self tests failed.
29     }
30     return 0;      // Success
31 }
32