• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #[cfg(feature = "alloc")]
21 extern crate alloc;
22 
23 #[cfg(not(feature = "std"))]
24 extern crate core as std;
25 
26 mod bcc;
27 mod dice;
28 mod error;
29 mod ops;
30 #[cfg(feature = "alloc")]
31 mod retry;
32 
33 pub use bcc::{
34     bcc_format_config_descriptor, bcc_handover_main_flow, bcc_handover_parse, bcc_main_flow,
35     BccHandover, DiceConfigValues,
36 };
37 pub use dice::{
38     derive_cdi_certificate_id, derive_cdi_private_key_seed, dice_main_flow, Cdi, CdiValues, Config,
39     DiceArtifacts, DiceMode, Hash, Hidden, InlineConfig, InputValues, PrivateKey, PrivateKeySeed,
40     PublicKey, Signature, CDI_SIZE, HASH_SIZE, HIDDEN_SIZE, ID_SIZE, PRIVATE_KEY_SEED_SIZE,
41 };
42 pub use error::{DiceError, Result};
43 // Currently, open-dice library only supports a single signing and verification algorithm.
44 // The value of DICE_COSE_KEY_ALG_VALUE depends on the algorithm chosen by the underlying C
45 // library at build time. Refer to b/342333212 for more information.
46 pub use open_dice_cbor_bindgen::DICE_COSE_KEY_ALG_VALUE;
47 pub use ops::{
48     derive_cdi_leaf_priv, generate_certificate, hash, kdf, keypair_from_seed, sign, verify,
49 };
50 #[cfg(feature = "alloc")]
51 pub use retry::{
52     retry_bcc_format_config_descriptor, retry_bcc_main_flow, retry_dice_main_flow,
53     retry_generate_certificate, OwnedDiceArtifacts,
54 };
55