Newer
Older
This repo will contain a prototype manifest generator following the specification in the SUIT draft (https://tools.ietf.org/html/draft-moran-suit-manifest-01)
To encode:
```
python3 ./encode.py ./test-file.json ./test-out.cbor
```
NOTE: aliases, dependencies, and extensions are not supported in this version.
To sign:
```
openssl ecparam -name secp256r1 -out secp256r1.pem
openssl ecparam -in secp256r1.pem -genkey -noout -out secp256r1-key.pem
openssl ec -in secp256r1-key.pem -pubout -out ecpubkey.pem
python3 ./sign.py secp256r1-key.pem ecpubkey.pem ./test-out.cbor ./test-out-signed.cose
```
To see what was created:
```
>>> import cbor
>>> fd = open('test-out-signed.cose','rb')
>>> s = fd.read()
>>> pod = cbor.loads(s)
>>> print(pod)
{1: Tag(98, [b'\xa1\x03\x18*', {}, None, [[b'\xa1\x01&', {4: b"l$S'\xd8\x19\xb8\xb4}k\x85_\x1b\x8c\xda \xd9\x98\x11\x7f\x85\xccY\x04B\x14\x1e\xcc\x89\xc2w\xfa"}, b"0F\x02!\x00\xb8\x0c9\x02]\t\xa7\x9e\x9f\x92J:\x87fI}\xde\xf6\xcc\xee\xe7\xbc\x11\x8aY^\x9e\xefC\xd4@\xa8\x02!\x00\xd6q\x82\xf42\xe2\x13T\x8e\x18\x96\x97U\x1d1\x9dW\xfa\xc4\x84\x14M\xb9\xbc?'@\xe5s\x8du7"]]]), 2: b"\xa5\x01\x01\x02\x02\x05\x81\xa3\x01\x81A0\x02\x1a\x00\x01p\xde\x03\x84D\xa1\x01\x18)\xa0\xf6X P4\xd9\x9a\x08]\xce\xf3y\xec\xa72~P\x1b\xc2&_\x1dP\xf6\x8c\xca\x17X.\x7fJ4\x1d\xc3e\x06\x84D\xa1\x01\x18)\xa0\xf6X \xbe\x86\xe5\xed\xac\x07\x82,\xde\x9d\x81z1\xbd\x82\xdc\xae\xe3\x98\xe6\xe4'\x87]\xbc)\xfbh\x1de\x94v\x08\x84D\xa1\x01\x18)\xa0\xf6X N'\x14Y\x84y\xd8\xb6cH\x05\xdfP\x19\xef4 \xed\xff\x03)\x89J\xcc\x91\xde\x8c\x8d\xe1o\xb0\xcf", 4: b'\xa1\x01\x81\xa2\x01\x81A0\x02\x81\xa2\x01\x82\x01\x01\x03\x82\x00x8https://tools.ietf.org/html/draft-moran-suit-manifest-03', 6: b'\xa1\x01x\xc8Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed tincidunt ante, a sodales ligula. Phasellus ullamcorper odio commodo ipsum egestas, vitae lacinia leo ornare. Suspendisse posuere sed.'}
This shows a OuterWrapper structure that contains a CoseSign_Tagged structure.
{
1: Tag(98, [
b'\xa1\x03\x18*',
{},
None,
[[ b'\xa1\x01&',
{4: b"l$S'\xd8\x19\xb8\xb4}k\x85_\x1b\x8c\xda \xd9\x98\x11\x7f\x85\xccY\x04B\x14\x1e\xcc\x89\xc2w\xfa"},
b"0F\x02!\x00\xb8\x0c9\x02]\t\xa7\x9e\x9f\x92J:\x87fI}\xde\xf6\xcc\xee\xe7\xbc\x11\x8aY^\x9e\xefC\xd4@\xa8\x02!\x00\xd6q\x82\xf42\xe2\x13T\x8e\x18\x96\x97U\x1d1\x9dW\xfa\xc4\x84\x14M\xb9\xbc?'@\xe5s\x8du7"]]
]),
2: b"\xa5\x01\x01\x02\x02\x05\x81\xa3\x01\x81A0\x02\x1a\x00\x01p\xde\x03\x84D\xa1\x01\x18)\xa0\xf6X P4\xd9\x9a\x08]\xce\xf3y\xec\xa72~P\x1b\xc2&_\x1dP\xf6\x8c\xca\x17X.\x7fJ4\x1d\xc3e\x06\x84D\xa1\x01\x18)\xa0\xf6X \xbe\x86\xe5\xed\xac\x07\x82,\xde\x9d\x81z1\xbd\x82\xdc\xae\xe3\x98\xe6\xe4'\x87]\xbc)\xfbh\x1de\x94v\x08\x84D\xa1\x01\x18)\xa0\xf6X N'\x14Y\x84y\xd8\xb6cH\x05\xdfP\x19\xef4 \xed\xff\x03)\x89J\xcc\x91\xde\x8c\x8d\xe1o\xb0\xcf",
4: b'\xa1\x01\x81\xa2\x01\x81A0\x02\x81\xa2\x01\x82\x01\x01\x03\x82\x00x8https://tools.ietf.org/html/draft-moran-suit-manifest-03',
6: b'\xa1\x01x\xc8Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed tincidunt ante, a sodales ligula. Phasellus ullamcorper odio commodo ipsum egestas, vitae lacinia leo ornare. Suspendisse posuere sed.'
}
>>> Manifest = cbor.loads(pod[2])
{1: 1, 2: 2, 5: [{1: [b'0'], 2: 94430, 3: [b'\xa1\x01\x18)', {}, None, b'P4\xd9\x9a\x08]\xce\xf3y\xec\xa72~P\x1b\xc2&_\x1dP\xf6\x8c\xca\x17X.\x7fJ4\x1d\xc3e']}], 6: [b'\xa1\x01\x18)', {}, None, b"\xbe\x86\xe5\xed\xac\x07\x82,\xde\x9d\x81z1\xbd\x82\xdc\xae\xe3\x98\xe6\xe4'\x87]\xbc)\xfbh\x1de\x94v"], 8: [b'\xa1\x01\x18)', {}, None, b"N'\x14Y\x84y\xd8\xb6cH\x05\xdfP\x19\xef4 \xed\xff\x03)\x89J\xcc\x91\xde\x8c\x8d\xe1o\xb0\xcf"]}
```
Here, the SUIT draft manifest structure is represented:
```
{
1: 1, # Manifest Version
2: 2, # Manifest Sequence Number
5: [{ # Payloads
1: [b'0'], # Component ID
2: 94430,
3: [ # COSE Digest
b'\xa1\x01\x18)',
{},
None,
b'P4\xd9\x9a\x08]\xce\xf3y\xec\xa72~P\x1b\xc2&_\x1dP\xf6\x8c\xca\x17X.\x7fJ4\x1d\xc3e'
]
}],
6: [ # Installation Info reference COSE Digest
b'\xa1\x01\x18)',
{},
None,
b"\xbe\x86\xe5\xed\xac\x07\x82,\xde\x9d\x81z1\xbd\x82\xdc\xae\xe3\x98\xe6\xe4'\x87]\xbc)\xfbh\x1de\x94v"],
8: [ # Text Info reference COSE Digest
b'\xa1\x01\x18)',
{},
None,
b"N'\x14Y\x84y\xd8\xb6cH\x05\xdfP\x19\xef4 \xed\xff\x03)\x89J\xcc\x91\xde\x8c\x8d\xe1o\xb0\xcf"]
}