xref: /aosp_15_r20/external/avb/rust/src/lib.rs (revision d289c2ba6de359471b23d594623b906876bc48a0)
1*d289c2baSAndroid Build Coastguard Worker // Copyright 2023, The Android Open Source Project
2*d289c2baSAndroid Build Coastguard Worker //
3*d289c2baSAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*d289c2baSAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*d289c2baSAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*d289c2baSAndroid Build Coastguard Worker //
7*d289c2baSAndroid Build Coastguard Worker //     http://www.apache.org/licenses/LICENSE-2.0
8*d289c2baSAndroid Build Coastguard Worker //
9*d289c2baSAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*d289c2baSAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*d289c2baSAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*d289c2baSAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*d289c2baSAndroid Build Coastguard Worker // limitations under the License.
14*d289c2baSAndroid Build Coastguard Worker 
15*d289c2baSAndroid Build Coastguard Worker //! Rust libavb.
16*d289c2baSAndroid Build Coastguard Worker //!
17*d289c2baSAndroid Build Coastguard Worker //! This library wraps the libavb C code with safe Rust APIs. This does not materially affect the
18*d289c2baSAndroid Build Coastguard Worker //! safety of the library itself, since the internal implementation is still C. The goal here is
19*d289c2baSAndroid Build Coastguard Worker //! instead to provide a simple way to use libavb from Rust, in order to make Rust a more
20*d289c2baSAndroid Build Coastguard Worker //! appealing option for code that may want to use libavb such as bootloaders.
21*d289c2baSAndroid Build Coastguard Worker //!
22*d289c2baSAndroid Build Coastguard Worker //! This library is [no_std] for portability.
23*d289c2baSAndroid Build Coastguard Worker 
24*d289c2baSAndroid Build Coastguard Worker // ANDROID: Use std to allow building as a dylib.
25*d289c2baSAndroid Build Coastguard Worker // This condition lets us make the hack to add a dependency on std for the
26*d289c2baSAndroid Build Coastguard Worker // panic_handler and eh_personality conditional on actually building a dylib.
27*d289c2baSAndroid Build Coastguard Worker #![cfg_attr(not(any(test, android_dylib)), no_std)]
28*d289c2baSAndroid Build Coastguard Worker 
29*d289c2baSAndroid Build Coastguard Worker mod cert;
30*d289c2baSAndroid Build Coastguard Worker mod descriptor;
31*d289c2baSAndroid Build Coastguard Worker mod error;
32*d289c2baSAndroid Build Coastguard Worker mod ops;
33*d289c2baSAndroid Build Coastguard Worker mod verify;
34*d289c2baSAndroid Build Coastguard Worker 
35*d289c2baSAndroid Build Coastguard Worker pub use cert::{
36*d289c2baSAndroid Build Coastguard Worker     cert_generate_unlock_challenge, cert_validate_unlock_credential,
37*d289c2baSAndroid Build Coastguard Worker     cert_validate_vbmeta_public_key, CertOps, CertPermanentAttributes, CertUnlockChallenge,
38*d289c2baSAndroid Build Coastguard Worker     CertUnlockCredential, CERT_PIK_VERSION_LOCATION, CERT_PSK_VERSION_LOCATION, SHA256_DIGEST_SIZE,
39*d289c2baSAndroid Build Coastguard Worker };
40*d289c2baSAndroid Build Coastguard Worker pub use descriptor::{
41*d289c2baSAndroid Build Coastguard Worker     ChainPartitionDescriptor, ChainPartitionDescriptorFlags, Descriptor, DescriptorError,
42*d289c2baSAndroid Build Coastguard Worker     DescriptorResult, HashDescriptor, HashDescriptorFlags, HashtreeDescriptor,
43*d289c2baSAndroid Build Coastguard Worker     HashtreeDescriptorFlags, KernelCommandlineDescriptor, KernelCommandlineDescriptorFlags,
44*d289c2baSAndroid Build Coastguard Worker     PropertyDescriptor,
45*d289c2baSAndroid Build Coastguard Worker };
46*d289c2baSAndroid Build Coastguard Worker pub use error::{
47*d289c2baSAndroid Build Coastguard Worker     IoError, IoResult, SlotVerifyError, SlotVerifyNoDataResult, SlotVerifyResult,
48*d289c2baSAndroid Build Coastguard Worker     VbmetaVerifyError, VbmetaVerifyResult,
49*d289c2baSAndroid Build Coastguard Worker };
50*d289c2baSAndroid Build Coastguard Worker pub use ops::{Ops, PublicKeyForPartitionInfo};
51*d289c2baSAndroid Build Coastguard Worker pub use verify::{
52*d289c2baSAndroid Build Coastguard Worker     slot_verify, HashtreeErrorMode, PartitionData, SlotVerifyData, SlotVerifyFlags, VbmetaData,
53*d289c2baSAndroid Build Coastguard Worker };
54