I am trying to reverse engineer a packet protocol and I was abled to find a subroutine which is likely to be an encryption function. I do not know much about cryptography but it looked like a CBC encryption. Here's the pseudocode I got from IDA: http://pastebin.com/UGYpbthr and here is a part from the original subroutine: https://i.sstatic.net/EBlQa.png also here's a part from where the subroutine is called: https://i.sstatic.net/2S9Nc.png . Is it possible to translate this pseudocode to C code without further reverse engineering ? If so how should I do it ?
1 Answer
This specific pseudocode is actually regular C code because it doesn't access global variables and stack. You'll probably need to add some typedefs for basic types. Please note that this code should be compiled as 32 bit code (or any other where sizeof int is equal to sizeof of pointer for your specific system) to avoid problems with pointer sizes.
blowfish_enc
from tls.mbed.org/blowfish-source-code, with the loop in that source unrolled by the compiler. W.S. is right in that the function doesn't access global variables; however, the three parameters (typedint
by IDA) are in fact pointers, if you check their usage, so you need the data fields they point to anyway.mbedtls_blowfish_setkey
first, and i'd guess might find this function in your original code as well if you look for it.