Skip to content

Commit

Permalink
Updated tdx seam svn format in attestation token. (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvind5 authored Dec 5, 2024
1 parent a235f93 commit 4287a5e
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 40 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ REPO := localhost:5000
SHELL := /bin/bash

GITCOMMIT := $(shell git describe --always)
VERSION := v1.1.2
VERSION := v1.2.0
BUILDDATE := $(shell TZ=UTC date +%Y-%m-%dT%H:%M:%S%z)
PROXY_EXISTS := $(shell if [[ "${https_proxy}" || "${http_proxy}" ]]; then echo 1; else echo 0; fi)
DOCKER_PROXY_FLAGS := ""
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Follow these instructions to install the PyKMIP KMS. If your organization is usi

KBS can be built using targets from Makefile.

`make docker` is used to build the KBS docker image (key-broker-service:v1.1.2) using the Dockerfile.
`make docker` is used to build the KBS docker image (key-broker-service:v1.2.0) using the Dockerfile.

### Install the KBS

Expand Down Expand Up @@ -203,7 +203,7 @@ On Linux, follow the steps below to install the KBS:
4. Run the KBS container.
```bash
docker run -d --restart unless-stopped --name kbs --env-file <KBS env file> -p <KBS port>:9443 -v /etc/kbs/certs:/etc/kbs/certs -v /etc/hosts:/etc/hosts -v /opt/kbs:/opt/kbs trustauthority/key-broker-service:v1.1.2
docker run -d --restart unless-stopped --name kbs --env-file <KBS env file> -p <KBS port>:9443 -v /etc/kbs/certs:/etc/kbs/certs -v /etc/hosts:/etc/hosts -v /opt/kbs:/opt/kbs trustauthority/key-broker-service:v1.2.0
```
## KBS key creation and key retrieval
Expand Down
8 changes: 4 additions & 4 deletions docs/key_transfer_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ type KeyTransferPolicyCollection struct {
// "rtmr1": "a53c98b16f0de470338e7f072d9c5fcef6171327ec6c78b842e637251b1de6e37354c47fb68de27ef14bb67caf288d9b",
// "rtmr2": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
// "rtmr3": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
// "seamsvn": 0,
// "seamsvn": 258,
// "enforce_tcb_upto_date": false
// },
// "policy_ids": [
Expand All @@ -175,7 +175,7 @@ type KeyTransferPolicyCollection struct {
// "mrseam": [
// "0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe"
// ],
// "seamsvn": 0,
// "seamsvn": 258,
// "mrtd": [
// "cf656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50"
// ],
Expand Down Expand Up @@ -249,7 +249,7 @@ type KeyTransferPolicyCollection struct {
// "mrseam": [
// "0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe"
// ],
// "seamsvn": 0,
// "seamsvn": 258,
// "mrtd": [
// "cf656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50"
// ],
Expand Down Expand Up @@ -370,7 +370,7 @@ type KeyTransferPolicyCollection struct {
// "mrseam": [
// "0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe"
// ],
// "seamsvn": 0,
// "seamsvn": 258,
// "mrtd": [
// "cf656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50"
// ],
Expand Down
42 changes: 34 additions & 8 deletions docs/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ definitions:
type: object
x-go-package: intel/kbs/v1/model
PublicKey:
description: |-
The value of the modulus N is considered secret by this library and protected
from leaking through timing side-channels. However, neither the value of the
exponent E nor the precise bit size of N are similarly protected.
properties:
E:
format: int64
Expand Down Expand Up @@ -303,9 +307,9 @@ definitions:
type: string
x-go-name: RTMR3
seamsvn:
description: The Security Version Number of the TDX SEAM Module
example: 0
format: uint8
description: The Security Version Number of the TDX SEAM Module calculated as majorVersion x 256 + minorVersion
example: 258
format: uint16
type: integer
x-go-name: SeamSvn
type: object
Expand Down Expand Up @@ -515,7 +519,7 @@ paths:
"mrseam": [
"0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe"
],
"seamsvn": 0,
"seamsvn": 258,
"mrtd": [
"cf656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50"
],
Expand All @@ -535,7 +539,29 @@ paths:
post:
consumes:
- application/json
description: "Creates a key transfer policy. Only one SGX or TDX key transfer policy can be created at a time. A key \ntransfer policy can be created in the following ways: by providing a list of policy-ids, by providing TDX or SGX attributes, or by providing both a list of policy-ids and TDX or SGX attributes.\n\nThe serialized KeyTransferPolicy Go struct object represents the content of the request body.\n\n | Attribute | Description |\n |----------------------------------------------|-------------|\n | attestation_type | An array of attestation-type identifiers that the client must support to get the key. The client must advertise these with the key request, e.g., \"SGX,\" or \"TDX.\" Note that if the key server needs to restrict technologies, it must list technologies that can receive the key. |\n | mrsigner | An array of measurements of the SGX enclave’s code signing certificate. This is mandatory. The same issuer must be added as a trusted certificate in key server configuration settings. |\n | isvprodid | An array of (16-bit value) (ISVPRODID). This is mandatory. This is similar to a qualifier for the issuer, so the same issuer (code signing) key can sign separate products. |\n | mrenclave | An array of enclave measurements that are allowed to retrieve the key (MRENCLAVE). The client must have one of these measurements in the SGX quote. This supports the use case of providing a key only to an SGX enclave that locally enforces the key usage policy. |\n | isvsvn | Minimum security version number required for Enclave. |\n | client_permissions | An array of permissions to expect in the client API key. The client API key must have all of these names. |\n | mrsignerseam | An array of measurements of seam module issuer. This is mandatory. |\n | mrseam | An array of measurements of seam module. This is mandatory. |\n | mrtd | A array of TD measurements. |\n | rtmr0 | The measurement extended to RTMR0. |\n | rtmr1 | The measurement extended to RTMR1. |\n | rtmr2 | The measurement extended to RTMR2. |\n | rtmr3 | The measurement extended to RTMR3. |\n | seamsvn | The minimum security version number of seam module. |\n | enforce_tcb_upto_date | The boolean value to enforce an up-to-date TCB. |\n | policy_ids | A array of TD/Enclave Attestation Policy Ids. |\n"
description: |
Creates a key transfer policy. Only one SGX or TDX key transfer policy can be created at a time. A key
transfer policy can be created in the following ways: by providing a list of policy-ids, by providing TDX or SGX attributes, or by providing both a list of policy-ids and TDX or SGX attributes.
The serialized KeyTransferPolicy Go struct object represents the content of the request body.
| Attribute | Description |
|----------------------------------------------|-------------|
| attestation_type | An array of attestation-type identifiers that the client must support to get the key. The client must advertise these with the key request, e.g., "SGX," or "TDX." Note that if the key server needs to restrict technologies, it must list technologies that can receive the key. |
| mrsigner | An array of measurements of the SGX enclave’s code signing certificate. This is mandatory. The same issuer must be added as a trusted certificate in key server configuration settings. |
| isvprodid | An array of (16-bit value) (ISVPRODID). This is mandatory. This is similar to a qualifier for the issuer, so the same issuer (code signing) key can sign separate products. |
| mrenclave | An array of enclave measurements that are allowed to retrieve the key (MRENCLAVE). The client must have one of these measurements in the SGX quote. This supports the use case of providing a key only to an SGX enclave that locally enforces the key usage policy. |
| isvsvn | Minimum security version number required for Enclave. |
| mrsignerseam | An array of measurements of seam module issuer. This is mandatory. |
| mrseam | An array of measurements of seam module. This is mandatory. |
| mrtd | A array of TD measurements. |
| rtmr0 | The measurement extended to RTMR0. |
| rtmr1 | The measurement extended to RTMR1. |
| rtmr2 | The measurement extended to RTMR2. |
| rtmr3 | The measurement extended to RTMR3. |
| seamsvn | The minimum security version number of seam module. |
| enforce_tcb_upto_date | The boolean value to enforce an up-to-date TCB. |
| policy_ids | A array of TD/Enclave Attestation Policy Ids. |
operationId: CreateKeyTransferPolicy
parameters:
- in: body
Expand Down Expand Up @@ -636,7 +662,7 @@ paths:
"rtmr1": "a53c98b16f0de470338e7f072d9c5fcef6171327ec6c78b842e637251b1de6e37354c47fb68de27ef14bb67caf288d9b",
"rtmr2": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"rtmr3": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"seamsvn": 0,
"seamsvn": 258,
"enforce_tcb_upto_date": false
},
"policy_ids": [
Expand All @@ -657,7 +683,7 @@ paths:
"mrseam": [
"0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe"
],
"seamsvn": 0,
"seamsvn": 258,
"mrtd": [
"cf656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50"
],
Expand Down Expand Up @@ -753,7 +779,7 @@ paths:
"mrseam": [
"0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe"
],
"seamsvn": 0,
"seamsvn": 258,
"mrtd": [
"cf656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50"
],
Expand Down
2 changes: 1 addition & 1 deletion model/attestation_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type TDXClaims struct {
TdxRTMR2 string `json:"tdx_rtmr2"`
TdxRTMR3 string `json:"tdx_rtmr3"`
TdxReportData string `json:"tdx_report_data,omitempty"`
TdxSeamSvn uint8 `json:"tdx_seamsvn"`
TdxSeamSvn uint16 `json:"tdx_seamsvn"`
TdxTDAttributeDebug bool `json:"tdx_td_attributes_debug"`
TdxTDAttributesSeptVe bool `json:"tdx_td_attributes_septve_disable"`
TdxTDAttributePKS bool `json:"tdx_td_attributes_protection_keys"`
Expand Down
6 changes: 3 additions & 3 deletions model/key_transfer_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ type TdxAttributes struct {
// Hash of the Contents of the TDX SEAM Module
// example: 0f3b72d0f9606086d6a7800e7d50b82fa6cb5ec64c7210353a0696c1eef343679bf5b9e8ec0bf58ab3fce10f2c166ebe
MrSeam []string `json:"mrseam,omitempty"`
// The Security Version Number of the TDX SEAM Module
// example: 00
SeamSvn *uint8 `json:"seamsvn,omitempty"`
// The Security Version Number of the TDX SEAM Module calculated as majorVersion x 256 + minorVersion
// example: 258
SeamSvn *uint16 `json:"seamsvn,omitempty"`
// SHA-384 measurement of a TD, accumulated during TD build.
// example: df656414fc0f49b23e2ae64b6f23b82901e2206aab36b671e360ebd414899dab51bbb60134bbe6ad8dcc70b995d9dc50
MRTD []string `json:"mrtd,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion repository/mocks/key_transfer_policy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func NewFakeKeyTransferPolicyStore() *MockKeyTransferPolicyStore {
log.WithError(err).Errorf("Error creating key transfer policy")
}

var j uint8 = 4
var j uint16 = 4

_, err = store.Create(&model.KeyTransferPolicy{
ID: uuid.MustParse("f64e25de-634f-44a3-b520-db480d8781ce"),
Expand Down
14 changes: 7 additions & 7 deletions service/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func validateSGXTokenClaims(tokenClaims *model.AttestationTokenClaim, sgxAttribu
func validateMrSigner(tokenMrSigner string, policyMrSigner []string) bool {

// if MrSigner is not provided in policy, it should not be evaluated
if policyMrSigner == nil || len(policyMrSigner) == 0 {
if len(policyMrSigner) == 0 {
logrus.Debug("MrSigner is not provided in key transfer policy, skipping MrSigner match against the token")
return true
}
Expand All @@ -89,7 +89,7 @@ func validateMrSigner(tokenMrSigner string, policyMrSigner []string) bool {
func validateIsvProdId(tokenIsvProdId uint16, policyIsvProdIds []uint16) bool {

// if IsvProdId is not provided in policy, it should not be evaluated
if policyIsvProdIds == nil || len(policyIsvProdIds) == 0 {
if len(policyIsvProdIds) == 0 {
logrus.Debug("IsvProdIds is not provided in key transfer policy, skipping IsvProdId match against the token")
return true
}
Expand All @@ -107,7 +107,7 @@ func validateIsvProdId(tokenIsvProdId uint16, policyIsvProdIds []uint16) bool {
func validateMrEnclave(tokenMrEnclave string, policyMrEnclave []string) bool {

// if MrEnclave is not provided in policy, it should not be evaluated
if policyMrEnclave == nil || len(policyMrEnclave) == 0 {
if len(policyMrEnclave) == 0 {
logrus.Debug("MrEnclave is not provided in key transfer policy, skipping MrEnclave match against the token")
return true
}
Expand Down Expand Up @@ -174,7 +174,7 @@ func validateTDXTokenClaims(tokenClaims *model.AttestationTokenClaim, tdxAttribu
func validateMrSignerSeam(tokenMrSignerSeam string, policyMrSignerSeam []string) bool {

// if MrSignerSeam is not provided in policy, it should not be evaluated
if policyMrSignerSeam == nil || len(policyMrSignerSeam) == 0 {
if len(policyMrSignerSeam) == 0 {
logrus.Debug("MrSignerSeam is not provided in key transfer policy, skipping MrSignerSeam match against the token")
return true
}
Expand All @@ -192,7 +192,7 @@ func validateMrSignerSeam(tokenMrSignerSeam string, policyMrSignerSeam []string)
func validateMrSeam(tokenMrSeam string, policyMrSeam []string) bool {

// if MrSeam is not provided in policy, it should not be evaluated
if policyMrSeam == nil || len(policyMrSeam) == 0 {
if len(policyMrSeam) == 0 {
logrus.Debug("MrSeam is not provided in key transfer policy, skipping MrSeam match against the token")
return true
}
Expand All @@ -207,7 +207,7 @@ func validateMrSeam(tokenMrSeam string, policyMrSeam []string) bool {
}

// validateSeamSvn- Function to Validate seamSvn
func validateSeamSvn(tokenSeamSvn uint8, policySeamSvn *uint8) bool {
func validateSeamSvn(tokenSeamSvn uint16, policySeamSvn *uint16) bool {

// if SeamSvn is not provided in policy, it should not be evaluated
if policySeamSvn == nil {
Expand All @@ -227,7 +227,7 @@ func validateSeamSvn(tokenSeamSvn uint8, policySeamSvn *uint8) bool {
func validateMrTD(tokenMrTD string, policyMrTD []string) bool {

// if MrTD is not provided in policy, it should not be evaluated
if policyMrTD == nil || len(policyMrTD) == 0 {
if len(policyMrTD) == 0 {
logrus.Debug("MrTD is not provided in key transfer policy, skipping MrTD match against the token")
return true
}
Expand Down
Loading

0 comments on commit 4287a5e

Please sign in to comment.