Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: remove Linux dependencies #1036

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
//go:build linux

// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only
elchead marked this conversation as resolved.
Show resolved Hide resolved

package issuer

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

"github.com/edgelesssys/contrast/internal/atls"
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"
)

// New creates an attestation issuer for the current platform.
func New(log *slog.Logger) (Issuer, error) {
func New(log *slog.Logger) (atls.Issuer, error) {
cpuid.Detect()
switch {
case cpuid.CPU.Supports(cpuid.SEV_SNP):
Expand All @@ -31,14 +32,3 @@ func New(log *slog.Logger) (Issuer, error) {
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
}
17 changes: 17 additions & 0 deletions internal/atls/issuer/issuer_universal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//go:build !linux

// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only
elchead marked this conversation as resolved.
Show resolved Hide resolved

package issuer

import (
"log/slog"

"github.com/edgelesssys/contrast/internal/atls"
)

// New creates an attestation issuer for the current platform.
func New(_ *slog.Logger) (atls.Issuer, error) {
panic("issuing is only supported on Linux")
}
2 changes: 2 additions & 0 deletions internal/attestation/snp/issuer/issuer.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build linux

// Copyright 2024 Edgeless Systems GmbH
// SPDX-License-Identifier: AGPL-3.0-only
elchead marked this conversation as resolved.
Show resolved Hide resolved

Expand Down