1. 程式人生 > 其它 >微軟本地CryptAPI加密演算法逆向速查

微軟本地CryptAPI加密演算法逆向速查

技術標籤:逆向

if (CryptAcquireContextW(&phProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) //參4是加密型別,參五是Flag
{
		if (CryptImportKey(phProv, pbKEY, KEYLEN, 0, 0, &phKey)){//匯入KEY,引數2為金鑰
			result = CryptDecrypt(phKey, 0, 1, 0, pData, pDataLen);//參5是待加密資料,解密完還是在該地址,參6是加密資料的長度,解密資料的長度。result返回1表示解密成功
}

在這裡插入圖片描述

CryptAcquireContextW的引數四dwProvType

#define PROV_RSA_FULL           1
#define PROV_RSA_SIG            2
#define PROV_DSS                3
#define PROV_FORTEZZA           4
#define PROV_MS_EXCHANGE        5
#define PROV_SSL                6
#define PROV_RSA_SCHANNEL       12
#define PROV_DSS_DH             13
#define PROV_EC_ECDSA_SIG 14 #define PROV_EC_ECNRA_SIG 15 #define PROV_EC_ECDSA_FULL 16 #define PROV_EC_ECNRA_FULL 17 #define PROV_DH_SCHANNEL 18 #define PROV_SPYRUS_LYNKS 20 #define PROV_RNG 21 #define PROV_INTEL_SEC 22 #if (NTDDI_VERSION >= NTDDI_WINXP)
#define PROV_REPLACE_OWF 23 #define PROV_RSA_AES 24 0x18 #endif //(NTDDI_VERSION >= NTDDI_WINXP) // certenrolld_end

CryptAcquireContextW的引數五dwFlags

// dwFlags definitions for CryptAcquireContext
#define CRYPT_VERIFYCONTEXT 0xF0000000
#define CRYPT_NEWKEYSET 0x00000008
#define CRYPT_DELETEKEYSET 0x00000010
#define CRYPT_MACHINE_KEYSET 0x00000020
#define CRYPT_SILENT 0x00000040

// dwFlag definitions for CryptGenKey
#define CRYPT_EXPORTABLE 0x00000001
#define CRYPT_USER_PROTECTED 0x00000002
#define CRYPT_CREATE_SALT 0x00000004
#define CRYPT_UPDATE_KEY 0x00000008
#define CRYPT_NO_SALT 0x00000010
#define CRYPT_PREGEN 0x00000040
#define CRYPT_RECIPIENT 0x00000010
#define CRYPT_INITIATOR 0x00000040
#define CRYPT_ONLINE 0x00000080
#define CRYPT_SF 0x00000100
#define CRYPT_CREATE_IV 0x00000200
#define CRYPT_KEK 0x00000400
#define CRYPT_DATA_KEY 0x00000800
#define CRYPT_VOLATILE 0x00001000
#define CRYPT_SGCKEY 0x00002000

/ dwFlag definitions for CryptGenKey
#define CRYPT_Y_ONLY 0x00000001
#define CRYPT_SSL2_FALLBACK 0x00000002
#define CRYPT_DESTROYKEY 0x00000004
#define CRYPT_OAEP 0x00000040 // used with RSA encryptions/decryptions
// CryptExportKey, CryptImportKey,
// CryptEncrypt and CryptDecrypt
#define CRYPT_BLOB_VER3 0x00000080 // export version 3 of a blob type

CryptImportKey

在這裡插入圖片描述