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

add new tests for ES{256,384,512} #4

Merged
merged 6 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ jobs:
- name: set up PATH
run: echo "$(gem env gempath | cut -d':' -f1)/bin" >> $GITHUB_PATH
- uses: actions/checkout@v2
- name: test schema against test vectors
run: cddl=cddl mdspell=unused make tests
- name: test schema against any extra document
run: cddl=cddl mdspell=unused make extra
- name: test schema against test vectors and any extra document
run: cddl=cddl mdspell=unused make check
51 changes: 39 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
.DEFAULT_GOAL := all
all: check spell

SCHEMA := gluecose-schema.cddl

TESTS := sign1-verify-0000.json
TESTS += sign1-sign-0000.json

TESTS := $(wildcard sign1*.json)
EXTRA := misc/gocose-result-sign1-verify-0000.json
DOCS := README.md

include tools.mk

.PHONY: tests
tests: ; for f in $(TESTS) ; do $(cddl) $(SCHEMA) v $$f ; done
check::

.PHONY: extra
extra: ; for f in $(EXTRA) ; do $(cddl) $(SCHEMA) v $$f ; done
# $(1): check targets infix (e.g., "x" creates targets "check-x-schema"
# and "check-x-files")
# $(2): reference CDDL schema
# $(3): files to be checked against the reference schema
define check_validity

.PHONY: spell
spell: ; $(mdspell) --en-us README.md
.PHONY: check-$(1)-schema
check-$(1)-schema: $(2)
@echo "><> validating schema: $$<" ; \
$$(cddl) $$< g 1 &>/dev/null

.PHONY: check-$(1)-files
check-$(1)-files: $(2) $(3)
@for f in $(3) ; do \
echo "><> validating file: $$$$f against $$< schema" ; \
$$(cddl) $$< v $$$$f &>/dev/null || exit 1 ; \
done

all: tests extra spell
check:: check-$(1)-schema check-$(1)-files

endef

$(eval $(call check_validity,test,$(SCHEMA),$(TESTS)))
$(eval $(call check_validity,extra,$(SCHEMA),$(EXTRA)))

.PHONY: spell
spell: $(DOCS) ; @$(mdspell) --en-us $^

help:
@echo
@echo "Available targets:"
@echo " check - run all validations"
@echo " check-test-schema - validate the test vectors schema"
@echo " check-test-files - validate tests against the schema"
@echo " check-extra-files - validate any extra files against the schema"
@echo " spell - check documentation for spelling errors"
@echo
3 changes: 2 additions & 1 deletion gluecose-schema.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ HexString = text .regexp "([a-f0-9]{2})+"
; See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
COSEAlgo /= "ES256"
COSEAlgo /= "ES384"
COSEAlgo /= "ES512"
; COSEAlgo /= TODO

JWK = {
Expand All @@ -82,4 +83,4 @@ Implementation = {
sourceLang: [ + text ]
? targetLang: [ + text ]
deterministic: bool
}
}
13 changes: 7 additions & 6 deletions sign1-sign-0000.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"uuid": "D55A49BD-53D9-42B1-9E76-E0CF2AD33E9D",
"title": "And another one...",
"description": "Second attempt at a Sign1 test case (sign)",
"key": {
"title": "Sign1 w/ external input - ECDSA w/ SHA-256 (sign)",
"description": "Sign with one signer using ECDSA w/ SHA-256 supplying external input",
"key": {
"kty": "EC",
"crv": "P-256",
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
Expand All @@ -18,16 +18,17 @@
},
"unprotectedHeaders": {
"cborHex": "a104423131",
"cborDiag": "{4: h'3131'}"
"cborDiag": "{4: '11'}"
},
"tbsHex": {
"cborHex": "846a5369676e61747572653143a101264c11aa22bb33cc44dd5500669954546869732069732074686520636f6e74656e742e",
"cborDiag": "['Signature1', h'A10126', h'11AA22BB33CC44DD55006699', h'546869732069732074686520636F6E74656E742E']"
"cborDiag": "[\"Signature1\", h'A10126', h'11AA22BB33CC44DD55006699', h'546869732069732074686520636F6E74656E742E']"
},
"external": "11aa22bb33cc44dd55006699",
"detached": false,
"expectedOutput": {
"cborHex": "d28443a10126a10442313154546869732069732074686520636f6e74656e742e58403a7487d9a528cb61dd8e99bd652c12577fc47d70ee5af2e703c420584f060fc7a8d61e4a35862b2b531a8447030ab966aeed8dd45ebc507c761431e349995770",
"cborDiag": "18([h'A10126', {4: h'3131'}, h'546869732069732074686520636F6E74656E742E', h'3A7487D9A528CB61DD8E99BD652C12577FC47D70EE5AF2E703C420584F060FC7A8D61E4A35862B2B531A8447030AB966AEED8DD45EBC507C761431E349995770'])"
"cborDiag": "18([h'A10126', {4: '11'}, h'546869732069732074686520636F6E74656E742E', h'3A7487D9A528CB61DD8E99BD652C12577FC47D70EE5AF2E703C420584F060FC7A8D61E4A35862B2B531A8447030AB966AEED8DD45EBC507C761431E349995770'])"
},
"fixedOutputLength": 32
}
Expand Down
34 changes: 34 additions & 0 deletions sign1-sign-0001.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"uuid": "0F78DB1C-C30F-47B1-AF19-6D0C0B2F3803",
"title": "Sign1 - ECDSA w/ SHA-256 (sign)",
"description": "Sign with one signer using ECDSA w/ SHA-256",
"key": {
"kty": "EC",
"crv": "P-256",
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4",
"d": "V8kgd2ZBRuh2dgyVINBUqpPDr7BOMGcF22CQMIUHtNM"
},
"alg": "ES256",
"sign1::sign": {
"payload": "546869732069732074686520636f6e74656e742e",
"protectedHeaders": {
"cborHex": "a201260300",
"cborDiag": "{1: -7, 3: 0}"
},
"unprotectedHeaders": {
"cborHex": "a104423131",
"cborDiag": "{4: '11'}"
},
"tbsHex": {
"cborHex": "846a5369676e61747572653145a2012603004054546869732069732074686520636f6e74656e742e",
"cborDiag": "[\"Signature1\", h'A201260300', h'', h'546869732069732074686520636F6E74656E742E']"
},
"detached": false,
"expectedOutput": {
"cborHex": "d28445a201260300a10442313154546869732069732074686520636f6e74656e742e58402ad3b9dcc1e13d04f357e11cc8acd825196620e62f0d8deca72672508b829d90e07a3f23be6aa36fd6ebd31e2ed08d1760bffd981f991bfc94a45199a54875c4",
"cborDiag": "18([h'A201260300', {4: '11'}, h'546869732069732074686520636F6E74656E742E', h'2AD3B9DCC1E13D04F357E11CC8ACD825196620E62F0D8DECA72672508B829D90E07A3F23BE6AA36FD6EBD31E2ED08D1760BFFD981F991BFC94A45199A54875C4'])"
},
"fixedOutputLength": 34
}
}
35 changes: 35 additions & 0 deletions sign1-sign-0002.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"uuid": "E693D0C8-C702-4E6C-A70D-0D4DA4C408A0",
"title": "Sign1 - ECDSA w/ SHA-384 (sign)",
"description": "Sign with one signer using ECDSA w/ SHA-384",
"key": {
"kty": "EC",
"kid": "P384",
"crv": "P-384",
"x": "kTJyP2KSsBBhnb4kjWmMF7WHVsY55xUPgb7k64rDcjatChoZ1nvjKmYmPh5STRKc",
"y": "mM0weMVU2DKsYDxDJkEP9hZiRZtB8fPfXbzINZj_fF7YQRynNWedHEyzAJOX2e8s",
"d": "ok3Nq97AXlpEusO7jIy1FZATlBP9PNReMU7DWbkLQ5dU90snHuuHVDjEPmtV0fTo"
},
"alg": "ES384",
"sign1::sign": {
"payload": "546869732069732074686520636f6e74656e742e",
"protectedHeaders": {
"cborHex": "a1013822",
"cborDiag": "{1: -35}"
},
"unprotectedHeaders": {
"cborHex": "a1044450333834",
"cborDiag": "{4: 'P384'}"
},
"tbsHex": {
"cborHex": "846a5369676e61747572653144a10138224054546869732069732074686520636f6e74656e742e",
"cborDiag": "[\"Signature1\", h'A1013822', h'', h'546869732069732074686520636F6E74656E742E']"
},
"detached": false,
"expectedOutput": {
"cborHex": "d28444a1013822a104445033383454546869732069732074686520636f6e74656e742e5860aa46c1ab71cd3c1e68ed62c27653797cb72cba3a856fd5e2f38794eee0d666e88139ec51fb62466f4865ca56df493905911e329e829c1887f6259681360a8e7f7d3fd080dcb0720066f13e1621656700c99d6e3771ac2549fde998ee9b1e2cad",
"cborDiag": "18([h'A1013822', {4: 'P384'}, h'546869732069732074686520636F6E74656E742E', h'AA46C1AB71CD3C1E68ED62C27653797CB72CBA3A856FD5E2F38794EEE0D666E88139EC51FB62466F4865CA56DF493905911E329E829C1887F6259681360A8E7F7D3FD080DCB0720066F13E1621656700C99D6E3771AC2549FDE998EE9B1E2CAD'])"
},
"fixedOutputLength": 35
}
}
36 changes: 36 additions & 0 deletions sign1-sign-0003.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"uuid": "06EFA821-9026-4CDD-A4FB-634103472BC3",
"title": "Sign1 - ECDSA w/ SHA-512 (sign)",
"description": "Sign with one signer using ECDSA w/ SHA-512",
"key": {
"kty": "EC",
"kid": "[email protected]",
"use": "sig",
"crv": "P-521",
"x": "AHKZLLOsCOzz5cY97ewNUajB957y-C-U88c3v13nmGZx6sYl_oJXu9A5RkTKqjqvjyekWF-7ytDyRXYgCF5cj0Kt",
"y": "AdymlHvOiLxXkEhayXQnNCvDX4h9htZaCJN34kfmC6pV5OhQHiraVySsUdaQkAgDPrwQrJmbnX9cwlGfP-HqHZR1",
"d": "AAhRON2r9cqXX1hg-RoI6R1tX5p2rUAYdmpHZoC1XNM56KtscrX6zbKipQrCW9CGZH3T4ubpnoTKLDYJ_fF3_rJt"
},
"alg": "ES512",
"sign1::sign": {
"payload": "546869732069732074686520636f6e74656e742e",
"protectedHeaders": {
"cborHex": "a1013823",
"cborDiag": "{1: -36}"
},
"unprotectedHeaders": {
"cborHex": "a104581e62696c626f2e62616767696e7340686f626269746f6e2e6578616d706c65",
"cborDiag": "{4: '[email protected]'}"
},
"tbsHex": {
"cborHex": "846a5369676e61747572653144a10138234054546869732069732074686520636f6e74656e742e",
"cborDiag": "[\"Signature1\", h'A1013823', h'', h'546869732069732074686520636F6E74656E742E']"
},
"detached": false,
"expectedOutput": {
"cborHex": "d28444a1013823a104581e62696c626f2e62616767696e7340686f626269746f6e2e6578616d706c6554546869732069732074686520636f6e74656e742e58840128bbda237a1b55568da74cefe02cf2d2a6216f80ac757bea8effc056d2f634f6e257077b0dabe9d4b3689eb8228e20f60bc74ff84ae3a38ee9a69e158cbf80f93a017acf5877e5083548a45143b602ccd776c5eb39537a2e68dc8c47ff62e10fc42f045b781e4313fbf421903785c3dfeb181c3a93b46a67a9b0e82947ee83f7b44cf0",
"cborDiag": "18([h'A1013823', {4: '[email protected]'}, h'546869732069732074686520636F6E74656E742E', h'0128BBDA237A1B55568DA74CEFE02CF2D2A6216F80AC757BEA8EFFC056D2F634F6E257077B0DABE9D4B3689EB8228E20F60BC74FF84AE3A38EE9A69E158CBF80F93A017ACF5877E5083548A45143B602CCD776C5EB39537A2E68DC8C47FF62E10FC42F045B781E4313FBF421903785C3DFEB181C3A93B46A67A9B0E82947EE83F7B44CF0'])"
},
"fixedOutputLength": 62
}
}
7 changes: 3 additions & 4 deletions sign1-verify-0000.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"uuid": "66584A57-390B-4A52-B7B6-B7CA4FC4204F",
"title": "Let's go",
"description": "First attempt at drafting a Sign1 test case",
"title": "Sign1 w/ external input - ECDSA w/ SHA-256 (verify)",
"description": "Verify signature with one signer using ECDSA w/ SHA-256 supplying external input",
"key": {
"kty": "EC",
"crv": "P-256",
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4",
"d": "V8kgd2ZBRuh2dgyVINBUqpPDr7BOMGcF22CQMIUHtNM"
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4"
},
"alg": "ES256",
"sign1::verify": {
Expand Down
19 changes: 19 additions & 0 deletions sign1-verify-0001.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"uuid": "2AF74107-34AB-4DD5-BC3C-E83895CAE1A4",
"title": "Sign1 - ECDSA w/ SHA-256 (verify)",
"description": "Verify signature with one signer using ECDSA w/ SHA-256",
"key": {
"kty": "EC",
"crv": "P-256",
"x": "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
"y": "IBOL-C3BttVivg-lSreASjpkttcsz-1rb7btKLv8EX4"
},
"alg": "ES256",
"sign1::verify": {
"taggedCOSESign1": {
"cborHex": "d28445a201260300a10442313154546869732069732074686520636f6e74656e742e58402ad3b9dcc1e13d04f357e11cc8acd825196620e62f0d8deca72672508b829d90e07a3f23be6aa36fd6ebd31e2ed08d1760bffd981f991bfc94a45199a54875c4",
"cborDiag": "18([h'A201260300', {4: '11'}, h'546869732069732074686520636F6E74656E742E', h'2AD3B9DCC1E13D04F357E11CC8ACD825196620E62F0D8DECA72672508B829D90E07A3F23BE6AA36FD6EBD31E2ED08D1760BFFD981F991BFC94A45199A54875C4'])"
},
"shouldVerify": true
}
}
20 changes: 20 additions & 0 deletions sign1-verify-0002.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"uuid": "C5763BDB-5A23-4E9E-9AA2-463A8B107033",
"title": "Sign1 - ECDSA w/ SHA-384 (verify)",
"description": "Verify signature with one signer using ECDSA w/ SHA-384",
"key": {
"kty": "EC",
"kid": "P384",
"crv": "P-384",
"x": "kTJyP2KSsBBhnb4kjWmMF7WHVsY55xUPgb7k64rDcjatChoZ1nvjKmYmPh5STRKc",
"y": "mM0weMVU2DKsYDxDJkEP9hZiRZtB8fPfXbzINZj_fF7YQRynNWedHEyzAJOX2e8s"
},
"alg": "ES384",
"sign1::verify": {
"taggedCOSESign1": {
"cborHex": "d28444a1013822a104445033383454546869732069732074686520636f6e74656e742e5860aa46c1ab71cd3c1e68ed62c27653797cb72cba3a856fd5e2f38794eee0d666e88139ec51fb62466f4865ca56df493905911e329e829c1887f6259681360a8e7f7d3fd080dcb0720066f13e1621656700c99d6e3771ac2549fde998ee9b1e2cad",
"cborDiag": "18([h'A1013822', {4: 'P384'}, h'546869732069732074686520636F6E74656E742E', h'AA46C1AB71CD3C1E68ED62C27653797CB72CBA3A856FD5E2F38794EEE0D666E88139EC51FB62466F4865CA56DF493905911E329E829C1887F6259681360A8E7F7D3FD080DCB0720066F13E1621656700C99D6E3771AC2549FDE998EE9B1E2CAD'])"
},
"shouldVerify": true
}
}
21 changes: 21 additions & 0 deletions sign1-verify-0003.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"uuid": "5F6E65B5-1E2F-4242-87CE-C76E26E927D8",
"title": "Sign1 - ECDSA w/ SHA-512 (verify)",
"description": "Verify signature with one signer using ECDSA w/ SHA-512",
"key": {
"kty": "EC",
"kid": "[email protected]",
"use": "sig",
"crv": "P-521",
"x": "AHKZLLOsCOzz5cY97ewNUajB957y-C-U88c3v13nmGZx6sYl_oJXu9A5RkTKqjqvjyekWF-7ytDyRXYgCF5cj0Kt",
"y": "AdymlHvOiLxXkEhayXQnNCvDX4h9htZaCJN34kfmC6pV5OhQHiraVySsUdaQkAgDPrwQrJmbnX9cwlGfP-HqHZR1"
},
"alg": "ES512",
"sign1::verify": {
"taggedCOSESign1": {
"cborHex": "d28444a1013823a104581e62696c626f2e62616767696e7340686f626269746f6e2e6578616d706c6554546869732069732074686520636f6e74656e742e58840128bbda237a1b55568da74cefe02cf2d2a6216f80ac757bea8effc056d2f634f6e257077b0dabe9d4b3689eb8228e20f60bc74ff84ae3a38ee9a69e158cbf80f93a017acf5877e5083548a45143b602ccd776c5eb39537a2e68dc8c47ff62e10fc42f045b781e4313fbf421903785c3dfeb181c3a93b46a67a9b0e82947ee83f7b44cf0",
"cborDiag": "18([h'A1013823', {4: '[email protected]'}, h'546869732069732074686520636F6E74656E742E', h'0128BBDA237A1B55568DA74CEFE02CF2D2A6216F80AC757BEA8EFFC056D2F634F6E257077B0DABE9D4B3689EB8228E20F60BC74FF84AE3A38EE9A69E158CBF80F93A017ACF5877E5083548A45143B602CCD776C5EB39537A2E68DC8C47FF62E10FC42F045B781E4313FBF421903785C3DFEB181C3A93B46A67A9B0E82947EE83F7B44CF0'])"
},
"shouldVerify": true
}
}