ASN1_CHOICE(ECPKPARAMETERS) = { ASN1_SIMPLE(ECPKPARAMETERS, value.named_curve, ASN1_OBJECT), ASN1_SIMPLE(ECPKPARAMETERS, value.parameters, ECPARAMETERS), ASN1_SIMPLE(ECPKPARAMETERS, value.implicitlyCA, ASN1_NULL) } ASN1_CHOICE_END(ECPKPARAMETERS)
static int ec_asn1_group2fieldid(const EC_GROUP *, X9_62_FIELDID *);  static int ec_asn1_group2curve(const EC_GROUP *, X9_62_CURVE *);  static EC_GROUP *ec_asn1_parameters2group(const ECPARAMETERS *);  static ECPARAMETERS *ec_asn1_group2parameters(const EC_GROUP *,ECPARAMETERS *);  static EC_GROUP *ec_asn1_pkparameters2group(const ECPKPARAMETERS *);  static ECPKPARAMETERS *ec_asn1_group2pkparameters(const EC_GROUP *, ECPKPARAMETERS *);     static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) { int			ok=0, nid; BIGNUM			*tmp = NULL;  if (group == NULL || field == NULL) return 0;   if (field->fieldType != NULL) ASN1_OBJECT_free(field->fieldType); if (field->p.other != NULL) ASN1_TYPE_free(field->p.other);  nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group));  if ((field->fieldType = OBJ_nid2obj(nid)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_OBJ_LIB); goto err; }  if (nid == NID_X9_62_prime_field) { if ((tmp = BN_new()) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; }  if (!EC_GROUP_get_curve_GFp(group, tmp, NULL, NULL, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); goto err; }  field->p.prime = BN_to_ASN1_INTEGER(tmp,NULL); if (field->p.prime == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_ASN1_LIB); goto err; } } else	 { int		field_type; X9_62_CHARACTERISTIC_TWO *char_two;  field->p.char_two = X9_62_CHARACTERISTIC_TWO_new(); char_two = field->p.char_two;  if (char_two == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; }  char_two->m = (long)EC_GROUP_get_degree(group);  field_type = EC_GROUP_get_basis_type(group);  if (field_type == 0) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); goto err; }  if ((char_two->type = OBJ_nid2obj(field_type)) == NULL) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_OBJ_LIB); goto err; }  if (field_type == NID_X9_62_tpBasis) { unsigned int k;  if (!EC_GROUP_get_trinomial_basis(group, &k)) goto err;  char_two->p.tpBasis = ASN1_INTEGER_new(); if (!char_two->p.tpBasis) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } if (!ASN1_INTEGER_set(char_two->p.tpBasis, (long)k)) { ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS, ERR_R_ASN1_LIB); goto err; } } else if (field_type == NID_X9_62_ppBasis) { unsigned int k1, k2, k3;  if (!EC_GROUP_get_pentanomial_basis(group, &k1, &k2, &k3)) goto err;  char_two->p.ppBasis = X9_62_PENTANOMIAL_new(); if (!char_two->p.ppBasis) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; }   char_two->p.ppBasis->k1 = (long)k1; char_two->p.ppBasis->k2 = (long)k2; char_two->p.ppBasis->k3 = (long)k3; } else  {  char_two->p.onBasis = ASN1_NULL_new(); if (!char_two->p.onBasis) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_MALLOC_FAILURE); goto err; } } }  ok = 1;  err :	if (tmp) BN_free(tmp); return(ok); }
} ASN1_SEQUENCE_END(X9_62_CURVE)ASN1_SEQUENCE(ECPARAMETERS) = {	ASN1_SIMPLE(ECPARAMETERS, version, LONG),	ASN1_SIMPLE(ECPARAMETERS, fieldID, X9_62_FIELDID),	ASN1_SIMPLE(ECPARAMETERS, curve, X9_62_CURVE),	ASN1_SIMPLE(ECPARAMETERS, base, ASN1_OCTET_STRING),	ASN1_SIMPLE(ECPARAMETERS, order, ASN1_INTEGER),	ASN1_OPT(ECPARAMETERS, cofactor, ASN1_INTEGER)} ASN1_SEQUENCE_END(ECPARAMETERS)DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)IMPLEMENT_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS)ASN1_CHOICE(ECPKPARAMETERS) = {	ASN1_SIMPLE(ECPKPARAMETERS, value.named_curve, ASN1_OBJECT),	ASN1_SIMPLE(ECPKPARAMETERS, value.parameters, ECPARAMETERS),	ASN1_SIMPLE(ECPKPARAMETERS, value.implicitlyCA, ASN1_NULL)} ASN1_CHOICE_END(ECPKPARAMETERS)