From 8cde8b9893819e9586bde2ce9be84f24689ff0d9 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 28 Oct 2013 02:47:48 +0100 Subject: 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 --- src/AES.c | 4 ++++ src/AESNI.c | 4 ++++ src/ARC2.c | 4 ++++ src/Blowfish.c | 4 ++++ src/CAST.c | 5 +++++ src/DES.c | 4 ++++ src/block_template.c | 1 + 7 files changed, 26 insertions(+) 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 @@ -434,6 +434,11 @@ block_init(block_state *self, unsigned char *key, int keylength) castschedulekeys(self, key, 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); -- cgit v1.2.1