diff --git a/cocli/CORIM.md b/cocli/CORIM.md index 6b3f5a48..6015a7ec 100644 --- a/cocli/CORIM.md +++ b/cocli/CORIM.md @@ -14,7 +14,7 @@ together with the CBOR-encoded CoMIDs, CoSWIDs and/or CoTS to be embedded. * Please inspect `corim` JSON templates as examples under `data/corim/templates` `corim-*.json` ``` -$ cocli corim create --template data/corim/templates/corim-full.json --comid comid-dice-refval.cbor --coswid data/coswid/1.cbor --cots data/cots/c1.cbor +$ cocli corim create --template data/corim/templates/corim-full.json --comid comid-dice-refval.cbor --coswid data/coswid/1.cbor --cots data/cots/vendor.cbor ``` On success, you should see something like the following printed to stdout: ``` @@ -174,7 +174,7 @@ well as any parent folder exists prior to issuing the command. On success, the found CoMIDs, CoSWIDs, CoTS are saved in CBOR format: ``` -$ cocli corim extract --file signed-corim.cbor --output-dir output.d/ +$ cocli corim extract --file data/corim/signed-corim.cbor --output-dir output.d/ $ tree output.d/ output.d/ ├── 000000-comid.cbor diff --git a/cocli/COTS.md b/cocli/COTS.md index d05c0c9c..9e576075 100644 --- a/cocli/COTS.md +++ b/cocli/COTS.md @@ -11,18 +11,18 @@ Use the `cots create` subcommand to create a CBOR-encoded CoTS. The `environment ``` -$ cocli cots create --environment c1.json --tas tas_dir +$ cocli cots create --environment data/cots/env/vendor.json --tafile data/cots/shared_ta.ta ``` On success, you should see something like the following printed to stdout: ``` ->> created "c1.cbor" +>> created "vendor.cbor" ``` The CBOR-encoded CoTS file is stored in the current working directory with a name derived from its environment template. If you want, you can specify a different target directory and file name using the `--output` command line switch (abbrev. `-o`) ``` -$ cocli cots create --environment c1.json --tas tas_dir --output /tmp/myCots.cbor +$ cocli cots create --environment data/cots/env/vendor.json --tafile data/cots/shared_ta.ta --output /tmp/myCots.cbor >> created "/tmp/myCots.cbor" ``` Note that the output directory, as well as all its parent directories, MUST pre-exist. @@ -41,19 +41,15 @@ For example: ``` $ cocli cots display --file c1.cbor ``` -provided the `c1.cbor` file contains valid CoTS, would print something like: +provided the `vendor.cbor` file contains valid CoTS, would print something like: ``` ->> [c1.cbor] +>> [vendor.cbor] { - "tag-identity": { - "id": "ab0f44b1-bfdc-4604-ab4a-30f80407ebcc", - "version": 5 - }, "environments": [ { "environment": { "class": { - "vendor": "Worthless Sea, Inc." + "vendor": "Zesty Hands, Inc." } } } @@ -61,49 +57,66 @@ provided the `c1.cbor` file contains valid CoTS, would print something like: "keys": { "tas": [ { - "format": 2, - "data": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAErYoMAdqe2gJT3CvCcifZxyE9+N8T6Jy5zbeo5LYtnOipmi1wXA9/gNtlwAbRCRQitH/GEcvUaGlzPZxIOITV/g==" + "format": 1, + "data": "ooICejCCAnYwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATjUaoQOSQHpL0DfKC8EVTQ5wHwZ085yyxPkhBpLOu+7B0nl33FYWV1Hg4je/37FTbpmohFkUKWYd81z8C/K1DMBBQBXEXJrLBGKnFd1xCgeMAVSfEBPzCCAgEwPjELMAkGA1UEBgwCVVMxEDAOBgNVBAoMB0V4YW1wbGUxHTAbBgNVBAMMFEV4YW1wbGUgVHJ1c3QgQW5jaG9yoIIBvTCCAWSgAwIBAgIVANCdkL89UlzHc9Ui7XfVniK7pFuIMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYMAlVTMRAwDgYDVQQKDAdFeGFtcGxlMR0wGwYDVQQDDBRFeGFtcGxlIFRydXN0IEFuY2hvcjAeFw0yMjA1MTkxNTEzMDdaFw0zMjA1MTYxNTEzMDdaMD4xCzAJBgNVBAYMAlVTMRAwDgYDVQQKDAdFeGFtcGxlMR0wGwYDVQQDDBRFeGFtcGxlIFRydXN0IEFuY2hvcjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABONRqhA5JAekvQN8oLwRVNDnAfBnTznLLE+SEGks677sHSeXfcVhZXUeDiN7/fsVNumaiEWRQpZh3zXPwL8rUMyjPzA9MB0GA1UdDgQWBBQBXEXJrLBGKnFd1xCgeMAVSfEBPzALBgNVHQ8EBAMCAoQwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiALBidABsfpzG0lTL9Eh9b6AUbqnzF+koEZbgvppvvt9QIgVoE+bhEN0j6wSPzePjLrEdD+PEgyjHJ5rbA11SPq/1M=" } ] } } + ``` -While a `cots` folder with the following contents: +While a `data/cots` folder with the following contents: ``` $ tree cots/ cots/ ├── rubbish.cbor -├── valid-cots-1.cbor -├── valid-cots-2.cbor +├── namedtastore.cbor +├── vendor.cbor ``` could be inspected in one go using: ``` -$ cocli cots display --dir cots/ +$ cocli cots display --dir data/cots/ ``` which would output something like: ``` ->> failed displaying "cots/rubbish.cbor": CBOR decoding failed: EOF ->> [cots/valid-cots-1.cbor] +>> [data/cots/namedtastore.cbor] { - "tag-identity": { - "id": "43bbe37f-2e61-4b33-aed3-53cff1428b16" - }, -[...] + "environments": [ + { + "namedtastore": "Miscellaneous TA Store" + } + ], + "keys": { + "tas": [ + { + "format": 1, + "data": "ooIC1TCCAtEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATN0f5kzywEzZOYbaV23O3N8cku39JoLNjlHPwECbXDDWp0LpAO1z248/hoy6UW/TZMTPPR/93XwHsG16mSFy8XBBSKhM/5gJWjvDbW7qUY1peNm9cfYDCCAlwwXDELMAkGA1UEBgwCVVMxHzAdBgNVBAoMFlNub2JiaXNoIEFwcGFyZWwsIEluYy4xLDAqBgNVBAMMI1Nub2JiaXNoIEFwcGFyZWwsIEluYy4gVHJ1c3QgQW5jaG9yoIIB+jCCAZ+gAwIBAgIUEBuTRGXAEEVEHhu4xafAnqm+qYgwCgYIKoZIzj0EAwIwXDELMAkGA1UEBgwCVVMxHzAdBgNVBAoMFlNub2JiaXNoIEFwcGFyZWwsIEluYy4xLDAqBgNVBAMMI1Nub2JiaXNoIEFwcGFyZWwsIEluYy4gVHJ1c3QgQW5jaG9yMB4XDTIyMDUxOTE1MTMwOFoXDTMyMDUxNjE1MTMwOFowXDELMAkGA1UEBgwCVVMxHzAdBgNVBAoMFlNub2JiaXNoIEFwcGFyZWwsIEluYy4xLDAqBgNVBAMMI1Nub2JiaXNoIEFwcGFyZWwsIEluYy4gVHJ1c3QgQW5jaG9yMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEzdH+ZM8sBM2TmG2ldtztzfHJLt/SaCzY5Rz8BAm1ww1qdC6QDtc9uPP4aMulFv02TEzz0f/d18B7BtepkhcvF6M/MD0wHQYDVR0OBBYEFIqEz/mAlaO8NtbupRjWl42b1x9gMAsGA1UdDwQEAwIChDAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQC2cf43f3PPlCO6/dxv40ftIgxxToKHF72UzENv7+y4ygIhAIGtC/r6SGaFMaP7zD2EloBuIXTtyWu8Hwl+YGdXRY93" + } + ] + } } ->> [cots/valid-cots-2.cbor] +>> failed displaying "data/cots/rubbish.cbor": CBOR decoding failed: cbor: cannot unmarshal primitives into Go value of type cots.ConciseTaStore +>> [data/cots/vendor.cbor] { - "tag-identity": { - "id": "ab0f44b1-bfdc-4604-ab4a-30f80407ebcc" - }, -[...] + "environments": [ + { + "environment": { + "class": { + "vendor": "Zesty Hands, Inc." + } + } + } + ], + "keys": { + "tas": [ + { + "format": 1, + "data": "ooICejCCAnYwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATjUaoQOSQHpL0DfKC8EVTQ5wHwZ085yyxPkhBpLOu+7B0nl33FYWV1Hg4je/37FTbpmohFkUKWYd81z8C/K1DMBBQBXEXJrLBGKnFd1xCgeMAVSfEBPzCCAgEwPjELMAkGA1UEBgwCVVMxEDAOBgNVBAoMB0V4YW1wbGUxHTAbBgNVBAMMFEV4YW1wbGUgVHJ1c3QgQW5jaG9yoIIBvTCCAWSgAwIBAgIVANCdkL89UlzHc9Ui7XfVniK7pFuIMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYMAlVTMRAwDgYDVQQKDAdFeGFtcGxlMR0wGwYDVQQDDBRFeGFtcGxlIFRydXN0IEFuY2hvcjAeFw0yMjA1MTkxNTEzMDdaFw0zMjA1MTYxNTEzMDdaMD4xCzAJBgNVBAYMAlVTMRAwDgYDVQQKDAdFeGFtcGxlMR0wGwYDVQQDDBRFeGFtcGxlIFRydXN0IEFuY2hvcjBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABONRqhA5JAekvQN8oLwRVNDnAfBnTznLLE+SEGks677sHSeXfcVhZXUeDiN7/fsVNumaiEWRQpZh3zXPwL8rUMyjPzA9MB0GA1UdDgQWBBQBXEXJrLBGKnFd1xCgeMAVSfEBPzALBgNVHQ8EBAMCAoQwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiALBidABsfpzG0lTL9Eh9b6AUbqnzF+koEZbgvppvvt9QIgVoE+bhEN0j6wSPzePjLrEdD+PEgyjHJ5rbA11SPq/1M=" + } + ] + } } -Error: 1/3 display(s) failed -``` -One of more files and directories can be supplied in the same invocation, e.g.: -``` -$ cocli cots display -f c1.cbor \ - -f cots/c2.cbor \ - -d /var/spool/cots \ - -d yet-another-cots-folder/ +Note: One of more files and directories can be supplied in the same invocation, using -f and -d directive: + ``` diff --git a/cocli/cmd/cotsCreate.go b/cocli/cmd/cotsCreate.go index eb3c52dd..af44bca9 100644 --- a/cocli/cmd/cotsCreate.go +++ b/cocli/cmd/cotsCreate.go @@ -54,6 +54,16 @@ func NewCotsCreateCtsCmd() *cobra.Command { --tas=tas_dir \ --cas=cas_dir \ --output=cots.cbor + + Alternatively one can specify individual TA files (in DER Format) or CA files (binary, DER-encoded X.509 Certificate) + + cocli cots create --environment=env-template.json \ + --purpose=eat \ + --purpose=corim \ + --permclaims=claims-template.json \ + --tafile=tas_dir \ + --cafile=cas_dir \ + --output=cots.cbor `, RunE: func(cmd *cobra.Command, args []string) error { @@ -100,7 +110,7 @@ func NewCotsCreateCtsCmd() *cobra.Command { &cotsCreateCtsTaDirs, "tas", "t", []string{}, "a directory containing binary DER-encoded trust anchor files", ) cmd.Flags().StringArrayVarP( - &cotsCreateCtsTaFiles, "tafile", "", []string{}, "a DER-encoded trust anchor file", + &cotsCreateCtsTaFiles, "tafile", "f", []string{}, "a DER-encoded trust anchor file", ) cmd.Flags().StringArrayVarP( diff --git a/cocli/data/cots/namedtastore.cbor b/cocli/data/cots/namedtastore.cbor new file mode 100644 index 00000000..2bbbcc17 Binary files /dev/null and b/cocli/data/cots/namedtastore.cbor differ diff --git a/cocli/data/cots/rubbish.cbor b/cocli/data/cots/rubbish.cbor new file mode 100644 index 00000000..336db72d Binary files /dev/null and b/cocli/data/cots/rubbish.cbor differ diff --git a/cocli/data/cots/vendor.cbor b/cocli/data/cots/vendor.cbor new file mode 100644 index 00000000..8996a35a Binary files /dev/null and b/cocli/data/cots/vendor.cbor differ