pkenc_adapt_hybrid

Hybrid Encryption Adapter for PKE (PKE Hybrid)

Description: Converts a Public Key Encryption scheme into a hybrid encryption scheme capable of encrypting arbitrary-length messages.

Notes: Uses symmetric encryption (AES) with a randomly generated session key.
The session key is encrypted using the underlying PKE scheme.
Works with ElGamal and CS98 schemes.

Adapter Properties

  • Type: hybrid encryption adapter

  • Underlying Scheme: any public key encryption scheme (e.g., ElGamal, CS98)

  • Purpose: enables PKE schemes to encrypt arbitrary-length byte messages

Implementation

Authors:
  1. Ayo Akinyele

Date:

2011

class pkenc_adapt_hybrid.HybridEnc(pkenc, msg_len=16, key_len=16, mode=charm.core.crypto.cryptobase.AES)[source]

Bases: PKEnc

>>> groupObj = ECGroup(prime192v1)
>>> pkenc = CS98(groupObj)
>>> hyenc = HybridEnc(pkenc, msg_len=groupObj.bitsize())
>>> (public_key, secret_key) = hyenc.keygen()
>>> msg = b'this is a new message'
>>> cipher_text = hyenc.encrypt(public_key, msg)
>>> decrypted_msg = hyenc.decrypt(public_key, secret_key, cipher_text)
>>> decrypted_msg == msg
True
decrypt(pk, sk, ct)[source]
encrypt(pk, M)[source]
keygen(secparam=None)[source]
pkenc_adapt_hybrid.main()[source]