support latest as version value

revert version to uint type and handle in Unmarshal

remove unused version type

fix

daniel feedback
This commit is contained in:
Adrian Stobbe 2023-05-16 17:54:25 +02:00
parent 6062b10035
commit 934722ae76
4 changed files with 48 additions and 5 deletions

View File

@ -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
}

View File

@ -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.

View File

@ -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__"],
)

View File

@ -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
}
}