Skip to content

Commit

Permalink
remove issuer dep on cli
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Nov 27, 2024
1 parent c2122dc commit a03f229
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
23 changes: 18 additions & 5 deletions internal/atls/issuer.go → internal/atls/issuer/issuer.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only

package atls
package issuer

import (
"context"
"encoding/asn1"
"fmt"
"log/slog"

"github.com/edgelesssys/contrast/internal/attestation/snp"
"github.com/edgelesssys/contrast/internal/attestation/tdx"
snpissuer "github.com/edgelesssys/contrast/internal/attestation/snp/issuer"
tdxissuer "github.com/edgelesssys/contrast/internal/attestation/tdx/issuer"
"github.com/edgelesssys/contrast/internal/logger"
"github.com/klauspost/cpuid/v2"
)
Expand All @@ -18,14 +20,25 @@ func PlatformIssuer(log *slog.Logger) (Issuer, error) {
cpuid.Detect()
switch {
case cpuid.CPU.Supports(cpuid.SEV_SNP):
return snp.NewIssuer(
return snpissuer.New(
logger.NewWithAttrs(logger.NewNamed(log, "issuer"), map[string]string{"tee-type": "snp"}),
), nil
case cpuid.CPU.Supports(cpuid.TDX_GUEST):
return tdx.NewIssuer(
return tdxissuer.New(
logger.NewWithAttrs(logger.NewNamed(log, "issuer"), map[string]string{"tee-type": "tdx"}),
), nil
default:
return nil, fmt.Errorf("unsupported platform: %T", cpuid.CPU)
}
}

// Issuer issues an attestation document.
type Issuer interface {
Getter
Issue(ctx context.Context, userData []byte, nonce []byte) (quote []byte, err error)
}

// Getter returns an ASN.1 Object Identifier.
type Getter interface {
OID() asn1.ObjectIdentifier
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only

package snp
// package issuer provides functions to create an aTLS issuer.
package issuer

import (
"context"
Expand All @@ -27,8 +28,8 @@ type Issuer struct {
logger *slog.Logger
}

// NewIssuer returns a new Issuer.
func NewIssuer(log *slog.Logger) *Issuer {
// New returns a new Issuer.
func New(log *slog.Logger) *Issuer {
return &Issuer{
thimGetter: NewTHIMGetter(http.DefaultClient),
logger: log,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only

package snp
package issuer

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only

package tdx
package issuer

import (
"context"
Expand All @@ -23,8 +23,8 @@ type Issuer struct {
logger *slog.Logger
}

// NewIssuer returns a new Issuer.
func NewIssuer(log *slog.Logger) *Issuer {
// New returns a new Issuer.
func New(log *slog.Logger) *Issuer {
return &Issuer{
logger: log,
}
Expand Down

0 comments on commit a03f229

Please sign in to comment.