summaryrefslogtreecommitdiff
path: root/SWIG/_evp.i
diff options
context:
space:
mode:
Diffstat (limited to 'SWIG/_evp.i')
-rw-r--r--SWIG/_evp.i13
1 files changed, 11 insertions, 2 deletions
diff --git a/SWIG/_evp.i b/SWIG/_evp.i
index d04e806..9a3b67b 100644
--- a/SWIG/_evp.i
+++ b/SWIG/_evp.i
@@ -430,8 +430,17 @@ PyObject *cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
const void *kbuf, *ibuf;
Py_ssize_t klen, ilen;
- if ((PyObject_AsReadBuffer(key, &kbuf, &klen) == -1)
- || (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1))
+ if (cipher == Py_None)
+ cipher = NULL;
+
+ if (key == Py_None)
+ kbuf = NULL;
+ else if (PyObject_AsReadBuffer(key, &kbuf, &klen) == -1)
+ return NULL;
+
+ if (iv == Py_None)
+ ibuf = NULL;
+ else if (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1)
return NULL;
if (!EVP_CipherInit(ctx, cipher, (unsigned char *)kbuf,