- if (ret->priv_key == NULL)
- ret->priv_key = BN_secure_new();
- if (ret->priv_key == NULL) {
- ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE);
- goto err;
- }
- ret->priv_key = BN_bin2bn(ASN1_STRING_data(priv_key->privateKey),
- ASN1_STRING_length(priv_key->privateKey),
- ret->priv_key);
- if (ret->priv_key == NULL) {
- ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_BN_LIB);
+ ASN1_OCTET_STRING *pkey = priv_key->privateKey;
+ if (EC_KEY_oct2priv(ret, ASN1_STRING_data(pkey),
+ ASN1_STRING_length(pkey)) == 0)