1 // Copyright 2024, 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 //! Gbl AVB state (version, color, etc). 16 17 use core::fmt::{Display, Formatter}; 18 19 /// https://source.android.com/docs/security/features/verifiedboot/boot-flow#communicating-verified-boot-state-to-users 20 #[derive(Clone, Copy, PartialEq)] 21 pub enum BootStateColor { 22 /// Success . 23 Green, 24 /// Success but custom key is used. 25 Yellow, 26 /// Device is unlocked. 27 Orange, 28 /// Dm-verity is corrupted. 29 RedEio, 30 /// No valid OS found. 31 Red, 32 } 33 34 /// To use in bootconfig. 35 impl Display for BootStateColor { fmt(&self, f: &mut Formatter) -> core::fmt::Result36 fn fmt(&self, f: &mut Formatter) -> core::fmt::Result { 37 f.write_str(match self { 38 BootStateColor::Green => "green", 39 BootStateColor::Yellow => "yellow", 40 BootStateColor::Orange => "orange", 41 BootStateColor::RedEio => "red_eio", 42 BootStateColor::Red => "red", 43 }) 44 } 45 } 46 47 /// https://source.android.com/docs/security/features/verifiedboot/boot-flow#locked-devices-with-custom-root-of-trust 48 #[derive(Clone, Copy, Debug, PartialEq)] 49 pub enum KeyValidationStatus { 50 /// Vbmeta key is matched with a production key. 51 Valid, 52 /// Vbmeta key is matched with a custom key. 53 ValidCustomKey, 54 /// Vbmeta key isn't matched. 55 Invalid, 56 } 57