The RSA_verify function takes the following parameters:
int RSA_verify(int type, unsigned char*m, unsigned int m_len,
unsigned char *sigbuf, unsigned int siglen, RSA* rsa);
the first parameter is the type of message digest algorithm, like NID_sha256.
Given that this code does not hash the message, the variable m is the hashed message, what purpose is there to passing in the first parameter?
Is the hash algorithm type stored somewhere, and is verify checking that the same algorithm is being used to verify as was used to sign? If so, this int has nothing to do with the function that was used, it could easily be wrong.