GithubHelp home page GithubHelp logo

securityinnovation / pgpy Goto Github PK

View Code? Open in Web Editor NEW
305.0 27.0 96.0 3.28 MB

Pretty Good Privacy for Python

License: BSD 3-Clause "New" or "Revised" License

Shell 0.31% Python 99.67% Ruby 0.02%

pgpy's Introduction

PGPy: Pretty Good Privacy for Python

Latest stable version

Travis-CI

Coveralls

Documentation Status

PGPy is a Python library for implementing Pretty Good Privacy into Python programs, conforming to the OpenPGP specification per RFC 4880.

Features

Currently, PGPy can load keys and signatures of all kinds in both ASCII armored and binary formats.

It can create and verify RSA, DSA, and ECDSA signatures, at the moment. It can also encrypt and decrypt messages using RSA and ECDH.

Installation

To install PGPy, simply:

$ pip install PGPy

Documentation

PGPy Documentation on Read the Docs

Discussion

Please report any bugs found on the issue tracker

You can also join #pgpy on Freenode to ask questions or get involved

Requirements

License

BSD 3-Clause licensed. See the bundled LICENSE file for more details.

pgpy's People

Contributors

anarcat avatar bitfehler avatar blag avatar camhawkins avatar cellebyte avatar commod0re avatar cravgabo avatar dkg avatar dlmueller avatar eli-schwartz avatar fuhrysteve avatar gee19 avatar hofrob avatar ignaloidas avatar j-m0 avatar j08ny avatar jonathancross avatar justinkb avatar kianmeng avatar kolanich avatar matt-wesley avatar mgorny avatar palbee avatar rot42 avatar sowbug avatar thesuperzapper avatar tirkarthi avatar tydeu avatar vollkorn1982 avatar wolf480pl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgpy's Issues

Verify inline signatures

Currently, verifying an inline signature is not directly possible (but it can be done by splitting the message and signature out ahead of time), but it should be.

Update the CI test matrix to test against OpenSSL 0.9.8

Currently, Travis is testing only against one version of OpenSSL (which I assume is 1.0.1, as that is what ships with Ubuntu 12.04 currently). The test matrix should be updated to test against 0.9.8 as well.

Looking at apt, openssl_1.0.1-4ubuntu3 is the default, which uses libssl_1.0.0. libssl_0.9.8 is also in the repo. Also, cryptography has openssl 0.9.8 in their test matrix.

Coveralls

I'll set up Coveralls for this repo and see how it looks.

Verify document/signature

In heading for the first release, we need to be able to verify a document against a provided signature.

Sphinx docs for 0.1.0

Initial Sphinx documentation needs to cover the following classes:

  • PGPKeyring
  • SignatureVerification

Allow exporting of keys from PGPKeyring objects

We should be able to export keys that are loaded into PGPKeyring objects.

This should be about 95% working already. There are two things that need to be accounted for:

  • According to the RFC, trust packets should not be exported (and therefore ignored) - which should be trivial to implement.
  • A key loaded from a keyring can not yet determine its magic string for output, so that should also be fixed

Change PGPKeyring context manager

Currently, the context manager is pretty useless aside from syntactical flavor:

with PGPKeyCollection(keys) as k:
    # do stuff with k

I think it would be much nicer to use context management to decide which loaded key to use. Something more like this:

kc = PGPKeyCollection(keys)

with kc.key(id='DEADBEEF'):
    kc.sign(document)

PGPDump revisit

  • add format abstract method to PGPObject
  • add format methods to PGPObject concrete subclasses, with the following flags:
    • a (for PGP* objects; also default for them) - just returns str(self) if Exportable; otherwise, raises ValueError('Invalid format specifier')
    • g for gpg --list-packets-style output
    • p[impl]... for pgpdump-style output with the corresponding flags (default for non-Exportables)

Secret keys are not being properly parsed

Currently, secret key parsing is not working properly, and it's failing on the multi-precision integer fields.

Thinking about it, and re-reading the appropriate part of RFC 4880, I'm guessing it's because I'm not fully parsing secret key information.

In order to fix it, I'll have to more intelligently parse the MPI fields based on algorithm.

PGPKeyring should add Trust packets to keys imported without them

Importing keys from a GPG keyring includes trust packets.

As mentioned in #10, exporting keys to ASCII armored blocks should not include Trust packets. Per RFC 4880:

The Trust packet is used only within keyrings and is not normally
exported.  Trust packets contain data that record the user's
specifications of which key holders are trustworthy introducers,
along with other information that implementing software uses for
trust information.  The format of Trust packets is defined by a given
implementation.

Trust packets SHOULD NOT be emitted to output streams that are
transferred to other users, and they SHOULD be ignored on any input
other than local keyring files.

So, we should be able to specify how much we trust a given key.

Use libgcrypt for crypto

OpenSSL does not reliably provide everything we need (and it's pretty heavy, as well).

It's probably worth switching to using libgcrypt (through cffi) and just piggybacking on GPG instead of OpenSSL.

Sign binary document

In heading for the first release, we'll need to be able to use a loaded secret key to sign a binary document (signature type 0x00).

Signing with 1024-bit DSA keys does not work on OSX (OpenSSL 0.9.8y)

Signing with DSA keys with p > 1024 bits works fine (although verifying signatures that were generated using keys with p > 1024 bits does not work). However, signing with DSA keys with p == 1024 bits does not work (see #16)

It is probably worth testing against multiple versions of OpenSSL, so the travis test-matrix should be updated to reflect this as well.

refactor unit tests

It's getting quite messy and a little bit out of hand to continue adding test material.

This will be a several step process:

  • Throw away all current test keys
  • Regenerate new test keys, like so, with the following naming convention:
    Test{alg}[-Enc{encalg}]-{bits}[.sec].key into the current directories.
    • unencrypted key material:
      • RSA (and RSA)
        • 1024-bit
        • 2048-bit
        • 3072-bit
        • 4096-bit
      • DSA (and ElGamal)
        • 1024-bit
        • 2048-bit
        • 3072-bit
        • 4096-bit
      • RSASignOnly
        • 1024-bit
        • 2048-bit
        • 3072-bit
        • 4096-bit
      • DSASignOnly
        • 1024-bit
        • 2048-bit
        • 3072-bit
        • 4096-bit
  • encrypted key material:
    • RSA (1024-bit)
      • IDEA
      • CAST5
      • CAST5Simple (--s2k-mode 0)
      • CAST5SaltedS2K (--s2k-mode 1)
      • CAST5MD5 (--s2k-digest-algo MD5)
      • CAST5SHA1 (--s2k-digest-algo SHA1)
      • CAST5RIPEMD160 (--s2k-digest-algo RIPEMD160)
      • CAST5SHA256 (--s2k-digest-algo SHA256)
      • CAST5SHA384 (--s2k-digest-algo SHA384)
      • CAST5SHA512 (--s2k-digest-algo SHA512)
      • CAST5SHA224 (--s2k-digest-algo SHA224)
      • 3DES
      • AES128
      • AES192
      • AES256
      • Blowfish
      • Camellia128
      • Camellia192
      • Camellia256
      • Twofish
    • DSA (1024-bit)
      • CAST5
  • Move keylists to conftest.py
  • Use gpg to sign tests/testdata/signed_message with each generated key above for testing signature verification
  • Rename TestPGPKeyring.test_sign_with_key to TestPGKeyring.test_sign
  • Refactor the parametrization for TestPGPKeyring.test_sign

Create inline signatures

Currently, there is an inline flag for PGPKeyring.sign(), but it has no effect.

We should be able to create inline signatures like GPG does.

decrypt passphrase-protected secret keys

As it turns out, if you export a passphrase-protected secret key to the ASCII armored format, the key material itself remains protected.

We need to be able to load this key material properly, and decrypt it using a correct passphrase.

Need to find a good crypto library

Before I can continue, I need to find a good crypto library (or set of libraries, as the case may be) that support the following algorithms:

Symmetric-Key Algorithms
  • IDEA
  • TripleDES
  • CAST5
  • Blowfish
  • AES 128, 192, 256
  • Twofish

Of these, TripleDES is the only one explicitly required for all implementations by the RFC specification; CAST5 and AES128 are heavily recommended.

IDEA is required only if the implementation needs to be able to interact with PGP 2.6.

Public-Key Algorithms
  • RSA
  • ElGamal
  • DSA

RSA and DSA are the two Public-Key algorithms that are required for signing things.

ElGamal is used for encryption only (for DSA keys generated with the ability to also encrypt). Naturally, RSA can be used for encryption also, unless the key is marked as being for signing only.

DSA Signature Verification

This is waiting on the impending release of Cryptography 0.4. Release 0.1.0 only really needs to understand RSA signatures, though, so this shouldn't block that.

Understand GPG Trust Packets

Currently, we can import a Trust packet no problem.

However, there is no parsing taking place - the payload stays in byte form, and it is meaningless.

PGPy should be able to understand a GPG Trust packet when loading an existing GPG keyring, so those trust preferences are maintained.

Load keys from a GPG keyring file

In working toward the first release, I still need to be able to load a GPG keyring file.

This will include being able to load public and secret keys from a keyring, as well as password protected secret keys.

Key material is not being tested currently

Currently, parsing PGP blocks is being done against the Python pgpdump pakage, which is very good.

However, I have not figured out how to compare key material with it (it may not allow that).

At any rate, I need to be able to check key material when parsing blocks to ensure everything is done right. As it stands, I am getting false positives on parsing keys properly because key material is not being checked.

Prepare for Release 0.1.0

Looks like Release 0.1.0 is about ready to go.

So, a couple small tasks left:

  • Start the release branch
  • Bump the version to 0.1.0
  • Read through all the documentation and verify its correctness.
  • Think about initial documentation for PGPSignature and PGPKey
  • Fill in some missing enum returns (most notably, HashAlgo)
  • Hide the package path in Sphinx for pgpy.signature.SignatureVerification
  • Add additional exception classes whenever a method can raise the same one in multiple situations
  • Publish documentation to github.io
  • Make sure setup.py works correctly
  • Last round of testing

And finally, sign the release, merge to master, tag as a release, and register the package to PyPI!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.