Skip to main content

Python module for handling PSKC files

Project description

A Python module to handle Portable Symmetric Key Container (PSKC) files as defined in RFC 6030. PSKC files are used to transport and provision symmetric keys and key meta data (seed files) to different types of crypto modules, commonly one-time password systems or other authentication devices.

This module can be used to extract keys from PSKC files for use in an OTP authentication system. The module can also be used for authoring PSKC files.

This module should be able to handle most common PSKC files.


The module provides a straightforward API that is mostly geared towards parsing existing PSKC files.

Extracting key material from encrypted PSKC files is as simple as:

>>> from pskc import PSKC
>>> pskc = PSKC('tests/rfc6030/figure7.pskcxml')
>>> pskc.encryption.derive_key('qwerty')
>>> for key in pskc.keys:
...     print('%s %s' % (key.serial, str(key.secret.decode())))
987654321 12345678901234567890

Writing am encrypted PSKC file is as simple as:

>>> pskc = PSKC()
>>> key = pskc.add_key(
...     id='456', secret='987654321', manufacturer='Manufacturer',
...     algorithm = 'urn:ietf:params:xml:ns:keyprov:pskc:hotp')
>>> pskc.encryption.setup_pbkdf2('passphrase')
>>> pskc.write('output.pskcxml')

The key object has a number of properties. See the pskc.key.Key documentation for details.

Security considerations

This code handles private key material and is written in Python. No precautions have been taken to lock pages in memory to prevent swapping. Also no attempt is currently made to securely dispose of memory that may have held private key material.

Download files

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

Files for python-pskc, version 1.1
Filename, size File type Python version Upload date Hashes
Filename, size python_pskc-1.1-py2.py3-none-any.whl (53.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size python-pskc-1.1.tar.gz (132.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page