summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Ramacher <sebastian+dev@ramacher.at>2013-10-28 02:47:48 +0100
committerSebastian Ramacher <sebastian+dev@ramacher.at>2013-10-28 17:24:20 +0100
commit8cde8b9893819e9586bde2ce9be84f24689ff0d9 (patch)
treeb0ad65ded19ca599e66f5f80fc220eb7e8980e34
parent4b2a15fef3e9f0ca3809a54ae2a18109dae4ae01 (diff)
downloadpycrypto-8cde8b9893819e9586bde2ce9be84f24689ff0d9.tar.gz
Add block_finalize to clean up block_state from ALGdealloc
This is the counterpart to block_init which is called from ALGnew. Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
-rw-r--r--src/AES.c4
-rw-r--r--src/AESNI.c4
-rw-r--r--src/ARC2.c4
-rw-r--r--src/Blowfish.c4
-rw-r--r--src/CAST.c5
-rw-r--r--src/DES.c4
-rw-r--r--src/block_template.c1
7 files changed, 26 insertions, 0 deletions
diff --git a/src/AES.c b/src/AES.c
index 5da189f..1e705da 100644
--- a/src/AES.c
+++ b/src/AES.c
@@ -1446,6 +1446,10 @@ static void block_init(block_state *state, unsigned char *key,
rijndaelKeySetupDec(state->dk, key, keylen*8);
}
+static void block_finalize(block_state* self)
+{
+}
+
static void block_encrypt(block_state *self, u8 *in, u8 *out)
{
rijndaelEncrypt(self->ek, self->rounds, in, out);
diff --git a/src/AESNI.c b/src/AESNI.c
index 5b388ef..81c6e9c 100644
--- a/src/AESNI.c
+++ b/src/AESNI.c
@@ -166,6 +166,10 @@ static void block_init(block_state* self, unsigned char* key, int keylen)
aes_key_setup_dec(self->dk, self->ek, nr);
}
+static void block_finalize(block_state* self)
+{
+}
+
static void block_encrypt(block_state* self, const u8* in, u8* out)
{
__m128i m = _mm_loadu_si128((const __m128i*) in);
diff --git a/src/ARC2.c b/src/ARC2.c
index 255e77e..71858f6 100644
--- a/src/ARC2.c
+++ b/src/ARC2.c
@@ -216,5 +216,9 @@ block_init(block_state *self, U8 *key, int keylength)
} while (i--);
}
+static void
+block_finalize(block_state* self)
+{
+}
#include "block_template.c"
diff --git a/src/Blowfish.c b/src/Blowfish.c
index 96f8628..f1ab55a 100644
--- a/src/Blowfish.c
+++ b/src/Blowfish.c
@@ -231,6 +231,10 @@ static void Blowfish_init(Blowfish_state *self, const unsigned char *key, int ke
#define block_encrypt Blowfish_encrypt
#define block_decrypt Blowfish_decrypt
+static void block_finalize(block_state *self)
+{
+}
+
#include "block_template.c"
/* vim:set ts=4 sw=4 sts=4 expandtab: */
diff --git a/src/CAST.c b/src/CAST.c
index ca5d0f0..d7b00f3 100644
--- a/src/CAST.c
+++ b/src/CAST.c
@@ -435,6 +435,11 @@ block_init(block_state *self, unsigned char *key, int keylength)
}
static void
+block_finalize(block_state* self)
+{
+}
+
+static void
block_encrypt(block_state *self, unsigned char *in,
unsigned char *out)
{
diff --git a/src/DES.c b/src/DES.c
index 9cbda53..5187870 100644
--- a/src/DES.c
+++ b/src/DES.c
@@ -76,6 +76,10 @@ static void block_init(block_state *self, unsigned char *key, int keylen)
}
}
+static void block_finalize(block_state *self)
+{
+}
+
static void block_encrypt(block_state *self, unsigned char *in, unsigned char *out)
{
int rc;
diff --git a/src/block_template.c b/src/block_template.c
index f940e0e..eec03d3 100644
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -84,6 +84,7 @@ static void
ALGdealloc(PyObject *ptr)
{
ALGobject *self = (ALGobject *)ptr;
+ block_finalize(&self->st);
/* Overwrite the contents of the object */
Py_XDECREF(self->counter);