Does anybody now, what is a BYTE structure of
HCRYPTKEY handle
Printable View
Does anybody now, what is a BYTE structure of
HCRYPTKEY handle
Hi
it's been some time since you asked this question, but if you're still looking for the answer, here it is. I'm not sure how it's done in Windows 98 which you probably had in mind, but for all the versions since XP to 10 it looks like below. It all comes from reverse engineering of cryptsp.dll and rsaenh.dll, so it's not perfect, but gives the brief overview of its internals:
First 10 fields are pointers to functions from rsaenh.dll which are just internal implementations of crypto api functions.Code:struct HCRYPTKEY
{
void* CPGenKey;
void* CPDeriveKey;
void* CPDestroyKey;
void* CPSetKeyParam;
void* CPGetKeyParam;
void* CPExportKey;
void* CPImportKey;
void* CPEncrypt;
void* CPDecrypt;
void* CPDuplicateKey;
HCRYPTPROV hCryptProv;
magic_s *magic; // XOR-ed
};
I'm not very sure of the structure of magic_s, but the only interesting field there is pointer to another structure containing key data:
All those structures are probably a little bit longer and contain additional fields, but I'm not sure about their purpose as it was not necessary for my research.Code:struct magic_s
{
key_data_s *key_data;
};
struct key_data_s
{
void *unknown; // XOR-ed
uint32_t alg;
uint32_t flags;
uint32_t key_size;
void* key_bytes;
};
Also notice pointers commented as XOR - their values are XOR-ed with magic constant equal to 0xE35A172C, so you must "unxor" them before using.
All of above is true for 32 bit version of cryptsp.dll / rsaenh.dll