-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yogesh Deshpande <[email protected]>
- Loading branch information
1 parent
51bedcb
commit 893379d
Showing
16 changed files
with
138 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
This package defines [`IEvidenceHandler`](ievidencehandler.go) and | ||
[`IEndorsementHandler`](iendorsementhandler.go) [pluggable](../plugin/README.md) | ||
This package defines [`IEvidenceHandler`](ievidencehandler.go), | ||
[`IEndorsementHandler`](iendorsementhandler.go) and [`IStoreHandler`](istorehandler.go) [pluggable](../plugin/README.md) | ||
interfaces and associated RPC channels. These are used to add new attestation | ||
scheme to Veraison services. Additionally, the package defines a [couple | ||
of wrappers](plugin.go) around `plugin.RegisterImplementation` for registering | ||
implementations of these two interfaces. | ||
implementations of these three interfaces. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Contributors to the Veraison project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
PLUGIN := ../../../bin/tpm-enacttrust-store-handler.plugin | ||
GOPKG := github.com/veraison/services/scheme/tpm-enacttrust | ||
SRCS := main.go | ||
|
||
include ../../../../mk/common.mk | ||
include ../../../../mk/plugin.mk | ||
include ../../../../mk/lint.mk | ||
include ../../../../mk/test.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright 2022-2024 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package main | ||
|
||
import ( | ||
"github.com/veraison/services/handler" | ||
"github.com/veraison/services/plugin" | ||
scheme "github.com/veraison/services/scheme/tpm-enacttrust" | ||
) | ||
|
||
func main() { | ||
handler.RegisterStoreHandler(&scheme.StoreHandler{}) | ||
plugin.Serve() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright 2021-2024 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package tpm_enacttrust | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/veraison/services/handler" | ||
"github.com/veraison/services/proto" | ||
) | ||
|
||
type StoreHandler struct { | ||
} | ||
|
||
func (s StoreHandler) GetName() string { | ||
return "tpm-enacttrust-store-handler" | ||
} | ||
|
||
func (s StoreHandler) GetAttestationScheme() string { | ||
return SchemeName | ||
} | ||
|
||
func (s StoreHandler) GetSupportedMediaTypes() []string { | ||
return nil | ||
} | ||
|
||
func (s StoreHandler) GetTrustAnchorIDs(token *proto.AttestationToken) ([]string, error) { | ||
supported := false | ||
for _, mt := range EvidenceMediaTypes { | ||
if token.MediaType == mt { | ||
supported = true | ||
break | ||
} | ||
} | ||
|
||
if !supported { | ||
err := handler.BadEvidence( | ||
"wrong media type: expect %q, but found %q", | ||
strings.Join(EvidenceMediaTypes, ", "), | ||
token.MediaType, | ||
) | ||
return []string{""}, err | ||
} | ||
|
||
var decoded Token | ||
|
||
if err := decoded.Decode(token.Data); err != nil { | ||
return nil, handler.BadEvidence(err) | ||
} | ||
|
||
return []string{tpmEnactTrustLookupKey(token.TenantId, decoded.NodeId.String())}, nil | ||
} | ||
|
||
func (s StoreHandler) SynthKeysFromRefValue( | ||
tenantID string, | ||
swComp *handler.Endorsement, | ||
) ([]string, error) { | ||
return synthKeysFromAttrs("software component", tenantID, swComp.Attributes) | ||
} | ||
|
||
func (s StoreHandler) SynthKeysFromTrustAnchor(tenantID string, ta *handler.Endorsement) ([]string, error) { | ||
return synthKeysFromAttrs("trust anchor", tenantID, ta.Attributes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2022-2024 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package tpm_enacttrust | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"github.com/veraison/services/proto" | ||
) | ||
|
||
func Test_GetTrustAnchorIds_ok(t *testing.T) { | ||
data, err := os.ReadFile("test/tokens/basic.token") | ||
require.NoError(t, err) | ||
|
||
ta := proto.AttestationToken{ | ||
TenantId: "0", | ||
MediaType: "application/vnd.enacttrust.tpm-evidence", | ||
Data: data, | ||
} | ||
|
||
var s StoreHandler | ||
|
||
taIDs, err := s.GetTrustAnchorIDs(&ta) | ||
require.NoError(t, err) | ||
assert.Equal(t, "TPM_ENACTTRUST://0/7df7714e-aa04-4638-bcbf-434b1dd720f1", taIDs[0]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters