Skip to main content

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//! [`UefiVars`](super::UefiVars) struct.
6
7use super::Signature;
8use super::UefiVar;
9
10/// Changes to apply to a collection of UEFI nvram variables.
11#[derive(Debug, Clone)]
12pub struct UefiVarsDelta {
13    /// Secure Boot signature vars
14    pub signatures: SignaturesDelta,
15    /// UEFI vars that are not Secure Boot signature vars
16    pub non_signature_vars: Vec<(String, UefiVar)>,
17}
18
19#[derive(Debug, Clone)]
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 the underlying template signatures, optionally using `Default` values
38/// from a base template. If no base template is provided, all required signature
39/// values must be specified explicitly.
40#[derive(Debug, Clone)]
41pub struct SignaturesReplace {
42    pub pk: SignatureDelta,
43    pub kek: SignatureDeltaVec,
44    pub db: SignatureDeltaVec,
45    pub dbx: SignatureDeltaVec,
46    pub moklist: Option<SignatureDeltaVec>,
47    pub moklistx: Option<SignatureDeltaVec>,
48}
49
50#[derive(Debug, Clone)]
51pub enum SignatureDelta {
52    Sig(Signature),
53    /// "Default" will pull the value of the signature from the specified
54    /// hardcoded template (and fail if one wasn't specified)
55    ///
56    /// It shouldn't be used in the hardcoded templates
57    Default,
58}
59
60#[derive(Debug, Clone)]
61pub enum SignatureDeltaVec {
62    Sigs(Vec<Signature>),
63    /// "Default" will pull the value of the signature from the specified
64    /// hardcoded template (and fail if one wasn't specified)
65    ///
66    /// It shouldn't be used in the hardcoded templates
67    Default,
68}