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

key_app_writer writes wrong public key in der format #1257

Closed
RonEld opened this Issue Jan 7, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@RonEld
Contributor

RonEld commented Jan 7, 2018

Description

  • Type: Bug
  • Priority: Minor
    Reported in the support forum by Aryeh R.

Bug

OS
linux|windows

mbed TLS build:
Version: development
OS version: Ubuntu16.04 and windows10 (irrelevant in this bug)

Expected behavior
parsing the created public key should pass
Actual behavior
parsing the created der public key fails with error -0x3d62
Steps to reproduce

  • Generate a key pair
  • use key_app_writer to write a public key in der format
  • try parsing the public key
./gen_key type=rsa rsa_keysize=4096 filename=rsa_4096_private.der format=der
./key_app_writer mode=private filename=rsa_4096_private.der output_mode=public output_format=der output_file=rsa_4096_public.der
./key_app mode=public filename=rsa_4096_public.der

I believe the bug is here
The - 1 is redundant. It adds a leading zero byte, which causes a failure in the ASN1 parsing, as it is not the expected tag.

RonEld added a commit to RonEld/mbedtls that referenced this issue Jan 7, 2018

remove additional zero byte when writing pub der
Remove `- 1` for setting location of output buffer,
which added a leading zero which cause failure in ASN1 parsing.
Fixes ARMmbed#1257
@ciarmcom

This comment has been minimized.

Member

ciarmcom commented Jan 7, 2018

ARM Internal Ref: IOTSSL-1991

@ciarmcom ciarmcom added the mirrored label Jan 7, 2018

@RonEld RonEld added the fix available label Jan 8, 2018

RonEld added a commit to RonEld/mbedtls that referenced this issue Jun 26, 2018

remove additional zero byte when writing pub der
Remove `- 1` for setting location of output buffer,
which added a leading zero which cause failure in ASN1 parsing.
Fixes ARMmbed#1257

RonEld added a commit to RonEld/mbedtls that referenced this issue Jun 26, 2018

remove additional zero byte when writing pub der
Remove `- 1` for setting location of output buffer,
which added a leading zero which cause failure in ASN1 parsing.
Fixes ARMmbed#1257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment