我正在解密加密的MS Excel(RC4加密與SHA1),密碼已經知道了。在vs2010中,我可以正確解密,但是,我的程序已經在Win和linux.And我也沒辦法讓linux下的加密密鑰,現在,這是贏下類似如下:解密的MS辦公室
int getEncrypKey(HCRYPTKEY *hKey, int blocknum)
{
//------------------------H0 = H(salt, password)-----
BYTE *pbSaltandPwdHash = NULL;
DWORD dwSaltandPwdLen = 0;
pbSaltandPwdHash = SHA1_2(psalt, 16, ppwd, strlen(pwd)/2, &dwSaltandPwdLen);
printf("SHA1 of SaltandPwd:\n");
for(DWORD i = 0 ; i < dwSaltandPwdLen ; i++) {
printf("%2.2x ",pbSaltandPwdHash[i]);
}
printf("\n");
//------------------------H0 = H(salt, password)-----
//------------------------Hfinal = H(H0, block)-----
HCRYPTHASH hHash1 = 0;
CryptCreateHash(hCryptProv, CALG_SHA1, 0, 0, &hHash1) ;
CryptHashData(hHash1, pbSaltandPwdHash, dwSaltandPwdLen, 0) ;
CryptHashData(hHash1, (unsigned char*)&blocknum, sizeof(blocknum), 0) ;
//------------------------Hfinal = H(H0, block)-----
CryptDeriveKey(hCryptProv, CALG_RC4, hHash1, 0x00280000, hKey);
if(hHash1 != 0) CryptDestroyHash(hHash1);
if(pbSaltandPwdHash != NULL) free(pbSaltandPwdHash);
return 0;
}
我知道如何讓H0
linux下,但我不知道如何讓hHash1
和hKey
。
1)這與以前的問題有何不同? 2)從MS的加密API移植到另一個加密API(例如OpenSSL)的哪一部分會對您造成問題? – CodesInChaos
@CodesInChaos我認爲我必須像'CryptCreateHash','CryptHashData'..and和'HCRYPTKEY'同樣的結構來解密MS加密的office文檔一樣。但是,我現在理解並解決它。感謝您的關注。 –