CAMLprim value xmlsecml_xmlSecKeyGenerate(value camlId, value camlSize, value camlType) { CAMLparam3(camlId, camlSize, camlType); xmlSecKeyDataId id; xmlSecSize size; xmlSecKeyDataType type; xmlSecKeyPtr key = NULL; assert ( Is_long(camlId) ); id = xmlSecKeyDataAesId; size = Int_val(camlSize); type = Int_val(camlType); key = xmlSecKeyGenerate(id, size, type); assert(key != NULL); CAMLreturn(alloc_key(key)); }
/** * xmlSecKeyGenerateByName: * @name: the requested key klass name (rsa, dsa, aes, ...). * @sizeBits: the new key size (in bits!). * @type: the new key type (session, permanent, ...). * * Generates new key of requested @klass and @type. * * Returns: pointer to newly created key or NULL if an error occurs. */ xmlSecKeyPtr xmlSecKeyGenerateByName(const xmlChar* name, xmlSecSize sizeBits, xmlSecKeyDataType type) { xmlSecKeyDataId dataId; xmlSecAssert2(name != NULL, NULL); dataId = xmlSecKeyDataIdListFindByName(xmlSecKeyDataIdsGet(), name, xmlSecKeyDataUsageAny); if(dataId == xmlSecKeyDataIdUnknown) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, xmlSecErrorsSafeString(name), XMLSEC_ERRORS_R_KEY_DATA_NOT_FOUND, XMLSEC_ERRORS_NO_MESSAGE); return(NULL); } return(xmlSecKeyGenerate(dataId, sizeBits, type)); }