Skip to content

Instantly share code, notes, and snippets.

@gregvish
Created November 3, 2013 14:26
Show Gist options
  • Save gregvish/7290797 to your computer and use it in GitHub Desktop.
Save gregvish/7290797 to your computer and use it in GitHub Desktop.
dm.xmlsec.binding setEnabledKeyData patch
diff --git a/src/_xmlsec.pyx b/src/_xmlsec.pyx
index 45e9427..ffbd1a0 100644
--- a/src/_xmlsec.pyx
+++ b/src/_xmlsec.pyx
@@ -388,8 +388,16 @@ cdef class DSigCtx:
if rv < 0:
raise Error("enableSignatureTransform failed", rv)
-
-
+ def setEnabledKeyData(self, keydata_list):
+ cdef KeyData keydata
+ cdef xmlSecPtrListPtr enabled_list
+ enabled_list = &(self.ctx.keyInfoReadCtx.enabledKeyData)
+ xmlSecPtrListEmpty(enabled_list)
+ for keydata in keydata_list:
+ rv = xmlSecPtrListAdd(enabled_list, <xmlSecPtr> keydata.id)
+ if rv < 0:
+ raise Error("setEnabledKeyData failed")
+
cdef class EncCtx:
"""Encryption context."""
diff --git a/src/cxmlsec.pxd b/src/cxmlsec.pxd
index 80afa7f..a8058df 100644
--- a/src/cxmlsec.pxd
+++ b/src/cxmlsec.pxd
@@ -56,6 +56,10 @@ cdef extern from 'cxmlsec.h':
xmlSecKeyDataTypeTrusted = 0x0100
xmlSecKeyDataTypeAny = 0xFFFF
+ ctypedef void * xmlSecPtrList
+ ctypedef xmlSecPtrList * xmlSecPtrListPtr
+ ctypedef void * xmlSecPtr
+
void xmlSecKeyDestroy(xmlSecKeyPtr) nogil
xmlSecKeyPtr xmlSecKeyDuplicate(xmlSecKeyPtr) nogil
xmlSecKeyPtr xmlSecCryptoAppKeyLoad(const_char *, xmlSecKeyDataFormat, const_char *, void *, void *) nogil
@@ -66,6 +70,8 @@ cdef extern from 'cxmlsec.h':
xmlSecKeyPtr xmlSecKeyGenerate(xmlSecKeyDataId, size_t, xmlSecKeyDataType) nogil
int xmlSecKeySetName(xmlSecKeyPtr, const_xmlChar *) nogil
const_xmlChar * xmlSecKeyGetName(xmlSecKeyPtr) nogil
+ int xmlSecPtrListAdd(xmlSecPtrListPtr, xmlSecPtr) nogil
+ int xmlSecPtrListEmpty(xmlSecPtrListPtr) nogil
cdef struct _xmlSecTransformKlass:
const_xmlChar * name
@@ -126,6 +132,9 @@ cdef extern from 'cxmlsec.h':
int xmlSecCryptoAppKeysMngrCertLoad(xmlSecKeysMngrPtr, char * filename, xmlSecKeyDataFormat, xmlSecKeyDataType) nogil
int xmlSecCryptoAppKeysMngrCertLoadMemory(xmlSecKeysMngrPtr, const_unsigned_char *, size_t, xmlSecKeyDataFormat, xmlSecKeyDataType) nogil
+ cdef struct xmlSecKeyInfoCtx:
+ xmlSecPtrList enabledKeyData
+
ctypedef enum xmlSecDSigStatus:
xmlSecDSigStatusUnknown = 0
xmlSecDSigStatusSucceeded = 1
@@ -134,8 +143,8 @@ cdef extern from 'cxmlsec.h':
## void * userData
## unsigned int flags
## unsigned int flags2
-## xmlSecKeyInfoCtx keyInfoReadCtx
-## xmlSecKeyInfoCtx keyInfoWriteCtx
+ xmlSecKeyInfoCtx keyInfoReadCtx
+ xmlSecKeyInfoCtx keyInfoWriteCtx
## xmlSecTransformCtx transformCtx
## xmlSecTransformUriType enabledReferenceUris
## xmlSecPtrListPtr enabledReferenceTransforms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment