Skip to main content

Python implementation of the RFC3161 specification, using pyasn1

Project description

https://img.shields.io/pypi/l/rfc3161ng.svg Build 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())

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfc3161ng-2.1.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

rfc3161ng-2.1.0-py2.py3-none-any.whl (8.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file rfc3161ng-2.1.0.tar.gz.

File metadata

  • Download URL: rfc3161ng-2.1.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for rfc3161ng-2.1.0.tar.gz
Algorithm Hash digest
SHA256 a34b841037ff7d7f18c09ec591252b2382c47d47f45da89827f09fa8ed656c9c
MD5 fbe2f398e44e5f46d77903a43414d18e
BLAKE2b-256 f576d0ab1ea2d72e4fdfda6fac60b186304ccb93d11147ceb28c50f50efc7b91

See more details on using hashes here.

File details

Details for the file rfc3161ng-2.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: rfc3161ng-2.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for rfc3161ng-2.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e0c867c5440c72b01cebcef609333152ddc8c5dda642112c5a46ab6a3232426c
MD5 3aa9d6ed94a861f63a69cebe3527fa30
BLAKE2b-256 e98113d8d1cb52f8d38e7cb40b793f783096c07ebaa672f03acfa07cf1e8c713

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page