diff --git a/internal/config/azure.go b/internal/config/azure.go index 23c31762d..171b548a1 100644 --- a/internal/config/azure.go +++ b/internal/config/azure.go @@ -16,6 +16,7 @@ import ( "github.com/edgelesssys/constellation/v2/internal/attestation/measurements" "github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider" "github.com/edgelesssys/constellation/v2/internal/config/snpversion" + "github.com/edgelesssys/constellation/v2/internal/config/version" "github.com/edgelesssys/constellation/v2/internal/variant" ) @@ -209,18 +210,18 @@ func convertLatestToNumber(c *AzureSEVSNP, versionType snpversion.Type, aux *fus return false } -func getUintAndStringPtrToVersion(c *AzureSEVSNP, versionType snpversion.Type, aux *fusedAzureSEVSNP) (versionUint *uint8, versionString *string) { +func getUintAndStringPtrToVersion(c *AzureSEVSNP, versionType version.Type, aux *fusedAzureSEVSNP) (versionUint *uint8, versionString *string) { switch versionType { - case snpversion.Bootloader: + case version.Bootloader: versionUint = &c.BootloaderVersion versionString = &aux.BootloaderVersion - case snpversion.TEE: + case version.TEE: versionUint = &c.TEEVersion versionString = &aux.TEEVersion - case snpversion.SNP: + case version.SNP: versionUint = &c.SNPVersion versionString = &aux.SNPVersion - case snpversion.Microcode: + case version.Microcode: versionUint = &c.MicrocodeVersion versionString = &aux.MicrocodeVersion } diff --git a/internal/config/config.go b/internal/config/config.go index 01748857f..67855ab69 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -722,6 +722,7 @@ func (c AWSNitroTPM) EqualTo(other AttestationCfg) (bool, error) { return false, fmt.Errorf("cannot compare %T with %T", c, other) } return c.Measurements.EqualTo(otherCfg.Measurements), nil + } // SNPFirmwareSignerConfig is the configuration for validating the firmware signer. diff --git a/internal/config/version/BUILD.bazel b/internal/config/version/BUILD.bazel new file mode 100644 index 000000000..92221bd3c --- /dev/null +++ b/internal/config/version/BUILD.bazel @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "version", + srcs = ["version.go"], + importpath = "github.com/edgelesssys/constellation/v2/internal/config/version", + visibility = ["//:__subpackages__"], +) diff --git a/internal/config/version/version.go b/internal/config/version/version.go new file mode 100644 index 000000000..0f13ce222 --- /dev/null +++ b/internal/config/version/version.go @@ -0,0 +1,33 @@ +/* +Copyright (c) Edgeless Systems GmbH + +SPDX-License-Identifier: AGPL-3.0-only +*/ + +package version + +const ( + Bootloader Type = "bootloader" // Bootloader is the version of the Azure SEVSNP bootloader. + TEE Type = "tee" // TEE is the version of the Azure SEVSNP TEE. + SNP Type = "snp" // SNP is the version of the Azure SEVSNP SNP. + Microcode Type = "microcode" // Microcode is the version of the Azure SEVSNP microcode. +) + +// Type is the type of the version to be requested. +type Type (string) + +// GetVersion returns the version of the given type. +func GetVersion(t Type) uint8 { + switch t { + case Bootloader: + return 2 + case TEE: + return 0 + case SNP: + return 6 + case Microcode: + return 93 + default: + return 1 + } +}