From 5701bad5489ca283df9da8ea1067a54da484c754 Mon Sep 17 00:00:00 2001 From: meejah Date: Mon, 24 Jun 2019 12:05:12 -0600 Subject: [PATCH] a module for errors --- src/allmydata/crypto/ed25519.py | 7 +++---- src/allmydata/crypto/error.py | 15 +++++++++++++++ src/allmydata/crypto/rsa.py | 2 +- src/allmydata/crypto/util.py | 12 +----------- src/allmydata/introducer/client.py | 2 +- src/allmydata/mutable/servermap.py | 2 +- 6 files changed, 22 insertions(+), 18 deletions(-) create mode 100644 src/allmydata/crypto/error.py diff --git a/src/allmydata/crypto/ed25519.py b/src/allmydata/crypto/ed25519.py index b8404dec0..e05c92020 100644 --- a/src/allmydata/crypto/ed25519.py +++ b/src/allmydata/crypto/ed25519.py @@ -31,10 +31,9 @@ from cryptography.hazmat.primitives.serialization import ( PublicFormat, ) -from allmydata.crypto import ( - remove_prefix, - BadSignature, -) +from allmydata.crypto.util import remove_prefix +from allmydata.crypto.error import BadSignature + from allmydata.util.base32 import ( a2b, b2a, diff --git a/src/allmydata/crypto/error.py b/src/allmydata/crypto/error.py new file mode 100644 index 000000000..62c0b3e5b --- /dev/null +++ b/src/allmydata/crypto/error.py @@ -0,0 +1,15 @@ +""" +Exceptions raise by allmydata.crypto.* modules +""" + + +class BadSignature(Exception): + """ + An alleged signature did not match + """ + + +class BadPrefixError(Exception): + """ + A key did not start with the required prefix + """ diff --git a/src/allmydata/crypto/rsa.py b/src/allmydata/crypto/rsa.py index 611da1649..25a361640 100644 --- a/src/allmydata/crypto/rsa.py +++ b/src/allmydata/crypto/rsa.py @@ -5,7 +5,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa, padding from cryptography.hazmat.primitives.serialization import load_der_private_key, load_der_public_key, \ Encoding, PrivateFormat, PublicFormat, NoEncryption -from allmydata.crypto import BadSignature +from allmydata.crypto.error import BadSignature """ diff --git a/src/allmydata/crypto/util.py b/src/allmydata/crypto/util.py index 571f55387..7e4ebb92f 100644 --- a/src/allmydata/crypto/util.py +++ b/src/allmydata/crypto/util.py @@ -2,17 +2,7 @@ Utilities used by allmydata.crypto modules """ - -class BadSignature(Exception): - """ - An alleged signature did not match - """ - - -class BadPrefixError(Exception): - """ - A key did not start with the required prefix - """ +from allmydata.crypto.error import BadPrefixError def remove_prefix(s_bytes, prefix): diff --git a/src/allmydata/introducer/client.py b/src/allmydata/introducer/client.py index f6047dbff..225ec1abc 100644 --- a/src/allmydata/introducer/client.py +++ b/src/allmydata/introducer/client.py @@ -9,7 +9,7 @@ from allmydata.introducer.common import sign_to_foolscap, unsign_from_foolscap,\ get_tubid_string_from_ann from allmydata.util import log, yamlutil, connection_status from allmydata.util.rrefutil import add_version_to_remote_reference -from allmydata.crypto import BadSignature +from allmydata.crypto.error import BadSignature from allmydata.util.assertutil import precondition class InvalidCacheError(Exception): diff --git a/src/allmydata/mutable/servermap.py b/src/allmydata/mutable/servermap.py index a50db6e78..8dba6d8b5 100644 --- a/src/allmydata/mutable/servermap.py +++ b/src/allmydata/mutable/servermap.py @@ -8,7 +8,7 @@ from twisted.internet import defer from twisted.python import failure from foolscap.api import DeadReferenceError, RemoteException, eventually, \ fireEventually -from allmydata.crypto import BadSignature +from allmydata.crypto.error import BadSignature from allmydata.crypto import rsa from allmydata.util import base32, hashutil, log, deferredutil from allmydata.util.dictutil import DictOfSets