All Projects → trbs → rfc3161ng

trbs / rfc3161ng

Licence: other
A simple client library for cryptographic timestamping service implementing the protocol from RFC3161. Based on python-rfc3161 with some additional fixes.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to rfc3161ng

rfc3161timestampingserver
This project offers a rfc 3161 compliant timestamping authority/server
Stars: ✭ 30 (+7.14%)
Mutual labels:  rfc3161
timestamp
Time-Stamp Protocol (TSP) implementation for Go as specified in RFC3161
Stars: ✭ 51 (+82.14%)
Mutual labels:  rfc3161

rfc3161ng

CI Status Latest PyPI version Supports Wheel format

A simple client library for cryptographic timestamping service implementing the protocol from RFC3161.

This started as a fork of https://dev.entrouvert.org/projects/python-rfc3161 and has some additional patches such as Python3 support.

The latest version of this library is available from https://github.com/trbs/rfc3161ng/ .

Public providers

There are several timestamping services around. Here is a list of publicly available services you can try:

Example

>>> import rfc3161ng
>>> certificate = open('data/certum_certificate.crt', 'rb').read()
>>> rt = rfc3161ng.RemoteTimestamper('http://time.certum.pl', certificate=certificate)
>>> tst = rt.timestamp(data=b'John Doe')
>>> rt.check(tst, data=b'John Doe')
True
>>> rfc3161ng.get_timestamp(tst)
datetime.datetime(2017, 8, 31, 15, 42, 58, tzinfo=tzutc())

Example for a server that insist on SHA256:

>> import rfc3161ng >> timestamper = rfc3161ng.RemoteTimestamper('https://interop.redwax.eu/test/timestamp', hashname='sha256') >> tsr = timestamper(data=b'The RedWax Project', return_tsr=True) >> print('{}'.format(tsr))

Verifying timestamp using OpenSSL

One can verify the timestamp returned by the timeserver by using OpenSSL. For example with:

$ openssl ts -verify -data data_file.txt -in data_file.tsr -CAfile cacert.pem -untrusted tsa.crt

To save the tsr you can use code similar to:

>>> from pyasn1.codec.der import encoder
>>> import rfc3161ng
>>> ...
>>> timestamper = rfc3161ng.RemoteTimestamper('http://freetsa.org/tsr', certificate=certificate_data)
>>> tsr = timestamper(data=data_file.read(), return_tsr=True)
>>> with open("data_file.tsr", "wb") as f:
>>>     f.write(encoder.encode(tsr))

Alternatively you can just save the raw response.content returned from the certification server.

There is a test which also covers this in test_verify_timestamp_response_with_openssl.

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].