*/
#include <stdio.h>
+#include <string.h>
#include <openssl/crypto.h>
-#include "cryptlib.h"
+#include <openssl/buffer.h>
#include <openssl/dso.h>
#include <openssl/engine.h>
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
+#include <openssl/dh.h>
+#include <openssl/rand.h>
#ifndef OPENSSL_NO_HW
#ifndef OPENSSL_NO_HW_CSWIFT
#endif
#define CSWIFT_LIB_NAME "cswift engine"
-#include "hw_cswift_err.c"
+#include "e_cswift_err.c"
+
+#define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
static int cswift_destroy(ENGINE *e);
static int cswift_init(ENGINE *e);
static int cswift_finish(ENGINE *e);
-static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
+static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
/* BIGNUM stuff */
static int cswift_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
#ifndef OPENSSL_NO_RSA
/* RSA stuff */
-static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
+static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
#endif
/* This function is aliased to mod_exp (with the mont stuff dropped). */
static int cswift_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
0,
NULL,
NULL,
+ NULL,
NULL
};
#endif
NULL, /* init */
NULL, /* finish */
0, /* flags */
- NULL /* app_data */
+ NULL, /* app_data */
+ NULL, /* dsa_paramgen */
+ NULL /* dsa_keygen */
};
#endif
NULL,
NULL,
0,
+ NULL,
NULL
};
#endif
return 1;
}
+#ifdef OPENSSL_NO_DYNAMIC_ENGINE
static ENGINE *engine_cswift(void)
{
ENGINE *ret = ENGINE_new();
ENGINE_free(toadd);
ERR_clear_error();
}
+#endif
/* This is a process-global DSO handle used for loading and unloading
* the CryptoSwift library. NB: This is only set (or unset) during an
return 1;
}
-static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
+static int cswift_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
{
int initialised = ((cswift_dso == NULL) ? 0 : 1);
switch(cmd)
}
#ifndef OPENSSL_NO_RSA
-static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
+static int cswift_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
{
- BN_CTX *ctx;
int to_return = 0;
- if((ctx = BN_CTX_new()) == NULL)
- goto err;
if(!rsa->p || !rsa->q || !rsa->dmp1 || !rsa->dmq1 || !rsa->iqmp)
{
CSWIFTerr(CSWIFT_F_CSWIFT_RSA_MOD_EXP,CSWIFT_R_MISSING_KEY_COMPONENTS);
to_return = cswift_mod_exp_crt(r0, I, rsa->p, rsa->q, rsa->dmp1,
rsa->dmq1, rsa->iqmp, ctx);
err:
- if(ctx)
- BN_CTX_free(ctx);
return to_return;
}
#endif
/* This stuff is needed if this ENGINE is being compiled into a self-contained
* shared-library. */
-#ifdef ENGINE_DYNAMIC_SUPPORT
+#ifndef OPENSSL_NO_DYNAMIC_ENGINE
static int bind_fn(ENGINE *e, const char *id)
{
if(id && (strcmp(id, engine_cswift_id) != 0))
}
IMPLEMENT_DYNAMIC_CHECK_FN()
IMPLEMENT_DYNAMIC_BIND_FN(bind_fn)
-#endif /* ENGINE_DYNAMIC_SUPPORT */
+#endif /* OPENSSL_NO_DYNAMIC_ENGINE */
#endif /* !OPENSSL_NO_HW_CSWIFT */
#endif /* !OPENSSL_NO_HW */