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.dev4.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.dev4-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for swarmauri_crypto_paramiko-0.3.0.dev4.tar.gz
Algorithm Hash digest
SHA256 56125ba0fd8dc5cc1ce4d1928dbbb35438be8ac7148864dcedae9fe204ef056a
MD5 0f92099be926932105f7a0176773e284
BLAKE2b-256 4cbed225860590d3e898bc26d2699aefc385e6524b65f591822a891aec9c4eaa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for swarmauri_crypto_paramiko-0.3.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 7124a4de7c4114c5a044d3faf1be9575f283b0e24b3683e314a34d0621b307cc
MD5 86f8b65f93b0e4b3927bc7ee669f24c3
BLAKE2b-256 ef93d6f4da4c2b108cfd3b4bd69800ffac9428f1d4323b09e48a9ad03cba5821

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