-
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.
[WIP] Work on Introducing Store handlers
Signed-off-by: Yogesh Deshpande <[email protected]>
- Loading branch information
1 parent
c5d9aa8
commit 23b31e2
Showing
23 changed files
with
434 additions
and
163 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
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 2021 Contributors to the Veraison project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
PLUGIN := ../../../bin/cca-store-handler.plugin | ||
GOPKG := github.com/veraison/services/scheme/cca-ssd-platform | ||
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 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/cca-ssd-platform" | ||
) | ||
|
||
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,45 @@ | ||
// Copyright 2021-2023 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cca_ssd_platform | ||
|
||
import ( | ||
"github.com/veraison/services/handler" | ||
"github.com/veraison/services/proto" | ||
"github.com/veraison/services/scheme/common/arm" | ||
) | ||
|
||
type StoreHandler struct{} | ||
|
||
func (s StoreHandler) GetName() string { | ||
return "cca-store-handler" | ||
} | ||
|
||
func (s StoreHandler) GetAttestationScheme() string { | ||
return SchemeName | ||
} | ||
|
||
func (s StoreHandler) GetSupportedMediaTypes() []string { | ||
return nil | ||
} | ||
|
||
func (s StoreHandler) SynthKeysFromRefValue( | ||
tenantID string, | ||
refVal *handler.Endorsement, | ||
) ([]string, error) { | ||
return arm.SynthKeysFromRefValue(SchemeName, tenantID, refVal) | ||
|
||
} | ||
|
||
func (s StoreHandler) SynthKeysFromTrustAnchor(tenantID string, ta *handler.Endorsement) ([]string, error) { | ||
|
||
return arm.SynthKeysFromTrustAnchors(SchemeName, tenantID, ta) | ||
} | ||
|
||
func (s StoreHandler) GetTrustAnchorIDs(token *proto.AttestationToken) ([]string, error) { | ||
ta, err := arm.GetTrustAnchorID(SchemeName, token) | ||
if err != nil { | ||
return []string{""}, err | ||
} | ||
return []string{ta}, nil | ||
} |
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,77 @@ | ||
// Copyright 2021-2023 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cca_ssd_platform | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/veraison/services/handler" | ||
"github.com/veraison/services/proto" | ||
) | ||
|
||
var testNonce = []byte{ | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
0x41, 0x42, 0x41, 0x42, 0x41, 0x42, 0x41, 0x42, | ||
} | ||
|
||
func Test_GetTrustAnchorIDs_ok(t *testing.T) { | ||
tokenBytes, err := os.ReadFile("test/cca-token.cbor") | ||
require.NoError(t, err) | ||
|
||
token := proto.AttestationToken{ | ||
TenantId: "1", | ||
Data: tokenBytes, | ||
Nonce: testNonce, | ||
} | ||
|
||
expectedTaID := []string{"CCA_SSD_PLATFORM://1/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=/AQICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC"} | ||
|
||
scheme := &StoreHandler{} | ||
|
||
taID, err := scheme.GetTrustAnchorIDs(&token) | ||
require.NoError(t, err) | ||
assert.Equal(t, expectedTaID, taID) | ||
} | ||
|
||
func Test_SynthKeysFromTrustAnchor_ok(t *testing.T) { | ||
endorsementsBytes, err := os.ReadFile("test/ta-endorsements.json") | ||
require.NoError(t, err) | ||
|
||
var endors handler.Endorsement | ||
err = json.Unmarshal(endorsementsBytes, &endors) | ||
require.NoError(t, err) | ||
expectedKey := "CCA_SSD_PLATFORM://1/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=/Ac7rrnuJJ6MiflMDz14PH3s0u1Qq1yUKwD+83jbsLxUI" | ||
|
||
scheme := &StoreHandler{} | ||
key_list, err := scheme.SynthKeysFromTrustAnchor("1", &endors) | ||
require.NoError(t, err) | ||
assert.Equal(t, expectedKey, key_list[0]) | ||
|
||
} | ||
|
||
func Test_SynthKeysFromRefValue_ok(t *testing.T) { | ||
endorsementsBytes, err := os.ReadFile("test/refval-endorsements.json") | ||
require.NoError(t, err) | ||
|
||
var endors handler.Endorsement | ||
err = json.Unmarshal(endorsementsBytes, &endors) | ||
require.NoError(t, err) | ||
expectedKey := "CCA_SSD_PLATFORM://1/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" | ||
|
||
scheme := &StoreHandler{} | ||
key_list, err := scheme.SynthKeysFromRefValue("1", &endors) | ||
require.NoError(t, err) | ||
assert.Equal(t, expectedKey, key_list[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
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 2021 Contributors to the Veraison project. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
PLUGIN := ../../../bin/parsec-cca-store-handler.plugin | ||
GOPKG := github.com/veraison/services/scheme/parsec-cca | ||
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 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/parsec-cca" | ||
) | ||
|
||
func main() { | ||
handler.RegisterStoreHandler(&scheme.StoreHandler{}) | ||
plugin.Serve() | ||
} |
Oops, something went wrong.