1 month, 1 week ago.

Problem with ECDSA signatures in mbedtls

Hi, I want to implement more ECDSA signatures with the same key pair using mbedtls library. I have configured the key pair with:

mbedtls_ecdsa_genkey( &ctx_sign, MBEDTLS_ECP_DP_SECP256R1, mbedtls_ctr_drbg_random, &ctr_drbg )

and then I have called the mbedtls_ecdsa_write_signature in a for loop:

for(int i=0; i<3; i++){ mbedtls_ecdsa_write_signature( &ctx_sign, MBEDTLS_MD_SHA256, hash, sizeof( hash ), sig, &sig_len, mbedtls_ctr_drbg_random , &ctr_drbg )}

I have also unset the MBEDTLS_ECDSA_DETERMINISTIC to disable the deterministic signature, but, the generated signatures are the same.

The serial output is: . Seeding the random number generator... ok . Generating key pair... ok (key size: 256 bits) + Public key: 04D6D34AC60DBECE58CA48DE212F55234200F12FC77EF7ADF4530C1016315A70884D8A017B3665F6A96BC0CE25B19F1F37C8574822E6F09ADBD417F1A693E0D1E9 . Computing message hash... ok + Hash: 02F4CCF09D1F5740E28864C430F866B46B697646D376E7813D12B873DBE16CC6 . Signing message hash... ok (signature length = 72) + Signature: 3046022100C59E10B27DEF9EE40EB386130ADC220497A730944A282F012D9BC0DF6BF031A30221008470ACD03FDF042CDF087C2EF98B1DAE7E4A31D7E0755BFF91B74A3B0FCCB2FB ok (signature length = 72) + Signature: 3046022100C59E10B27DEF9EE40EB386130ADC220497A730944A282F012D9BC0DF6BF031A30221008470ACD03FDF042CDF087C2EF98B1DAE7E4A31D7E0755BFF91B74A3B0FCCB2FB ok (signature length = 72) + Signature: 3046022100C59E10B27DEF9EE40EB386130ADC220497A730944A282F012D9BC0DF6BF031A30221008470ACD03FDF042CDF087C2EF98B1DAE7E4A31D7E0755BFF91B74A3B0FCCB2FB . Preparing verification context... ok . Verifying signature... ok ok DONE

Could someone help me figure out where I'm wrong?

Be the first to answer this question.