Created
November 26, 2012 08:31
-
-
Save hamano/4147202 to your computer and use it in GitHub Desktop.
M2Crypto-0.21.1-bytes_to_key_with_iv.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/SWIG/_evp.i b/SWIG/_evp.i | |
index 0593eed..12c8b1f 100644 | |
--- a/SWIG/_evp.i | |
+++ b/SWIG/_evp.i | |
@@ -326,9 +326,9 @@ void cipher_ctx_free(EVP_CIPHER_CTX *ctx) { | |
PyObject *bytes_to_key(const EVP_CIPHER *cipher, EVP_MD *md, | |
PyObject *data, PyObject *salt, | |
- PyObject *iv, /* Not used */ | |
int iter) { | |
unsigned char key[EVP_MAX_KEY_LENGTH]; | |
+ unsigned char iv[EVP_MAX_IV_LENGTH]; | |
const void *dbuf, *sbuf; | |
int dlen, klen; | |
Py_ssize_t slen; | |
@@ -341,8 +341,10 @@ PyObject *bytes_to_key(const EVP_CIPHER *cipher, EVP_MD *md, | |
assert((slen == 8) || (slen == 0)); | |
klen = EVP_BytesToKey(cipher, md, (unsigned char *)sbuf, | |
(unsigned char *)dbuf, dlen, iter, | |
- key, NULL); /* Since we are not returning IV no need to derive it */ | |
- ret = PyString_FromStringAndSize((char*)key, klen); | |
+ key, iv); | |
+ ret = PyTuple_New(2); | |
+ PyTuple_SetItem(ret, 0, PyString_FromStringAndSize((char*)key, klen)); | |
+ PyTuple_SetItem(ret, 1, PyString_FromStringAndSize((char*)iv, cipher->iv_len)); | |
return ret; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment