Skip to content

Commit

Permalink
Added Scheme skeleton to Realm Provisioning Path
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed Nov 28, 2023
1 parent cc95c0e commit c3848d5
Show file tree
Hide file tree
Showing 14 changed files with 465 additions and 24 deletions.
1 change: 1 addition & 0 deletions scheme/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SUBDIR += psa-iot
SUBDIR += tpm-enacttrust
SUBDIR += parsec-tpm
SUBDIR += parsec-cca
SUBDIR += cca-realm

clean: ; $(RM) -rf ./bin

Expand Down
15 changes: 15 additions & 0 deletions scheme/cca-realm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Contributors to the Veraison project.
# SPDX-License-Identifier: Apache-2.0

.DEFAULT_GOAL := test

GOPKG := github.com/veraison/services/scheme/cca-realm
SRCS := $(wildcard *.go)

SUBDIR += plugin

include ../../mk/common.mk
include ../../mk/lint.mk
include ../../mk/pkg.mk
include ../../mk/subdir.mk
include ../../mk/test.mk
48 changes: 24 additions & 24 deletions scheme/cca-realm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@

```json
{
"scheme": "CCA_REALM",
"type": "REFERENCE_VALUE",
"attributes": {
"cca_realm.vendor": "Worload Client Ltd",
"cca_realm.id": "CD1F0E55-26F9-460D-B9D8-F7FDE171787C",
"cca_realm.alg-id": "sha-256",
"cca_realm.measurement-array": [
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
}
]
}
"scheme": "CCA_REALM",
"type": "REFERENCE_VALUE",
"attributes": {
"cca_realm.vendor": "Worload Client Ltd",
"cca_realm.id": "CD1F0E55-26F9-460D-B9D8-F7FDE171787C",
"cca_realm.alg-id": "sha-256",
"cca_realm.measurement-array": [
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
},
{
"measurement-value": "h0KPxSKAPTEGXnvOPPA/5HUJZjHl4Hu9eg/eYMTPJcc="
}
]
}
}
```
33 changes: 33 additions & 0 deletions scheme/cca-realm/endorsement_handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2022-2023 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package cca_realm

import (
"github.com/veraison/services/handler"
)

type EndorsementHandler struct{}

func (o EndorsementHandler) Init(params handler.EndorsementHandlerParams) error {
return nil // no-op
}

func (o EndorsementHandler) Close() error {
return nil // no-op
}

func (o EndorsementHandler) GetName() string {
return "unsigned-corim (CCA realm profile)"
}

func (o EndorsementHandler) GetAttestationScheme() string {
return SchemeName
}

func (o EndorsementHandler) GetSupportedMediaTypes() []string {
return EndorsementMediaTypes
}

func (o EndorsementHandler) Decode(data []byte) (*handler.EndorsementHandlerResponse, error) {
return nil, nil
}
65 changes: 65 additions & 0 deletions scheme/cca-realm/endorsement_handler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2022-2023 Contributors to the Veraison project.
// SPDX-License-Identifier: Apache-2.0
package cca_realm

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestDecoder_GetAttestationScheme(t *testing.T) {
d := &EndorsementHandler{}

expected := SchemeName

actual := d.GetAttestationScheme()

assert.Equal(t, expected, actual)
}

func TestDecoder_GetSupportedMediaTypes(t *testing.T) {
d := &EndorsementHandler{}

expected := EndorsementMediaTypes

actual := d.GetSupportedMediaTypes()

assert.Equal(t, expected, actual)
}

func TestDecoder_Init(t *testing.T) {
d := &EndorsementHandler{}

assert.Nil(t, d.Init(nil))
}

func TestDecoder_Close(t *testing.T) {
d := &EndorsementHandler{}

assert.Nil(t, d.Close())
}

func TestDecoder_Decode_empty_data(t *testing.T) {
d := &EndorsementHandler{}

emptyData := []byte{}

expectedErr := `empty data`

_, err := d.Decode(emptyData)

assert.EqualError(t, err, expectedErr)
}

func TestDecoder_Decode_invalid_data(t *testing.T) {
d := &EndorsementHandler{}

invalidCbor := []byte("invalid CBOR")

expectedErr := `CBOR decoding failed: cbor: cannot unmarshal UTF-8 text string into Go value of type corim.UnsignedCorim`

_, err := d.Decode(invalidCbor)

assert.EqualError(t, err, expectedErr)
}
Loading

0 comments on commit c3848d5

Please sign in to comment.