#include <openssl/rsa.h>
#endif
#include <openssl/bn.h>
+#include <openssl/err.h>
/* RSAX is available **ONLY* on x86_64 CPUs */
#undef COMPILE_RSAX
#ifndef OPENSSL_NO_RSA
-#include <stdint.h>
-typedef uint64_t UINT64;
-typedef uint16_t UINT16;
+#ifdef _WIN32
+typedef unsigned __int64 UINT64;
+#else
+typedef unsigned long long UINT64;
+#endif
+typedef unsigned short UINT16;
/* Table t is interleaved in the following manner:
* The order in memory is t[0][0], t[0][1], ..., t[0][7], t[1][0], ...
RSA_set_ex_data(rsa, rsax_ex_data_idx, hptr);
}
- if (hptr[idx].type == BN_num_bits(m))
+ if (hptr[idx].type == (UINT64)BN_num_bits(m))
return hptr+idx;
if (BN_num_bits(m) == 512) {
static int e_rsax_rsa_finish(RSA *rsa)
{
E_RSAX_MOD_CTX *hptr = RSA_get_ex_data(rsa, rsax_ex_data_idx);
- if(!hptr) return 0;
-
- OPENSSL_free(hptr);
- RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL);
+ if(hptr)
+ {
+ OPENSSL_free(hptr);
+ RSA_set_ex_data(rsa, rsax_ex_data_idx, NULL);
+ }
+ if (rsa->_method_mod_n)
+ BN_MONT_CTX_free(rsa->_method_mod_n);
+ if (rsa->_method_mod_p)
+ BN_MONT_CTX_free(rsa->_method_mod_p);
+ if (rsa->_method_mod_q)
+ BN_MONT_CTX_free(rsa->_method_mod_q);
return 1;
}
err:
/* Cleanup */
if (ctx != NULL) {
- BN_CTX_end(ctx); }
+ BN_CTX_end(ctx); BN_CTX_free(ctx); }
BN_free(&two_768);
BN_free(&two_640);
BN_free(&two_128);