Cryptographic Permits

Creating A6 Permits With JWT

Mi'kail Eli'yah
14 min readJun 4, 2024
“papers please …”

There are likely just 6 keys (A6) you require for most cryptographic services. Permissions can be attested by means of cryptographic permits. One of the ways may be to use tokens of some kind.

The Utilities

Let’s start with some helper functions.

# Generic utility to display variable names and their values
def display(variables):
global_vars = globals()
print(f"There are {len(variables)} items:")
for var in variables:
var_name = [name for name in global_vars if global_vars[name] is var]
if var_name:
print(f"{var_name[0]} = {var}")
print(f"Value not found in global scope: {var}")

import json

def dict_to_json(data):
Converts a dictionary to JSON format.
return json.dumps(data, indent=4)

Key Generation

import secrets

from cryptography.hazmat.primitives.asymmetric import rsa

from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend

def create_key_pair_RSA(keysize = 2048):
private_key = rsa.generate_private_key(public_exponent=65537,key_size=keysize)
public_key = private_key.public_key()