2023-03-09 05:22:58 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
2023-03-29 03:30:13 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/variant"
|
2023-03-09 05:22:58 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/measurement-reader/internal/sorted"
|
|
|
|
"github.com/edgelesssys/constellation/v2/measurement-reader/internal/tpm"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
log := logger.New(logger.JSONLog, zapcore.InfoLevel)
|
2023-03-29 03:30:13 -04:00
|
|
|
variantString := os.Getenv(constants.AttestationVariant)
|
|
|
|
attestationVariant, err := variant.FromString(variantString)
|
2023-03-09 05:22:58 -05:00
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to parse attestation variant")
|
|
|
|
}
|
|
|
|
|
|
|
|
var m []sorted.Measurement
|
|
|
|
switch attestationVariant {
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.AWSNitroTPM{}, variant.AzureSEVSNP{}, variant.AzureTrustedLaunch{}, variant.GCPSEVES{}, variant.QEMUVTPM{}:
|
2023-03-09 05:22:58 -05:00
|
|
|
m, err = tpm.Measurements()
|
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to read TPM measurements")
|
|
|
|
}
|
|
|
|
default:
|
2023-03-29 03:30:13 -04:00
|
|
|
log.With(zap.String("attestationVariant", variantString)).Fatalf("Unsupported attestation variant")
|
2023-03-09 05:22:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Measurements:")
|
|
|
|
for _, measurement := range m {
|
|
|
|
fmt.Printf("\t%s : 0x%0X\n", measurement.Index, measurement.Value)
|
|
|
|
}
|
|
|
|
}
|