Skip to content

Commit

Permalink
CBORTAGS_ATTR_MAP - added expiry_date and issue_date
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelinux committed Nov 14, 2023
1 parent ad30453 commit 0b12a14
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
67 changes: 67 additions & 0 deletions examples/it_data_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import cbor2
import os

from pymdoccbor.mdoc.issuer import MdocCborIssuer

PKEY = {
'KTY': 'EC2',
'CURVE': 'P_256',
'ALG': 'ES256',
'D': os.urandom(32),
'KID': b"demo-kid"
}

PID_DATA = {
"org.iso.18013.5.1": {
"expiry_date": "2024-02-22",
"issue_date": "2023-11-14",
"issuing_country": "IT",
"issuing_authority": "Gli amici della Salaria",
"family_name": "Rossi",
"given_name": "Mario",
"birth_date": "1956-01-12",
"document_number": "XX1234567",
"portrait": b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00\x90\x00\x90\x00\x00\xff\xdb\x00C\x00\x13\r\x0e\x11\x0e\x0c\x13\x11\x0f\x11\x15\x14\x13\x17\x1d0\x1f\x1d\x1a\x1a\x1d:*,#0E=IGD=CALVm]LQhRAC_\x82`hqu{|{J\\\x86\x90\x85w\x8fmx{v\xff\xdb\x00C\x01\x14\x15\x15\x1d\x19\x1d8\x1f\x1f8vOCOvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\xff\xc0\x00\x11\x08\x00\x18\x00d\x03\x01"\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x1b\x00\x00\x03\x01\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x06\x04\x01\x02\x03\x07\xff\xc4\x002\x10\x00\x01\x03\x03\x03\x02\x05\x02\x03\t\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x00\x05\x11\x06\x12!\x131\x14\x15Qaq"A\x07\x81\xa1\x165BRs\x91\xb2\xc1\xf1\xff\xc4\x00\x15\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\xc4\x00\x1a\x11\x01\x01\x01\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01A\x11!1a\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xa5\xbb\xde"\xda#)\xc7\xd6\x92\xbc}\r\x03\xf5,\xfb\x0f\xf7^z~\xf3\xe7p\x97#\xa1\xd0\xda\xe1F\xdd\xfb\xb3\xc09\xce\x07\xad+\xd4z~2\xdb\xb8\xdd\x1dR\xd6\xefK(Od\xa4\x80\x06}\xfbQ\xf8\x7f\xfb\x95\xff\x00\xeb\x9f\xf1M!]\xe6j\xf0\x89\xceD\xb7\xdb\xde\x9c\xb6\x89\n(8\xed\xdf\x18\x07\x8fz\xddb\xd4\x11\xefM\xb9\xb1\ne\xd6\xb9Z\x14s\x81\xea\rI[\x932u\xfek\xbau\xc1\x14\x10J\x8b\xa4\x10A>\x98=\xff\x00OZ\xf5\xd3KKL\xdec-\x0b\xf1\xfd\x15\x92\xbd\xd9\x1cd\x11\xf3\x93L/\xa6\xafkT\x97]\x10m\xcfJe\xaeV\xe8V\x00\x1e\xbc\x03\xc7\xce)\xdd\x9e\xef\x1e\xf1\x0f\xc4G\xdc\x9d\xa7j\xd2\xae\xe957\xa1\xba~Op\xdd\x8e\xff\x00W\xc6\xdf\xfb^\x1a\x19\x85J\x83u\x8eTR\x87P\x94n\xc6pHP\xcd\x03{\xce\xb0\x8bm},\xc7m3\x17\xfc{\\\xc0O\xb6pri\xc5\xc6\xe0\xc5\xb6\n\xe5I$!#\xb0\xe4\x93\xf6\x02\xa0uU\x9e5\x99p\xd9\x8d\xb8\x95%EkQ\xc9Q\xc8\xaf\xa1>\xa8\xe9\x8e<Yh6x=\\c\xf5\xa6\x1a\x99\xfd\xb7)\x08u\xdbK\xe8\x8a\xb3\x84\xbb\xbb\xbf\xc7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a7\x91\xc2\\O<z\x11\xf7\x15\x86&\x8fJf\xb7&\xe3=\xe9\xeao\x1bR\xb1\x81\xc7`rNG\xb5\x14R\nZ(\xa2\x83\xff\xd9',
"driving_privileges": [
{
"vehicle_category_code": "A",
"issue_date": cbor2.CBORTag(
1004,
value=cbor2.dumps(
"2020-09-17"
)
),
"expiry_date": cbor2.CBORTag(
1004,
value=cbor2.dumps(
"2031-06-10"
)
)
}
],
"un_distinguishing_sign": "I"
},
"org.iso.18013.5.1.it": {
"verification.evidence": {
"organization_name": "Motorizzazione Civile",
"organization_id": "m_inf",
"country_code": "it",
},
"verification.trust_framework": "eidas",
"verification.assurance_level": "high"
}
}

mdoci = MdocCborIssuer(
private_key=PKEY
)

mdoc = mdoci.new(
doctype="org.iso.18013.5.1.mDL",
data=PID_DATA,
devicekeyinfo=PKEY # TODO
)

mdoc
mdoci.dump()
mdoci.dumps()
2 changes: 1 addition & 1 deletion pymdoccbor/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.5"
__version__ = "0.5.6"
4 changes: 3 additions & 1 deletion pymdoccbor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
)

CBORTAGS_ATTR_MAP = {
"birth_date": 1004
"birth_date": 1004,
"expiry_date": 1004,
"issue_date": 1004
}

1 change: 1 addition & 0 deletions pymdoccbor/tests/test_02_mdoc_issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ def test_mdoc_issuer():
mdoci.dump()
mdoci.dumps()


0 comments on commit 0b12a14

Please sign in to comment.