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

Uploaded Python 3

File details

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

File metadata

  • Download URL: kveynar-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bdf44b1337d6efa7ace9754f6c2137606a2e2ee548c3600f77b7c800db57dbda
MD5 1a5f02597457917e1a18bfc615a30b74
BLAKE2b-256 073895886a3f295b161761589f1804141fef56aa6b638e6a8e689e7cfe60ae11

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kveynar-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f951c602e5853330fb97712faa31751d78605034d4718c550f58fb8e02aaefc3
MD5 639ee048a32325253a5b3f014c5185bb
BLAKE2b-256 43f816969adffe2a7390a382d2ff9e87a1946dbd1a8ade60d82e448c2b873dd9

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