diff options
-rw-r--r-- | SWIG/_m2crypto_wrap.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/SWIG/_m2crypto_wrap.c b/SWIG/_m2crypto_wrap.c index 837ce6c..ff75af5 100644 --- a/SWIG/_m2crypto_wrap.c +++ b/SWIG/_m2crypto_wrap.c @@ -6085,8 +6085,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, |