diff --git a/0001-Rename-DSA-RSA-PublicKey-to-Py-DSA-RSA-PublicKey.patch b/0001-Rename-DSA-RSA-PublicKey-to-Py-DSA-RSA-PublicKey.patch new file mode 100644 index 0000000..acaa998 --- /dev/null +++ b/0001-Rename-DSA-RSA-PublicKey-to-Py-DSA-RSA-PublicKey.patch @@ -0,0 +1,594 @@ +From 079d4f65a743fb9e952ab109c1a24997c15398a7 Mon Sep 17 00:00:00 2001 +From: Alexander Scheel +Date: Thu, 3 Dec 2020 10:03:50 -0500 +Subject: [PATCH] Rename {DSA,RSA}PublicKey to Py{DSA,RSA}PublicKey + +These two structs have also been added to NSS as of v3.58. Because we +duplicate the name with different members, we should prefix the +python-nss classes with "Py" in the C code to distinguish them. + +Signed-off-by: Alexander Scheel +--- + src/py_nss.c | 180 +++++++++++++++++++++++++-------------------------- + src/py_nss.h | 8 +-- + 2 files changed, 94 insertions(+), 94 deletions(-) + +diff --git a/src/py_nss.c b/src/py_nss.c +index 3e8ccdb..d033ac2 100644 +--- a/src/py_nss.c ++++ b/src/py_nss.c +@@ -7091,7 +7091,7 @@ KEYPQGParams_new_from_SECKEYPQGParams(const SECKEYPQGParams *params) + } + + /* ========================================================================== */ +-/* =========================== RSAPublicKey Class =========================== */ ++/* ========================== PyRSAPublicKey Class ========================== */ + /* ========================================================================== */ + + /* ============================ Attribute Access ============================ */ +@@ -7100,7 +7100,7 @@ KEYPQGParams_new_from_SECKEYPQGParams(const SECKEYPQGParams *params) + // via integer_secitem_to_pylong() + + static PyObject * +-RSAPublicKey_get_modulus(RSAPublicKey *self, void *closure) ++PyRSAPublicKey_get_modulus(PyRSAPublicKey *self, void *closure) + { + TraceMethodEnter(self); + +@@ -7109,7 +7109,7 @@ RSAPublicKey_get_modulus(RSAPublicKey *self, void *closure) + } + + static PyObject * +-RSAPublicKey_get_exponent(RSAPublicKey *self, void *closure) ++PyRSAPublicKey_get_exponent(PyRSAPublicKey *self, void *closure) + { + TraceMethodEnter(self); + +@@ -7118,20 +7118,20 @@ RSAPublicKey_get_exponent(RSAPublicKey *self, void *closure) + } + + static +-PyGetSetDef RSAPublicKey_getseters[] = { +- {"modulus", (getter)RSAPublicKey_get_modulus, (setter)NULL, "RSA modulus", NULL}, +- {"exponent", (getter)RSAPublicKey_get_exponent, (setter)NULL, "RSA exponent", NULL}, ++PyGetSetDef PyRSAPublicKey_getseters[] = { ++ {"modulus", (getter)PyRSAPublicKey_get_modulus, (setter)NULL, "RSA modulus", NULL}, ++ {"exponent", (getter)PyRSAPublicKey_get_exponent, (setter)NULL, "RSA exponent", NULL}, + {NULL} /* Sentinel */ + }; + +-static PyMemberDef RSAPublicKey_members[] = { ++static PyMemberDef PyRSAPublicKey_members[] = { + {NULL} /* Sentinel */ + }; + + /* ============================== Class Methods ============================= */ + + static PyObject * +-RSAPublicKey_format_lines(RSAPublicKey *self, PyObject *args, PyObject *kwds) ++PyRSAPublicKey_format_lines(PyRSAPublicKey *self, PyObject *args, PyObject *kwds) + { + static char *kwlist[] = {"level", NULL}; + int level = 0; +@@ -7147,12 +7147,12 @@ RSAPublicKey_format_lines(RSAPublicKey *self, PyObject *args, PyObject *kwds) + return NULL; + } + +- if ((obj = RSAPublicKey_get_modulus(self, NULL)) == NULL) { ++ if ((obj = PyRSAPublicKey_get_modulus(self, NULL)) == NULL) { + goto fail; + } + FMT_SEC_INT_OBJ_APPEND_AND_CLEAR(lines, _("Modulus"), obj, level, fail); + +- if ((obj = RSAPublicKey_get_exponent(self, NULL)) == NULL) { ++ if ((obj = PyRSAPublicKey_get_exponent(self, NULL)) == NULL) { + goto fail; + } + FMT_SEC_INT_OBJ_APPEND_AND_CLEAR(lines, _("Exponent"), obj, level, fail); +@@ -7165,41 +7165,41 @@ RSAPublicKey_format_lines(RSAPublicKey *self, PyObject *args, PyObject *kwds) + } + + static PyObject * +-RSAPublicKey_format(RSAPublicKey *self, PyObject *args, PyObject *kwds) ++PyRSAPublicKey_format(PyRSAPublicKey *self, PyObject *args, PyObject *kwds) + { + TraceMethodEnter(self); + +- return format_from_lines((format_lines_func)RSAPublicKey_format_lines, (PyObject *)self, args, kwds); ++ return format_from_lines((format_lines_func)PyRSAPublicKey_format_lines, (PyObject *)self, args, kwds); + } + + static PyObject * +-RSAPublicKey_str(RSAPublicKey *self) ++PyRSAPublicKey_str(PyRSAPublicKey *self) + { + PyObject *py_formatted_result = NULL; + + TraceMethodEnter(self); + +- py_formatted_result = RSAPublicKey_format(self, empty_tuple, NULL); ++ py_formatted_result = PyRSAPublicKey_format(self, empty_tuple, NULL); + return py_formatted_result; + + } + +-static PyMethodDef RSAPublicKey_methods[] = { +- {"format_lines", (PyCFunction)RSAPublicKey_format_lines, METH_VARARGS|METH_KEYWORDS, generic_format_lines_doc}, +- {"format", (PyCFunction)RSAPublicKey_format, METH_VARARGS|METH_KEYWORDS, generic_format_doc}, ++static PyMethodDef PyRSAPublicKey_methods[] = { ++ {"format_lines", (PyCFunction)PyRSAPublicKey_format_lines, METH_VARARGS|METH_KEYWORDS, generic_format_lines_doc}, ++ {"format", (PyCFunction)PyRSAPublicKey_format, METH_VARARGS|METH_KEYWORDS, generic_format_doc}, + {NULL, NULL} /* Sentinel */ + }; + + /* =========================== Class Construction =========================== */ + + static PyObject * +-RSAPublicKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ++PyRSAPublicKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { +- RSAPublicKey *self; ++ PyRSAPublicKey *self; + + TraceObjNewEnter(type); + +- if ((self = (RSAPublicKey *)type->tp_alloc(type, 0)) == NULL) { ++ if ((self = (PyRSAPublicKey *)type->tp_alloc(type, 0)) == NULL) { + return NULL; + } + +@@ -7211,7 +7211,7 @@ RSAPublicKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + } + + static int +-RSAPublicKey_traverse(RSAPublicKey *self, visitproc visit, void *arg) ++PyRSAPublicKey_traverse(PyRSAPublicKey *self, visitproc visit, void *arg) + { + TraceMethodEnter(self); + +@@ -7221,7 +7221,7 @@ RSAPublicKey_traverse(RSAPublicKey *self, visitproc visit, void *arg) + } + + static int +-RSAPublicKey_clear(RSAPublicKey* self) ++PyRSAPublicKey_clear(PyRSAPublicKey* self) + { + TraceMethodEnter(self); + +@@ -7231,31 +7231,31 @@ RSAPublicKey_clear(RSAPublicKey* self) + } + + static void +-RSAPublicKey_dealloc(RSAPublicKey* self) ++PyRSAPublicKey_dealloc(PyRSAPublicKey* self) + { + TraceMethodEnter(self); + +- RSAPublicKey_clear(self); ++ PyRSAPublicKey_clear(self); + Py_TYPE(self)->tp_free((PyObject*)self); + } + +-PyDoc_STRVAR(RSAPublicKey_doc, ++PyDoc_STRVAR(PyRSAPublicKey_doc, + "An object representing an RSA Public Key"); + + static int +-RSAPublicKey_init(RSAPublicKey *self, PyObject *args, PyObject *kwds) ++PyRSAPublicKey_init(PyRSAPublicKey *self, PyObject *args, PyObject *kwds) + { + TraceMethodEnter(self); + + return 0; + } + +-static PyTypeObject RSAPublicKeyType = { ++static PyTypeObject PyRSAPublicKeyType = { + PyVarObject_HEAD_INIT(NULL, 0) +- "nss.nss.RSAPublicKey", /* tp_name */ +- sizeof(RSAPublicKey), /* tp_basicsize */ ++ "nss.nss.PyRSAPublicKey", /* tp_name */ ++ sizeof(PyRSAPublicKey), /* tp_basicsize */ + 0, /* tp_itemsize */ +- (destructor)RSAPublicKey_dealloc, /* tp_dealloc */ ++ (destructor)PyRSAPublicKey_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ +@@ -7266,39 +7266,39 @@ static PyTypeObject RSAPublicKeyType = { + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ +- (reprfunc)RSAPublicKey_str, /* tp_str */ ++ (reprfunc)PyRSAPublicKey_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ +- RSAPublicKey_doc, /* tp_doc */ +- (traverseproc)RSAPublicKey_traverse, /* tp_traverse */ +- (inquiry)RSAPublicKey_clear, /* tp_clear */ ++ PyRSAPublicKey_doc, /* tp_doc */ ++ (traverseproc)PyRSAPublicKey_traverse, /* tp_traverse */ ++ (inquiry)PyRSAPublicKey_clear, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ +- RSAPublicKey_methods, /* tp_methods */ +- RSAPublicKey_members, /* tp_members */ +- RSAPublicKey_getseters, /* tp_getset */ ++ PyRSAPublicKey_methods, /* tp_methods */ ++ PyRSAPublicKey_members, /* tp_members */ ++ PyRSAPublicKey_getseters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ +- (initproc)RSAPublicKey_init, /* tp_init */ ++ (initproc)PyRSAPublicKey_init, /* tp_init */ + 0, /* tp_alloc */ +- RSAPublicKey_new, /* tp_new */ ++ PyRSAPublicKey_new, /* tp_new */ + }; + + PyObject * +-RSAPublicKey_new_from_SECKEYRSAPublicKey(SECKEYRSAPublicKey *rsa) ++PyRSAPublicKey_new_from_SECKEYRSAPublicKey(SECKEYRSAPublicKey *rsa) + { +- RSAPublicKey *self = NULL; ++ PyRSAPublicKey *self = NULL; + + TraceObjNewEnter(NULL); + +- if ((self = (RSAPublicKey *) RSAPublicKeyType.tp_new(&RSAPublicKeyType, NULL, NULL)) == NULL) { ++ if ((self = (PyRSAPublicKey *) PyRSAPublicKeyType.tp_new(&PyRSAPublicKeyType, NULL, NULL)) == NULL) { + return NULL; + } + +@@ -7317,13 +7317,13 @@ RSAPublicKey_new_from_SECKEYRSAPublicKey(SECKEYRSAPublicKey *rsa) + } + + /* ========================================================================== */ +-/* =========================== DSAPublicKey Class =========================== */ ++/* ========================== PyDSAPublicKey Class ========================== */ + /* ========================================================================== */ + + /* ============================ Attribute Access ============================ */ + + static PyObject * +-DSAPublicKey_get_pqg_params(DSAPublicKey *self, void *closure) ++PyDSAPublicKey_get_pqg_params(PyDSAPublicKey *self, void *closure) + { + TraceMethodEnter(self); + +@@ -7332,7 +7332,7 @@ DSAPublicKey_get_pqg_params(DSAPublicKey *self, void *closure) + } + + static PyObject * +-DSAPublicKey_get_public_value(DSAPublicKey *self, void *closure) ++PyDSAPublicKey_get_public_value(PyDSAPublicKey *self, void *closure) + { + TraceMethodEnter(self); + +@@ -7341,20 +7341,20 @@ DSAPublicKey_get_public_value(DSAPublicKey *self, void *closure) + } + + static +-PyGetSetDef DSAPublicKey_getseters[] = { +- {"pqg_params", (getter)DSAPublicKey_get_pqg_params, (setter)NULL, "DSA P,Q,G params as a KEYPQGParams object", NULL}, +- {"public_value", (getter)DSAPublicKey_get_public_value, (setter)NULL, "DSA public_value", NULL}, ++PyGetSetDef PyDSAPublicKey_getseters[] = { ++ {"pqg_params", (getter)PyDSAPublicKey_get_pqg_params, (setter)NULL, "DSA P,Q,G params as a KEYPQGParams object", NULL}, ++ {"public_value", (getter)PyDSAPublicKey_get_public_value, (setter)NULL, "DSA public_value", NULL}, + {NULL} /* Sentinel */ + }; + +-static PyMemberDef DSAPublicKey_members[] = { ++static PyMemberDef PyDSAPublicKey_members[] = { + {NULL} /* Sentinel */ + }; + + /* ============================== Class Methods ============================= */ + + static PyObject * +-DSAPublicKey_format_lines(DSAPublicKey *self, PyObject *args, PyObject *kwds) ++PyDSAPublicKey_format_lines(PyDSAPublicKey *self, PyObject *args, PyObject *kwds) + { + static char *kwlist[] = {"level", NULL}; + int level = 0; +@@ -7371,13 +7371,13 @@ DSAPublicKey_format_lines(DSAPublicKey *self, PyObject *args, PyObject *kwds) + return NULL; + } + +- if ((obj = DSAPublicKey_get_pqg_params(self, NULL)) == NULL) { ++ if ((obj = PyDSAPublicKey_get_pqg_params(self, NULL)) == NULL) { + goto fail; + } + CALL_FORMAT_LINES_AND_APPEND(lines, obj, level, fail); + Py_CLEAR(obj); + +- if ((obj = DSAPublicKey_get_public_value(self, NULL)) == NULL) { ++ if ((obj = PyDSAPublicKey_get_public_value(self, NULL)) == NULL) { + goto fail; + } + FMT_SEC_INT_OBJ_APPEND_AND_CLEAR(lines, _("Public Value"), obj, level, fail); +@@ -7390,41 +7390,41 @@ DSAPublicKey_format_lines(DSAPublicKey *self, PyObject *args, PyObject *kwds) + } + + static PyObject * +-DSAPublicKey_format(DSAPublicKey *self, PyObject *args, PyObject *kwds) ++PyDSAPublicKey_format(PyDSAPublicKey *self, PyObject *args, PyObject *kwds) + { + TraceMethodEnter(self); + +- return format_from_lines((format_lines_func)DSAPublicKey_format_lines, (PyObject *)self, args, kwds); ++ return format_from_lines((format_lines_func)PyDSAPublicKey_format_lines, (PyObject *)self, args, kwds); + } + + static PyObject * +-DSAPublicKey_str(DSAPublicKey *self) ++PyDSAPublicKey_str(PyDSAPublicKey *self) + { + PyObject *py_formatted_result = NULL; + + TraceMethodEnter(self); + +- py_formatted_result = DSAPublicKey_format(self, empty_tuple, NULL); ++ py_formatted_result = PyDSAPublicKey_format(self, empty_tuple, NULL); + return py_formatted_result; + + } + +-static PyMethodDef DSAPublicKey_methods[] = { +- {"format_lines", (PyCFunction)DSAPublicKey_format_lines, METH_VARARGS|METH_KEYWORDS, generic_format_lines_doc}, +- {"format", (PyCFunction)DSAPublicKey_format, METH_VARARGS|METH_KEYWORDS, generic_format_doc}, ++static PyMethodDef PyDSAPublicKey_methods[] = { ++ {"format_lines", (PyCFunction)PyDSAPublicKey_format_lines, METH_VARARGS|METH_KEYWORDS, generic_format_lines_doc}, ++ {"format", (PyCFunction)PyDSAPublicKey_format, METH_VARARGS|METH_KEYWORDS, generic_format_doc}, + {NULL, NULL} /* Sentinel */ + }; + + /* =========================== Class Construction =========================== */ + + static PyObject * +-DSAPublicKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) ++PyDSAPublicKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { +- DSAPublicKey *self; ++ PyDSAPublicKey *self; + + TraceObjNewEnter(type); + +- if ((self = (DSAPublicKey *)type->tp_alloc(type, 0)) == NULL) { ++ if ((self = (PyDSAPublicKey *)type->tp_alloc(type, 0)) == NULL) { + return NULL; + } + +@@ -7436,7 +7436,7 @@ DSAPublicKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + } + + static int +-DSAPublicKey_traverse(DSAPublicKey *self, visitproc visit, void *arg) ++PyDSAPublicKey_traverse(PyDSAPublicKey *self, visitproc visit, void *arg) + { + TraceMethodEnter(self); + +@@ -7446,7 +7446,7 @@ DSAPublicKey_traverse(DSAPublicKey *self, visitproc visit, void *arg) + } + + static int +-DSAPublicKey_clear(DSAPublicKey* self) ++PyDSAPublicKey_clear(PyDSAPublicKey* self) + { + TraceMethodEnter(self); + +@@ -7456,31 +7456,31 @@ DSAPublicKey_clear(DSAPublicKey* self) + } + + static void +-DSAPublicKey_dealloc(DSAPublicKey* self) ++PyDSAPublicKey_dealloc(PyDSAPublicKey* self) + { + TraceMethodEnter(self); + +- DSAPublicKey_clear(self); ++ PyDSAPublicKey_clear(self); + Py_TYPE(self)->tp_free((PyObject*)self); + } + +-PyDoc_STRVAR(DSAPublicKey_doc, ++PyDoc_STRVAR(PyDSAPublicKey_doc, + "A object representing a DSA Public Key"); + + static int +-DSAPublicKey_init(DSAPublicKey *self, PyObject *args, PyObject *kwds) ++PyDSAPublicKey_init(PyDSAPublicKey *self, PyObject *args, PyObject *kwds) + { + TraceMethodEnter(self); + + return 0; + } + +-static PyTypeObject DSAPublicKeyType = { ++static PyTypeObject PyDSAPublicKeyType = { + PyVarObject_HEAD_INIT(NULL, 0) +- "nss.nss.DSAPublicKey", /* tp_name */ +- sizeof(DSAPublicKey), /* tp_basicsize */ ++ "nss.nss.PyDSAPublicKey", /* tp_name */ ++ sizeof(PyDSAPublicKey), /* tp_basicsize */ + 0, /* tp_itemsize */ +- (destructor)DSAPublicKey_dealloc, /* tp_dealloc */ ++ (destructor)PyDSAPublicKey_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ +@@ -7491,39 +7491,39 @@ static PyTypeObject DSAPublicKeyType = { + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ +- (reprfunc)DSAPublicKey_str, /* tp_str */ ++ (reprfunc)PyDSAPublicKey_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ +- DSAPublicKey_doc, /* tp_doc */ +- (traverseproc)DSAPublicKey_traverse, /* tp_traverse */ +- (inquiry)DSAPublicKey_clear, /* tp_clear */ ++ PyDSAPublicKey_doc, /* tp_doc */ ++ (traverseproc)PyDSAPublicKey_traverse, /* tp_traverse */ ++ (inquiry)PyDSAPublicKey_clear, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ +- DSAPublicKey_methods, /* tp_methods */ +- DSAPublicKey_members, /* tp_members */ +- DSAPublicKey_getseters, /* tp_getset */ ++ PyDSAPublicKey_methods, /* tp_methods */ ++ PyDSAPublicKey_members, /* tp_members */ ++ PyDSAPublicKey_getseters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ +- (initproc)DSAPublicKey_init, /* tp_init */ ++ (initproc)PyDSAPublicKey_init, /* tp_init */ + 0, /* tp_alloc */ +- DSAPublicKey_new, /* tp_new */ ++ PyDSAPublicKey_new, /* tp_new */ + }; + + PyObject * +-DSAPublicKey_new_from_SECKEYDSAPublicKey(SECKEYDSAPublicKey *dsa) ++PyDSAPublicKey_new_from_SECKEYDSAPublicKey(SECKEYDSAPublicKey *dsa) + { +- DSAPublicKey *self = NULL; ++ PyDSAPublicKey *self = NULL; + + TraceObjNewEnter(NULL); + +- if ((self = (DSAPublicKey *) DSAPublicKeyType.tp_new(&DSAPublicKeyType, NULL, NULL)) == NULL) { ++ if ((self = (PyDSAPublicKey *) PyDSAPublicKeyType.tp_new(&PyDSAPublicKeyType, NULL, NULL)) == NULL) { + return NULL; + } + +@@ -7882,8 +7882,8 @@ static + PyGetSetDef PublicKey_getseters[] = { + {"key_type", (getter)PublicKey_get_key_type, (setter)NULL, "key type (e.g. rsaKey, dsaKey, etc.) as an int", NULL}, + {"key_type_str", (getter)PublicKey_get_key_type_str, (setter)NULL, "key type as a string", NULL}, +- {"rsa", (getter)PublicKey_get_rsa, (setter)NULL, "RSA key as a RSAPublicKey object", NULL}, +- {"dsa", (getter)PublicKey_get_dsa, (setter)NULL, "RSA key as a RSAPublicKey object", NULL}, ++ {"rsa", (getter)PublicKey_get_rsa, (setter)NULL, "RSA key as a PyRSAPublicKey object", NULL}, ++ {"dsa", (getter)PublicKey_get_dsa, (setter)NULL, "RSA key as a PyRSAPublicKey object", NULL}, + {NULL} /* Sentinel */ + }; + +@@ -8087,13 +8087,13 @@ PublicKey_new_from_SECKEYPublicKey(SECKEYPublicKey *pk) + + switch(pk->keyType) { /* FIXME: handle the other cases */ + case rsaKey: +- if ((self->py_rsa_key = RSAPublicKey_new_from_SECKEYRSAPublicKey(&pk->u.rsa)) == NULL) { ++ if ((self->py_rsa_key = PyRSAPublicKey_new_from_SECKEYRSAPublicKey(&pk->u.rsa)) == NULL) { + Py_CLEAR(self); + return NULL; + } + break; + case dsaKey: +- if ((self->py_dsa_key = DSAPublicKey_new_from_SECKEYDSAPublicKey(&pk->u.dsa)) == NULL) { ++ if ((self->py_dsa_key = PyDSAPublicKey_new_from_SECKEYDSAPublicKey(&pk->u.dsa)) == NULL) { + Py_CLEAR(self); + return NULL; + } +@@ -25310,8 +25310,8 @@ MOD_INIT(nss) + TYPE_READY(AlgorithmIDType); + TYPE_READY(RSAGenParamsType); + TYPE_READY(KEYPQGParamsType); +- TYPE_READY(RSAPublicKeyType); +- TYPE_READY(DSAPublicKeyType); ++ TYPE_READY(PyRSAPublicKeyType); ++ TYPE_READY(PyDSAPublicKeyType); + TYPE_READY(SignedDataType); + TYPE_READY(PublicKeyType); + TYPE_READY(SubjectPublicKeyInfoType); +diff --git a/src/py_nss.h b/src/py_nss.h +index c93b3a2..4bc94e6 100644 +--- a/src/py_nss.h ++++ b/src/py_nss.h +@@ -116,24 +116,24 @@ typedef struct { + } SignedCRL; + + /* ========================================================================== */ +-/* ============================ RSAPublicKey Class ========================== */ ++/* =========================== PyRSAPublicKey Class ========================= */ + /* ========================================================================== */ + + typedef struct { + PyObject_HEAD + PyObject *py_modulus; + PyObject *py_exponent; +-} RSAPublicKey; ++} PyRSAPublicKey; + + /* ========================================================================== */ +-/* ============================ DSAPublicKey Class ========================== */ ++/* =========================== PyDSAPublicKey Class ========================= */ + /* ========================================================================== */ + + typedef struct { + PyObject_HEAD + PyObject *py_pqg_params; + PyObject *py_public_value; +-} DSAPublicKey; ++} PyDSAPublicKey; + + /* ========================================================================== */ + /* ============================ RSAGenParams Class ========================== */ +-- +2.26.2 + +From 51343db2e865b05054f0204dc6116a5633c671c7 Mon Sep 17 00:00:00 2001 +From: Alexander Scheel +Date: Mon, 7 Dec 2020 08:41:32 -0500 +Subject: [PATCH] Fix python names of RSAPublicKey, DSAPublicKey + +In 079d4f65a743fb9e952ab109c1a24997c15398a7, I was a little greedy on my +find/replace and ended up adjusting the Python names of these structs as +well as the C names. We wish to keep the Python names the same, so +revert that part of the patch. + +Credit to Stanislav Levin for finding and reporting this. + +Signed-off-by: Alexander Scheel +--- + src/py_nss.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/py_nss.c b/src/py_nss.c +index d033ac2..a01dd07 100644 +--- a/src/py_nss.c ++++ b/src/py_nss.c +@@ -7252,7 +7252,7 @@ PyRSAPublicKey_init(PyRSAPublicKey *self, PyObject *args, PyObject *kwds) + + static PyTypeObject PyRSAPublicKeyType = { + PyVarObject_HEAD_INIT(NULL, 0) +- "nss.nss.PyRSAPublicKey", /* tp_name */ ++ "nss.nss.RSAPublicKey", /* tp_name */ + sizeof(PyRSAPublicKey), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PyRSAPublicKey_dealloc, /* tp_dealloc */ +@@ -7477,7 +7477,7 @@ PyDSAPublicKey_init(PyDSAPublicKey *self, PyObject *args, PyObject *kwds) + + static PyTypeObject PyDSAPublicKeyType = { + PyVarObject_HEAD_INIT(NULL, 0) +- "nss.nss.PyDSAPublicKey", /* tp_name */ ++ "nss.nss.DSAPublicKey", /* tp_name */ + sizeof(PyDSAPublicKey), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PyDSAPublicKey_dealloc, /* tp_dealloc */ +-- +2.26.2 + diff --git a/python-nss.changes b/python-nss.changes index 003fc96..274048d 100644 --- a/python-nss.changes +++ b/python-nss.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Tue Dec 15 19:07:03 UTC 2020 - Matej Cepl + +- Add missing patches from Fedora package + (https://src.fedoraproject.org/rpms/python-nss/tree/master): + - 0001-Rename-DSA-RSA-PublicKey-to-Py-DSA-RSA-PublicKey.patch + (bmo#1474274) + - sphinx.patch +- Add generated documentation to -doc subpackage. + ------------------------------------------------------------------- Fri Mar 1 20:01:07 CET 2019 - Matej Cepl diff --git a/python-nss.spec b/python-nss.spec index 45196ac..ed4a244 100644 --- a/python-nss.spec +++ b/python-nss.spec @@ -1,7 +1,7 @@ # # spec file for package python-nss # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,11 +22,19 @@ Release: 0 Summary: Python bindings for mozilla-nss and mozilla-nspr License: MPL-1.1+ OR GPL-2.0-or-later OR LGPL-2.0-or-later Group: Development/Languages/Python -URL: http://www.mozilla.org/projects/security/pki/python-nss +URL: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Python_binding_for_NSS Source: https://files.pythonhosted.org/packages/source/p/python-nss/python-nss-%{version}.tar.bz2 +# PATCH-FIX-UPSTREAM 0001-Rename-DSA-RSA-PublicKey-to-Py-DSA-RSA-PublicKey.patch bmo#1474274 mcepl@suse.com +# Incompatibility with NSS 3.58+ +Patch0: 0001-Rename-DSA-RSA-PublicKey-to-Py-DSA-RSA-PublicKey.patch +# PATCH-FIX-UPSTREAM sphinx.patch bsc#[0-9]+ mcepl@suse.com +# this patch makes things totally awesome +Patch1: sphinx.patch +BuildRequires: %{python_module Sphinx} BuildRequires: %{python_module devel} BuildRequires: %{python_module docutils} BuildRequires: %{python_module setuptools} +BuildRequires: fdupes BuildRequires: mozilla-nspr-devel BuildRequires: mozilla-nss-devel # Required for tests @@ -40,14 +48,23 @@ supporting SSL, TLS, PKI, PKIX, X509, PKCS*, etc. NSS is an alternative to OpenSSL and used extensively by major software projects. NSS is FIPS-140 certified. +%package -n %{name}-doc +Summary: Documentation files for %name +Group: Documentation/Other + +%description -n %{name}-doc +HTML Documentation and examples for %name. + %prep -%setup -q -n python-nss-%{version} +%autosetup -p1 -n python-nss-%{version} %build -%python_build +%python_build build_doc +rm -rf build/sphinx/html/.buildinfo %install %python_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} %check %{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch} @@ -59,4 +76,8 @@ $python test/run_tests -i %doc README doc/ChangeLog %{python_sitearch}/* +%files -n %{name}-doc +%license LICENSE.mpl LICENSE.lgpl LICENSE.gpl +%doc build/sphinx/html + %changelog diff --git a/sphinx.patch b/sphinx.patch new file mode 100644 index 0000000..3b988c6 --- /dev/null +++ b/sphinx.patch @@ -0,0 +1,344 @@ +diff -r d767ac371ee3 doc/sphinx/source/conf.py +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/doc/sphinx/source/conf.py Fri Jul 06 11:24:08 2018 -0400 +@@ -0,0 +1,163 @@ ++# -*- coding: utf-8 -*- ++# ++# Configuration file for the Sphinx documentation builder. ++# ++# This file does only contain a selection of the most common options. For a ++# full list see the documentation: ++# http://www.sphinx-doc.org/en/master/config ++ ++# -- Path setup -------------------------------------------------------------- ++ ++# If extensions (or modules to document with autodoc) are in another directory, ++# add these directories to sys.path here. If the directory is relative to the ++# documentation root, use os.path.abspath to make it absolute, like shown here. ++# ++# import os ++# import sys ++# sys.path.insert(0, os.path.abspath('.')) ++ ++ ++# -- Project information ----------------------------------------------------- ++ ++project = 'python-nss' ++copyright = '2018, John Dennis' ++author = 'John Dennis' ++ ++# The short X.Y version ++version = '' ++# The full version, including alpha/beta/rc tags ++release = '' ++ ++ ++# -- General configuration --------------------------------------------------- ++ ++# If your documentation needs a minimal Sphinx version, state it here. ++# ++# needs_sphinx = '1.0' ++ ++# Add any Sphinx extension module names here, as strings. They can be ++# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ++# ones. ++extensions = [ ++ 'sphinx.ext.autodoc', ++ 'sphinx.ext.autosummary', ++] ++ ++autodoc_default_flags = ['members'] ++autosummary_generate = True ++ ++# Add any paths that contain templates here, relative to this directory. ++templates_path = ['_templates'] ++ ++# The suffix(es) of source filenames. ++# You can specify multiple suffix as a list of string: ++# ++# source_suffix = ['.rst', '.md'] ++source_suffix = '.rst' ++ ++# The master toctree document. ++master_doc = 'index' ++ ++# The language for content autogenerated by Sphinx. Refer to documentation ++# for a list of supported languages. ++# ++# This is also used if you do content translation via gettext catalogs. ++# Usually you set "language" from the command line for these cases. ++language = None ++ ++# List of patterns, relative to source directory, that match files and ++# directories to ignore when looking for source files. ++# This pattern also affects html_static_path and html_extra_path . ++exclude_patterns = [] ++ ++# The name of the Pygments (syntax highlighting) style to use. ++pygments_style = 'sphinx' ++ ++ ++# -- Options for HTML output ------------------------------------------------- ++ ++# The theme to use for HTML and HTML Help pages. See the documentation for ++# a list of builtin themes. ++# ++html_theme = 'alabaster' ++ ++# Theme options are theme-specific and customize the look and feel of a theme ++# further. For a list of options available for each theme, see the ++# documentation. ++# ++# html_theme_options = {} ++ ++# Add any paths that contain custom static files (such as style sheets) here, ++# relative to this directory. They are copied after the builtin static files, ++# so a file named "default.css" will overwrite the builtin "default.css". ++html_static_path = ['_static'] ++ ++# Custom sidebar templates, must be a dictionary that maps document names ++# to template names. ++# ++# The default sidebars (for documents that don't match any pattern) are ++# defined by theme itself. Builtin themes are using these templates by ++# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', ++# 'searchbox.html']``. ++# ++# html_sidebars = {} ++ ++ ++# -- Options for HTMLHelp output --------------------------------------------- ++ ++# Output file base name for HTML help builder. ++htmlhelp_basename = 'python-nssdoc' ++ ++ ++# -- Options for LaTeX output ------------------------------------------------ ++ ++latex_elements = { ++ # The paper size ('letterpaper' or 'a4paper'). ++ # ++ # 'papersize': 'letterpaper', ++ ++ # The font size ('10pt', '11pt' or '12pt'). ++ # ++ # 'pointsize': '10pt', ++ ++ # Additional stuff for the LaTeX preamble. ++ # ++ # 'preamble': '', ++ ++ # Latex figure (float) alignment ++ # ++ # 'figure_align': 'htbp', ++} ++ ++# Grouping the document tree into LaTeX files. List of tuples ++# (source start file, target name, title, ++# author, documentclass [howto, manual, or own class]). ++latex_documents = [ ++ (master_doc, 'python-nss.tex', 'python-nss Documentation', ++ 'John Dennis', 'manual'), ++] ++ ++ ++# -- Options for manual page output ------------------------------------------ ++ ++# One entry per manual page. List of tuples ++# (source start file, name, description, authors, manual section). ++man_pages = [ ++ (master_doc, 'python-nss', 'python-nss Documentation', ++ [author], 1) ++] ++ ++ ++# -- Options for Texinfo output ---------------------------------------------- ++ ++# Grouping the document tree into Texinfo files. List of tuples ++# (source start file, target name, title, author, ++# dir menu entry, description, category) ++texinfo_documents = [ ++ (master_doc, 'python-nss', 'python-nss Documentation', ++ author, 'python-nss', 'One line description of project.', ++ 'Miscellaneous'), ++] ++ ++ ++# -- Extension configuration ------------------------------------------------- +diff -r d767ac371ee3 doc/sphinx/source/index.rst +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/doc/sphinx/source/index.rst Fri Jul 06 11:24:08 2018 -0400 +@@ -0,0 +1,43 @@ ++.. python-nss documentation master file, created by ++ sphinx-quickstart on Thu Jun 28 09:36:37 2018. ++ You can adapt this file completely to your liking, but it should at least ++ contain the root `toctree` directive. ++ ++Welcome to python-nss's documentation! ++====================================== ++ ++Sub-modules ++=========== ++ ++The functionality of python-nss is implemented in several sub-modules. ++Each sub-module focuses on related functions, classes and data. The ++bulk of NSS functionality (e.g. general cryptography) appears in the ++`nss.nss` module. You can detailed information on the module, it's ++data, it's classes and functions by following the link to the ++sub-module in the table below. You can also use the `Index` in the ++next section to jump directly to a specific item. ++ ++ ++.. autosummary:: ++ :toctree: generated ++ ++ nss.io ++ nss.ssl ++ nss.nss ++ nss.error ++ ++ ++Indices and tables ++================== ++ ++* :ref:`genindex` ++* :ref:`modindex` ++* :ref:`search` ++ ++.. automodule:: nss ++ :members: ++ ++.. toctree:: ++ :maxdepth: 2 ++ :caption: Contents: ++ +diff -r d767ac371ee3 setup.py +--- a/setup.py Tue Feb 28 18:24:19 2017 -0500 ++++ b/setup.py Fri Jul 06 11:24:08 2018 -0400 +@@ -15,21 +15,25 @@ + from distutils.util import subst_vars, change_root + from distutils.command.build_py import build_py as _build_py + from distutils.command.sdist import sdist as _sdist ++from sphinx.setup_command import BuildDoc as SphinxBuildDoc + ++name = 'python-nss' + version = "1.0.1" ++release = version + + doc_manifest = [ + [['include README LICENSE* doc/ChangeLog', + 'recursive-include doc *.py *.txt', +- 'prune doc/examples/pki'], ++ 'prune doc/examples/pki', ++ 'prune doc/sphinx'], + [('^doc/', '')], None], + [['recursive-include test run_tests setup_certs.py test_*.py util.py *.txt', + 'prune test/pki'], + None , None], + [['recursive-include lib *.py *.txt',], + [('^lib/', '')] , 'examples'], +- [['recursive-include build/doc/html *'], +- [('^build/doc/', 'api/')], None], ++ [['recursive-include build/sphinx/html *'], ++ [('^build/sphinx/', 'api/')], None], + ] + + def update_version(): +@@ -114,13 +118,13 @@ + user_options = [('docdir=', 'd', "directory root for documentation"), + ] + +- def has_epydoc (self): +- if find_executable('epydoc'): ++ def has_sphinx (self): ++ if find_executable('sphinx-build'): + return True + else: + return False + +- sub_commands = [('build_api_doc', has_epydoc), ++ sub_commands = [('build_sphinx', has_sphinx), + ] + + def initialize_options(self): +@@ -137,46 +141,15 @@ + + def run(self): + self.run_command('build') ++ # Add build directory to Python path so doc builder can import ++ # in-tree built modules ++ sys.path.insert(0, self.build_lib) + for cmd_name in self.get_sub_commands(): + self.run_command(cmd_name) ++ # Remove the build directory from Python path ++ del sys.path[0] + + +-class BuildApiDoc(Command): +- description = 'generate the API documentation' +- user_options = [('docdir=', 'd', "directory root for documentation"), +- ('action=', 'a', "epydoc action (html, latex, dvi, ps, pdf, check, pickle"), +- ('htmldir', 'H', "directory to locate the API HTML files under"), +- ] +- +- def initialize_options(self): +- self.build_base = None +- self.build_lib = None +- self.docdir = None +- self.action = None +- self.htmldir = None +- +- def finalize_options(self): +- self.set_undefined_options('build', +- ('build_base', 'build_base'), +- ('build_lib', 'build_lib')) +- +- if self.action is None: +- self.action = 'html' +- +- if self.docdir is None: +- if self.action == 'html': +- self.docdir = change_root(self.get_finalized_command('build_doc').docdir, 'html') +- else: +- self.docdir = self.get_finalized_command('build_doc').docdir +- +- def run(self): +- prog = find_executable('epydoc') +- pkg_dirs = [change_root(self.build_lib, pkg) for pkg in self.distribution.packages] +- cmd = [prog, '-v', '--%s' % self.action, '--docformat', 'restructuredtext', '-o', self.docdir] +- #if self.verbose: cmd.append('-v') +- cmd.extend(pkg_dirs) +- self.mkpath(self.docdir) +- spawn(cmd) + + class InstallDoc(Command): + description = 'install documentation' +@@ -373,7 +346,7 @@ + + #bug_tracker = 'https://bugzilla.redhat.com/buglist.cgi?submit&component=python-nss&product=Fedora&classification=Fedora' + #bug_enter = 'https://bugzilla.redhat.com/enter_bug.cgi?component=python-nss&product=Fedora&classification=Fedora', +- setup(name = 'python-nss', ++ setup(name = name, + version = version, + description = 'Python bindings for Network Security Services (NSS) and Netscape Portable Runtime (NSPR)', + long_description = long_description, +@@ -393,12 +366,17 @@ + package_dir = {'nss':'src'}, + packages = ['nss'], + cmdclass = {'build_doc' : BuildDoc, +- 'build_api_doc' : BuildApiDoc, ++ 'build_sphinx' : SphinxBuildDoc, + 'install_doc' : InstallDoc, + 'build_py' : BuildPy, + 'sdist' : SDist, + }, +- ++ command_options={ ++ 'build_sphinx': { ++ 'project': ('setup.py', name), ++ 'version': ('setup.py', version), ++ 'release': ('setup.py', release), ++ 'source_dir': ('setup.py', 'doc/sphinx/source')}}, + ) + + return 0