Skip to content

Commit

Permalink
v0.3.9 update - removed --batch flag from encrypt()
Browse files Browse the repository at this point in the history
  • Loading branch information
rmlibre committed Dec 14, 2019
1 parent 4bd2b26 commit 0c12db2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 39 deletions.
9 changes: 8 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Changes for version 0.3.8
# Changes for version 0.3.9
## Known Issues
- Because of Debian [bug #930665](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930665), and related GnuPG [bug #T4393](https://dev.gnupg.org/T4393), importing keys from the default keyserver [keys.openpgp.org](https://keys.openpgp.org/) doesn't work automatically on all systems. Not without email confirmation, at least. That's because the keyserver will not publish uid information attached to a key before a user confirms access to the email address assigned to the uploaded key. And, because GnuPG folks are still holding up the merging, and back-porting, of patches that would allow GnuPG to automatically handle keys without uids gracefully. This effects the `network_import()` method specifically, but also the `text_import()` and `file_import()` methods, if they happen to be passed a key or filename argument which refers to a key without uid information. The gpg2 binary in this package can be replaced manually if a user's system has access to a patched version.
- This program may only be reliably compatible with keys that are also created with this program. That's because our terminal parsing is reliant on specific metadata to be similar across all encountered keys. It seems most keys have successfully been parsed with recent updates, though more testing is needed.
- Currently, the package is part synchronous, and part asynchronous. This is not ideal, so a decision has to be made: either to stay mixed style, or choose one consistent style.
- We're still in unstable and have to build out our test suite. Contributions welcome.
## Minor Changes
- Added new tests.
## Major Changes
- Fixed new crash caused by `--batch` keyword in `encrypt()`. When a key being used to encrypt isn't ultimately trusted, gnupg raises an error, but this isn't a desired behavior. So, `--batch` is removed from the command sent from the method.


# Changes for version 0.3.8
## Minor Changes
- Added new tests.
- Removed `base_command()` method because it was only a layer of indirection. It was merged into `command()`.
## Major Changes
- Added the `--batch`, `--quiet` and `--yes` arguments to the default commands contructed by the `command()` method.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
setup(
name="tiny_gnupg",
license="GPLv3",
version="0.3.8",
version="0.3.9",
description=description,
long_description=long_description,
url="https://github.com/rmlibre/tiny_gnupg",
Expand Down
69 changes: 36 additions & 33 deletions tests/test_tiny_gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# All rights reserved.
#

import os
import sys
import pytest
import asyncio
Expand Down Expand Up @@ -85,38 +84,42 @@ def test_command(gpg):

def test_cipher(gpg):
message = "\n twenty\ntwo\narmed\ndogs\nrush\nthe\nkibble \n\n"
encrypted_message_0 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
local_user=gpg.fingerprint,
)
encrypted_message_1 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
)
encrypted_message_2 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
local_user=gpg.fingerprint,
sign=False,
)
encrypted_message_3 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
sign=False,
)
assert gpg.decrypt(encrypted_message_0) == message + "\n"
assert gpg.decrypt(encrypted_message_1) == message + "\n"
assert gpg.decrypt(encrypted_message_2) == message + "\n"
assert gpg.decrypt(encrypted_message_3) == message + "\n"
signed_message_0 = gpg.sign(message)
signed_message_1 = gpg.sign(signed_message_0)
signed_message_2 = gpg.sign(signed_message_1)
signed_message_3 = gpg.sign(signed_message_2)
gpg.verify(signed_message_0)
gpg.verify(signed_message_1)
gpg.verify(signed_message_2)
gpg.verify(signed_message_3)
for trust_level in range(1, 6):
for fingerprint in gpg.list_keys():
gpg.trust(fingerprint, trust_level)
encrypted_message_0 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
local_user=gpg.fingerprint,
)
encrypted_message_1 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
)
encrypted_message_2 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
local_user=gpg.fingerprint,
sign=False,
)
encrypted_message_3 = gpg.encrypt(
message=message,
uid=gpg.fingerprint,
sign=False,
)
assert gpg.decrypt(encrypted_message_0) == message + "\n"
assert gpg.decrypt(encrypted_message_1) == message + "\n"
assert gpg.decrypt(encrypted_message_2) == message + "\n"
assert gpg.decrypt(encrypted_message_3) == message + "\n"
signed_message_0 = gpg.sign(message)
signed_message_1 = gpg.sign(signed_message_0)
signed_message_2 = gpg.sign(signed_message_1)
signed_message_3 = gpg.sign(signed_message_2)
signed_message_3 = gpg.sign(signed_message_3)
gpg.verify(signed_message_0)
gpg.verify(signed_message_1)
gpg.verify(signed_message_2)
gpg.verify(signed_message_3)


def test_file_io(gpg):
Expand Down
2 changes: 1 addition & 1 deletion tiny_gnupg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
# All rights reserved.
#

__version__ = "0.3.8"
__version__ = "0.3.9"

from .tiny_gnupg import GnuPG, __all__
5 changes: 2 additions & 3 deletions tiny_gnupg/tiny_gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def encrypt(self, message="", uid="", sign=True, local_user=""):
uid,
with_passphrase=True,
)
command.remove("--batch") # avoid crash with untrusted keys
if self.key_trust(uid) != "ultimate":
inputs = self.encode_inputs(self.passphrase, "y", message)
else:
Expand Down Expand Up @@ -305,9 +306,7 @@ def key_email(self, uid=""):
for part in parts.split("\nuid"):
if "@" in part and "]" in part:
part = part[part.find("]") + 1 :]
if part.startswith("<"):
part = part[1:-1]
elif "<" in part:
if "<" in part and ">" in part:
part = part[part.find("<") + 1 : part.find(">")]
return part

Expand Down

0 comments on commit 0c12db2

Please sign in to comment.