Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbedtls writes ECDSA signatures in ASN1 #96

Open
chrysn opened this issue Dec 28, 2020 · 0 comments
Open

mbedtls writes ECDSA signatures in ASN1 #96

chrysn opened this issue Dec 28, 2020 · 0 comments

Comments

@chrysn
Copy link
Contributor

chrysn commented Dec 28, 2020

It seems (from code inspection while digging through what safe buffer sizes for signature buffers are and whether *siglen can be predetermined; I'm not at the point of using it yet) that the mbedtls ECDSA implementation uses ASN.1 encoding for signatures where COSE expects its own fixed-length encoding.

Code path:

  • cose_crypto_sign_ecdsa at src/crypt/mbedtls.c calls mbedtls_ecdsa_write_signature
  • mbedtls_ecdsa_write_signature at library/ecdsa.c calls (via mbedtls_ecdsa_write_signature_restartable) ecdsa_signature_to_asn1 into sig[*siglen]
  • ecdsa_signature_to_asn1 does ASN.1 encoding

while https://tools.ietf.org/html/rfc8152#section-8.1 says:

Using the function defined in [RFC8017], the signature is:
Signature = I2OSP(R, n) | I2OSP(S, n)
where n = ceiling(key_length / 8)

As mbedtls is the only ECDSA implementation in libcose, it wouldn't run against common test vectors. Has this been tested against any external COSE implementation yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant