Skip to main content
Visitor II
October 6, 2026
Question

Signature verification using ECDSA

Hello,

 

We are trying to implement ECDSA where cloud generates Public and Private key and calculates hash of our firmware using SHA 256 and Sign the firmware using P256 method. I am using ECDSA API to verify the firmware in our bootloader I am facing some issues in verification I am using all the things based on example project prime256v1.c file for constants

uint32_t verify_firmware_signature_P256( const uint8_t* hash )

{

  PKA_ECDSAVerifInTypeDef in = {0};

 

  in.primeOrderSize  = 32U;            // 256 bits = 32 bytes

  in.modulusSize   = 32U;            // 256 bits = 32 bytes

  in.coefSign     = 1U;             // 1 indicates a is negative (-3)

  in.coef       = prime256v1_absA;      // Coefficient |a| = 3

  in.modulus     = prime256v1_Prime;      // Prime p

  in.basePointX    = prime256v1_GeneratorX;   // Generator Gx

  in.basePointY    = prime256v1_GeneratorY;   // Generator Gy

  in.primeOrder    = prime256v1_Order;      // Curve order n

  in.pPubKeyCurvePtX = pub_x;           // Public key X

  in.pPubKeyCurvePtY = pub_y;           // Public key Y

  in.RSign      = sig_r;           // Signature R

  in.SSign      = sig_s;           // Signature S

  in.hash       = hash;           // SHA-256 digest

 

  if (HAL_PKA_ECDSAVerif( &hpka, &in, 1000 ) != HAL_OK ) 

{

    return HAL_ERROR; 

  }

 

/* Returns true if signature is valid. */

  return HAL_PKA_ECDSAVerif_IsValidSignature( &hpka );

}

 

Here are my questions

1) I am calculating SHA as cloud and I am able to match SHA256 as same as the cloud, should I pass directly or reverse it? (to big endian).

2) Public key x|y and Signature r|s provided by the cloud is in big endian formate should I pass directly to HAL_PKA_ECDSAVerify without converting ?

3) Can we have a example project which shows how to validate the signature?

 

Regards,

Mayur SJ