Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove implementation of deprecated PGP "quick check" #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
@@ -1,3 +1,4 @@
Simon Arneaud
Nevins Bartolomeo
Thorsten E. Behrens
Tim Berners-Lee
Expand Down
1 change: 1 addition & 0 deletions Changelog.rst
Expand Up @@ -9,6 +9,7 @@ Resolved issues

* Undefined warning was raised with libgmp version < 5
* Forgot inclusion of ``alloca.h``
* Removed implementation of deprecated "quick check" feature of PGP block cipher mode.

3.4.2 (8 March 2016)
+++++++++++++++++++
Expand Down
13 changes: 7 additions & 6 deletions lib/Crypto/Cipher/_mode_openpgp.py
Expand Up @@ -41,16 +41,17 @@ class OpenPgpMode(object):
"""OpenPGP mode.

This mode is a variant of CFB, and it is only used in PGP and
OpenPGP_ applications.
OpenPGP_ applications. If in doubt, use another mode.

An Initialization Vector (*IV*) is required.

Unlike CFB, the *encrypted* IV (not the IV itself) is
transmitted to the receiver.

The IV is a random data block. Two of its bytes are duplicated to act
as a checksum for the correctness of the key. The encrypted IV is
therefore 2 bytes longer than the clean IV.
The IV is a random data block. For legacy reasons, two of its bytes are
duplicated to act as a checksum for the correctness of the key, which is now
known to be insecure and is ignored. The encrypted IV is therefore 2 bytes
longer than the clean IV.

.. _OpenPGP: http://tools.ietf.org/html/rfc4880

Expand Down Expand Up @@ -80,8 +81,8 @@ def __init__(self, factory, key, iv, cipher_params):
# ... decryption
self._encrypted_IV = iv
iv = IV_cipher.decrypt(iv)
if iv[-2:] != iv[-4:-2]:
raise ValueError("Failed integrity check for OPENPGP IV")
# First two bytes are for a deprecated "quick check" feature that
# should not be used. (https://eprint.iacr.org/2005/033)
iv = iv[:-2]
else:
raise ValueError("Length of IV must be %d or %d bytes"
Expand Down