Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CRYS_ECDSA_Sign signature encoding?

Hello, I am doing some testing with nRF52840 and its CryptoCell 310 and I am trying to produce an ECDSA signature and verify it using mbedTLS.

CC310 Sign & Verify is working great, but how can I convert this signature into another format? For example DER used by mbedTLS.

This is how a mbedTLS ECDSA signature looks like this, we can see the DER header in there:

3045022100B0B64DB18F6E0003FAAF31A4AEEF291B4104532F446FC45C0F074ED82935C7500220226060EDCAA553C605AD1F598CA63FD6172EB3F0BC9AACDCA16EAB7509E215DD

Signature produced by CRYS_ECDSA_Sign looks like this:

ACCDC3BCA844324A7B440C3BB19377BE6C06223BB2E903920CF23AE0B3F0243A2F321E1EE01C9A449AFAC203D398B20D6DA0E2629483127F08C07995DB1F72FF


How is R and S encoded in this signature? Is there any function that can convert it into the DER encoding used in mbedTLS? I am stuck on this one for over a day.. Please help

Thanks in advance

Parents
  • Turns out I was doing the conversion correctly, after calling CRYS_ECDSA_Sign with the "CRYS_ECPKI_AFTER_HASH_SHA256_mode" hash mode and feeding in its SHA256 hash instead of the message, it worked and MbedTLS has verified it properly. 

    Well, still not sure why it didn' work with "CRYS_ECPKI_HASH_SHA256_mode", but at least I got it working now

Reply
  • Turns out I was doing the conversion correctly, after calling CRYS_ECDSA_Sign with the "CRYS_ECPKI_AFTER_HASH_SHA256_mode" hash mode and feeding in its SHA256 hash instead of the message, it worked and MbedTLS has verified it properly. 

    Well, still not sure why it didn' work with "CRYS_ECPKI_HASH_SHA256_mode", but at least I got it working now

Children
Related