oreparaz / p256

ECDSA P-256 signature verification in a single C file targetting embedded use
15 stars 6 forks source link

missing br_secp384r1, br_secp521r1 when linking #27

Open dmw99 opened 17 hours ago

dmw99 commented 17 hours ago

When attempting to build the demo on linux, I get

gcc -c p256.c
gcc -o demo demo.c p256.o
/usr/bin/ld: p256.o: warning: relocation against `br_secp521r1' in read-only section `.text'
/usr/bin/ld: p256.o: in function `br_ecdsa_i31_vrfy_raw':
p256.c:(.text+0x4d3e): undefined reference to `br_secp384r1'
/usr/bin/ld: p256.c:(.text+0x4d4e): undefined reference to `br_secp521r1'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

I get a similar error building on Windows. These structs just seem to lack a definition. I see where they are in BearSSL, so I'm going to try and just pull them over.

dmw99 commented 15 hours ago

I realized that the secp384 and secp521 curve definitions aren't present because this reduction is just for signatures using p256. In that case I think the fix is just to delete the extern const declarations for these curves, and remove where they are referenced inside the br_ecdsa_i31_vrfy_raw method. Doing this got me working.