ANSSI-FR / MLA

Multi Layer Archive - A pure rust encrypted and compressed archive file format
GNU Lesser General Public License v3.0
330 stars 20 forks source link

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

Closed commial closed 3 months ago

commial commented 4 months ago

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 commented 3 months ago

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