Created
April 21, 2012 18:17
-
-
Save bricef/2438927 to your computer and use it in GitHub Desktop.
AES Decryption in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int decrypt( | |
void* buffer, | |
int buffer_len, | |
char* IV, | |
char* key, | |
int key_len | |
){ | |
MCRYPT td = mcrypt_module_open("rijndael-128", NULL, "cbc", NULL); | |
int blocksize = mcrypt_enc_get_block_size(td); | |
if( buffer_len % blocksize != 0 ){return 1;} | |
mcrypt_generic_init(td, key, key_len, IV); | |
mdecrypt_generic(td, buffer, buffer_len); | |
mcrypt_generic_deinit (td); | |
mcrypt_module_close(td); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment