Skip to content

An another Python implementation of HPKE (Hybrid Public Key Encryption)

License

Notifications You must be signed in to change notification settings

felisevan/AnotherHPKE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AnotherHPKE

HPKE((Hybrid Public Key Encryption)) implementation in Python3 and package cryptography according to RFC 9180.

Announcement

Inspired by Universal Declaration of Human Rights and 17 SDG goals, we contribute to this project in the position of safeguarding the common interests and universal values of all humankind.

😭Please give us undergraduate students a little star, hoping this project meets your needs.😋

🥰Your recognition and support matters! 🥰

Stand with Ukraine

Usage

from src.anotherhpke import Ciphersuite, KemIds, KdfIds, AeadIds
import os

ciphersuite = Ciphersuite(KemIds.DHKEM_X25519_HKDF_SHA256, KdfIds.HKDF_SHA256, AeadIds.ChaCha20Poly1305)
sender_pri, sender_pub = ciphersuite.kem.derive_key_pair(os.urandom(32))
recipient_pri, recipient_pub = ciphersuite.kem.derive_key_pair(os.urandom(32))

# Sender side
enc, ctx = ciphersuite.SetupBaseS(recipient_pub)
encrypted = ctx.seal(b"plain text")

# Recipient side
ctx = ciphersuite.SetupBaseR(enc, recipient_pri)
decrypted = ctx.open(encrypted)

Feature Matrix

  • Modes
    • mode_base
    • mode_psk
    • mode_auth
    • mode_auth_psk
  • AEADs
    • AES-128-GCM
    • AES-256-GCM
    • ChaCha20Poly1305
    • AES-256-SIV (Draft only, don't recommend for production use, see this)
    • AES-512-SIV (Draft only, don't recommend for production use, see this)
    • Export only
  • KEMs
    • DHKEM(P-256, HKDF-SHA256)
    • DHKEM(P-384, HKDF-SHA384)
    • DHKEM(P-521, HKDF-SHA512)
    • DHKEM(X25519, HKDF-SHA256)
    • DHKEM(X448, HKDF-SHA512)
    • DHKEM(CP-256, HKDF-SHA256)
    • DHKEM(CP-384, HKDF-SHA384)
    • DHKEM(CP-521, HKDF-SHA512)
    • DHKEM(secp256k1, HKDF-SHA256)
    • X25519Kyber768Draft00
  • KDFs
    • HKDF-SHA256
    • HKDF-SHA384
    • HKDF-SHA512

Just FYI, our project have a working derive_key_pair function for each implemented KEMs.

Dependency

This project simply uses python3 with package cryptography.

  • pip
    pip install cryptography

  • conda
    conda install -c anaconda cryptography
    or
    conda install -c conda-forge cryptography

Related Efforts

hpke-py
pyhpke

Author

@felisevan
@14MBD4

License

AGPL-3.0 license