Skip to main content

The ctypes Python wrapper for the Infineon OPTIGA(TM) Trust family of security solutions

Project description


A ctypes based Python wrapper to work with the OPTIGA(TM) Trust security solutions.



Function Module
Elliptic Curves Cryptograpy
Certificate Signing Request optigatrust.x509.csr
Certificate handling optigatrust.x509.cert
Random Number Generation optigatrust.rand
Write/Read General Purpose Data


Required Hardware

  • OPTIGA(TM) Trust Personalisation Board, or
  • any FTDI USB-HID/I2C Converter board
  • (planned) Embedded Linux with open I2C lines; e.g. RPi3


$ pip install optigatrust


optigatrust is licensed under the terms of the MIT license. See the LICENSE file for the exact license text.


The documentation for optigatrust is composed of tutorials on basic usage and links to the source for the various pre-defined type classes.


from optigatrust.util.types import *
from optigatrust.rand import *
from import *
from optigatrust.x509 import *
import base64

print("Rand size 8 bytes: {0}\n".format(list(get_random_bytes(8))))
print("Rand size 16 bytes: {0}\n".format(list(get_random_bytes(16))))
print("Rand size 255 bytes: {0}\n".format(list(get_random_bytes(255))))

ecc_key = ecc.generate_keypair()
print("Generate NIST-P256 Keypair: {0}\n".format(list(ecc_key.pkey)))

ecdsa_signature = ecdsa.sign(ecc_key, b'Hello World')
print("Generate ECDSA Signature using the keypair: {0}\n".format(list(ecdsa_signature.signature)))

csr_key = ecc.generate_keypair(curve='secp256r1', keyid=KeyId.USER_PRIVKEY_3)
print("Generate NIST-P256 Keypair for a new certificate: {0}\n".format(list(csr_key.pkey)))

builder = csr.Builder(
		'country_name': 'DE',
		'state_or_province_name': 'Bayern',
		'organization_name': 'Infineon Technologies AG',
		'common_name': 'OPTIGA(TM) Trust IoT',

request =
csr = base64.b64encode(request.dump())
print("A new CSR {0}\n".format(csr))


Tests are written using pytest and require this package to be installed:

$ git clone --recurse-submodules
$ cd python-optiga-trust
$ cd tests
$ pytest

To run only some tests, pass a regular expression as a parameter to tests.

$ pytest


Existing releases can be found at

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

optigatrust-0.3.8.tar.gz (15.6 kB view hashes)

Uploaded Source

Built Distribution

optigatrust-0.3.8-py3-none-any.whl (244.2 kB view hashes)

Uploaded Python 3

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