From b382f9f9229121054ae6a87678ee3601381de099 Mon Sep 17 00:00:00 2001 From: "Dwayne C. Litzenberger" Date: Thu, 24 May 2012 07:47:26 -0400 Subject: In ALGnew, check the mode before checking other parameters --- src/block_template.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/block_template.c b/src/block_template.c index 3526cd1..bc7aa74 100644 --- a/src/block_template.c +++ b/src/block_template.c @@ -145,37 +145,37 @@ ALGnew(PyObject *self, PyObject *args, PyObject *kwdict) return NULL; } - if (KEY_SIZE!=0 && keylen!=KEY_SIZE) + if (modeMODE_CTR) { PyErr_Format(PyExc_ValueError, + "Unknown cipher feedback mode %i", + mode); + return NULL; + } + if (mode == MODE_PGP) { + PyErr_Format(PyExc_ValueError, + "MODE_PGP is not supported anymore"); + return NULL; + } + if (KEY_SIZE!=0 && keylen!=KEY_SIZE) + { + PyErr_Format(PyExc_ValueError, "Key must be %i bytes long, not %i", KEY_SIZE, keylen); return NULL; } if (KEY_SIZE==0 && keylen==0) { - PyErr_SetString(PyExc_ValueError, + PyErr_SetString(PyExc_ValueError, "Key cannot be the null string"); return NULL; } if (IVlen != BLOCK_SIZE && IVlen != 0) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "IV must be %i bytes long", BLOCK_SIZE); return NULL; } - if (modeMODE_CTR) - { - PyErr_Format(PyExc_ValueError, - "Unknown cipher feedback mode %i", - mode); - return NULL; - } - if (mode == MODE_PGP) { - PyErr_Format(PyExc_ValueError, - "MODE_PGP is not supported anymore"); - return NULL; - } /* Mode-specific checks */ if (mode == MODE_CFB) { -- cgit v1.2.1