static	DSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)
{
	int ret=0;
	char *hptr=NULL;
	DSA_SIG *psign=NULL;
	char msg[64]="ENGINE_dsa_do_sign";
	if (!p_surewarehk_Dsa_Sign)
	{
		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);
	}
	else if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))
	{
		SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);
	}
	else
	{
		if((psign = DSA_SIG_new()) == NULL)
		{
			SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ERR_R_MALLOC_FAILURE);
			goto err;
		}
		psign->r=BN_new();
		psign->s=BN_new();
		bn_expand2(psign->r, 20/sizeof(BN_ULONG));
		bn_expand2(psign->s, 20/sizeof(BN_ULONG));
		if (!psign->r || psign->r->dmax!=20/sizeof(BN_ULONG) ||
			!psign->s || psign->s->dmax!=20/sizeof(BN_ULONG))
			goto err;
		ret=p_surewarehk_Dsa_Sign(msg,flen,from,psign->r->d,psign->s->d,hptr);
		surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
	}
	psign->r->top=20/sizeof(BN_ULONG);
	bn_fix_top(psign->r);
	psign->s->top=20/sizeof(BN_ULONG);
	bn_fix_top(psign->s);
err:
	if (psign)
	{
		DSA_SIG_free(psign);
		psign=NULL;
	}
	return psign;
}
['static\tDSA_SIG * surewarehk_dsa_do_sign(const unsigned char *from, int flen, DSA *dsa)\n{\n\tint ret=0;\n\tchar *hptr=NULL;\n\tDSA_SIG *psign=NULL;\n\tchar msg[64]="ENGINE_dsa_do_sign";\n\tif (!p_surewarehk_Dsa_Sign)\n\t{\n\t\tSUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ENGINE_R_NOT_INITIALISED);\n\t}\n\telse if (!(hptr=DSA_get_ex_data(dsa, dsaHndidx)))\n\t{\n\t\tSUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,SUREWARE_R_MISSING_KEY_COMPONENTS);\n\t}\n\telse\n\t{\n\t\tif((psign = DSA_SIG_new()) == NULL)\n\t\t{\n\t\t\tSUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t}\n\t\tpsign->r=BN_new();\n\t\tpsign->s=BN_new();\n\t\tbn_expand2(psign->r, 20/sizeof(BN_ULONG));\n\t\tbn_expand2(psign->s, 20/sizeof(BN_ULONG));\n\t\tif (!psign->r || psign->r->dmax!=20/sizeof(BN_ULONG) ||\n\t\t\t!psign->s || psign->s->dmax!=20/sizeof(BN_ULONG))\n\t\t\tgoto err;\n\t\tret=p_surewarehk_Dsa_Sign(msg,flen,from,psign->r->d,psign->s->d,hptr);\n\t\tsurewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);\n\t}\n\tpsign->r->top=20/sizeof(BN_ULONG);\n\tbn_fix_top(psign->r);\n\tpsign->s->top=20/sizeof(BN_ULONG);\n\tbn_fix_top(psign->s);\nerr:\n\tif (psign)\n\t{\n\t\tDSA_SIG_free(psign);\n\t\tpsign=NULL;\n\t}\n\treturn psign;\n}', 'void *DSA_get_ex_data(DSA *d, int idx)\n\t{\n\treturn(CRYPTO_get_ex_data(&d->ex_data,idx));\n\t}', 'void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)\n\t{\n\tif (ad->sk == NULL)\n\t\treturn(0);\n\telse if (idx >= sk_num(ad->sk))\n\t\treturn(0);\n\telse\n\t\treturn(sk_value(ad->sk,idx));\n\t}', 'int sk_num(const STACK *st)\n{\n\tif(st == NULL) return -1;\n\treturn st->num;\n}', 'char *sk_value(const STACK *st, int i)\n{\n\tif(st == NULL) return NULL;\n\treturn st->data[i];\n}', 'static void ERR_SUREWARE_error(int function, int reason, char *file, int line)\n\t{\n\tif (SUREWARE_lib_error_code == 0)\n\t\tSUREWARE_lib_error_code=ERR_get_next_error_library();\n\tERR_PUT_error(SUREWARE_lib_error_code,function,reason,file,line);\n\t}', 'int ERR_get_next_error_library(void)\n\t{\n\terr_fns_check();\n\treturn ERRFN(get_next_lib)();\n\t}', 'static void err_fns_check(void)\n\t{\n\tif (err_fns) return;\n\tCRYPTO_w_lock(CRYPTO_LOCK_ERR);\n\tif (!err_fns)\n\t\terr_fns = &err_defaults;\n\tCRYPTO_w_unlock(CRYPTO_LOCK_ERR);\n\t}', 'void ERR_put_error(int lib, int func, int reason, const char *file,\n\t     int line)\n\t{\n\tERR_STATE *es;\n#ifdef _OSD_POSIX\n\tif (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {\n\t\tchar *end;\n\t\tfile += sizeof("*POSIX(")-1;\n\t\tend = &file[strlen(file)-1];\n\t\tif (*end == \')\')\n\t\t\t*end = \'\\0\';\n\t\tif ((end = strrchr(file, \'/\')) != NULL)\n\t\t\tfile = &end[1];\n\t}\n#endif\n\tes=ERR_get_state();\n\tes->top=(es->top+1)%ERR_NUM_ERRORS;\n\tif (es->top == es->bottom)\n\t\tes->bottom=(es->bottom+1)%ERR_NUM_ERRORS;\n\tes->err_buffer[es->top]=ERR_PACK(lib,func,reason);\n\tes->err_file[es->top]=file;\n\tes->err_line[es->top]=line;\n\terr_clear_data(es,es->top);\n\t}']