示例#1
0
static int cluster_labs_finish(ENGINE *e)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_FINISH, CL_R_NOT_LOADED);
        return 0;
    }
    if (!DSO_free(cluster_labs_dso)) {
        CLerr(CL_F_CLUSTER_LABS_FINISH, CL_R_DSO_FAILURE);
        return 0;
    }

    cluster_labs_dso = NULL;
    p_cl_engine_init = NULL;
    p_cl_mod_exp = NULL;
    p_cl_rsa_mod_exp = NULL;
    p_cl_mod_exp_crt = NULL;
    p_cl_rsa_priv_enc = NULL;
    p_cl_rsa_priv_dec = NULL;
    p_cl_rsa_pub_enc = NULL;
    p_cl_rsa_pub_dec = NULL;
    p_cl_rand_bytes = NULL;
    p_cl_dsa_sign = NULL;
    p_cl_dsa_verify = NULL;

    return (1);

}
示例#2
0
static int cluster_labs_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
	{
	int initialised = ((cluster_labs_dso == NULL) ? 0 : 1);

	switch(cmd)
		{
	case CLUSTER_LABS_CMD_SO_PATH:
		if(p == NULL)
			{
			CLerr(CL_F_CLUSTER_LABS_CTRL,ERR_R_PASSED_NULL_PARAMETER);
			return 0;
			}
		if(initialised)
			{
			CLerr(CL_F_CLUSTER_LABS_CTRL,CL_R_ALREADY_LOADED);
			return 0;
			}
		CLUSTER_LABS_LIB_NAME = (const char *)p;
		return 1;
	default:
		break;
		}
	CLerr(CL_F_CLUSTER_LABS_CTRL,CL_R_COMMAND_NOT_IMPLEMENTED);
	return 0;
	}
示例#3
0
static int cluster_labs_rand_bytes(unsigned char *buf, int num)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_RAND_BYTES, CL_R_NOT_LOADED);
        return 0;
    }
    if (p_cl_mod_exp_crt == NULL) {
        CLerr(CL_F_CLUSTER_LABS_RAND_BYTES, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_rand_bytes(buf, num);

}
示例#4
0
static int cluster_labs_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_RSA_MOD_EXP, CL_R_NOT_LOADED);
        return 0;
    }
    if (p_cl_rsa_mod_exp == NULL) {
        CLerr(CL_F_CLUSTER_LABS_RSA_MOD_EXP, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_rsa_mod_exp(r0, I, rsa);

}
示例#5
0
static int cluster_labs_rsa_priv_dec(int flen, const unsigned char *from,
                                     unsigned char *to, RSA *rsa, int padding)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_RSA_PRIV_DEC, CL_R_NOT_LOADED);
        return 0;
    }
    if (p_cl_rsa_priv_dec == NULL) {
        CLerr(CL_F_CLUSTER_LABS_RSA_PRIV_DEC, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_rsa_priv_dec(flen, from, to, rsa, padding);

}
示例#6
0
static DSA_SIG *cluster_labs_dsa_sign(const unsigned char *dgst, int dlen,
                                      DSA *dsa)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_DSA_SIGN, CL_R_NOT_LOADED);
        return 0;
    }
    if (p_cl_dsa_sign == NULL) {
        CLerr(CL_F_CLUSTER_LABS_DSA_SIGN, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_dsa_sign(dgst, dlen, dsa);

}
示例#7
0
static int cluster_labs_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                                const BIGNUM *m, BN_CTX *ctx)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_MOD_EXP, CL_R_NOT_LOADED);
        return 0;
    }
    if (p_cl_mod_exp == NULL) {
        CLerr(CL_F_CLUSTER_LABS_MOD_EXP, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_mod_exp(r, a, p, m, ctx);

}
示例#8
0
static int cluster_labs_dsa_verify(const unsigned char *dgst, int dgst_len,
                                   DSA_SIG *sig, DSA *dsa)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_DSA_VERIFY, CL_R_NOT_LOADED);
        return 0;
    }

    if (p_cl_dsa_verify == NULL) {
        CLerr(CL_F_CLUSTER_LABS_DSA_VERIFY, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_dsa_verify(dgst, dgst_len, sig, dsa);

}
示例#9
0
static int cluster_labs_mod_exp_crt(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
                                    const BIGNUM *q, const BIGNUM *dmp1,
                                    const BIGNUM *dmq1, const BIGNUM *iqmp,
                                    BN_CTX *ctx)
{

    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_MOD_EXP_CRT, CL_R_NOT_LOADED);
        return 0;
    }
    if (p_cl_mod_exp_crt == NULL) {
        CLerr(CL_F_CLUSTER_LABS_MOD_EXP_CRT, CL_R_FUNCTION_NOT_BINDED);
        return 0;
    }

    return p_cl_mod_exp_crt(r, a, p, q, dmp1, dmq1, iqmp, ctx);

}
示例#10
0
int cluster_labs_init(ENGINE *e)
{

    cl_engine_init *p1;
    cl_mod_exp *p2;
    cl_mod_exp_crt *p3;
    cl_rsa_mod_exp *p4;
    cl_rsa_priv_enc *p5;
    cl_rsa_priv_dec *p6;
    cl_rsa_pub_enc *p7;
    cl_rsa_pub_dec *p8;
    cl_rand_bytes *p20;
    cl_dsa_sign *p30;
    cl_dsa_verify *p31;

    /* engine already loaded */
    if (cluster_labs_dso != NULL) {
        CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_ALREADY_LOADED);
        goto err;
    }
    /* try to load engine    */
    cluster_labs_dso = DSO_load(NULL, CLUSTER_LABS_LIB_NAME, NULL, 0);
    if (cluster_labs_dso == NULL) {
        CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_DSO_FAILURE);
        goto err;
    }
    /* bind functions */
#define BINDIT(t, name) (t *)DSO_bind_func(cluster_labs_dso, name)
    if ((p1 = (cl_engine_init, CLUSTER_LABS_F1)) == NULL
        || (p2 = BINDIT(cl_mod_exp, CLUSTER_LABS_F2)) == NULL
        || (p3 = BINDIT(cl_mod_exp_crt, CLUSTER_LABS_F3)) == NULL
        || (p4 = BINDIT(cl_rsa_mod_exp, CLUSTER_LABS_F4)) == NULL
        || (p5 = BINDIT(cl_rsa_priv_enc, CLUSTER_LABS_F5)) == NULL
        || (p6 = BINDIT(cl_rsa_priv_dec, CLUSTER_LABS_F6)) == NULL
        || (p7 = BINDIT(cl_rsa_pub_enc, CLUSTER_LABS_F7)) == NULL
        || (p8 = BINDIT(cl_rsa_pub_dec, CLUSTER_LABS_F8)) == NULL
        || (p20 = BINDIT(cl_rand_bytes, CLUSTER_LABS_F20)) == NULL
        || (p30 = BINDIT(cl_dsa_sign, CLUSTER_LABS_F30)) == NULL
        || (p31 = BINDIT(cl_dsa_verify, CLUSTER_LABS_F31)) == NULL) {
        CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_DSO_FAILURE);
        goto err;
    }

    /* copy function pointers */
    p_cl_engine_init = p1;
    p_cl_mod_exp = p2;
    p_cl_mod_exp_crt = p3;
    p_cl_rsa_mod_exp = p4;
    p_cl_rsa_priv_enc = p5;
    p_cl_rsa_priv_dec = p6;
    p_cl_rsa_pub_enc = p7;
    p_cl_rsa_pub_dec = p8;
    p_cl_rand_bytes = p20;
    p_cl_dsa_sign = p30;
    p_cl_dsa_verify = p31;

    /* cluster labs engine init */
    if (p_cl_engine_init() == 0) {
        CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_INIT_FAILED);
        goto err;
    }

    return (1);

 err:
    /* reset all pointers */
    DSO_free(cluster_labs_dso);
    cluster_labs_dso = NULL;
    p_cl_engine_init = NULL;
    p_cl_mod_exp = NULL;
    p_cl_mod_exp_crt = NULL;
    p_cl_rsa_mod_exp = NULL;
    p_cl_rsa_priv_enc = NULL;
    p_cl_rsa_priv_dec = NULL;
    p_cl_rsa_pub_enc = NULL;
    p_cl_rsa_pub_dec = NULL;
    p_cl_rand_bytes = NULL;
    p_cl_dsa_sign = NULL;
    p_cl_dsa_verify = NULL;

    return (0);
}