Add the possibility to build without the ENGINE framework.
PR: 287
This commit is contained in:
@@ -124,8 +124,10 @@ struct rsa_st
|
||||
int pad;
|
||||
long version;
|
||||
const RSA_METHOD *meth;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/* functional reference if 'meth' is ENGINE-provided */
|
||||
ENGINE *engine;
|
||||
#endif
|
||||
BIGNUM *n;
|
||||
BIGNUM *e;
|
||||
BIGNUM *d;
|
||||
|
||||
@@ -61,7 +61,9 @@
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/rand.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
#ifndef RSA_NULL
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/rsa.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
const char *RSA_version="RSA" OPENSSL_VERSION_PTEXT;
|
||||
|
||||
@@ -108,11 +110,13 @@ int RSA_set_method(RSA *rsa, const RSA_METHOD *meth)
|
||||
const RSA_METHOD *mtmp;
|
||||
mtmp = rsa->meth;
|
||||
if (mtmp->finish) mtmp->finish(rsa);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (rsa->engine)
|
||||
{
|
||||
ENGINE_finish(rsa->engine);
|
||||
rsa->engine = NULL;
|
||||
}
|
||||
#endif
|
||||
rsa->meth = meth;
|
||||
if (meth->init) meth->init(rsa);
|
||||
return 1;
|
||||
@@ -130,6 +134,7 @@ RSA *RSA_new_method(ENGINE *engine)
|
||||
}
|
||||
|
||||
ret->meth = RSA_get_default_method();
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (engine)
|
||||
{
|
||||
if (!ENGINE_init(engine))
|
||||
@@ -154,6 +159,7 @@ RSA *RSA_new_method(ENGINE *engine)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret->pad=0;
|
||||
ret->version=0;
|
||||
@@ -175,8 +181,10 @@ RSA *RSA_new_method(ENGINE *engine)
|
||||
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
|
||||
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
|
||||
{
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (ret->engine)
|
||||
ENGINE_finish(ret->engine);
|
||||
#endif
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, ret, &ret->ex_data);
|
||||
OPENSSL_free(ret);
|
||||
ret=NULL;
|
||||
@@ -205,8 +213,10 @@ void RSA_free(RSA *r)
|
||||
|
||||
if (r->meth->finish)
|
||||
r->meth->finish(r);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (r->engine)
|
||||
ENGINE_finish(r->engine);
|
||||
#endif
|
||||
|
||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_RSA, r, &r->ex_data);
|
||||
|
||||
|
||||
@@ -62,7 +62,9 @@
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/objects.h>
|
||||
#include <openssl/x509.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
/* Size of an SSL signature: MD5+SHA1 */
|
||||
#define SSL_SIG_LENGTH 36
|
||||
@@ -77,10 +79,12 @@ int RSA_sign(int type, const unsigned char *m, unsigned int m_len,
|
||||
const unsigned char *s = NULL;
|
||||
X509_ALGOR algor;
|
||||
ASN1_OCTET_STRING digest;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if((rsa->flags & RSA_FLAG_SIGN_VER)
|
||||
&& ENGINE_get_RSA(rsa->engine)->rsa_sign)
|
||||
return ENGINE_get_RSA(rsa->engine)->rsa_sign(type,
|
||||
m, m_len, sigret, siglen, rsa);
|
||||
#endif
|
||||
/* Special case: SSL signature, just check the length */
|
||||
if(type == NID_md5_sha1) {
|
||||
if(m_len != SSL_SIG_LENGTH) {
|
||||
@@ -155,10 +159,12 @@ int RSA_verify(int dtype, const unsigned char *m, unsigned int m_len,
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if((rsa->flags & RSA_FLAG_SIGN_VER)
|
||||
&& ENGINE_get_RSA(rsa->engine)->rsa_verify)
|
||||
return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype,
|
||||
m, m_len, sigbuf, siglen, rsa);
|
||||
#endif
|
||||
|
||||
s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
|
||||
if (s == NULL)
|
||||
|
||||
@@ -16,7 +16,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#else
|
||||
#include <openssl/rsa.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
#define SetKey \
|
||||
key->n = BN_bin2bn(n, sizeof(n)-1, key->n); \
|
||||
|
||||
Reference in New Issue
Block a user