ratsdtoken

package module
v0.0.0-...-e792517 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

ratsd-token

Go packages for encoding and decoding RATSD evidence tokens. The legacy JSON token is provided by github.com/veraison/ratsd-token; the CBOR/COSE token is provided by the separate Go module github.com/veraison/ratsd-token/v2.

Both modules require Go 1.26 or newer. See the CDDL specification and the v2 token example for their wire formats.

The root module also contains github.com/veraison/ratsd-token/tokens for attester payloads shared by RATSD and its consumers. It provides TSMReport and GPUEvidence with JSON and CBOR support as appropriate. Their formats are specified in TSM report CDDL and NVIDIA GPU evidence CDDL.

Consumers of github.com/veraison/ratsd/tokens should switch to github.com/veraison/ratsd-token/tokens. Once all such imports are updated, they can remove the github.com/veraison/ratsd module requirement and run go mod tidy.

Token generator

gen-ratsd-token packages one or more component evidence tokens into a signed RATSD v2 CBOR/COSE token. Its source is in v2/cmd/gen-ratsd-token.

Build it from this checkout:

cd v2
go build -o gen-ratsd-token ./cmd/gen-ratsd-token
cd ..

Each component is specified as three positional arguments: its collection key, media type, and file path. For example, from the repository root:

./v2/gen-ratsd-token \
  --key v2/cmd/gen-ratsd-token/testdata/ec-p256.jwk \
  --nonce 0123456789abcdef \
  --oemid 1337 \
  --output ratsd-token.cbor \
  cca \
    'application/eat-collection; profile="http://arm.com/CCA-SSD/1.0.0"' \
    v2/cmd/gen-ratsd-token/testdata/cca-good.cbor \
  eat-da \
    'application/eat-ucs+json; eat_profile="tag:linaro.org,2025:device#1.0.0"' \
    v2/cmd/gen-ratsd-token/testdata/da-spdm-good.cbor

The signing key must be a private JWK. Without --key, the command reads key.jwk in the current directory. Supported keys are EC P-256/P-384/P-521, Ed25519, and RSA with a PS256, PS384, or PS512 JWK algorithm. The included key is a public test fixture and must not be used for real signing.

--nonce takes a hex-encoded value; omitting it generates a random 64-byte nonce. The default output is ratsd-token.cbor. Use --help for the remaining claim overrides and logging options.

After building, ./scripts/gen-sample-token generates a token using the bundled fixtures and writes it into the current directory.

The utility and sample data were moved from veraison/gen-ratsd-token at commit 96f2df7d9b0b01772255ca651d0f842354dd37bb. The utility now uses this repository's v2 module directly.

Testing

Run tests in each module:

go test ./...
cd v2 && go test ./...

The library was moved from veraison/ratsd at commit 7ab53a031ba9a376a69b86397c5ed60954d1894d. Consumers of the old module paths should update imports to the paths above.

Documentation

Overview

Copyright 2026 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	LegacyProfile = "tag:github.com,2024:veraison/ratsd"

	NonceAdjustFunctionShake128 = "shake-128"
	NonceAdjustFunctionShake256 = "shake-256"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	EatProfile          *eat.Profile    `json:"eat_profile"`
	EatNonce            *eat.Nonce      `json:"eat_nonce"`
	CMW                 string          `json:"cmw"`
	NonceAdjustFunction *string         `json:"vnd.veraison.nonce_adjust_function,omitempty"`
	NonceAdjustMap      map[string]uint `json:"vnd.veraison.nonce_adjust_map,omitempty"`
}

Claims contains the legacy RATSD token claims defined in docs/ratsd-token.cddl.

func (Claims) GetCMW

func (c Claims) GetCMW() *cmw.CMW

GetCMW returns the legacy CMW collection claim.

func (Claims) GetEatNonce

func (c Claims) GetEatNonce() *eat.Nonce

GetEatNonce returns the EAT nonce claim.

func (Claims) GetEatProfile

func (c Claims) GetEatProfile() *eat.Profile

GetEatProfile returns the EAT profile claim.

func (Claims) GetKeyandNonceSz

func (c Claims) GetKeyandNonceSz(key string) (uint, bool)

GetKeyandNonceSz returns the configured adjusted nonce size for the given key. The boolean result reports whether the key was present in the nonce-adjust map.

func (Claims) GetNonceAdjustFn

func (c Claims) GetNonceAdjustFn() string

GetNonceAdjustFn returns the nonce adjustment algorithm, if set.

func (Claims) GetNonceAdjustMap

func (c Claims) GetNonceAdjustMap() map[string]uint

GetNonceAdjustMap returns a copy of the nonce adjustment map.

func (*Claims) SetCMW

func (c *Claims) SetCMW(v interface{}) error

SetCMW serializes the supplied CMW object into the legacy base64 claim form.

func (*Claims) SetKeyandNonceSz

func (c *Claims) SetKeyandNonceSz(key string, sz uint) error

SetKeyandNonceSz sets the nonce-adjusted size for a given key.

func (*Claims) SetNonce

func (c *Claims) SetNonce(v []byte) error

SetNonce replaces the stored EAT nonce with the supplied raw nonce value.

func (*Claims) SetNonceAdjustFn

func (c *Claims) SetNonceAdjustFn(alg string) error

SetNonceAdjustFn sets the nonce adjustment algorithm.

type Evidence

type Evidence struct {
	Claims Claims `json:"-"`
}

Evidence exposes the legacy RATSD token as a single claims container.

func NewEvidence

func NewEvidence() *Evidence

NewEvidence returns an Evidence with the legacy EAT profile preset.

func (Evidence) GetClaims

func (e Evidence) GetClaims() (c Claims, err error)

GetClaims returns a copy of the stored claims after validating the evidence state.

func (Evidence) MarshalJSON

func (e Evidence) MarshalJSON() ([]byte, error)

MarshalJSON encodes Evidence using the flat legacy claim layout.

func (*Evidence) SetClaims

func (e *Evidence) SetClaims(c Claims) error

SetClaims attaches the supplied claims to the Evidence instance. Only successfully validated claims are allowed to be set.

func (*Evidence) UnmarshalJSON

func (e *Evidence) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes Evidence from the flat legacy claim layout.

func (*Evidence) Valid

func (e *Evidence) Valid() error

Valid checks whether the Evidence matches the legacy RATSD token shape.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址