📄 perlcryptlib.xs
字号:
const void * keyID = (SvIOK(ST(3)) ? (const void *)SvIV(ST(3)) : (const void *)SvPV_nolen(ST(3))); const char * password = (SvIOK(ST(4)) ? (const char *)SvIV(ST(4)) : (const char *)SvPV_nolen(ST(4))); CODE: RETVAL = cryptGetPrivateKey(cryptHandle, &cryptContext, keyIDtype, keyID, password); OUTPUT: RETVAL cryptContextint cryptGetPublicKey(cryptObject, publicKey, keyIDtype, keyID) const int cryptObject; int publicKey; const int keyIDtype; const void * keyID = (SvIOK(ST(3)) ? (const void *)SvIV(ST(3)) : (const void *)SvPV_nolen(ST(3))); /* Consente di passare 0 come NULL */ CODE: RETVAL = cryptGetPublicKey(cryptObject, &publicKey, keyIDtype, keyID); OUTPUT: RETVAL publicKeyint cryptAddCertExtension(certificate, oid, criticalFlag, extension, extensionLength) const int certificate; const char * oid; const int criticalFlag; const void * extension; const int extensionLength;int cryptAddRandom(randomData, randomDataLength) const void * randomData = (SvIOK(ST(0)) ? (const void *)SvIV(ST(0)) : (const void *)SvPV_nolen(ST(0))); const int randomDataLength;int cryptAsyncCancel(cryptObject) const int cryptObject;int cryptAsyncQuery(cryptObject) const int cryptObject;int cryptCAAddItem(keyset, certificate) const int keyset; const int certificate;int cryptCADeleteItem(keyset, certType, keyIDtype, keyID) const int keyset; const int certType; const int keyIDtype; const void * keyID;int cryptCACertManagement(cryptCert, action, keyset, caKey, certRequest) int cryptCert; const int action; const int keyset; const int caKey; const int certRequest; CODE: RETVAL = cryptCACertManagement(&cryptCert, action, keyset, caKey, certRequest); OUTPUT: RETVAL cryptCertint cryptCAGetItem(keyset, certificate, certType, keyIDtype, keyID) const int keyset; int certificate; const int certType; const int keyIDtype; const void * keyID = (SvIOK(ST(4)) ? (const void *)SvIV(ST(4)) : (const void *)SvPV_nolen(ST(4))); CODE: RETVAL = cryptCAGetItem(keyset, &certificate, certType, keyIDtype, keyID); OUTPUT: RETVAL certificateint cryptCheckSignature(signature, signatureLength, sigCheckKey, hashContext) const void * signature; const int signatureLength; const int sigCheckKey; const int hashContext;int cryptCheckSignatureEx(signature, signatureLength, sigCheckKey, hashContext, extraData) const void * signature; const int signatureLength; const int sigCheckKey; const int hashContext; int extraData; CODE: RETVAL = cryptCheckSignatureEx(signature, signatureLength, sigCheckKey, hashContext, &extraData); OUTPUT: RETVAL extraDataint cryptCreateSession(cryptSession, cryptUser, sessionType) int cryptSession; const int cryptUser; const int sessionType; CODE: RETVAL = cryptCreateSession(&cryptSession, cryptUser, sessionType); OUTPUT: RETVAL cryptSessionint cryptCreateSignature(signature, signatureMaxLength, signatureLength, signContext, hashContext) void * signature = (SvIOK(ST(0)) ? (void *)SvIV(ST(0)) : (void *)SvPV_nolen(ST(0))); const int signatureMaxLength; int signatureLength; const int signContext; const int hashContext; CODE: RETVAL = cryptCreateSignature(signature, signatureMaxLength, &signatureLength, signContext, hashContext); if ( RETVAL == CRYPT_OK ) sv_setpvn(ST(0), signature, signatureLength); OUTPUT: RETVAL signatureLengthint cryptCreateSignatureEx(signature, signatureMaxLength, signatureLength, formatType, signContext, hashContext, extraData) void * signature = (SvIOK(ST(0)) ? (void *)SvIV(ST(0)) : (void *)SvPV_nolen(ST(0))); const int signatureMaxLength; int signatureLength; const int formatType; const int signContext; const int hashContext; const int extraData; CODE: RETVAL = cryptCreateSignatureEx(signature, signatureMaxLength, &signatureLength, formatType, signContext, hashContext, extraData); if ( RETVAL == CRYPT_OK ) sv_setpvn(ST(0), signature, signatureLength); OUTPUT: RETVAL signatureLengthint cryptDecrypt(cryptContext, buffer, length) const int cryptContext; void * buffer; const int length; CODE: RETVAL = cryptDecrypt(cryptContext, buffer, length); if ( RETVAL == CRYPT_OK ) sv_setpvn(ST(1), buffer, length); OUTPUT: RETVALint cryptDeleteAttribute(cryptObject, attributeType) const int cryptObject; const int attributeType;int cryptDeleteCertExtension(certificate, oid) const int certificate; const char * oid;int cryptDeleteKey(cryptObject, keyIDtype, keyID) const int cryptObject; const int keyIDtype; const void * keyID;int cryptDestroyObject(cryptObject) const int cryptObject;int cryptDestroySession(cryptSession) const int cryptSession;int cryptDeviceClose(device) const int device;int cryptDeviceCreateContext(cryptDevice, cryptContext, cryptAlgo) const int cryptDevice; int cryptContext; const int cryptAlgo; CODE: RETVAL = cryptDeviceCreateContext(cryptDevice, &cryptContext, cryptAlgo); OUTPUT: RETVAL cryptContextint cryptDeviceOpen(device, cryptUser, deviceType, name) int device; const int cryptUser; const int deviceType; const char * name = (SvIOK(ST(0)) ? (const char *)SvIV(ST(0)) : (const char *)SvPV_nolen(ST(0))); CODE: RETVAL = cryptDeviceOpen(&device, cryptUser, deviceType, name); OUTPUT: RETVAL deviceint cryptDeviceQueryCapability(cryptDevice, cryptAlgo, cryptQueryInfo) const int cryptDevice; const int cryptAlgo; HV * cryptQueryInfo; CODE: CRYPT_QUERY_INFO dummy; RETVAL = cryptDeviceQueryCapability(cryptDevice, cryptAlgo, &dummy); if ( RETVAL == CRYPT_OK ) { hv_store(cryptQueryInfo, "algoName", 8, newSVpv(dummy.algoName, strlen(dummy.algoName)), 0); hv_store(cryptQueryInfo, "blockSize", 9, newSVnv(dummy.blockSize), 0); hv_store(cryptQueryInfo, "minKeySize", 10, newSVnv(dummy.minKeySize), 0); hv_store(cryptQueryInfo, "keySize", 7, newSVnv(dummy.keySize), 0); hv_store(cryptQueryInfo, "maxKeySize", 10, newSVnv(dummy.maxKeySize), 0); } OUTPUT: RETVALint cryptEncrypt(cryptContext, buffer, length) const int cryptContext; void * buffer; const int length; CODE: RETVAL = cryptEncrypt(cryptContext, buffer, length); if ( RETVAL == CRYPT_OK ) sv_setpvn(ST(1), buffer, length); OUTPUT: RETVALint cryptExportKeyEx(encryptedKey, encryptedKeyMaxLength, encryptedKeyLength, formatType, exportKey, sessionKeyContext) void * encryptedKey = (SvIOK(ST(0)) ? (void *)SvIV(ST(0)) : (void *)SvPV_nolen(ST(0))); const int encryptedKeyMaxLength; int encryptedKeyLength; const int formatType; const int exportKey; const int sessionKeyContext; CODE: RETVAL = cryptExportKeyEx(encryptedKey, encryptedKeyMaxLength, &encryptedKeyLength, formatType, exportKey, sessionKeyContext); if ( RETVAL == CRYPT_OK ) sv_setpvn(ST(0), encryptedKey, encryptedKeyLength); OUTPUT: RETVAL encryptedKeyLengthint cryptGenerateKeyAsync(cryptContext) const int cryptContext;int cryptGetCertExtension(certificate, oid, criticalFlag, extension, extensionMaxLength, extensionLength) const int certificate; const char * oid; int criticalFlag; void * extension; const int extensionMaxLength; int extensionLength; CODE: RETVAL = cryptGetCertExtension(certificate, oid, &criticalFlag, extension, extensionMaxLength, &extensionLength); if ( RETVAL == CRYPT_OK ) sv_setpvn(ST(3), extension, extensionLength); OUTPUT: RETVAL criticalFlag extensionLengthint cryptQueryCapability(cryptAlgo, cryptQueryInfo) const int cryptAlgo; HV * cryptQueryInfo; CODE: CRYPT_QUERY_INFO dummy; RETVAL = cryptQueryCapability(cryptAlgo, &dummy); if ( RETVAL == CRYPT_OK ) { hv_store(cryptQueryInfo, "algoName", 8, newSVpv(dummy.algoName, strlen(dummy.algoName)), 0); hv_store(cryptQueryInfo, "blockSize", 9, newSVnv(dummy.blockSize), 0); hv_store(cryptQueryInfo, "minKeySize", 10, newSVnv(dummy.minKeySize), 0); hv_store(cryptQueryInfo, "keySize", 7, newSVnv(dummy.keySize), 0); hv_store(cryptQueryInfo, "maxKeySize", 10, newSVnv(dummy.maxKeySize), 0); } OUTPUT: RETVALint cryptQueryObject(objectData, objectDataLength, cryptObjectInfo) const void * objectData; const int objectDataLength; HV * cryptObjectInfo; CODE: CRYPT_OBJECT_INFO dummy; RETVAL = cryptQueryObject(objectData, objectDataLength, &dummy); if ( RETVAL == CRYPT_OK ) { hv_store(cryptObjectInfo, "objectType", 10, newSVnv(dummy.objectType), 0); hv_store(cryptObjectInfo, "cryptAlgo", 9, newSVnv(dummy.cryptAlgo), 0); hv_store(cryptObjectInfo, "cryptMode", 9, newSVnv(dummy.cryptMode), 0); hv_store(cryptObjectInfo, "hashAlgo", 8, newSVnv(dummy.hashAlgo), 0); hv_store(cryptObjectInfo, "salt", 4, newSVpv(dummy.salt, dummy.saltSize), 0); hv_store(cryptObjectInfo, "saltSize", 8, newSVnv(dummy.saltSize), 0); } OUTPUT: RETVAL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -