tannercollin / py-seccure

SECCURE compatible Elliptic Curve cryptography in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

py-seccure

Simple Elliptic Curve Cryptography for Python compatible with the excellent SECCURE command line utility (version 0.5). It's licensed under LGPLv3. See LICENSE.

Do not use ``py-seccure`` when its operation can be timed by an attacker. See timing attack.

Usage

Public key from private

To get the public key from the private, you can use the original commandline utility:

$ seccure-key
Assuming curve p160.
Enter private key: my private key
The public key is: 8W;>i^H0qi|J&$coR5MFpR*Vn

In Python:

Encrypting a string

To encrypt for a public key, one would use the original commandline utility as follows.

$ seccure-encrypt -o private.msg '8W;>i^H0qi|J&$coR5MFpR*Vn'  
Assuming MAC length of 80 bits.
Go ahead and type your message ...
This is a very very secret message!
^D

In Python:

There is a shorthand to encrypt a file:

Decrypting

To decrypt the message with the original utility:

$ seccure-decrypt -i private.msg
Assuming MAC length of 80 bits.
Assuming curve p160.
Enter private key: my private key
This is a very very secret message!
Integrity check successful, message unforged!

In Python:

And to decrypt a file:

Creating a signature

To create a signature:

$ seccure-sign
Assuming curve p160.
Enter private key: my private key
Go ahead and type your message ...
This message will be signed
^D
Signature: $HPI?t(I*1vAYsl$|%21WXND=6Br*[>k(OR9B!GOwHqL0s+3Uq

In Python:

Verifying a signature

To verify a signature:

$ seccure-verify '8W;>i^H0qi|J&$coR5MFpR*Vn' '$HPI?t(I*1vAYsl$|%21WXND=6Br*[>k(OR9B!GOwHqL0s+3Uq'  
Go ahead and type your message ...
This message will be signed
^D
Signature successfully verified!

In Python:

Installation

On Debian Wheezy

$ apt-get install libgmp3-dev build-essential python-dev python-pip
$ pip install seccure

On Ubuntu

$ apt-get install libgmp-dev build-essential python-dev python-pip
$ pip install seccure

On Mac with MacPorts

$ port install gmp
$ pip install seccure

Please contribute!

To help out, you could:

  1. Test and report any bugs or other difficulties.
  2. Implement missing features, such as seccure-dh, seccure-veridec and seccure-signcrypt.
  3. Package py-seccure (or the original SECCURE itself) for your platform.
  4. Write more unit tests.

image

About

SECCURE compatible Elliptic Curve cryptography in Python

License:GNU Lesser General Public License v3.0


Languages

Language:Python 100.0%