Create openssl EC_KEY object based on EC point value

I want to verify the ECDSA signature using openssl. The EC-point value I is retrieved from the ECDSA key pair that I generated using PKCS11. Below is the code I have now done.

VerifyEccData(int hashAlgo,BYTE *data,int dataLen,BYTE *signature,int 
signatureLen,BYTE* curveType,BYTE* ecPoint,int ecPointLen)
{
  const unsigned char * a = (unsigned char *)ecPoint + 2
  EC_KEY *ec = EC_KEY_new();
  int eccGrpSN = OBJ_txt2nid("secp112r1");
  EC_GROUP *ecgroup  = EC_GROUP_new_by_curve_name(eccGrpSN);
  EC_KEY_set_group(ec,ecgroup ); 
  o2i_ECPublicKey(&ec,  &a, ecPointLen-2);
  SHA1(data, dataLen,shaResult);
  ECDSA_verify(0,shaResult, sizeof(shaResult), signature,signatureLen, ec);
}

      

Above code return

error: 10067066: elliptic curve routines: ec_GFp_simple_oct2point: invalid encoding

I'm not sure what is the point of this error. If anyone can help or point me in the right direction, really appreciate.

I found this one https://www.mail-archive.com/ opensc-devel@lists.opensc-project.org /msg08847.html , but when I try it gives another error.

error: 0D07209B: asn1 encoding routines: ASN1_get_object: too long

+3


source to share





All Articles