aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAyrx <terrycwk1994@gmail.com>2014-03-16 14:36:17 +0800
committerAyrx <terrycwk1994@gmail.com>2014-03-16 14:36:17 +0800
commitf56c54e36ce06e8e29691c3c4dfd000e8477a41d (patch)
tree4a3e86f945b37c950b35d8eb0d11930485c907d4 /cryptography
parent3fb221f1fb02ffed7a558bd06ba41bb75c329fc5 (diff)
downloadcryptography-f56c54e36ce06e8e29691c3c4dfd000e8477a41d.tar.gz
cryptography-f56c54e36ce06e8e29691c3c4dfd000e8477a41d.tar.bz2
cryptography-f56c54e36ce06e8e29691c3c4dfd000e8477a41d.zip
Added backend check to cipher primitives
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/primitives/ciphers/base.py8
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")