Skip to main content

Kveynar - chiffre authentifie original (portage Python), par Memet Jakupi.

Project description

Kveynar - portage Python

CI

Auteur : Memet Jakupi - chercheur en forensique numerique.

Portage Python fidele de l'implementation Rust de reference. Il reproduit ../rust/vectors/kat.json octet pour octet (test d'interoperabilite) : un message chiffre par Rust se dechiffre par Python et inversement.

La specification commune est ../rust/SPEC.md ; l'analyse de securite honnete est dans ../rust/DESIGN.md.

Avertissement

Chiffre maison a vocation educative / d'obfuscation / CTF. Renforce et teste, mais non audite publiquement. Ne pas l'utiliser seul face a un adversaire etatique.

Note de performance

Ce portage privilegie la lisibilite, pas la vitesse. Le KDF est memory-hard : au facteur par defaut (2^17 = 16 Mio) il est lent en Python pur. Pour des essais rapides, baissez le facteur memoire (--mem 12 ou with_work_factor(cle, 12)). L'implementation Rust reste la version performante.

Utilisation (bibliotheque)

from kveynar import Kveynar

kv = Kveynar.with_work_factor("ma cle privee".encode(), 12)
c = kv.encrypt("Pershendetje, bote!".encode())
assert kv.decrypt(c).decode() == "Pershendetje, bote!"

# donnees associees, armure texte, obfuscation de source
kv.encrypt_with_ad(b"corps", b"entete-public")
kv.encrypt_armored(b"data")
kv.obfuscate_source("def f(): return 42")

# mode forteresse (cascade Gjarper + Bora, 100 % maison)
fort = Kveynar.fortress_with_work_factor("cle".encode(), 14)
Methode Description
new(pass) / with_work_factor(pass, log2_mem) contexte (facteur memoire KDF)
fortress(...) / fortress_with_work_factor(...) / set_cascade(bool) mode cascade
encrypt / decrypt (+ _with_ad) conteneur binaire .kvy (AEAD)
encrypt_with_params(pt, ad, kripa, fara) chiffrement deterministe (avance/tests)
encrypt_armored / decrypt_armored sortie texte (armure Drita)
obfuscate_source / deobfuscate_source (+ _bytes) obfuscation de code

Ligne de commande

python -m kveynar enc   -k "ma cle" --mem 14 secret.txt -o secret.kvy
python -m kveynar enc   -k "ma cle" --fortress secret.txt -o secret.kvy
python -m kveynar dec   -k "ma cle" secret.kvy -o secret.txt   # mode auto-detecte
python -m kveynar obf   -k "ma cle" app.py -o app.py.kvy
python -m kveynar deobf -k "ma cle" app.py.kvy -o app.py

Cle aussi via --key-file <fichier> ou la variable d'environnement KVEYNAR_KEY.

Tests

# depuis la racine du depot
set PYTHONPATH=python   &  python -m unittest discover -s python/tests -t python   # Windows cmd
PYTHONPATH=python python -m unittest discover -s python/tests -t python            # bash

Le test test_vectors.py prouve l'interoperabilite octet-pour-octet avec Rust.

Structure

python/
  kveynar/
    __init__.py     API publique (classe Kveynar)
    _u64.py         arithmetique 64 bits (mod 2^64)
    _consts.py      constantes (forge, IV, RC, ODD, rotations, alphabet Drita)
    _vala.py        permutation Vala + eponge
    _kdf.py         Celesi (KDF memory-hard, Mundimi)
    _gjarper.py     bloc primaire inversible
    _bora.py        second bloc (mode cascade)
    _cipher.py      mode operatoire + MAC Vula + conteneur
    _armor.py       armure base64 Drita
    _obfuscate.py   enveloppe d'obfuscation de source
    _rng.py         alea systeme (os.urandom)
    errors.py       exceptions KveynarError
    __main__.py     outil CLI
  tests/            test_vectors (KAT interop), roundtrip, tamper, nondeterminism
  examples/         basic, file_encrypt, obfuscate_source
  pyproject.toml

Licence

MIT.

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

kveynar-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

kveynar-0.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file kveynar-0.1.0.tar.gz.

File metadata

  • Download URL: kveynar-0.1.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for kveynar-0.1.0.tar.gz
Algorithm Hash digest
SHA256 189153139f39d3e64d14aed6291f8a5323f6d87e74f3f523d8bdb8d6ef8b4d64
MD5 beecc898454041f6c67ff43f5d8e87dd
BLAKE2b-256 5516b3009020b4cf09f71e11c916ef895e01f9dadd3725a562660af96e04a34e

See more details on using hashes here.

File details

Details for the file kveynar-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kveynar-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for kveynar-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2038ce1340013cfb0b6a0199a875913e29c99015187d246216b9cd13499eac1e
MD5 e588a35b08abc02c2c8460e01bfb207e
BLAKE2b-256 b74a464604bfac0722242e19bc9965a9dacfdbcc085cb439a3a7d16cb9046498

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