diff --git a/pymdoccbor/tests/test_02_mdoc_issuer.py b/pymdoccbor/tests/test_02_mdoc_issuer.py index 2b7e758..076dd9b 100644 --- a/pymdoccbor/tests/test_02_mdoc_issuer.py +++ b/pymdoccbor/tests/test_02_mdoc_issuer.py @@ -2,21 +2,14 @@ import os from pycose.messages import Sign1Message - +from pycose.keys import EC2Key from pymdoccbor.mdoc.issuer import MdocCborIssuer from pymdoccbor.mdoc.verifier import MdocCbor from pymdoccbor.mso.issuer import MsoIssuer from . pid_data import PID_DATA -PKEY = { - 'KTY': 'EC2', - 'CURVE': 'P_256', - 'ALG': 'ES256', - 'D': os.urandom(32), - 'KID': b"demo-kid" -} - +PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"}) def test_mso_writer(): msoi = MsoIssuer( diff --git a/pymdoccbor/tests/test_03_mdoc_issuer.py b/pymdoccbor/tests/test_03_mdoc_issuer.py index c9cbc7d..2c20e15 100644 --- a/pymdoccbor/tests/test_03_mdoc_issuer.py +++ b/pymdoccbor/tests/test_03_mdoc_issuer.py @@ -1,16 +1,10 @@ -import os +from pycose.keys import EC2Key from pymdoccbor.mdoc.issuer import MdocCborIssuer from pymdoccbor.tests.micov_data import MICOV_DATA from pymdoccbor.tests.pid_data import PID_DATA -PKEY = { - 'KTY': 'EC2', - 'CURVE': 'P_256', - 'ALG': 'ES256', - 'D': os.urandom(32), - 'KID': b"demo-kid" -} +PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"}) mdoc = MdocCborIssuer(PKEY) diff --git a/pymdoccbor/tests/test_04_issuer_signed.py b/pymdoccbor/tests/test_04_issuer_signed.py index b11be83..24f974b 100644 --- a/pymdoccbor/tests/test_04_issuer_signed.py +++ b/pymdoccbor/tests/test_04_issuer_signed.py @@ -1,16 +1,10 @@ -import os +from pycose.keys import EC2Key from pymdoccbor.mdoc.issuersigned import IssuerSigned from pymdoccbor.mdoc.issuer import MdocCborIssuer from pymdoccbor.tests.micov_data import MICOV_DATA from pymdoccbor.tests.test_03_mdoc_issuer import mdoc -PKEY = { - 'KTY': 'EC2', - 'CURVE': 'P_256', - 'ALG': 'ES256', - 'D': os.urandom(32), - 'KID': b"demo-kid" -} +PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"}) mdoc = MdocCborIssuer(PKEY) mdoc.new( diff --git a/pymdoccbor/tests/test_05_mdoc_verifier.py b/pymdoccbor/tests/test_05_mdoc_verifier.py index 13c3eb3..5f3eed1 100644 --- a/pymdoccbor/tests/test_05_mdoc_verifier.py +++ b/pymdoccbor/tests/test_05_mdoc_verifier.py @@ -1,15 +1,9 @@ -import os +from pycose.keys import EC2Key from pymdoccbor.mdoc.verifier import MobileDocument from pymdoccbor.mdoc.issuer import MdocCborIssuer from pymdoccbor.tests.micov_data import MICOV_DATA -PKEY = { - 'KTY': 'EC2', - 'CURVE': 'P_256', - 'ALG': 'ES256', - 'D': os.urandom(32), - 'KID': b"demo-kid" -} +PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"}) mdoc = MdocCborIssuer(PKEY) mdoc.new( @@ -59,4 +53,4 @@ def test_mobile_document_verify(): document = mdoc.signed["documents"][0] doc = MobileDocument(**document) - #assert mdoc.verify() == True \ No newline at end of file + assert doc.verify() == True \ No newline at end of file diff --git a/pymdoccbor/tests/test_06_mso_issuer.py b/pymdoccbor/tests/test_06_mso_issuer.py index 3e926b2..b68812d 100644 --- a/pymdoccbor/tests/test_06_mso_issuer.py +++ b/pymdoccbor/tests/test_06_mso_issuer.py @@ -1,15 +1,9 @@ -import os +from pycose.keys import EC2Key from pycose.messages import CoseMessage from pymdoccbor.mso.issuer import MsoIssuer from pymdoccbor.tests.micov_data import MICOV_DATA -PKEY = { - 'KTY': 'EC2', - 'CURVE': 'P_256', - 'ALG': 'ES256', - 'D': os.urandom(32), - 'KID': b"demo-kid" -} +PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"}) def test_mso_issuer_fail(): try: diff --git a/pymdoccbor/tests/test_07_mso_verifier.py b/pymdoccbor/tests/test_07_mso_verifier.py index 3f2767c..b74159d 100644 --- a/pymdoccbor/tests/test_07_mso_verifier.py +++ b/pymdoccbor/tests/test_07_mso_verifier.py @@ -1,16 +1,11 @@ import os +from pycose.keys import CoseKey, EC2Key from pymdoccbor.mso.verifier import MsoVerifier from pymdoccbor.mdoc.issuer import MdocCborIssuer from pymdoccbor.tests.micov_data import MICOV_DATA from pycose.messages import CoseMessage -PKEY = { - 'KTY': 'EC2', - 'CURVE': 'P_256', - 'ALG': 'ES256', - 'D': os.urandom(32), - 'KID': b"demo-kid" -} +PKEY = EC2Key.generate_key(crv="P_256", optional_params={"ALG": "ES256"}) mdoc = MdocCborIssuer(PKEY) mdoc.new(