2023-03-09 03:47:28 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package choose
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/atls"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/aws"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/azure/snp"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/azure/trustedlaunch"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/gcp"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/qemu"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/vtpm"
|
2023-04-06 11:00:56 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
2023-03-29 03:30:13 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/variant"
|
2023-03-09 03:47:28 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Issuer returns the issuer for the given variant.
|
2023-03-29 03:30:13 -04:00
|
|
|
func Issuer(attestationVariant variant.Variant, log vtpm.AttestationLogger) (atls.Issuer, error) {
|
|
|
|
switch attestationVariant {
|
|
|
|
case variant.AWSNitroTPM{}:
|
2023-03-09 03:47:28 -05:00
|
|
|
return aws.NewIssuer(log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.AzureTrustedLaunch{}:
|
2023-03-09 03:47:28 -05:00
|
|
|
return trustedlaunch.NewIssuer(log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.AzureSEVSNP{}:
|
2023-03-09 03:47:28 -05:00
|
|
|
return snp.NewIssuer(log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.GCPSEVES{}:
|
2023-03-09 03:47:28 -05:00
|
|
|
return gcp.NewIssuer(log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.QEMUVTPM{}:
|
2023-03-09 03:47:28 -05:00
|
|
|
return qemu.NewIssuer(log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.Dummy{}:
|
|
|
|
return atls.NewFakeIssuer(variant.Dummy{}), nil
|
2023-03-09 03:47:28 -05:00
|
|
|
default:
|
2023-03-29 03:30:13 -04:00
|
|
|
return nil, fmt.Errorf("unknown attestation variant: %s", attestationVariant)
|
2023-03-09 03:47:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validator returns the validator for the given variant.
|
|
|
|
func Validator(
|
2023-04-06 11:00:56 -04:00
|
|
|
attestationVariant variant.Variant, measurements measurements.M, idKeyCfg config.SNPFirmwareSignerConfig, log vtpm.AttestationLogger,
|
2023-03-09 03:47:28 -05:00
|
|
|
) (atls.Validator, error) {
|
2023-03-29 03:30:13 -04:00
|
|
|
switch attestationVariant {
|
|
|
|
case variant.AWSNitroTPM{}:
|
2023-04-06 11:00:56 -04:00
|
|
|
return aws.NewValidator(config.AWSNitroTPM{Measurements: measurements}, log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.AzureTrustedLaunch{}:
|
2023-04-06 11:00:56 -04:00
|
|
|
return trustedlaunch.NewValidator(config.AzureTrustedLaunch{Measurements: measurements}, log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.AzureSEVSNP{}:
|
2023-04-06 11:00:56 -04:00
|
|
|
cfg := config.DefaultForAzureSEVSNP()
|
|
|
|
cfg.Measurements = measurements
|
|
|
|
cfg.FirmwareSignerConfig = idKeyCfg
|
|
|
|
return snp.NewValidator(cfg, log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.GCPSEVES{}:
|
2023-04-06 11:00:56 -04:00
|
|
|
return gcp.NewValidator(config.GCPSEVES{Measurements: measurements}, log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.QEMUVTPM{}:
|
2023-04-06 11:00:56 -04:00
|
|
|
return qemu.NewValidator(config.QEMUVTPM{Measurements: measurements}, log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.Dummy{}:
|
|
|
|
return atls.NewFakeValidator(variant.Dummy{}), nil
|
2023-03-09 03:47:28 -05:00
|
|
|
default:
|
2023-03-29 03:30:13 -04:00
|
|
|
return nil, fmt.Errorf("unknown attestation variant: %s", attestationVariant)
|
2023-03-09 03:47:28 -05:00
|
|
|
}
|
|
|
|
}
|