PyBitmessage-2021-04-27/src/pyelliptic
Dmitri Bogomolov da8bd36614
Fix python3 issues in pyelliptic:
- use dotted imports, remove unneeded shebangs
 - openssl._OpenSSL._version is of type bytes
 - use b'\x00' literal instead of chr(0) in eccblind and test_openssl
 - use // and divmod in arithmetic to fit PEP238:
   https://docs.python.org/3/whatsnew/2.2.html#pep-238-changing-the-division-operator
2021-02-18 17:11:36 +02:00
..
LICENSE Debian packaging 2013-04-01 20:23:32 +01:00
README.md Debian packaging 2013-04-01 20:23:32 +01:00
__init__.py Blind signature updates 2020-03-31 14:13:32 +08:00
arithmetic.py Fix python3 issues in pyelliptic: 2021-02-18 17:11:36 +02:00
cipher.py Fix python3 issues in pyelliptic: 2021-02-18 17:11:36 +02:00
ecc.py Fix python3 issues in pyelliptic: 2021-02-18 17:11:36 +02:00
eccblind.py Fix python3 issues in pyelliptic: 2021-02-18 17:11:36 +02:00
eccblindchain.py Blind signature updates 2020-03-31 14:13:32 +08:00
hash.py Fix python3 issues in pyelliptic: 2021-02-18 17:11:36 +02:00
openssl.py Fix python3 issues in pyelliptic: 2021-02-18 17:11:36 +02:00

README.md

PyElliptic

PyElliptic is a high level wrapper for the cryptographic library : OpenSSL. Under the GNU General Public License

Python3 compatible. For GNU/Linux and Windows. Require OpenSSL

Features

Asymmetric cryptography using Elliptic Curve Cryptography (ECC)

  • Key agreement : ECDH
  • Digital signatures : ECDSA
  • Hybrid encryption : ECIES (like RSA)

Symmetric cryptography

  • AES-128 (CBC, OFB, CFB)
  • AES-256 (CBC, OFB, CFB)
  • Blowfish (CFB and CBC)
  • RC4

Other

  • CSPRNG
  • HMAC (using SHA512)
  • PBKDF2 (SHA256 and SHA512)

Example

#!/usr/bin/python

import pyelliptic

# Symmetric encryption
iv = pyelliptic.Cipher.gen_IV('aes-256-cfb')
ctx = pyelliptic.Cipher("secretkey", iv, 1, ciphername='aes-256-cfb')

ciphertext = ctx.update('test1')
ciphertext += ctx.update('test2')
ciphertext += ctx.final()

ctx2 = pyelliptic.Cipher("secretkey", iv, 0, ciphername='aes-256-cfb')
print ctx2.ciphering(ciphertext)

# Asymmetric encryption
alice = pyelliptic.ECC() # default curve: sect283r1
bob = pyelliptic.ECC(curve='sect571r1')

ciphertext = alice.encrypt("Hello Bob", bob.get_pubkey())
print bob.decrypt(ciphertext)

signature = bob.sign("Hello Alice")
# alice's job :
print pyelliptic.ECC(pubkey=bob.get_pubkey()).verify(signature, "Hello Alice")

# ERROR !!!
try:
    key = alice.get_ecdh_key(bob.get_pubkey())
except: print("For ECDH key agreement, the keys must be defined on the same curve !")

alice = pyelliptic.ECC(curve='sect571r1')
print alice.get_ecdh_key(bob.get_pubkey()).encode('hex')
print bob.get_ecdh_key(alice.get_pubkey()).encode('hex')