X509_PUBKEY *pk;
X509_ALGOR *a;
ASN1_OBJECT *o;
- unsigned char *s,*p;
+ unsigned char *s,*p = NULL;
int i;
if (x == NULL) return(0);
dsa->write_params=0;
ASN1_TYPE_free(a->parameter);
i=i2d_DSAparams(dsa,NULL);
- p=(unsigned char *)OPENSSL_malloc(i);
+ if ((p=(unsigned char *)OPENSSL_malloc(i)) == NULL) goto err;
pp=p;
i2d_DSAparams(dsa,&pp);
a->parameter=ASN1_TYPE_new();
if ((a->parameter = ASN1_TYPE_new()) == NULL)
{
X509err(X509_F_X509_PUBKEY_SET, ERR_R_ASN1_LIB);
- OPENSSL_free(p);
goto err;
}
- if ((ECDSA_get_parameter_flags(ecdsa) & ECDSA_FLAG_NAMED_CURVE) && (nid = EC_GROUP_get_nid(ecdsa->group)))
+ if (EC_GROUP_get_asn1_flag(ecdsa->group)
+ && (nid = EC_GROUP_get_nid(ecdsa->group)))
{
/* just set the OID */
a->parameter->type = V_ASN1_OBJECT;
}
if ((i=i2d_PublicKey(pkey,NULL)) <= 0) goto err;
- if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL) goto err;
+ if ((s=(unsigned char *)OPENSSL_malloc(i+1)) == NULL)
+ {
+ X509err(X509_F_X509_PUBKEY_SET,ERR_R_MALLOC_FAILURE);
+ goto err;
+ }
p=s;
i2d_PublicKey(pkey,&p);
if (!M_ASN1_BIT_STRING_set(pk->public_key,s,i)) goto err;
/* type == V_ASN1_OBJECT => the parameters are given
* by an asn1 OID
*/
+ ECDSA *ecdsa;
if (ret->pkey.ecdsa == NULL)
ret->pkey.ecdsa = ECDSA_new();
- if (ret->pkey.ecdsa->group)
- EC_GROUP_free(ret->pkey.ecdsa->group);
- ret->pkey.ecdsa->parameter_flags |= ECDSA_FLAG_NAMED_CURVE;
- if ((ret->pkey.ecdsa->group = EC_GROUP_new_by_name(OBJ_obj2nid(a->parameter->value.object))) == NULL)
+ ecdsa = ret->pkey.ecdsa;
+ if (ecdsa->group)
+ EC_GROUP_free(ecdsa->group);
+ if ((ecdsa->group = EC_GROUP_new_by_name(
+ OBJ_obj2nid(a->parameter->value.object))) == NULL)
goto err;
+ EC_GROUP_set_asn1_flag(ecdsa->group,
+ OPENSSL_EC_NAMED_CURVE);
}
/* the case implicitlyCA is currently not implemented */
ret->save_parameters = 1;