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

Some algorithm identifiers are not correctly encoded #361

Open
RonEld opened this issue Feb 6, 2020 · 2 comments
Open

Some algorithm identifiers are not correctly encoded #361

RonEld opened this issue Feb 6, 2020 · 2 comments

Comments

@RonEld
Copy link
Contributor

RonEld commented Feb 6, 2020

Description

Raised in the forum by Michal Kochel:

I think there is an error in function mbedtls_asn1_write_algorithm_identifier (library\asn1write.c).
Depending on par_len it encodes par_len or NULL. But there is a third option.
If we look at https://tools.ietf.org/html/rfc7427#page-14 there are some algorithm identifiers which do not have parameter and NULL should not be placed.

We can see this problem when comparing what OpenSSL and Mbed TLS produces.

Mbed TLS produces following ASN.1

10:d=3 hl=2 l= 1 prim: INTEGER :00
13:d=2 hl=2 l= 3 prim: INTEGER :652040
18:d=2 hl=2 l= 12 cons: SEQUENCE
20:d=3 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
30:d=3 hl=2 l= 0 prim: NULL
32:d=2 hl=2 l= 53 cons: SEQUENCE

OpenSSL produces following ASN.1

4:d=1 hl=4 l= 279 cons: SEQUENCE
8:d=2 hl=2 l= 3 prim: INTEGER :652040
13:d=2 hl=2 l= 10 cons: SEQUENCE
15:d=3 hl=2 l= 8 prim: OBJECT :ecdsa-with-SHA256
25:d=2 hl=2 l= 53 cons: SEQUENCE
27:d=3 hl=2 l= 11 cons: SET

Problem was found when I wanted to create a CA certificate and an endpoint certificate (both with keys based on elliptic curves).
When CA certificate was created with RSA key, everything was correct.
There was no problem when endpoint certificate had key based on elliptic curves.
When I used keys based on elliptic curves with CA certificate Chrome reported NET::ERR_CERT_INVALID during SSL_do_handshake.

Issue request type

[ ] Question
[ ] Enhancement
[x ] Bug
@ciarmcom
Copy link
Member

ciarmcom commented Feb 6, 2020

Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-1046

@mkochel
Copy link

mkochel commented Apr 3, 2020

When can we expect correction of this bug?

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

No branches or pull requests

3 participants