Skrip Posted March 7, 2009 Posted March 7, 2009 Does anybody have an AESPHM decryption in AutoIt? If so, please post it here. I have some source for this decryption. But I haven't any clue how to convert it to autoit. expandcollapse popupint AESPHM_Decrypt(u8 *passphrase, u8 *output, u8 *input) { AES_KEY ctx; int inputlen, ivoff, paddingLen, payloadLen; u8 key[SHA256_DIGEST_LENGTH], iv[IV_SIZE], checkDigest[HMAC_SHA_DIGESTSIZE], firstPadByte, *digest, *ivSeed, *payload; input = strdup(input); inputlen = hex2byte(input, input); if(inputlen < MINIMUM_CIPHERTEXT_LENGTH) { fprintf(stderr, "\nError: the encrypted hex password (%d) is shorter than %d bytes\n", inputlen, MINIMUM_CIPHERTEXT_LENGTH); free(input); return(-1); } digest = input + inputlen - HMAC_SHA_DIGESTSIZE; ivSeed = digest - IV_SEED_SIZE; SHA256(passphrase, strlen(passphrase), key); HMAC(EVP_sha1(), key, SHA256_DIGEST_LENGTH, input, digest - input, checkDigest, NULL); if(memcmp(checkDigest, digest, HMAC_SHA_DIGESTSIZE)) { fprintf(stderr, "\nError: the hmac checksum differs, the key is wrong\n"); free(input); return(-1); } AESPHM_GenerateIvFromSeed(ivSeed, iv); AES_set_encrypt_key(key, SHA256_DIGEST_LENGTH << 3, &ctx); ivoff = 0; // AES_cfb128_encrypt in OpenSSL, but due to a difference with Crypto++ I use myaesdec myaesdec(&ctx, 1, &ivoff, iv, input, &firstPadByte); paddingLen = (firstPadByte & 15) + 3; if((input + paddingLen) > ivSeed) { fprintf(stderr, "\nError: the initial padded bytes (%d) are longer than the seed (%d)\n", paddingLen, IV_SEED_SIZE); free(input); return(-1); } payload = input + paddingLen; payloadLen = ivSeed - payload; if(payloadLen) { myaesdec(&ctx, paddingLen - 1, &ivoff, iv, input + 1, output); myaesdec(&ctx, payloadLen, &ivoff, iv, payload, output); } free(input); return(payloadLen); } [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now