Skip to content

wc_ecc_verify_hash return error when static memory is used #722

@hajjihraf

Description

@hajjihraf

When the API wc_ecc_verify_hash_ex calls "wc_ecc_mulmod" it returns an error because the heap is set to NULL.

I managed to fix the issue by calling "wc_ecc_mulmod_ex" instead of "wc_ecc_mulmod" and passed key->heap parameter.

below is the fixed code (ecc.c file lines 3788 and 3790) :

#ifndef ECC_SHAMIR
{
mp_digit mp;

   /* compute u1*mG + u2*mQ = mG */
   if (err == MP_OKAY)
       err = wc_ecc_mulmod_ex(&u1, mG, mG, curve->Af, curve->prime, 0, key->heap);
   if (err == MP_OKAY)
       err = wc_ecc_mulmod_ex(&u2, mQ, mQ, curve->Af, curve->prime, 0, key->heap);

   /* find the montgomery mp */
   if (err == MP_OKAY)
       err = mp_montgomery_setup(curve->prime, &mp);

   /* add them */
   if (err == MP_OKAY)
       err = ecc_projective_add_point(mQ, mG, mG, curve->Af,
                                                        curve->prime, mp);

   /* reduce */
   if (err == MP_OKAY)
       err = ecc_map(mG, curve->prime, mp);
}

#else

Thanks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions