if ((len2 = BN_bn2bin(tmp2, buffer)) == 0) goto err; if ((ret->b = M_ASN1_OCTET_STRING_new()) == NULL) OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB) if (!M_ASN1_OCTET_STRING_set(ret->b, buffer, len2)) OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB)
else { if ((len1 = BN_bn2bin(tmp1, buffer)) == 0) goto err; if (!M_ASN1_OCTET_STRING_set(ret->a, buffer, len1)) OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB) } if (len2 == 0)  { if (!M_ASN1_OCTET_STRING_set(ret->a, char_buf, 1)) OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB) } else { if ((len2 = BN_bn2bin(tmp2, buffer)) == 0) goto err; if (!M_ASN1_OCTET_STRING_set(ret->b, buffer, len2)) OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB) }
X9_62_CURVE   *ECDSA_get_X9_62_CURVE(const ECDSA *ecdsa, X9_62_CURVE *curve){	int	ok=0, reason=ERR_R_BN_LIB, len1=0, len2=0;	X9_62_CURVE *ret=NULL;	BIGNUM      *tmp1=NULL, *tmp2=NULL;	unsigned char *buffer=NULL;	if (!ecdsa || !ecdsa->group)		OPENSSL_ECDSA_ABORT(ECDSA_R_MISSING_PARAMETERS)	if ((tmp1 = BN_new()) == NULL || (tmp2 = BN_new()) == NULL) goto err;	if (curve == NULL)	{		if ((ret = X9_62_CURVE_new()) == NULL)			OPENSSL_ECDSA_ABORT(ECDSA_R_X9_62_CURVE_NEW_FAILURE)	}	else	{		ret = curve;		if (ret->a)	ASN1_OCTET_STRING_free(ret->a);		if (ret->b)	ASN1_OCTET_STRING_free(ret->b);		if (ret->seed)	ASN1_BIT_STRING_free(ret->seed);	}	if (!EC_GROUP_get_curve_GFp(ecdsa->group, NULL, tmp1, tmp2, NULL))		OPENSSL_ECDSA_ABORT(ERR_R_EC_LIB)	if ((len1 = BN_num_bytes(tmp1)) == 0)		OPENSSL_ECDSA_ABORT(ECDSA_R_UNEXPECTED_PARAMETER_LENGTH)	if ((buffer = OPENSSL_malloc(len1)) == NULL)		OPENSSL_ECDSA_ABORT(ERR_R_MALLOC_FAILURE)	if ((len1 = BN_bn2bin(tmp1, buffer)) == 0) goto err;	if ((ret->a = M_ASN1_OCTET_STRING_new()) == NULL)		OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB)	if (!M_ASN1_OCTET_STRING_set(ret->a, buffer, len1))		OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB)	if ((len2 = BN_num_bytes(tmp2)) == 0)		OPENSSL_ECDSA_ABORT(ECDSA_R_UNEXPECTED_PARAMETER_LENGTH)	if (len1 < len2)	{		OPENSSL_free(buffer);		if ((buffer = OPENSSL_malloc(len2)) == NULL)			OPENSSL_ECDSA_ABORT(ERR_R_MALLOC_FAILURE)	}	if ((len2 = BN_bn2bin(tmp2, buffer)) == 0) goto err;	if ((ret->b = M_ASN1_OCTET_STRING_new()) == NULL)		OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB)	if (!M_ASN1_OCTET_STRING_set(ret->b, buffer, len2))		OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB)	if (ecdsa->seed)	{			if ((ret->seed = ASN1_BIT_STRING_new()) == NULL) goto err;		if (!ASN1_BIT_STRING_set(ret->seed, ecdsa->seed, (int)ecdsa->seed_len))			OPENSSL_ECDSA_ABORT(ERR_R_ASN1_LIB)	}	else		ret->seed = NULL;	ok = 1;err :	if (!ok)	{		if (ret && !curve) X9_62_CURVE_free(ret);		ret = NULL;		ECDSAerr(ECDSA_F_ECDSA_GET_X9_62_CURVE, reason);	}	if (buffer) OPENSSL_free(buffer);	if (tmp1)   BN_free(tmp1);	if (tmp2)   BN_free(tmp2);	return(ret);}