xref: /aosp_15_r20/system/keymint/wire/src/secureclock.rs (revision 9860b7637a5f185913c70aa0caabe3ecb78441e4)
1*9860b763SAndroid Build Coastguard Worker // Copyright 2022, The Android Open Source Project
2*9860b763SAndroid Build Coastguard Worker //
3*9860b763SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License");
4*9860b763SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License.
5*9860b763SAndroid Build Coastguard Worker // You may obtain a copy of the License at
6*9860b763SAndroid Build Coastguard Worker //
7*9860b763SAndroid Build Coastguard Worker //     http://www.apache.org/licenses/LICENSE-2.0
8*9860b763SAndroid Build Coastguard Worker //
9*9860b763SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software
10*9860b763SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS,
11*9860b763SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*9860b763SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and
13*9860b763SAndroid Build Coastguard Worker // limitations under the License.
14*9860b763SAndroid Build Coastguard Worker 
15*9860b763SAndroid Build Coastguard Worker //! Local types that are equivalent to those generated for the SecureClock HAL interface
16*9860b763SAndroid Build Coastguard Worker 
17*9860b763SAndroid Build Coastguard Worker use crate::{cbor_type_error, AsCborValue, CborError};
18*9860b763SAndroid Build Coastguard Worker use alloc::{
19*9860b763SAndroid Build Coastguard Worker     format,
20*9860b763SAndroid Build Coastguard Worker     string::{String, ToString},
21*9860b763SAndroid Build Coastguard Worker     vec::Vec,
22*9860b763SAndroid Build Coastguard Worker };
23*9860b763SAndroid Build Coastguard Worker use kmr_derive::AsCborValue;
24*9860b763SAndroid Build Coastguard Worker 
25*9860b763SAndroid Build Coastguard Worker pub const TIME_STAMP_MAC_LABEL: &[u8] = b"Auth Verification";
26*9860b763SAndroid Build Coastguard Worker 
27*9860b763SAndroid Build Coastguard Worker #[derive(Debug, Clone, Eq, Hash, PartialEq, AsCborValue)]
28*9860b763SAndroid Build Coastguard Worker pub struct TimeStampToken {
29*9860b763SAndroid Build Coastguard Worker     pub challenge: i64,
30*9860b763SAndroid Build Coastguard Worker     pub timestamp: Timestamp,
31*9860b763SAndroid Build Coastguard Worker     pub mac: Vec<u8>,
32*9860b763SAndroid Build Coastguard Worker }
33*9860b763SAndroid Build Coastguard Worker 
34*9860b763SAndroid Build Coastguard Worker #[derive(Debug, Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd, AsCborValue)]
35*9860b763SAndroid Build Coastguard Worker pub struct Timestamp {
36*9860b763SAndroid Build Coastguard Worker     pub milliseconds: i64,
37*9860b763SAndroid Build Coastguard Worker }
38