diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-03-16 08:07:55 -0430 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-03-16 08:07:55 -0430 |
commit | 1e7ce06edb9179cf2afc66b031767d9246242fad (patch) | |
tree | 73bf237fc89851950325a78c1ded24f8343cb4b1 /cryptography | |
parent | 77fdd4e4559c30ee0155430f6fe192311b5eae8b (diff) | |
parent | 471c1184eb8a7c24111abdc0bcb418c6c6839757 (diff) | |
download | cryptography-1e7ce06edb9179cf2afc66b031767d9246242fad.tar.gz cryptography-1e7ce06edb9179cf2afc66b031767d9246242fad.tar.bz2 cryptography-1e7ce06edb9179cf2afc66b031767d9246242fad.zip |
Merge pull request #806 from Ayrx/add-backend-check-to-cipher
Added backend check to cipher primitives
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/primitives/ciphers/base.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cryptography/hazmat/primitives/ciphers/base.py b/cryptography/hazmat/primitives/ciphers/base.py index d366e4cf..2c804cac 100644 --- a/cryptography/hazmat/primitives/ciphers/base.py +++ b/cryptography/hazmat/primitives/ciphers/base.py @@ -16,12 +16,18 @@ from __future__ import absolute_import, division, print_function from cryptography import utils from cryptography.exceptions import ( AlreadyFinalized, NotYetFinalized, AlreadyUpdated, -) + UnsupportedInterface) + +from cryptography.hazmat.backends.interfaces import CipherBackend from cryptography.hazmat.primitives import interfaces class Cipher(object): def __init__(self, algorithm, mode, backend): + if not isinstance(backend, CipherBackend): + raise UnsupportedInterface( + "Backend object does not implement CipherBackend") + if not isinstance(algorithm, interfaces.CipherAlgorithm): raise TypeError("Expected interface of interfaces.CipherAlgorithm") |