Update bytes/str stuff in crypt_verify and crypto_sign
diff --git a/OpenSSL/crypto/crypto.c b/OpenSSL/crypto/crypto.c
index 87f3e75..a81773d 100644
--- a/OpenSSL/crypto/crypto.c
+++ b/OpenSSL/crypto/crypto.c
@@ -24,6 +24,18 @@
PyObject *crypto_Error;
+int crypto_byte_converter(PyObject *input, void* output) {
+ char **message = output;
+ if (input == Py_None) {
+ *message = NULL;
+ } else if (PyBytes_CheckExact(input)) {
+ *message = PyBytes_AsString(input);
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
static int
global_passphrase_callback(char *buf, int len, int rwflag, void *cb_arg)
{
@@ -612,8 +624,9 @@
EVP_MD_CTX md_ctx;
unsigned char sig_buf[512];
- if (!PyArg_ParseTuple(args, "O!ss:sign", &crypto_PKey_Type,
- &pkey, &data, &digest_name)) {
+ if (!PyArg_ParseTuple(
+ args, "O!" BYTESTRING_FMT BYTESTRING_FMT ":sign", &crypto_PKey_Type,
+ &pkey, &data, &digest_name)) {
return NULL;
}
@@ -657,8 +670,11 @@
EVP_MD_CTX md_ctx;
EVP_PKEY *pkey;
- if (!PyArg_ParseTuple(args, "O!t#ss:verify", &crypto_X509_Type, &cert, &signature, &sig_len,
- &data, &digest_name)) {
+#ifdef PY3
+ if (!PyArg_ParseTuple(args, "O!y#yy:verify", &crypto_X509_Type, &cert, &signature, &sig_len, &data, &digest_name)) {
+#else
+ if (!PyArg_ParseTuple(args, "O!t#ss:verify", &crypto_X509_Type, &cert, &signature, &sig_len, &data, &digest_name)) {
+#endif
return NULL;
}
diff --git a/OpenSSL/crypto/crypto.h b/OpenSSL/crypto/crypto.h
index 9b9663d..75961a7 100644
--- a/OpenSSL/crypto/crypto.h
+++ b/OpenSSL/crypto/crypto.h
@@ -74,6 +74,8 @@
extern crypto_PKCS7_New_RETURN crypto_PKCS7_New crypto_PKCS7_New_PROTO;
extern crypto_NetscapeSPKI_New_RETURN crypto_NetscapeSPKI_New crypto_NetscapeSPKI_New_PROTO;
+int crypto_byte_converter(PyObject *input, void *output);
+
#else /* crypto_MODULE */
extern void **crypto_API;
diff --git a/OpenSSL/crypto/revoked.c b/OpenSSL/crypto/revoked.c
index c876373..e9b1297 100644
--- a/OpenSSL/crypto/revoked.c
+++ b/OpenSSL/crypto/revoked.c
@@ -123,19 +123,6 @@
}
-static int
-crypto_byte_converter(PyObject *input, void* output) {
- char **message = output;
- if (input == Py_None) {
- *message = NULL;
- } else if (PyBytes_CheckExact(input)) {
- *message = PyBytes_AsString(input);
- } else {
- return 0;
- }
- return 1;
-}
-
static char crypto_Revoked_set_reason_doc[] = "\n\
Set the reason of a Revoked object.\n\
\n\