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"
|
2023-03-08 08:13:57 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation"
|
2023-06-09 09:41:02 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/aws/nitrotpm"
|
|
|
|
awssnp "github.com/edgelesssys/constellation/v2/internal/attestation/aws/snp"
|
|
|
|
azuresnp "github.com/edgelesssys/constellation/v2/internal/attestation/azure/snp"
|
2024-01-24 09:10:15 -05:00
|
|
|
azuretdx "github.com/edgelesssys/constellation/v2/internal/attestation/azure/tdx"
|
2023-03-09 03:47:28 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/azure/trustedlaunch"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/gcp"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/qemu"
|
2023-03-08 08:13:57 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/tdx"
|
2023-06-09 09:41:02 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
|
2023-04-06 11:00:56 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
2023-03-09 03:47:28 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Issuer returns the issuer for the given variant.
|
2023-03-08 08:13:57 -05:00
|
|
|
func Issuer(attestationVariant variant.Variant, log attestation.Logger) (atls.Issuer, error) {
|
2023-03-29 03:30:13 -04:00
|
|
|
switch attestationVariant {
|
2023-06-09 09:41:02 -04:00
|
|
|
case variant.AWSSEVSNP{}:
|
|
|
|
return awssnp.NewIssuer(log), nil
|
2023-03-29 03:30:13 -04:00
|
|
|
case variant.AWSNitroTPM{}:
|
2023-06-09 09:41:02 -04:00
|
|
|
return nitrotpm.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-06-09 09:41:02 -04:00
|
|
|
return azuresnp.NewIssuer(log), nil
|
2024-01-24 09:10:15 -05:00
|
|
|
case variant.AzureTDX{}:
|
|
|
|
return azuretdx.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-08 08:13:57 -05:00
|
|
|
case variant.QEMUTDX{}:
|
|
|
|
return tdx.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.
|
2023-03-08 08:13:57 -05:00
|
|
|
func Validator(cfg config.AttestationCfg, log attestation.Logger) (atls.Validator, error) {
|
2023-05-03 05:11:53 -04:00
|
|
|
switch cfg := cfg.(type) {
|
2023-06-09 09:41:02 -04:00
|
|
|
case *config.AWSSEVSNP:
|
|
|
|
return awssnp.NewValidator(cfg, log), nil
|
2023-05-03 05:11:53 -04:00
|
|
|
case *config.AWSNitroTPM:
|
2023-06-09 09:41:02 -04:00
|
|
|
return nitrotpm.NewValidator(cfg, log), nil
|
2023-05-03 05:11:53 -04:00
|
|
|
case *config.AzureTrustedLaunch:
|
|
|
|
return trustedlaunch.NewValidator(cfg, log), nil
|
|
|
|
case *config.AzureSEVSNP:
|
2023-06-09 09:41:02 -04:00
|
|
|
return azuresnp.NewValidator(cfg, log), nil
|
2024-01-24 09:10:15 -05:00
|
|
|
case *config.AzureTDX:
|
|
|
|
return azuretdx.NewValidator(cfg, log), nil
|
2023-05-03 05:11:53 -04:00
|
|
|
case *config.GCPSEVES:
|
|
|
|
return gcp.NewValidator(cfg, log), nil
|
|
|
|
case *config.QEMUVTPM:
|
|
|
|
return qemu.NewValidator(cfg, log), nil
|
2023-03-08 08:13:57 -05:00
|
|
|
case *config.QEMUTDX:
|
|
|
|
return tdx.NewValidator(cfg, log), nil
|
2023-05-03 05:11:53 -04:00
|
|
|
case *config.DummyCfg:
|
2023-03-29 03:30:13 -04:00
|
|
|
return atls.NewFakeValidator(variant.Dummy{}), nil
|
2023-03-09 03:47:28 -05:00
|
|
|
default:
|
2023-09-29 08:29:50 -04:00
|
|
|
return nil, fmt.Errorf("unknown attestation variant: %s", cfg.GetVariant())
|
2023-03-09 03:47:28 -05:00
|
|
|
}
|
|
|
|
}
|