diff --git a/linked_data_sig.py b/linked_data_sig.py index 8da07dc97..a2790fc81 100644 --- a/linked_data_sig.py +++ b/linked_data_sig.py @@ -9,6 +9,7 @@ __email__ = "bob@libreserver.org" __status__ = "Production" __module_group__ = "Security" +import random import base64 import hashlib from datetime import datetime @@ -100,6 +101,7 @@ def generate_json_signature(doc: {}, private_key_pem: str) -> None: return options = { "type": "RsaSignature2017", + "nonce": '%030x' % random.randrange(16**64), "creator": doc["actor"] + "#main-key", "created": datetime.utcnow().replace(microsecond=0).isoformat() + "Z", } diff --git a/tests.py b/tests.py index 9ccbf9984..7f6ba9a22 100644 --- a/tests.py +++ b/tests.py @@ -3880,9 +3880,9 @@ def _test_jsonld(): assert signed_document assert signed_document.get('signature') assert signed_document['signature'].get('signatureValue') + assert signed_document['signature'].get('nonce') assert signed_document['signature'].get('type') assert len(signed_document['signature']['signatureValue']) > 50 - # print str(signed_document['signature']) assert signed_document['signature']['type'] == 'RsaSignature2017' assert verify_json_signature(signed_document, public_key_pem) @@ -3912,6 +3912,7 @@ def _test_jsonld(): assert len(str(signed_document['signature']['signatureValue'])) > 340 assert (signed_document['signature']['signatureValue'] != signed_document2['signature']['signatureValue']) + print('json-ld tests passed') def _test_site_active():