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

Introduce "mlakey-parser" for ASN.1 MLA key import & export #215

Merged
merged 18 commits into from
Aug 2, 2024

Conversation

commial
Copy link
Contributor

@commial commial commented Jul 30, 2024

Partially fix #195

This PR introduces mlakey-parser in replacement of the crate curve25519-parser.
Indeed, the new hybrid key uses more than a curve 25519 key.

This PR updates the others crates to use the new MLA key format, and add some test key for tests.

A few notes:

The format used to serialize the private key in ASN.1 is the following:

    0:d=0  hl=4 l=3239 cons: SEQUENCE          
    4:d=1  hl=2 l=  46 cons:  SEQUENCE          
    6:d=2  hl=2 l=   1 prim:   INTEGER           :00
    9:d=2  hl=2 l=   5 cons:   SEQUENCE          
    11:d=3  hl=2 l=   3 prim:    OBJECT            :X25519
    16:d=2  hl=2 l=  34 prim:   OCTET STRING      [HEX DUMP]:...
    52:d=1  hl=4 l=3187 cons:  SEQUENCE          
    56:d=2  hl=2 l=   1 prim:   INTEGER           :01
    59:d=2  hl=2 l=  10 cons:   SEQUENCE          
    61:d=3  hl=2 l=   8 prim:    OBJECT            :1.2.250.1.223.201
    71:d=2  hl=4 l=3168 prim:   OCTET STRING      [HEX DUMP]:...

Or, as a tree:

Seq(
    Seq(
        Int,
        Seq(
            OID(1.3.101.112), // ED25519 OR OID(1.3.101.110), // X25519
        ),
        OctetString(TAG_OCTETSTRING + LENGTH + DATA),
    ),
    Seq(
        Int,
        Seq(
            OID(1.2.250.1.223.201)
        ),
        OctetString(private key)
    )
)

The two main sequence can be inverted: starting from the MLKEM, then the X/Ed25519 key.

@commial commial added mlar Concerns the mlar utility tests Relative to the testing capabilities refactoring Code refactoring labels Jul 30, 2024
@commial commial added this to the Format v2 milestone Jul 30, 2024
@commial commial force-pushed the mlakey-parser branch 2 times, most recently from 34ea974 to 27c0c52 Compare August 2, 2024 09:32
@commial
Copy link
Contributor Author

commial commented Aug 2, 2024

The last C bindings test is failing due to the use of archive_v1.mla, which is expected

@commial commial merged commit 7403923 into formatv2 Aug 2, 2024
21 of 33 checks passed
@commial commial deleted the mlakey-parser branch August 2, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlar Concerns the mlar utility refactoring Code refactoring tests Relative to the testing capabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant