2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
2023-01-19 09:57:50 -05:00
|
|
|
*/
|
2022-09-05 03:06:08 -04:00
|
|
|
|
2023-01-19 09:57:50 -05:00
|
|
|
/*
|
2022-08-31 14:10:49 -04:00
|
|
|
Package oid defines OIDs for different CSPs. Currently this is used in attested TLS to distinguish the attestation documents.
|
|
|
|
OIDs beginning with 1.3.9900 are reserved and can be used without registration.
|
|
|
|
|
|
|
|
* The 1.3.9900.1 branch is reserved for placeholder values and testing.
|
|
|
|
|
|
|
|
* The 1.3.9900.2 branch is reserved for AWS.
|
|
|
|
|
|
|
|
* The 1.3.9900.3 branch is reserved for GCP.
|
|
|
|
|
|
|
|
* The 1.3.9900.4 branch is reserved for Azure.
|
|
|
|
|
|
|
|
* The 1.3.9900.5 branch is reserved for QEMU.
|
|
|
|
|
|
|
|
Deprecated OIDs should never be reused for different purposes.
|
|
|
|
Instead, new OIDs should be added in the appropriate branch at the next available index.
|
|
|
|
*/
|
2022-03-22 11:03:15 -04:00
|
|
|
package oid
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/asn1"
|
2023-03-09 05:22:58 -05:00
|
|
|
"fmt"
|
2022-03-22 11:03:15 -04:00
|
|
|
)
|
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// Getter returns an ASN.1 Object Identifier.
|
2022-03-22 11:03:15 -04:00
|
|
|
type Getter interface {
|
|
|
|
OID() asn1.ObjectIdentifier
|
|
|
|
}
|
|
|
|
|
2023-03-02 04:48:16 -05:00
|
|
|
// FromString returns the OID for the given string.
|
|
|
|
func FromString(oid string) (Getter, error) {
|
|
|
|
switch oid {
|
|
|
|
case dummy:
|
|
|
|
return Dummy{}, nil
|
|
|
|
case awsNitroTPM:
|
|
|
|
return AWSNitroTPM{}, nil
|
|
|
|
case gcpSEVES:
|
|
|
|
return GCPSEVES{}, nil
|
|
|
|
case azureSEVSNP:
|
|
|
|
return AzureSEVSNP{}, nil
|
|
|
|
case azureTrustedLaunch:
|
|
|
|
return AzureTrustedLaunch{}, nil
|
|
|
|
case qemuVTPM:
|
|
|
|
return QEMUVTPM{}, nil
|
|
|
|
}
|
2023-03-09 05:22:58 -05:00
|
|
|
return nil, fmt.Errorf("unknown OID: %q", oid)
|
2023-03-02 04:48:16 -05:00
|
|
|
}
|
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// Dummy OID for testing.
|
2022-03-22 11:03:15 -04:00
|
|
|
type Dummy struct{}
|
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// OID returns the struct's object identifier.
|
2022-03-22 11:03:15 -04:00
|
|
|
func (Dummy) OID() asn1.ObjectIdentifier {
|
2022-08-31 14:10:49 -04:00
|
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 1, 1}
|
2022-03-22 11:03:15 -04:00
|
|
|
}
|
|
|
|
|
2023-03-02 04:48:16 -05:00
|
|
|
// String returns the string representation of the OID.
|
|
|
|
func (Dummy) String() string {
|
|
|
|
return dummy
|
|
|
|
}
|
|
|
|
|
|
|
|
// AWSNitroTPM holds the AWS nitro TPM OID.
|
|
|
|
type AWSNitroTPM struct{}
|
2022-03-22 11:03:15 -04:00
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// OID returns the struct's object identifier.
|
2023-03-02 04:48:16 -05:00
|
|
|
func (AWSNitroTPM) OID() asn1.ObjectIdentifier {
|
2022-08-31 14:10:49 -04:00
|
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 2, 1}
|
2022-03-22 11:03:15 -04:00
|
|
|
}
|
|
|
|
|
2023-03-02 04:48:16 -05:00
|
|
|
// String returns the string representation of the OID.
|
|
|
|
func (AWSNitroTPM) String() string {
|
|
|
|
return awsNitroTPM
|
|
|
|
}
|
|
|
|
|
|
|
|
// GCPSEVES holds the GCP SEV-ES OID.
|
|
|
|
type GCPSEVES struct{}
|
2022-03-22 11:03:15 -04:00
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// OID returns the struct's object identifier.
|
2023-03-02 04:48:16 -05:00
|
|
|
func (GCPSEVES) OID() asn1.ObjectIdentifier {
|
2022-08-31 14:10:49 -04:00
|
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 3, 1}
|
|
|
|
}
|
|
|
|
|
2023-03-02 04:48:16 -05:00
|
|
|
// String returns the string representation of the OID.
|
|
|
|
func (GCPSEVES) String() string {
|
|
|
|
return gcpSEVES
|
|
|
|
}
|
|
|
|
|
|
|
|
// AzureSEVSNP holds the OID for Azure SNP CVMs.
|
|
|
|
type AzureSEVSNP struct{}
|
2022-08-31 14:10:49 -04:00
|
|
|
|
|
|
|
// OID returns the struct's object identifier.
|
2023-03-02 04:48:16 -05:00
|
|
|
func (AzureSEVSNP) OID() asn1.ObjectIdentifier {
|
2022-08-31 14:10:49 -04:00
|
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 4, 1}
|
2022-03-22 11:03:15 -04:00
|
|
|
}
|
|
|
|
|
2023-03-02 04:48:16 -05:00
|
|
|
// String returns the string representation of the OID.
|
|
|
|
func (AzureSEVSNP) String() string {
|
|
|
|
return azureSEVSNP
|
|
|
|
}
|
|
|
|
|
2022-11-09 09:57:54 -05:00
|
|
|
// AzureTrustedLaunch holds the OID for Azure TrustedLaunch VMs.
|
2022-08-31 14:10:49 -04:00
|
|
|
type AzureTrustedLaunch struct{}
|
2022-03-22 11:03:15 -04:00
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// OID returns the struct's object identifier.
|
2022-08-31 14:10:49 -04:00
|
|
|
func (AzureTrustedLaunch) OID() asn1.ObjectIdentifier {
|
|
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 4, 2}
|
2022-03-22 11:03:15 -04:00
|
|
|
}
|
|
|
|
|
2023-03-02 04:48:16 -05:00
|
|
|
// String returns the string representation of the OID.
|
|
|
|
func (AzureTrustedLaunch) String() string {
|
|
|
|
return azureTrustedLaunch
|
|
|
|
}
|
|
|
|
|
|
|
|
// QEMUVTPM holds the QEMUVTPM OID.
|
|
|
|
type QEMUVTPM struct{}
|
2022-04-21 10:27:34 -04:00
|
|
|
|
2022-04-28 08:31:01 -04:00
|
|
|
// OID returns the struct's object identifier.
|
2023-03-02 04:48:16 -05:00
|
|
|
func (QEMUVTPM) OID() asn1.ObjectIdentifier {
|
2022-08-31 14:10:49 -04:00
|
|
|
return asn1.ObjectIdentifier{1, 3, 9900, 5, 1}
|
2022-04-21 10:27:34 -04:00
|
|
|
}
|
2023-03-02 04:48:16 -05:00
|
|
|
|
|
|
|
// String returns the string representation of the OID.
|
|
|
|
func (QEMUVTPM) String() string {
|
|
|
|
return qemuVTPM
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
dummy = "dummy"
|
|
|
|
awsNitroTPM = "aws-nitro-tpm"
|
|
|
|
gcpSEVES = "gcp-sev-es"
|
|
|
|
azureSEVSNP = "azure-sev-snp"
|
|
|
|
azureTrustedLaunch = "azure-trustedlaunch"
|
|
|
|
qemuVTPM = "qemu-vtpm"
|
|
|
|
)
|