Added a PaddingContext interface
diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py
index 49c19d0..217490f 100644
--- a/cryptography/hazmat/primitives/interfaces.py
+++ b/cryptography/hazmat/primitives/interfaces.py
@@ -45,3 +45,17 @@
"""
finalize return bytes
"""
+
+
+class PaddingContext(six.with_metaclass(abc.ABCMeta)):
+ @abc.abstractmethod
+ def update(self, data):
+ """
+ update takes bytes and return bytes
+ """
+
+ @abc.abstractmethod
+ def finalize(self):
+ """
+ finalize return bytes
+ """
diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py
index 09e4b9f..8e2219e 100644
--- a/cryptography/hazmat/primitives/padding.py
+++ b/cryptography/hazmat/primitives/padding.py
@@ -13,6 +13,8 @@
import six
+from cryptography.hazmat.primitives import interfaces
+
class PKCS7(object):
def __init__(self, block_size):
@@ -40,6 +42,7 @@
return unpadder.update(data) + unpadder.finalize()
+@interfaces.register(interfaces.PaddingContext)
class _PaddingContext(object):
def __init__(self, block_size):
super(_PaddingContext, self).__init__()
@@ -70,6 +73,7 @@
return result
+@interfaces.register(interfaces.PaddingContext)
class _UnpaddingContext(object):
def __init__(self, block_size):
super(_UnpaddingContext, self).__init__()