Well, acording to the method EC_GROUP_new_by_curve_name that is referenced
by EC_KEY_new_by_curve_name():

"EC_GROUP* EC_GROUP_new_by_curve_name (int nid)

     {
      size_t i;
      EC_GROUP *ret = NULL;

      if (nid <= 0)
            return NULL;

      for (i=0; i<curve_list_length; i++)
            if (curve_list[i].nid == nid)
                  {
                  ret = ec_group_new_from_data(curve_list[i].data);
                  break;
                  }

      if (ret == NULL)
            {
            ECerr(EC_F_EC_GROUP_NEW_BY_CURVE_NAME, EC_R_UNKNOWN_GROUP);
            return NULL;
            }

      EC_GROUP_set_curve_name(ret, nid);

      return ret;
      }
"

Your curve must be in the curve list, but the NID_ecdsa_with_SHA256 is
not. You must use one of curves listed in the array curve_list in the
file crypto/ec/ec_curve.c.

For example: NID_secp112r1

Att,


On Tue, May 22, 2012 at 12:07 PM, Khuc, Chuong D. <ck...@swri.org> wrote:

>  Hi,
> I got a problem with
> EC_KEY_new_by_curve_name: it always return NULL. Here is how I used it:
> EC_KEY *eckey = EC_KEY_new_by_curve_name(NID_ecdsa_with_SHA256);
> If(eckey == NULL)
> {
>  printf("ERROR: NULL ECKEY!\r\n");
> }
> Do you happen to know the reason?
>



-- 
Rick Lopes de Souza
Mestrando em Ciências da Computação
LabSEC - UFSC
Gerente projeto ASI-HSM

Reply via email to