crypto/engine/hw_cswift.c:667: error: UNINITIALIZED_VALUE
  The value read from hac was never initialized.
Showing all 1 steps of the trace


crypto/engine/hw_cswift.c:667:3: 
665.   err:
666.   	if(acquired)
667. > 		release_context(hac);
668.   	if(ctx)
669.   		{

static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)
	{
	SW_CONTEXT_HANDLE hac;
	SW_PARAM sw_param;
	SW_STATUS sw_status;
	SW_LARGENUMBER arg, res;
	unsigned char *ptr;
	BN_CTX *ctx;
	BIGNUM *dsa_p = NULL;
	BIGNUM *dsa_q = NULL;
	BIGNUM *dsa_g = NULL;
	BIGNUM *dsa_key = NULL;
	BIGNUM *result = NULL;
	DSA_SIG *to_return = NULL;
	int acquired = 0;
	if((ctx = BN_CTX_new()) == NULL)
		goto err;
	if(!get_context(&hac))
		{
		ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_GET_HANDLE_FAILED);
		goto err;
		}
	acquired = 1;
	BN_CTX_start(ctx);
	dsa_p = BN_CTX_get(ctx);
	dsa_q = BN_CTX_get(ctx);
	dsa_g = BN_CTX_get(ctx);
	dsa_key = BN_CTX_get(ctx);
	result = BN_CTX_get(ctx);
	if(!result)
		{
		ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_BN_CTX_FULL);
		goto err;
		}
	if(!bn_wexpand(dsa_p, dsa->p->top) ||
			!bn_wexpand(dsa_q, dsa->q->top) ||
			!bn_wexpand(dsa_g, dsa->g->top) ||
			!bn_wexpand(dsa_key, dsa->priv_key->top) ||
			!bn_wexpand(result, dsa->p->top))
		{
		ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_BN_EXPAND_FAIL);
		goto err;
		}
	sw_param.type = SW_ALG_DSA;
	sw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,
				(unsigned char *)dsa_p->d);
	sw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;
	sw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,
				(unsigned char *)dsa_q->d);
	sw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;
	sw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,
				(unsigned char *)dsa_g->d);
	sw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;
	sw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->priv_key,
				(unsigned char *)dsa_key->d);
	sw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;
	sw_status = p_CSwift_AttachKeyParam(hac, &sw_param);
	switch(sw_status)
		{
	case SW_OK:
		break;
	case SW_ERR_INPUT_SIZE:
		ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,
			ENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);
		goto err;
	default:
		{
		char tmpbuf[20];
		ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_REQUEST_FAILED);
		sprintf(tmpbuf, "%ld", sw_status);
		ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
		}
		goto err;
		}
	arg.nbytes = dlen;
	arg.value = (unsigned char *)dgst;
	res.nbytes = BN_num_bytes(dsa->p);
	memset(result->d, 0, res.nbytes);
	res.value = (unsigned char *)result->d;
	sw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_SIGN, &arg, 1,
		&res, 1);
	if(sw_status != SW_OK)
		{
		char tmpbuf[20];
		ENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_REQUEST_FAILED);
		sprintf(tmpbuf, "%ld", sw_status);
		ERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);
		goto err;
		}
	ptr = (unsigned char *)result->d;
	if((to_return = DSA_SIG_new()) == NULL)
		goto err;
	to_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL);
	to_return->s = BN_bin2bn((unsigned char *)result->d + 20, 20, NULL);
err:
	if(acquired)
		release_context(hac);
	if(ctx)
		{
		BN_CTX_end(ctx);
		BN_CTX_free(ctx);
		}
	return to_return;
	}
['static DSA_SIG *cswift_dsa_sign(const unsigned char *dgst, int dlen, DSA *dsa)\n\t{\n\tSW_CONTEXT_HANDLE hac;\n\tSW_PARAM sw_param;\n\tSW_STATUS sw_status;\n\tSW_LARGENUMBER arg, res;\n\tunsigned char *ptr;\n\tBN_CTX *ctx;\n\tBIGNUM *dsa_p = NULL;\n\tBIGNUM *dsa_q = NULL;\n\tBIGNUM *dsa_g = NULL;\n\tBIGNUM *dsa_key = NULL;\n\tBIGNUM *result = NULL;\n\tDSA_SIG *to_return = NULL;\n\tint acquired = 0;\n\tif((ctx = BN_CTX_new()) == NULL)\n\t\tgoto err;\n\tif(!get_context(&hac))\n\t\t{\n\t\tENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_GET_HANDLE_FAILED);\n\t\tgoto err;\n\t\t}\n\tacquired = 1;\n\tBN_CTX_start(ctx);\n\tdsa_p = BN_CTX_get(ctx);\n\tdsa_q = BN_CTX_get(ctx);\n\tdsa_g = BN_CTX_get(ctx);\n\tdsa_key = BN_CTX_get(ctx);\n\tresult = BN_CTX_get(ctx);\n\tif(!result)\n\t\t{\n\t\tENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_BN_CTX_FULL);\n\t\tgoto err;\n\t\t}\n\tif(!bn_wexpand(dsa_p, dsa->p->top) ||\n\t\t\t!bn_wexpand(dsa_q, dsa->q->top) ||\n\t\t\t!bn_wexpand(dsa_g, dsa->g->top) ||\n\t\t\t!bn_wexpand(dsa_key, dsa->priv_key->top) ||\n\t\t\t!bn_wexpand(result, dsa->p->top))\n\t\t{\n\t\tENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_BN_EXPAND_FAIL);\n\t\tgoto err;\n\t\t}\n\tsw_param.type = SW_ALG_DSA;\n\tsw_param.up.dsa.p.nbytes = BN_bn2bin(dsa->p,\n\t\t\t\t(unsigned char *)dsa_p->d);\n\tsw_param.up.dsa.p.value = (unsigned char *)dsa_p->d;\n\tsw_param.up.dsa.q.nbytes = BN_bn2bin(dsa->q,\n\t\t\t\t(unsigned char *)dsa_q->d);\n\tsw_param.up.dsa.q.value = (unsigned char *)dsa_q->d;\n\tsw_param.up.dsa.g.nbytes = BN_bn2bin(dsa->g,\n\t\t\t\t(unsigned char *)dsa_g->d);\n\tsw_param.up.dsa.g.value = (unsigned char *)dsa_g->d;\n\tsw_param.up.dsa.key.nbytes = BN_bn2bin(dsa->priv_key,\n\t\t\t\t(unsigned char *)dsa_key->d);\n\tsw_param.up.dsa.key.value = (unsigned char *)dsa_key->d;\n\tsw_status = p_CSwift_AttachKeyParam(hac, &sw_param);\n\tswitch(sw_status)\n\t\t{\n\tcase SW_OK:\n\t\tbreak;\n\tcase SW_ERR_INPUT_SIZE:\n\t\tENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,\n\t\t\tENGINE_R_SIZE_TOO_LARGE_OR_TOO_SMALL);\n\t\tgoto err;\n\tdefault:\n\t\t{\n\t\tchar tmpbuf[20];\n\t\tENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_REQUEST_FAILED);\n\t\tsprintf(tmpbuf, "%ld", sw_status);\n\t\tERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);\n\t\t}\n\t\tgoto err;\n\t\t}\n\targ.nbytes = dlen;\n\targ.value = (unsigned char *)dgst;\n\tres.nbytes = BN_num_bytes(dsa->p);\n\tmemset(result->d, 0, res.nbytes);\n\tres.value = (unsigned char *)result->d;\n\tsw_status = p_CSwift_SimpleRequest(hac, SW_CMD_DSS_SIGN, &arg, 1,\n\t\t&res, 1);\n\tif(sw_status != SW_OK)\n\t\t{\n\t\tchar tmpbuf[20];\n\t\tENGINEerr(ENGINE_F_CSWIFT_DSA_SIGN,ENGINE_R_REQUEST_FAILED);\n\t\tsprintf(tmpbuf, "%ld", sw_status);\n\t\tERR_add_error_data(2, "CryptoSwift error number is ",tmpbuf);\n\t\tgoto err;\n\t\t}\n\tptr = (unsigned char *)result->d;\n\tif((to_return = DSA_SIG_new()) == NULL)\n\t\tgoto err;\n\tto_return->r = BN_bin2bn((unsigned char *)result->d, 20, NULL);\n\tto_return->s = BN_bin2bn((unsigned char *)result->d + 20, 20, NULL);\nerr:\n\tif(acquired)\n\t\trelease_context(hac);\n\tif(ctx)\n\t\t{\n\t\tBN_CTX_end(ctx);\n\t\tBN_CTX_free(ctx);\n\t\t}\n\treturn to_return;\n\t}']