#![expect(missing_docs)]
#![forbid(unsafe_code)]
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ParseJsonError {
#[error("malformed JSON: {0}")]
Json(#[from] serde_json::Error),
#[error("semantic error when parsing delta: {0}")]
SemanticDelta(#[from] convert::JsonToDeltaError),
#[error("semantic error when parsing template: {0}")]
SemanticTemplate(#[from] JsonToTemplateError),
}
#[derive(Debug, Error)]
pub enum JsonToTemplateError {
#[error("template cannot use \"Default\" variable type")]
CannotUseDefault,
#[error("template cannot use \"append\" operations")]
CannotUseAppend,
}
pub fn load_template_from_json(
data: &[u8],
) -> Result<firmware_uefi_custom_vars::CustomVars, ParseJsonError> {
use firmware_uefi_custom_vars::CustomVars;
use firmware_uefi_custom_vars::Signature;
use firmware_uefi_custom_vars::Signatures;
use firmware_uefi_custom_vars::delta::CustomVarsDelta;
use firmware_uefi_custom_vars::delta::SignatureDelta;
use firmware_uefi_custom_vars::delta::SignatureDeltaVec;
use firmware_uefi_custom_vars::delta::SignaturesDelta;
fn deny_default(sig: SignatureDelta) -> Result<Signature, JsonToTemplateError> {
match sig {
SignatureDelta::Sig(sig) => Ok(sig),
SignatureDelta::Default => Err(JsonToTemplateError::CannotUseDefault),
}
}
fn deny_default_vec(sigs: SignatureDeltaVec) -> Result<Vec<Signature>, JsonToTemplateError> {
match sigs {
SignatureDeltaVec::Sigs(sig) => Ok(sig),
SignatureDeltaVec::Default => Err(JsonToTemplateError::CannotUseDefault),
}
}
let CustomVarsDelta {
signatures,
custom_vars,
} = load_delta_from_json(data)?;
Ok(CustomVars {
signatures: Some(match signatures {
SignaturesDelta::Append(_) => panic!("hardcoded templates cannot use append"),
SignaturesDelta::Replace(signatures) => Signatures {
pk: deny_default(signatures.pk)?,
kek: deny_default_vec(signatures.kek)?,
db: deny_default_vec(signatures.db)?,
dbx: deny_default_vec(signatures.dbx)?,
moklist: signatures
.moklist
.map(deny_default_vec)
.transpose()?
.unwrap_or_default(),
moklistx: signatures
.moklistx
.map(deny_default_vec)
.transpose()?
.unwrap_or_default(),
},
}),
custom_vars,
})
}
pub fn load_delta_from_json(
data: &[u8],
) -> Result<firmware_uefi_custom_vars::delta::CustomVarsDelta, ParseJsonError> {
let json: json::JsonRoot = serde_json::from_slice(data)?;
let delta = convert::json_to_delta(json)?;
Ok(delta)
}
mod json {
use guid::Guid;
use serde::Deserialize;
use std::collections::BTreeMap;
#[derive(Debug, Deserialize)]
pub struct JsonRoot {
#[serde(rename = "type", deserialize_with = "parse::validate_root_type")]
pub _type: (),
#[serde(rename = "properties")]
pub properties: Properties,
}
#[derive(Debug, Deserialize)]
pub struct Properties {
#[serde(rename = "uefiSettings")]
pub uefi_settings: UefiSettings,
}
#[derive(Debug, Deserialize)]
#[serde(tag = "signatureMode", content = "signatures")]
pub enum Signatures {
#[serde(rename = "Append")]
Append(SignaturesAppend),
#[serde(rename = "Replace")]
Replace(SignaturesReplace),
}
#[derive(Debug, Deserialize)]
pub struct UefiSettings {
#[serde(flatten)]
pub signatures: Signatures,
#[serde(flatten)]
pub custom_vars: BTreeMap<String, CustomVar>,
}
#[derive(Debug, Deserialize)]
pub struct CustomVar {
#[serde(rename = "guid", deserialize_with = "parse::base64_guid")]
pub guid: Guid,
#[serde(rename = "attributes", deserialize_with = "parse::base64_u32")]
pub attr: u32,
#[serde(rename = "value", with = "serde_helpers::base64_vec")]
pub value: Vec<u8>,
}
#[derive(Debug, Deserialize)]
pub struct SignaturesAppend {
#[serde(rename = "KEK")]
pub kek: Option<Vec<Signature>>,
#[serde(rename = "db")]
pub db: Option<Vec<Signature>>,
#[serde(rename = "dbx")]
pub dbx: Option<Vec<Signature>>,
#[serde(rename = "MokList")]
pub moklist: Option<Vec<Signature>>,
#[serde(rename = "MokListX")]
pub moklistx: Option<Vec<Signature>>,
}
#[derive(Debug, Deserialize)]
pub struct SignaturesReplace {
#[serde(rename = "PK")]
pub pk: Signature,
#[serde(rename = "KEK")]
pub kek: Vec<Signature>,
#[serde(rename = "db")]
pub db: Vec<Signature>,
#[serde(rename = "dbx")]
pub dbx: Vec<Signature>,
#[serde(rename = "MokList")]
pub moklist: Option<Vec<Signature>>,
#[serde(rename = "MokListX")]
pub moklistx: Option<Vec<Signature>>,
}
#[derive(Debug, Deserialize)]
#[serde(tag = "type")]
pub enum Signature {
#[serde(rename = "x509")]
X509 { value: Vec<X509Cert> },
#[serde(rename = "sha256")]
Sha256 { value: Vec<Sha256Digest> },
#[serde(rename = "Default")]
Default,
}
#[derive(Debug, Deserialize)]
#[serde(transparent)]
pub struct X509Cert {
#[serde(with = "serde_helpers::base64_vec")]
pub data: Vec<u8>,
}
#[derive(Debug, Deserialize)]
#[serde(transparent)]
pub struct Sha256Digest {
#[serde(deserialize_with = "parse::base64_u8_32")]
pub data: [u8; 32],
}
mod parse {
use base64::Engine;
use guid::Guid;
use serde::Deserialize;
use serde::Deserializer;
use zerocopy::FromBytes;
pub fn validate_root_type<'de, D: Deserializer<'de>>(d: D) -> Result<(), D::Error> {
let s: &str = Deserialize::deserialize(d)?;
if s != "Microsoft.Compute/disks" {
return Err(serde::de::Error::custom(
r#"root "type" must be "Microsoft.Compute/disks""#,
));
}
Ok(())
}
pub fn base64_u8_32<'de, D: Deserializer<'de>>(d: D) -> Result<[u8; 32], D::Error> {
let s: &str = Deserialize::deserialize(d)?;
let v = base64::engine::general_purpose::STANDARD
.decode(s)
.map_err(serde::de::Error::custom)?;
v.try_into().map_err(|v: Vec<_>| {
serde::de::Error::custom(format!("expected 32 bytes. found {} bytes", v.len()))
})
}
#[expect(clippy::many_single_char_names)]
pub fn base64_u32<'de, D: Deserializer<'de>>(d: D) -> Result<u32, D::Error> {
let s: &str = Deserialize::deserialize(d)?;
let v = base64::engine::general_purpose::STANDARD
.decode(s)
.map_err(serde::de::Error::custom)?;
let v: [u8; 4] = match v.as_slice() {
&[a] => [a, 0, 0, 0],
&[a, b] => [a, b, 0, 0],
&[a, b, c] => [a, b, c, 0],
&[a, b, c, d] => [a, b, c, d],
other => {
return Err(serde::de::Error::custom(format!(
"expected 4 bytes. found {} bytes",
other.len()
)));
}
};
Ok(u32::from_le_bytes(v))
}
pub fn base64_guid<'de, D: Deserializer<'de>>(d: D) -> Result<Guid, D::Error> {
let s: &str = Deserialize::deserialize(d)?;
let v = base64::engine::general_purpose::STANDARD
.decode(s)
.map_err(serde::de::Error::custom)?;
if v.len() != size_of::<Guid>() {
return Err(serde::de::Error::custom(format!(
"expected {} bytes. found {} bytes",
size_of::<Guid>(),
v.len()
)));
}
Ok(Guid::read_from_prefix(v.as_slice()).unwrap().0) }
}
}
mod convert {
use super::json;
use firmware_uefi_custom_vars as base;
use firmware_uefi_custom_vars::delta;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum JsonToDeltaError {
#[error("Default can only be used once per signature array")]
MultipleDefault,
#[error("Default cannot be used alongside any other vars in the signature array")]
DefaultWithOtherVars,
#[error("Default cannot be used alongside Append")]
DefaultWithAppend,
}
fn validate_default(
sigs: Vec<delta::SignatureDelta>,
) -> Result<delta::SignatureDeltaVec, JsonToDeltaError> {
let num_sigs = sigs.len();
let num_defaults = sigs
.iter()
.filter(|s| matches!(s, delta::SignatureDelta::Default))
.count();
let sigs = sigs
.into_iter()
.map(|s| match s {
delta::SignatureDelta::Default => None,
delta::SignatureDelta::Sig(sig) => Some(sig),
})
.collect::<Option<Vec<_>>>();
match sigs {
Some(sigs) => Ok(delta::SignatureDeltaVec::Sigs(sigs)),
None => {
if num_defaults != 1 {
return Err(JsonToDeltaError::MultipleDefault);
}
if num_sigs != 1 {
return Err(JsonToDeltaError::DefaultWithOtherVars);
}
Ok(delta::SignatureDeltaVec::Default)
}
}
}
fn deny_default(sig_delta: json::Signature) -> Result<base::Signature, JsonToDeltaError> {
let ret = match sig_delta {
json::Signature::X509 { value } => {
base::Signature::X509(value.into_iter().map(Into::into).collect())
}
json::Signature::Sha256 { value } => {
base::Signature::Sha256(value.into_iter().map(Into::into).collect())
}
json::Signature::Default => return Err(JsonToDeltaError::DefaultWithAppend),
};
Ok(ret)
}
fn json_to_base_sig_vec(
sigs: Vec<json::Signature>,
) -> Result<Vec<base::Signature>, JsonToDeltaError> {
sigs.into_iter()
.map(deny_default)
.collect::<Result<Vec<_>, _>>()
}
fn json_to_delta_sig_vec(sigs: Vec<json::Signature>) -> Vec<delta::SignatureDelta> {
sigs.into_iter().map(Into::into).collect()
}
pub(super) fn json_to_delta(
json: json::JsonRoot,
) -> Result<delta::CustomVarsDelta, JsonToDeltaError> {
let custom_vars: Vec<(String, base::CustomVar)> = json
.properties
.uefi_settings
.custom_vars
.into_iter()
.map(|(k, v)| (k, v.into()))
.collect();
let ret = match json.properties.uefi_settings.signatures {
json::Signatures::Append(json::SignaturesAppend {
kek,
db,
dbx,
moklist,
moklistx,
}) => delta::CustomVarsDelta {
signatures: delta::SignaturesDelta::Append(delta::SignaturesAppend {
kek: kek.map(json_to_base_sig_vec).transpose()?,
db: db.map(json_to_base_sig_vec).transpose()?,
dbx: dbx.map(json_to_base_sig_vec).transpose()?,
moklist: moklist.map(json_to_base_sig_vec).transpose()?,
moklistx: moklistx.map(json_to_base_sig_vec).transpose()?,
}),
custom_vars,
},
json::Signatures::Replace(json::SignaturesReplace {
pk,
kek,
db,
dbx,
moklist,
moklistx,
}) => delta::CustomVarsDelta {
signatures: delta::SignaturesDelta::Replace(delta::SignaturesReplace {
pk: pk.into(),
kek: validate_default(json_to_delta_sig_vec(kek))?,
db: validate_default(json_to_delta_sig_vec(db))?,
dbx: validate_default(json_to_delta_sig_vec(dbx))?,
moklist: moklist
.map(|sigs| validate_default(json_to_delta_sig_vec(sigs)))
.transpose()?,
moklistx: moklistx
.map(|sigs| validate_default(json_to_delta_sig_vec(sigs)))
.transpose()?,
}),
custom_vars,
},
};
Ok(ret)
}
impl From<json::CustomVar> for base::CustomVar {
fn from(json_custom_var: json::CustomVar) -> base::CustomVar {
base::CustomVar {
guid: json_custom_var.guid,
attr: json_custom_var.attr,
value: json_custom_var.value,
}
}
}
impl From<json::Signature> for delta::SignatureDelta {
fn from(json_signature: json::Signature) -> delta::SignatureDelta {
match json_signature {
json::Signature::X509 { value } => delta::SignatureDelta::Sig(
base::Signature::X509(value.into_iter().map(Into::into).collect()),
),
json::Signature::Sha256 { value } => delta::SignatureDelta::Sig(
base::Signature::Sha256(value.into_iter().map(Into::into).collect()),
),
json::Signature::Default => delta::SignatureDelta::Default,
}
}
}
impl From<json::Sha256Digest> for base::Sha256Digest {
fn from(json_digest: json::Sha256Digest) -> base::Sha256Digest {
base::Sha256Digest(json_digest.data)
}
}
impl From<json::X509Cert> for base::X509Cert {
fn from(json_cert: json::X509Cert) -> base::X509Cert {
base::X509Cert(json_cert.data)
}
}
}
#[cfg(test)]
mod test {
use super::*;
const APPEND: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Append",
"signatures": {
"db": [{
"type": "sha256",
"value": ["i4HHnT7SW4zUdcQ7LyvOyfVOTr9BxCWWoP/W3lqGE0Q=",
"ELLxN/fAUzttWO5WW3SOdJ4a99OAWy56o2ga46W1Efc="]
}],
"dbx": [{
"type": "sha256",
"value": ["Bkk5Ef7VzGk3M7FLY/MyHyl+ygAF1P8ju9HBSl53Cak=",
"h6/eEfJXfmqGLZWr/ekVjhQAiG3OlGw6Yi4MAbBjpqc="]
}]
}
}
}
}
"#;
#[test]
fn append() {
let data = serde_json::from_str::<json::JsonRoot>(APPEND);
let _ = data.unwrap();
}
const APPEND_DEFAULT: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Append",
"signatures": {
"db": [{
"type": "Default",
}]
}
}
}
}
"#;
#[test]
fn append_default() {
let data = serde_json::from_str::<json::JsonRoot>(APPEND_DEFAULT);
assert!(data.is_err())
}
const REPLACE_MALFORMED_DB: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Replace",
"signatures": {
"PK": {
"type": "x509",
"value": ["MIIHFjCCBP6gAwIBAgITMwAAACDxXiUkn6t10A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8rB2EvrfT9XNbLmT3W0sGADIlOukXkd1ptBHxWGVHCy3g01D3ywNHK6l2A78HnrorIcXaIWuIfF6Rv2tZclbzif45H6inmYw2kOt6McIAWX+MoUrgDXxPPAFBB1azSgG7WZYPNcsMVXTjbSMoS/ng=="]
}],
"db": [{
"type": "x509",
"value": ["InvalidKey"]
}],
"dbx": [{
"type": "Default"
}]
}
}
}
}
"#;
#[test]
fn replace_malformed_db() {
let data = serde_json::from_str::<json::JsonRoot>(REPLACE_MALFORMED_DB);
assert!(data.is_err())
}
const REPLACE_MISSING_SIGNATURE_MODE: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatures": {
"PK": {
"type": "x509",
"value": ["MIIHFjCCBP6gAwIBAgITMwAAACDxXiUkn6t10AAAAAAAIDANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjE6MDgGA1UEAxMxTWljcm9zb2Z0IENvcnBvcmF0aW9uIFRoaXJkIFBhcnR5IE1hcmtldHBsYWNlIFBDQTAeFw0xMzAxMjQyMjAyNDBaFw0xNDA0MjQyMjAyNDBaMHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBIeXBlci1WIEZpcm13YXJlIFBLMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAx+U8Ti27qO+TAIhy9goO+UPD7TSEPfB8kjYpY8FPaKSP3mngCInzaRaEOj26L05uo/XydIDHHxn078nTthGmyBbPUe1Vm8GjvFODiE3s7rzebPhFo+qKLjuZ35gjyx+5dyRmUqQ73/wLGz3GvGIpNMO+3KAdSWRUC804I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9cD1uLp4B6Mr/pvbNFaE7ILKrkElcJxr6f6QD9eWH+XnlB+yKgyNS/8oKRB799d8pdF2uQXIee0PkJKcwv7fb35sD3vUwUXdNFGWOQ/lXlbYGAWW9AemQrOgd/0IGfJxVsyfhiOkh8um/Vh+1GlnFZF+gfJ/E+UNi4o8h4Tr4869Q+WtLYSTjmorWnxE+lKqgcgtHLvgUt8AEfiaPcFgsOEztaOI0WUZChrnrHykwYKHTjixLw3FFIdv/Y0uvDm25+bD4OTNJ4TvlELvKYuQRkE7gRtn2PlDWWXLDbz9AJJP9HU7p6kk/FBBQHngLU8Kaid2blLtlml7rw/3hwXQRcKtUxSBH/swBKo3NmHaSmkbNNho7dYCz2yUDNPPbCJ5rbHwvAOiRmCpxAfCIYLx/fLoeTJgv9ispSIUS8rB2EvrfT9XNbLmT3W0sGADIlOukXkd1ptBHxWGVHCy3g01D3ywNHK6l2A78HnrorIcXaIWuIfF6Rv2tZclbzif45H6inmYw2kOt6McIAWX+MoUrgDXxPPAFBB1azSgG7WZYPNcsMVXTjbSMoS/ng=="]
}],
"dbx": [{
"type": "Default"
}]
}
}
}
}
"#;
#[test]
fn replace_missing_signature_mode() {
let data = serde_json::from_str::<json::JsonRoot>(REPLACE_MISSING_SIGNATURE_MODE);
assert!(data.is_err())
}
const REPLACE_MULTI_DEFAULT: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Replace",
"signatures": {
"PK": {
"type": "x509",
"value": ["MIIHFjCCBP6gAwIBAgITMwAAACDxXiUkn6t10AAAAAAAIDANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjE6MDgGA1UEAxMxTWljcm9zb2Z0IENvcnBvcmF0aW9uIFRoaXJkIFBhcnR5IE1hcmtldHBsYWNlIFBDQTAeFw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AwEB/zAfBgNVHSMEGDAWgBTV9lbLj+iiXGJo0T2UkFvXzpoYxDBWBgNVHR8ETzBNMEugSaBHhkVodHRwOi8vY3JsLm1pY3Jvc29mdC5jb20vcGtpL2NybC9wcm9kdWN0cy9NaWNSb29DZXJBdXRfMjAxMC0wNi0yMy5jcmwwWgYIKwYBBQUHAQEETjBMMEoGCCsGAQUFBzAChj5odHRwOi8vd3d3Lm1pY3Jvc29mdC5jb20vcGtpL2NlcnRzL01pY1Jvb0NlckF1dF8yMDEwLTA2LTIzLmNydDANBgkqhkiG9w0BAQsFAAOCAgEAFPx8cVGlecJusu85Prw8Ug9uKz8QE3P+qGjQSKY0TYqWBSbuMUaQYXnW/zguRWv0wOUouNodj4rbCdcax0wKNmZqjOwb1wSQqBgXpJu54kAyNnbEwVrGv+QEwOoW06zDaO9irN1UbFAwWKbrfP6Up06O9Ox8hnNXwlIhczRa86OKVsgE2gcJ7fiL4870fo6u8PYLigj7P8kdcn9TuOu+Y+DjPTFlsIHl8qzNFqSfPaixm8JC0JCEX1Qd/4nquh1HkG+wc05Bn0CfX+WhKrIRkXOKISjwzt5zOV8+q1xg7N8DEKjTCen09paFtn9RiGZHGY2isBI9gSpoBXe7kUxie7bBB8e6eoc0Aw5LYnqZ6cr8zko3yS2kV3wc/j3cuA9a+tbEswKFAjrqs9lu5GkhN96B0fZ1GQVn05NXXikbOcjuLeHN5EVzW9DSznqrFhmCRljQXp2Bs2evbDXyvOU/JOI1ogp1BvYYVpnUeCzRBRvr0IgBnaoQ8QXfun4sY7cGmyMhxPl4bOJYFwY2K5ESA8yk2fItuvmUnUDtGEXxzopcaz6rA9NwGCoKauBfR9HVYwoy8q/XNh8qcFrlQlkIcUtXun6DgfAhPPQcwcW5kJMOiEWThumxIJm+mMvFlaRdYtagYwggvXUQd30980W5n5efy1eAbzOpBM93pGIcWX4="]
}],
"dbx": [{
"type": "Default"
}]
}
}
}
}
"#;
#[test]
fn replace_multi_default() {
let data = serde_json::from_str::<json::JsonRoot>(REPLACE_MULTI_DEFAULT).unwrap();
let data = convert::json_to_delta(data);
assert!(data.is_err())
}
const REPLACE_MIXED_DEFAULT: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Replace",
"signatures": {
"PK": {
"type": "x509",
"value": ["MIIHFjCCBP6gAwIBAgITMwAAACDxXiUkn6t10AAAAAAAIDANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjE6MDgGA1UEAxMxTWljcm9zb2Z0IENvcnBvcmF0aW9uIFRoaXJkIFBhcnR5IE1hcmtldHBsYWNlIFBDQTAeFw0xMzAxMjQyMjAyNDBaFw0xNDA0MjQyMjAyNDBaMHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBIeXBlci1WIEZpcm13YXJlIFBLMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAx+U8Ti27qO+TAIhy9goO+UPD7TSEPfB8kjYpY8FPaKSP3mngCInzaRaEOj26L05uo/XydIDHHxn078nTthGmyBbPUe1Vm8GjvFODiE3s7rzebPhFo+qKLjuZ35gjyx+5dyRmUqQ73/wLGz3GvGIpNMO+3KAdSWRUC804IIsdZvtJPZYh0102A4pOMa+FaOzbe0js/b4SsHnHYt6ede0qvyRbuwSeJHliFYDH7qNpTv0sWCbn5P9z8vLgLCxjPTKOyN+F/08SuxtqO+oiwU8ph6ngmlWfHYWStX60iRFD2zPG2kTpckXooMQ5oKvMZo2SxHo6Oxa2KCaK73C8w/de0Rgwx1Uh6o+rIdnmNjUDNDGE+QYEvyU1azebL6TZ8sGOuU9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en09paFtn9RiGZHGY2isBI9gSpoBXe7kUxie7bBB8e6eoc0Aw5LYnqZ6cr8zko3yS2kV3wc/j3cuA9a+tbEswKFAjrqs9lu5GkhN96B0fZ1GQVn05NXXikbOcjuLeHN5EVzW9DSznqrFhmCRljQXp2Bs2evbDXyvOU/JOI1ogp1BvYYVpnUeCzRBRvr0IgBnaoQ8QXfun4sY7cGmyMhxPl4bOJYFwY2K5ESA8yk2fItuvmUnUDtGEXxzopcaz6rA9NwGCoKauBfR9HVYwoy8q/XNh8qcFrlQlkIcUtXun6DgfAhPPQcwcW5kJMOiEWThumxIJm+mMvFlaRdYtagYwggvXUQd30980W5n5efy1eAbzOpBM93pGIcWX4="]
}],
"dbx": [{
"type": "Default"
}]
}
}
}
}
"#;
#[test]
fn replace_mixed_default() {
let data = serde_json::from_str::<json::JsonRoot>(REPLACE_MIXED_DEFAULT).unwrap();
let data = convert::json_to_delta(data);
assert!(data.is_err())
}
const REPLACE: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Replace",
"signatures": {
"PK": {
"type": "x509",
"value": ["MIIHFjCCBP6gAwIBAgITMwAAACDxXiUkn6t10AAAAAAAIDANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjE6MDgGA1UEAxMxTWljcm9zb2Z0IENvcnBvcmF0aW9uIFRoaXJkIFBhcnR5IE1hcmtldHBsYWNlIFBDQTAeFw0xMzAxMjQyMjAyNDBaFw0xNDA0MjQyMjAyNDBaMHwxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xJjAkBgNVBAMTHU1pY3Jvc29mdCBIeXBlci1WIEZpc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CAgEAFPx8cVGlecJusu85Prw8Ug9uKz8QE3P+qGjQSKY0TYqWBSbuMUaQYXnW/zguRWv0wOUouNodj4rbCdcax0wKNmZqjOwb1wSQqBgXpJu54kAyNnbEwVrGv+QEwOoW06zDaO9irN1UbFAwWKbrfP6Up06O9Ox8hnNXwlIhczRa86OKVsgE2gcJ7fiL4870fo6u8PYLigj7P8kdcn9TuOu+Y+DjPTFlsIHl8qzNFqSfPaixm8JC0JCEX1Qd/4nquh1HkG+wc05Bn0CfX+WhKrIRkXOKISjwzt5zOV8+q1xg7N8DEKjTCen09paFtn9RiGZHGY2isBI9gSpoBXe7kUxie7bBB8e6eoc0Aw5LYnqZ6cr8zko3yS2kV3wc/j3cuA9a+tbEswKFAjrqs9lu5GkhN96B0fZ1GQVn05NXXikbOcjuLeHN5EVzW9DSznqrFhmCRljQXp2Bs2evbDXyvOU/JOI1ogp1BvYYVpnUeCzRBRvr0IgBnaoQ8QXfun4sY7cGmyMhxPl4bOJYFwY2K5ESA8yk2fItuvmUnUDtGEXxzopcaz6rA9NwGCoKauBfR9HVYwoy8q/XNh8qcFrlQlkIcUtXun6DgfAhPPQcwcW5kJMOiEWThumxIJm+mMvFlaRdYtagYwggvXUQd30980W5n5efy1eAbzOpBM93pGIcWX4="]
}],
"dbx": [{
"type": "Default"
}]
}
}
}
}
"#;
#[test]
fn replace() {
let data = serde_json::from_str::<json::JsonRoot>(REPLACE);
let _ = data.unwrap();
}
const PRIVATE_VARS: &str = r#"
{
"type": "Microsoft.Compute/disks",
"properties": {
"uefiSettings" : {
"signatureMode": "Replace",
"signatures": {
"PK": {
"type": "x509",
"value": ["MIIHFjCCBP6gAwIBAgITMwAAACDxXiUkn6t10AAAAAAAIDANBgkqhkiG9w0BAQsFADCBkDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjE6MDgGA1UE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": {
"guid":"Yd/ki8qT0hGqDQDgmAMrjA==",
"attributes":"Jw==",
"value":"VGVzdCBWYXJpYWJsZSAy"
}
}
}
}
"#;
#[test]
fn private_vars() {
let data = serde_json::from_str::<json::JsonRoot>(PRIVATE_VARS);
let data = data.unwrap();
match data.properties.uefi_settings.custom_vars.get("Var1") {
Some(v) => assert_eq!(v.attr, 7),
None => panic!(),
}
match data.properties.uefi_settings.custom_vars.get("Var2") {
Some(v) => assert_eq!(v.attr, 39),
None => panic!(),
}
}
}