Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial stab at the schema #3

Merged
merged 14 commits into from
Mar 23, 2022
Merged
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# test-vectors
Repository to hold the various test inputs
# GlueCOSE Validation Suite

**Caution: this is a work in progress in its very early stage.**

This is a repository of GlueCOSE test cases. Eventually, this will morph in to
the GlueCOSE validation suite.

Here's a first stab at the [CDDL schema](gluecose-schema.cddl) for specifying
test cases as well as their results.

And here's the first test case for a [successful Sign1](sign1-0000.json) that
has been [validated](misc/gocose-result-sign1-0000.json) using the go-cose
implementation.

Implementation note: use `/dev/zero` as PRNG in order to make the randomised
test deterministic.
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved
73 changes: 73 additions & 0 deletions gluecose-schema.cddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
start = TestCaseInput / TestCaseOutput

TestCaseInput = {
uuid: text ; unique identifier for the test case
? title: text
? description: text
operation
}

TestCaseOutput = {
uuid: text ; unique identifier for the test case
implementation: Implementation
executionTs: text ; RFC3339 date-time
result: Result
}

Result /= "success"
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved
Result /= "skipped"
Result /= "failure"
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved

Implementation = {
name: text
version: text
publicRepoURL: text
license: text
}

operation //= ( "sign1" => OpSign1 )
operation //= ( "sign" => TODO )
operation //= ( "encrypt" => TODO )
operation //= ( "encrypt0" => TODO )
operation //= ( "mac" => TODO )
operation //= ( "mac0" => TODO )

TODO = "todo"

OpSign1 = {
input: Sign1Input
intermediate: Sign1Intermediate
output
}

output //= ( "expectedOutput" => CBORBlob )
output //= ( "expectedFailure" => text ) ; failure reason

Sign1Input = {
key: JWK
alg: SignAlgo
payload: HexString
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved
protectedHeaders: CBORBlob
unprotectedHeaders: CBORBlob
? external: HexString
}

Sign1Intermediate = {
tbsHex: HexString
}

CBORBlob = {
cborHex: HexString
cborDiag: text
}

HexString = text .regexp "([a-f0-9]{2})+"

; See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
SignAlgo /= "ES256"
SignAlgo /= "ES384"
; SignAlgo /= TODO

JWK = {
+ text => text
}
11 changes: 11 additions & 0 deletions misc/gocose-result-sign1-0000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"uuid": "66584A57-390B-4A52-B7B6-B7CA4FC4204F",
"implementation": {
"name": "go-cose",
"version": "0.0.1",
"publicRepoURL": "https://github.com/veraison/go-cose",
"license": "MPL 2.0"
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved
},
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved
"executionTs": "2022-03-03T18:49:03Z",
"result": "success"
}
34 changes: 34 additions & 0 deletions sign1-0000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"uuid": "66584A57-390B-4A52-B7B6-B7CA4FC4204F",
"title": "Let's go",
"description": "First attempt at drafting a Sign1 test case",
"sign1": {
"input": {
"key": {
"kty": "EC",
"crv": "P-256",
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4",
"d": "V8kgd2ZBRuh2dgyVINBUqpPDr7BOMGcF22CQMIUHtNM"
},
"alg": "ES256",
"payload": "546869732069732074686520636f6e74656e742e",
"protectedHeaders": {
"cborHex": "a10126",
"cborDiag": "{1: -7}"
},
"unprotectedHeaders": {
"cborHex": "a104423131",
"cborDiag": "{4: h'3131'}"
},
"external": "11aa22bb33cc44dd55006699"
},
"intermediate": {
"tbsHex": "846a5369676e61747572653143a101264c11aa22bb33cc44dd5500669954546869732069732074686520636f6e74656e742e"
},
"expectedOutput": {
"cborHex": "d28443a10126a10442313154546869732069732074686520636f6e74656e742e58403a7487d9a528cb61dd8e99bd652c12577fc47d70ee5af2e703c420584f060fc7a8d61e4a35862b2b531a8447030ab966aeed8dd45ebc507c761431e349995770",
thomas-fossati marked this conversation as resolved.
Show resolved Hide resolved
"cborDiag": "18([h'A10126', {4: h'3131'}, h'546869732069732074686520636F6E74656E742E', h'3A7487D9A528CB61DD8E99BD652C12577FC47D70EE5AF2E703C420584F060FC7A8D61E4A35862B2B531A8447030AB966AEED8DD45EBC507C761431E349995770'])"
}
}
}