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-03-09 03:47:28 -05:00
|
|
|
"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/qemu"
|
2023-03-08 08:13:57 -05:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/tdx"
|
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-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 {
|
|
|
|
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-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) {
|
|
|
|
case *config.AWSNitroTPM:
|
|
|
|
return aws.NewValidator(cfg, log), nil
|
|
|
|
case *config.AzureTrustedLaunch:
|
|
|
|
return trustedlaunch.NewValidator(cfg, log), nil
|
|
|
|
case *config.AzureSEVSNP:
|
2023-04-06 11:00:56 -04:00
|
|
|
return snp.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-05-03 05:11:53 -04:00
|
|
|
return nil, fmt.Errorf("unknown attestation variant")
|
2023-03-09 03:47:28 -05:00
|
|
|
}
|
|
|
|
}
|