Skip to main content

An (interim) JOSE library, featuring support for Ed25519, X25519, ChaCha20/Poly1305 and AES256-GCM as required for PyKauriID

Project description

SingleSource PyJOSE Library

An (interim) JOSE library, featuring support for Ed25519, X25519, ChaCha20/Poly1305 and AES256-GCM as required for PyKauriID.

Installation

To install use pip:

$ pip install sspyjose

Or clone the repo:

$ git clone https://gitlab.com/kauriid/sspyjose.git
$ python setup.py install

Set up and activate for Python 3:

virtualenv ${HOME}/.virtualenvs/sspyjose \
           --system-site-packages --python=/usr/bin/python3
source ${HOME}/.virtualenvs/sspyjose/bin/activate

Install required packages:

pip install -e .

For installing the additional development, testing or documentation dependencies, add a qualifier with one or more of these commands:

pip install -e .[dev]       # Development dependencies
pip install -e .[test]      # Testing dependencies
pip install -e .[dev,test]  # All dependencies together

Usage

Signing to a JWS

from sspyjose.jwk import Ed25519Jwk
from sspyjose.jws import Ed25519Jws

# Make a signing key object from a JWK as a JSON string.
# The JWK must contain the private key seed.
jwk = Ed25519Jwk(from_json=jwk_string)
# If the JWK is already parsed to a Python dictionary, use this:
# jwk = Ed25519Jwk(from_dict=jwk_dict)

# Make a JWS signing object.
signer = Ed25519Jws(jwk=jwk)

# Assign the content to authenticate.
signer.payload = {'answer': 42}

# Sign it, and get the content in a compact serialisation format
# (`jws` is a string).
signer.sign()
jws = jws.serialise()

Verifying a JWS

from sspyjose.jwk import Ed25519Jwk
from sspyjose.jws import Ed25519Jws

# Make a signing key object from a JWK as a JSON string.
# The JWK only needs to contain the public key.
jwk = Ed25519Jwk(from_json=jwk_string)
# If the JWK is already parsed to a Python dictionary, use this:
# jwk = Ed25519Jwk(from_dict=jwk_dict)

# Make a JWS verifier object.
verifier = Ed25519Jws(jwk=jwk)

# Load the signed JWS as a compact form string.
verifier.load_compact(jws)

# Verify it, and get the payload.
verifier.verify()
print(verifier.payload)

Contributing

TBD

Example

TBD

Licence

Copyright 2018 by SingleSource Limited, Auckland, New Zealand

This work is licensed under the Apache 2.0 open source licence. Terms and conditions apply.

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

sspyjose-0.2.6.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sspyjose-0.2.6-py2.py3-none-any.whl (23.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sspyjose-0.2.6.tar.gz.

File metadata

  • Download URL: sspyjose-0.2.6.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.5

File hashes

Hashes for sspyjose-0.2.6.tar.gz
Algorithm Hash digest
SHA256 514a6d21870fe41b4c3915e90b4337e0fc551b9effd2ddfcd76dee503d574060
MD5 9bde7940e160514a9b4906d71420a7d2
BLAKE2b-256 06ec39b14f5e71e6faf1a9b1f572b6a4e048e855876cf33c8a740368d460bba5

See more details on using hashes here.

File details

Details for the file sspyjose-0.2.6-py2.py3-none-any.whl.

File metadata

  • Download URL: sspyjose-0.2.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.5

File hashes

Hashes for sspyjose-0.2.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2ce2ff4d09adc7090d8b23048381bbcac075f7fd3301b6af0c56e47c0315d854
MD5 66d785c4b374eea2d6a76c3e94a3c0a9
BLAKE2b-256 a5a4ffb53630dd521ab0829efcf81d7c27a039ce646fa4bedb48a0218945907f

See more details on using hashes here.

Supported by

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