Skip to main content

Paramiko-backed RSA + AES-GCM crypto provider for Swarmauri

Project description

Swamauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_crypto_paramiko


Swarmauri Crypto Paramiko

Paramiko-backed crypto provider implementing the ICrypto contract via CryptoBase.

  • AES-256-GCM symmetric encrypt/decrypt
  • RSA-OAEP(SHA-256) wrap/unwrap
  • Multi-recipient hybrid envelopes using OpenSSH public keys

Installation

pip install swarmauri_crypto_paramiko

Usage

Symmetric AEAD Encryption

from swarmauri_crypto_paramiko import ParamikoCrypto
from swarmauri_core.crypto.types import KeyRef, KeyType, KeyUse, ExportPolicy

crypto = ParamikoCrypto()

sym = KeyRef(
    kid="sym1",
    version=1,
    type=KeyType.SYMMETRIC,
    uses=(KeyUse.ENCRYPT, KeyUse.DECRYPT),
    export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
    material=b"\x00" * 32,
)

ct = await crypto.encrypt(sym, b"hello")
pt = await crypto.decrypt(sym, ct)

RSA Key Wrapping/Unwrapping

import paramiko
from cryptography.hazmat.primitives import serialization
from swarmauri_core.crypto.types import KeyRef, KeyType, KeyUse, ExportPolicy

crypto = ParamikoCrypto()

key = paramiko.RSAKey.generate(2048)
pub_line = f"{key.get_name()} {key.get_base64()}\n".encode()
priv_pem = key.key.private_bytes(
    encoding=serialization.Encoding.PEM,
    format=serialization.PrivateFormat.PKCS8,
    encryption_algorithm=serialization.NoEncryption(),
)

recipient = KeyRef(
    kid="rsa1",
    version=1,
    type=KeyType.RSA,
    uses=(KeyUse.WRAP, KeyUse.UNWRAP),
    export_policy=ExportPolicy.PUBLIC_ONLY,
    public=pub_line,
    material=priv_pem,
)

wrapped = await crypto.wrap(recipient)
unwrapped = await crypto.unwrap(recipient, wrapped)

Hybrid Envelope for Multiple Recipients

env = await crypto.encrypt_for_many([recipient], b"secret")

Entry point

The provider is registered under the swarmauri.cryptos entry-point as ParamikoCrypto.

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

swarmauri_crypto_paramiko-0.3.0.dev3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_crypto_paramiko-0.3.0.dev3-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_crypto_paramiko-0.3.0.dev3.tar.gz.

File metadata

File hashes

Hashes for swarmauri_crypto_paramiko-0.3.0.dev3.tar.gz
Algorithm Hash digest
SHA256 14d4c4e13d75fcbb2e30f589741ea24a47f2a28a170c667da902d821b6284fa2
MD5 5be4383c705a1adbf6879d2337164fae
BLAKE2b-256 8af8a9723757ca5464869c6377b4db3d63db4006a02adef59dbf53e7324d7a06

See more details on using hashes here.

File details

Details for the file swarmauri_crypto_paramiko-0.3.0.dev3-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_crypto_paramiko-0.3.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b0127e511bdc88a7b1d18a90fd2b5f68658be4d00d05131bdd3ad5482bd984a
MD5 7cc70a13ef56699d4577d0283091d861
BLAKE2b-256 c94ecafffe9c8b18b50214ee3af121b95705c25aa6893f116741d1b4c144f4f1

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