📄 python.c
字号:
status = cryptDecrypt(cryptContext, bufferPtr, length); finish: releasePointer(buffer, bufferPtr); return(processStatus(status));}static PyObject* python_cryptSetAttribute(PyObject* self, PyObject* args){ int status = 0; int cryptHandle = 0; int attributeType = 0; int value = 0; if (!PyArg_ParseTuple(args, "iii", &cryptHandle, &attributeType, &value)) return(NULL); status = cryptSetAttribute(cryptHandle, attributeType, value); return(processStatus(status));}static PyObject* python_cryptSetAttributeString(PyObject* self, PyObject* args){ int status = 0; int cryptHandle = 0; int attributeType = 0; PyObject* value = NULL; int valueLength = 0; unsigned char* valuePtr = 0; if (!PyArg_ParseTuple(args, "iiO", &cryptHandle, &attributeType, &value)) return(NULL); if (!getPointerRead(value, &valuePtr, &valueLength)) goto finish; status = cryptSetAttributeString(cryptHandle, attributeType, valuePtr, valueLength); finish: releasePointer(value, valuePtr); return(processStatus(status));}static PyObject* python_cryptGetAttribute(PyObject* self, PyObject* args){ int status = 0; int value = 0; int cryptHandle = 0; int attributeType = 0; if (!PyArg_ParseTuple(args, "ii", &cryptHandle, &attributeType)) return(NULL); status = cryptGetAttribute(cryptHandle, attributeType, &value); return(processStatusReturnInt(status, value));}static PyObject* python_cryptGetAttributeString(PyObject* self, PyObject* args){ int status = 0; int valueLength = 0; int cryptHandle = 0; int attributeType = 0; PyObject* value = NULL; unsigned char* valuePtr = 0; if (!PyArg_ParseTuple(args, "iiO", &cryptHandle, &attributeType, &value)) return(NULL); if (!processStatusBool(cryptGetAttributeString(cryptHandle, attributeType, NULL, &valueLength))) goto finish; if (!getPointerWriteCheckIndices(value, &valuePtr, &valueLength)) goto finish; status = cryptGetAttributeString(cryptHandle, attributeType, valuePtr, &valueLength); finish: releasePointer(value, valuePtr); return(processStatusReturnInt(status, valueLength));}static PyObject* python_cryptDeleteAttribute(PyObject* self, PyObject* args){ int status = 0; int cryptHandle = 0; int attributeType = 0; if (!PyArg_ParseTuple(args, "ii", &cryptHandle, &attributeType)) return(NULL); status = cryptDeleteAttribute(cryptHandle, attributeType); return(processStatus(status));}static PyObject* python_cryptAddRandom(PyObject* self, PyObject* args){ int status = 0; PyObject* randomData = NULL; int randomDataLength = 0; unsigned char* randomDataPtr = 0; //Special case to handle SLOWPOLL / FASTPOLL values if (PyArg_ParseTuple(args, "i", &randomDataLength)) return processStatus(cryptAddRandom(NULL, randomDataLength)); if (!PyArg_ParseTuple(args, "O", &randomData)) return(NULL); if (!getPointerRead(randomData, &randomDataPtr, &randomDataLength)) goto finish; status = cryptAddRandom(randomDataPtr, randomDataLength); finish: releasePointer(randomData, randomDataPtr); return(processStatus(status));}static PyObject* python_cryptQueryObject(PyObject* self, PyObject* args){ int status = 0; CRYPT_OBJECT_INFO cryptObjectInfo; PyObject* objectData = NULL; int objectDataLength = 0; unsigned char* objectDataPtr = 0; if (!PyArg_ParseTuple(args, "O", &objectData)) return(NULL); if (!getPointerRead(objectData, &objectDataPtr, &objectDataLength)) goto finish; status = cryptQueryObject(objectDataPtr, objectDataLength, &cryptObjectInfo); finish: releasePointer(objectData, objectDataPtr); return(processStatusReturnCryptObjectInfo(status, cryptObjectInfo));}static PyObject* python_cryptExportKey(PyObject* self, PyObject* args){ int status = 0; int encryptedKeyLength = 0; PyObject* encryptedKey = NULL; int encryptedKeyMaxLength = 0; int exportKey = 0; int sessionKeyContext = 0; unsigned char* encryptedKeyPtr = 0; if (!PyArg_ParseTuple(args, "Oiii", &encryptedKey, &encryptedKeyMaxLength, &exportKey, &sessionKeyContext)) return(NULL); if (!processStatusBool(cryptExportKey(NULL, encryptedKeyMaxLength, &encryptedKeyLength, exportKey, sessionKeyContext))) goto finish; if (!getPointerWriteCheckIndices(encryptedKey, &encryptedKeyPtr, &encryptedKeyLength)) goto finish; status = cryptExportKey(encryptedKeyPtr, encryptedKeyMaxLength, &encryptedKeyLength, exportKey, sessionKeyContext); finish: releasePointer(encryptedKey, encryptedKeyPtr); return(processStatusReturnInt(status, encryptedKeyLength));}static PyObject* python_cryptExportKeyEx(PyObject* self, PyObject* args){ int status = 0; int encryptedKeyLength = 0; PyObject* encryptedKey = NULL; int encryptedKeyMaxLength = 0; int formatType = 0; int exportKey = 0; int sessionKeyContext = 0; unsigned char* encryptedKeyPtr = 0; if (!PyArg_ParseTuple(args, "Oiiii", &encryptedKey, &encryptedKeyMaxLength, &formatType, &exportKey, &sessionKeyContext)) return(NULL); if (!processStatusBool(cryptExportKeyEx(NULL, encryptedKeyMaxLength, &encryptedKeyLength, formatType, exportKey, sessionKeyContext))) goto finish; if (!getPointerWriteCheckIndices(encryptedKey, &encryptedKeyPtr, &encryptedKeyLength)) goto finish; status = cryptExportKeyEx(encryptedKeyPtr, encryptedKeyMaxLength, &encryptedKeyLength, formatType, exportKey, sessionKeyContext); finish: releasePointer(encryptedKey, encryptedKeyPtr); return(processStatusReturnInt(status, encryptedKeyLength));}static PyObject* python_cryptImportKey(PyObject* self, PyObject* args){ int status = 0; PyObject* encryptedKey = NULL; int encryptedKeyLength = 0; int importKey = 0; int sessionKeyContext = 0; unsigned char* encryptedKeyPtr = 0; if (!PyArg_ParseTuple(args, "Oii", &encryptedKey, &importKey, &sessionKeyContext)) return(NULL); if (!getPointerRead(encryptedKey, &encryptedKeyPtr, &encryptedKeyLength)) goto finish; status = cryptImportKey(encryptedKeyPtr, encryptedKeyLength, importKey, sessionKeyContext); finish: releasePointer(encryptedKey, encryptedKeyPtr); return(processStatus(status));}static PyObject* python_cryptImportKeyEx(PyObject* self, PyObject* args){ int status = 0; int returnedContext = 0; PyObject* encryptedKey = NULL; int encryptedKeyLength = 0; int importKey = 0; int sessionKeyContext = 0; unsigned char* encryptedKeyPtr = 0; if (!PyArg_ParseTuple(args, "Oii", &encryptedKey, &importKey, &sessionKeyContext)) return(NULL); if (!getPointerRead(encryptedKey, &encryptedKeyPtr, &encryptedKeyLength)) goto finish; status = cryptImportKeyEx(encryptedKeyPtr, encryptedKeyLength, importKey, sessionKeyContext, &returnedContext); finish: releasePointer(encryptedKey, encryptedKeyPtr); return(processStatusReturnCryptHandle(status, returnedContext));}static PyObject* python_cryptCreateSignature(PyObject* self, PyObject* args){ int status = 0; int signatureLength = 0; PyObject* signature = NULL; int signatureMaxLength = 0; int signContext = 0; int hashContext = 0; unsigned char* signaturePtr = 0; if (!PyArg_ParseTuple(args, "Oiii", &signature, &signatureMaxLength, &signContext, &hashContext)) return(NULL); if (!processStatusBool(cryptCreateSignature(NULL, signatureMaxLength, &signatureLength, signContext, hashContext))) goto finish; if (!getPointerWriteCheckIndices(signature, &signaturePtr, &signatureLength)) goto finish; status = cryptCreateSignature(signaturePtr, signatureMaxLength, &signatureLength, signContext, hashContext); finish: releasePointer(signature, signaturePtr); return(processStatusReturnInt(status, signatureLength));}static PyObject* python_cryptCreateSignatureEx(PyObject* self, PyObject* args){ int status = 0; int signatureLength = 0; PyObject* signature = NULL; int signatureMaxLength = 0; int formatType = 0; int signContext = 0; int hashContext = 0; int extraData = 0; unsigned char* signaturePtr = 0; if (!PyArg_ParseTuple(args, "Oiiiii", &signature, &signatureMaxLength, &formatType, &signContext, &hashContext, &extraData)) return(NULL); if (!processStatusBool(cryptCreateSignatureEx(NULL, signatureMaxLength, &signatureLength, formatType, signContext, hashContext, extraData))) goto finish; if (!getPointerWriteCheckIndices(signature, &signaturePtr, &signatureLength)) goto finish; status = cryptCreateSignatureEx(signaturePtr, signatureMaxLength, &signatureLength, formatType, signContext, hashContext, extraData); finish: releasePointer(signature, signaturePtr); return(processStatusReturnInt(status, signatureLength));}static PyObject* python_cryptCheckSignature(PyObject* self, PyObject* args){ int status = 0; PyObject* signature = NULL; int signatureLength = 0; int sigCheckKey = 0; int hashContext = 0; unsigned char* signaturePtr = 0; if (!PyArg_ParseTuple(args, "Oii", &signature, &sigCheckKey, &hashContext)) return(NULL); if (!getPointerRead(signature, &signaturePtr, &signatureLength)) goto finish; status = cryptCheckSignature(signaturePtr, signatureLength, sigCheckKey, hashContext); finish: releasePointer(signature, signaturePtr); return(processStatus(status));}static PyObject* python_cryptCheckSignatureEx(PyObject* self, PyObject* args){ int status = 0; int extraData = 0; PyObject* signature = NULL; int signatureLength = 0; int sigCheckKey = 0; int hashContext = 0; unsigned char* signaturePtr = 0; if (!PyArg_ParseTuple(args, "Oii", &signature, &sigCheckKey, &hashContext)) return(NULL); if (!getPointerRead(signature, &signaturePtr, &signatureLength)) goto finish; status = cryptCheckSignatureEx(signaturePtr, signatureLength, sigCheckKey, hashContext, &extraData); finish: releasePointer(signature, signaturePtr); return(processStatusReturnCryptHandle(status, extraData));}static PyObject* python_cryptKeysetOpen(PyObject* self, PyObject* args){ int status = 0; int keyset = 0; int cryptUser = 0; int keysetType = 0; PyObject* name = NULL; int options = 0; unsigned char* namePtr = 0; if (!PyArg_ParseTuple(args, "iiOi", &cryptUser, &keysetType, &name, &options)) return(NULL); if (!getPointerReadString(name, &namePtr)) goto finish; status = cryptKeysetOpen(&keyset, cryptUser, keysetType, namePtr, options); finish: releasePointerString(name, namePtr); return(processStatusReturnCryptHandle(status, keyset));}static PyObject* python_cryptKeysetClose(PyObject* self, PyObject* args){ int status = 0; int keyset = 0; if (!PyArg_ParseTuple(args, "i", &keyset)) return(NULL); status = cryptKeysetClose(keyset); return(processStatus(status));}static PyObject* python_cryptGetPublicKey(PyObject* self, PyObject* args){ int status = 0; int cryptContext = 0; int keyset = 0; int keyIDtype = 0; PyObject* keyID = NULL; unsigned char* keyIDPtr = 0; if (!PyArg_ParseTuple(args, "iiO", &keyset, &keyIDtype, &keyID)) return(NULL); if (!getPointerReadString(keyID, &keyIDPtr)) goto finish; status = cryptGetPublicKey(keyset, &cryptContext, keyIDtype, keyIDPtr); finish: releasePointerString(keyID, keyIDPtr); return(processStatusReturnCryptHandle(status, cryptContext));}static PyObject* python_cryptGetPrivateKey(PyObject* self, PyObject* args){ int status = 0; int cryptContext = 0; int keyset = 0; int keyIDtype = 0; PyObject* keyID = NULL; PyObject* password = NULL; unsigned char* keyIDPtr = 0; unsigned char* passwordPtr = 0; if (!PyArg_ParseTuple(args, "iiOO", &keyset, &keyIDtype, &keyID, &password)) return(NULL); if (!getPointerReadString(keyID, &keyIDPtr)) goto finish; if (!getPointerReadString(password, &passwordPtr)) goto finish; status = cryptGetPrivateKey(keyset, &cryptContext, keyIDtype, keyIDPtr, passwordPtr); finish: releasePointerString(keyID, keyIDPtr); releasePointerString(password, passwordPtr); return(processStatusReturnCryptHandle(status, cryptContext));}static PyObject* python_cryptGetKey(PyObject* self, PyObject* args){ int status = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -