firmware_uefi_custom_vars/
delta.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Data types which define a "delta" operation on a
5//! [`CustomVars`](super::CustomVars) struct.
6
7use super::CustomVar;
8use super::Signature;
9
10/// Collection of custom UEFI nvram variables.
11#[derive(Debug)]
12pub struct CustomVarsDelta {
13    /// Secure Boot signature vars
14    pub signatures: SignaturesDelta,
15    /// Any additional custom vars
16    pub custom_vars: Vec<(String, CustomVar)>,
17}
18
19#[derive(Debug)]
20pub enum SignaturesDelta {
21    /// Vars should append onto underlying template
22    Append(SignaturesAppend),
23    /// Vars should replace the underlying template
24    Replace(SignaturesReplace),
25}
26
27/// Append CANNOT be used with `pk`
28#[derive(Debug, Clone)]
29pub struct SignaturesAppend {
30    pub kek: Option<Vec<Signature>>,
31    pub db: Option<Vec<Signature>>,
32    pub dbx: Option<Vec<Signature>>,
33    pub moklist: Option<Vec<Signature>>,
34    pub moklistx: Option<Vec<Signature>>,
35}
36
37/// Replace MUST include the base secure boot vars, and may optionally include
38/// the moklist vars.
39#[derive(Debug, Clone)]
40pub struct SignaturesReplace {
41    pub pk: SignatureDelta,
42    pub kek: SignatureDeltaVec,
43    pub db: SignatureDeltaVec,
44    pub dbx: SignatureDeltaVec,
45    pub moklist: Option<SignatureDeltaVec>,
46    pub moklistx: Option<SignatureDeltaVec>,
47}
48
49#[derive(Debug, Clone)]
50pub enum SignatureDelta {
51    Sig(Signature),
52    /// "Default" will pull the value of the signature from the specified
53    /// hardcoded template (and fail if one wasn't specified)
54    ///
55    /// It shouldn't be used in the hardcoded templates
56    Default,
57}
58
59#[derive(Debug, Clone)]
60pub enum SignatureDeltaVec {
61    Sigs(Vec<Signature>),
62    /// "Default" will pull the value of the signature from the specified
63    /// hardcoded template (and fail if one wasn't specified)
64    ///
65    /// It shouldn't be used in the hardcoded templates
66    Default,
67}