PyObject *xmlsec_KeysMngrGetKeysStore(PyObject *self, PyObject *args) { PyObject *mngr_obj; xmlSecKeysMngrPtr mngr; if (CheckArgs(args, "O:keysMngrGetKeysStore")) { if (!PyArg_ParseTuple(args, "O:keysMngrGetKeysStore", &mngr_obj)) return NULL; } else return NULL; mngr = xmlSecKeysMngrPtr_get(mngr_obj); return (wrap_xmlSecKeyStorePtr(xmlSecKeysMngrGetKeysStore(mngr))); }
/** * xmlSecKeysMngrFindKey: * @mngr: the pointer to keys manager. * @name: the desired key name. * @keyInfoCtx: the pointer to <dsig:KeyInfo/> node processing context. * * Lookups key in the keys manager keys store. The caller is responsible * for destroying the returned key using #xmlSecKeyDestroy method. * * Returns the pointer to a key or NULL if key is not found or an error occurs. */ xmlSecKeyPtr xmlSecKeysMngrFindKey(xmlSecKeysMngrPtr mngr, const xmlChar* name, xmlSecKeyInfoCtxPtr keyInfoCtx) { xmlSecKeyStorePtr store; xmlSecAssert2(mngr != NULL, NULL); xmlSecAssert2(keyInfoCtx != NULL, NULL); store = xmlSecKeysMngrGetKeysStore(mngr); if(store == NULL) { /* no store. is it an error? */ return(NULL); } return(xmlSecKeyStoreFindKey(store, name, keyInfoCtx)); }
int xmlSecNssAppliedKeysMngrPriKeyLoad( xmlSecKeysMngrPtr mngr , SECKEYPrivateKey* priKey ) { xmlSecKeyPtr key ; xmlSecKeyDataPtr data ; xmlSecKeyStorePtr keyStore ; xmlSecAssert2( mngr != NULL , -1 ) ; xmlSecAssert2( priKey != NULL , -1 ) ; keyStore = xmlSecKeysMngrGetKeysStore( mngr ) ; if( keyStore == NULL ) { xmlSecError( XMLSEC_ERRORS_HERE , NULL , "xmlSecKeysMngrGetKeysStore" , XMLSEC_ERRORS_R_XMLSEC_FAILED , XMLSEC_ERRORS_NO_MESSAGE ) ; return(-1) ; } xmlSecAssert2( xmlSecKeyStoreCheckId( keyStore , xmlSecNssKeysStoreId ) , -1 ) ; data = xmlSecNssPKIAdoptKey( priKey, NULL ) ; if( data == NULL ) { xmlSecError( XMLSEC_ERRORS_HERE , NULL , "xmlSecNssPKIAdoptKey" , XMLSEC_ERRORS_R_XMLSEC_FAILED , XMLSEC_ERRORS_NO_MESSAGE ) ; return(-1) ; } key = xmlSecKeyCreate() ; if( key == NULL ) { xmlSecError( XMLSEC_ERRORS_HERE , NULL , "xmlSecNssSymKeyDataKeyAdopt" , XMLSEC_ERRORS_R_XMLSEC_FAILED , XMLSEC_ERRORS_NO_MESSAGE ) ; xmlSecKeyDataDestroy( data ) ; return(-1) ; } if( xmlSecKeySetValue( key , data ) < 0 ) { xmlSecError( XMLSEC_ERRORS_HERE , NULL , "xmlSecNssSymKeyDataKeyAdopt" , XMLSEC_ERRORS_R_XMLSEC_FAILED , XMLSEC_ERRORS_NO_MESSAGE ) ; xmlSecKeyDataDestroy( data ) ; return(-1) ; } if( xmlSecNssKeysStoreAdoptKey( keyStore, key ) < 0 ) { xmlSecError( XMLSEC_ERRORS_HERE , NULL , "xmlSecNssSymKeyDataKeyAdopt" , XMLSEC_ERRORS_R_XMLSEC_FAILED , XMLSEC_ERRORS_NO_MESSAGE ) ; xmlSecKeyDestroy( key ) ; return(-1) ; } return(0) ; }