aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-13 15:44:01 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-02-13 15:44:01 -0600
commitba7d5ecd3e34c59ce58a4b1c2f86494602efe9e8 (patch)
treee7e01d828b33e849c0ed84cb006139282504e82f /cryptography
parentb477b53fc7e8afe64c380315e16eabfeaaaf7847 (diff)
parent43e4d7a1b97d66c6da1f4ce34faaa4ba45937739 (diff)
downloadcryptography-ba7d5ecd3e34c59ce58a4b1c2f86494602efe9e8.tar.gz
cryptography-ba7d5ecd3e34c59ce58a4b1c2f86494602efe9e8.tar.bz2
cryptography-ba7d5ecd3e34c59ce58a4b1c2f86494602efe9e8.zip
Merge branch 'master' into add-crt-coefficients
* master: Also clean up this syntax Fixed a missing word in the RSA docs Fix comments in padding.py to be accurate add versionadded to cast5 A few style nits in the docs add CAST5 support to changelog Changed .... lines to ~~~~ and s/Gnu\/Linux/Linux/ Pypy is not a real word either apparently. Added Pypy note and fixed libffi's "spelling" Added Debian mention, extra missing packages Added a docs section on Linux installation remove some extra linebreaks add cast5 docs Syntax highlight the go code. Be mad Rob Pike. add cbc, cfb, ofb support to CAST5 (aka CAST128) for openssl & cc re-add CAST5 ECB support (OpenSSL & CC backends). fixes #417 Switch this to a warning block Be clear about HKDF's applicability for password storage Conflicts: docs/hazmat/primitives/rsa.rst
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/backends/commoncrypto/backend.py14
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py8
-rw-r--r--cryptography/hazmat/primitives/ciphers/algorithms.py15
-rw-r--r--cryptography/hazmat/primitives/padding.py6
4 files changed, 37 insertions, 6 deletions
diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py
index e5d4ee00..5c08a356 100644
--- a/cryptography/hazmat/backends/commoncrypto/backend.py
+++ b/cryptography/hazmat/backends/commoncrypto/backend.py
@@ -25,7 +25,7 @@ from cryptography.hazmat.backends.interfaces import (
from cryptography.hazmat.bindings.commoncrypto.binding import Binding
from cryptography.hazmat.primitives import interfaces, constant_time
from cryptography.hazmat.primitives.ciphers.algorithms import (
- AES, Blowfish, TripleDES, ARC4
+ AES, Blowfish, TripleDES, ARC4, CAST5
)
from cryptography.hazmat.primitives.ciphers.modes import (
CBC, CTR, ECB, OFB, CFB, GCM
@@ -198,6 +198,18 @@ class Backend(object):
mode_cls,
mode_const
)
+ for mode_cls, mode_const in [
+ (CBC, self._lib.kCCModeCBC),
+ (ECB, self._lib.kCCModeECB),
+ (CFB, self._lib.kCCModeCFB),
+ (OFB, self._lib.kCCModeOFB)
+ ]:
+ self._register_cipher_adapter(
+ CAST5,
+ self._lib.kCCAlgorithmCAST,
+ mode_cls,
+ mode_const
+ )
self._register_cipher_adapter(
ARC4,
self._lib.kCCAlgorithmRC4,
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index ce37e5c8..8a4aeac5 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -26,7 +26,7 @@ from cryptography.hazmat.bindings.openssl.binding import Binding
from cryptography.hazmat.primitives import interfaces, hashes
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.ciphers.algorithms import (
- AES, Blowfish, Camellia, TripleDES, ARC4,
+ AES, Blowfish, Camellia, TripleDES, ARC4, CAST5
)
from cryptography.hazmat.primitives.ciphers.modes import (
CBC, CTR, ECB, OFB, CFB, GCM,
@@ -153,6 +153,12 @@ class Backend(object):
mode_cls,
GetCipherByName("bf-{mode.name}")
)
+ for mode_cls in [CBC, CFB, OFB, ECB]:
+ self.register_cipher_adapter(
+ CAST5,
+ mode_cls,
+ GetCipherByName("cast5-{mode.name}")
+ )
self.register_cipher_adapter(
ARC4,
type(None),
diff --git a/cryptography/hazmat/primitives/ciphers/algorithms.py b/cryptography/hazmat/primitives/ciphers/algorithms.py
index 19cf1920..a5cfce92 100644
--- a/cryptography/hazmat/primitives/ciphers/algorithms.py
+++ b/cryptography/hazmat/primitives/ciphers/algorithms.py
@@ -90,6 +90,21 @@ class Blowfish(object):
return len(self.key) * 8
+@utils.register_interface(interfaces.BlockCipherAlgorithm)
+@utils.register_interface(interfaces.CipherAlgorithm)
+class CAST5(object):
+ name = "CAST5"
+ block_size = 64
+ key_sizes = frozenset(range(40, 129, 8))
+
+ def __init__(self, key):
+ self.key = _verify_key_size(self, key)
+
+ @property
+ def key_size(self):
+ return len(self.key) * 8
+
+
@utils.register_interface(interfaces.CipherAlgorithm)
class ARC4(object):
name = "RC4"
diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py
index ddb2c63c..1717262c 100644
--- a/cryptography/hazmat/primitives/padding.py
+++ b/cryptography/hazmat/primitives/padding.py
@@ -86,8 +86,7 @@ class PKCS7(object):
class _PKCS7PaddingContext(object):
def __init__(self, block_size):
self.block_size = block_size
- # TODO: O(n ** 2) complexity for repeated concatentation, we should use
- # zero-buffer (#193)
+ # TODO: more copies than necessary, we should use zero-buffer (#193)
self._buffer = b""
def update(self, data):
@@ -120,8 +119,7 @@ class _PKCS7PaddingContext(object):
class _PKCS7UnpaddingContext(object):
def __init__(self, block_size):
self.block_size = block_size
- # TODO: O(n ** 2) complexity for repeated concatentation, we should use
- # zero-buffer (#193)
+ # TODO: more copies than necessary, we should use zero-buffer (#193)
self._buffer = b""
def update(self, data):