1 // Copyright 2023, The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! Implements safe wrappers around the public API of libopen-dice for
16 //! both std and nostd usages.
17 
18 #![cfg_attr(not(feature = "std"), no_std)]
19 
20 extern crate alloc;
21 
22 #[cfg(not(feature = "std"))]
23 extern crate core as std;
24 
25 mod bcc;
26 mod dice;
27 mod error;
28 mod ops;
29 mod retry;
30 
31 #[cfg(feature = "multialg")]
32 pub use bcc::bcc_handover_main_flow;
33 pub use bcc::{
34     bcc_format_config_descriptor, bcc_handover_parse, bcc_main_flow, BccHandover, DiceConfigValues,
35 };
36 #[cfg(feature = "multialg")]
37 pub use dice::DiceContext;
38 pub use dice::{
39     derive_cdi_certificate_id, derive_cdi_private_key_seed, dice_main_flow, Cdi, CdiValues, Config,
40     DiceArtifacts, DiceMode, Hash, Hidden, InlineConfig, InputValues, KeyAlgorithm, PrivateKey,
41     PrivateKeySeed, CDI_SIZE, HASH_SIZE, HIDDEN_SIZE, ID_SIZE, PRIVATE_KEY_SEED_SIZE,
42     VM_KEY_ALGORITHM,
43 };
44 pub use error::{DiceError, Result};
45 pub use ops::{
46     derive_cdi_leaf_priv, generate_certificate, hash, kdf, keypair_from_seed, sign, verify,
47 };
48 pub use retry::{
49     retry_bcc_format_config_descriptor, retry_bcc_main_flow, retry_dice_main_flow,
50     retry_generate_certificate, OwnedDiceArtifacts,
51 };
52