1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Data types which define a "delta" operation on a
//! [`CustomVars`](super::CustomVars) struct.

use super::CustomVar;
use super::Signature;

/// Collection of custom UEFI nvram variables.
#[derive(Debug)]
pub struct CustomVarsDelta {
    /// Secure Boot signature vars
    pub signatures: SignaturesDelta,
    /// Any additional custom vars
    pub custom_vars: Vec<(String, CustomVar)>,
}

#[derive(Debug)]
pub enum SignaturesDelta {
    /// Vars should append onto underlying template
    Append(SignaturesAppend),
    /// Vars should replace the underlying template
    Replace(SignaturesReplace),
}

/// Append CANNOT be used with `pk`
#[derive(Debug, Clone)]
pub struct SignaturesAppend {
    pub kek: Option<Vec<Signature>>,
    pub db: Option<Vec<Signature>>,
    pub dbx: Option<Vec<Signature>>,
    pub moklist: Option<Vec<Signature>>,
    pub moklistx: Option<Vec<Signature>>,
}

/// Replace MUST include the base secure boot vars, and may optionally include
/// the moklist vars.
#[derive(Debug, Clone)]
pub struct SignaturesReplace {
    pub pk: SignatureDelta,
    pub kek: SignatureDeltaVec,
    pub db: SignatureDeltaVec,
    pub dbx: SignatureDeltaVec,
    pub moklist: Option<SignatureDeltaVec>,
    pub moklistx: Option<SignatureDeltaVec>,
}

#[derive(Debug, Clone)]
pub enum SignatureDelta {
    Sig(Signature),
    /// "Default" will pull the value of the signature from the specified
    /// hardcoded template (and fail if one wasn't specified)
    ///
    /// It shouldn't be used in the hardcoded templates
    Default,
}

#[derive(Debug, Clone)]
pub enum SignatureDeltaVec {
    Sigs(Vec<Signature>),
    /// "Default" will pull the value of the signature from the specified
    /// hardcoded template (and fail if one wasn't specified)
    ///
    /// It shouldn't be used in the hardcoded templates
    Default,
}