Skip to content

Add other MLDSA test vectors#14470

Open
DarkaMaul wants to merge 2 commits intopyca:mainfrom
trail-of-forks:dm/mldsa-vectors
Open

Add other MLDSA test vectors#14470
DarkaMaul wants to merge 2 commits intopyca:mainfrom
trail-of-forks:dm/mldsa-vectors

Conversation

@DarkaMaul
Copy link
Contributor

For testing certain codepaths for unsupported key sizes and key serialization, we need some extra vectors.

Extracted from #14404 per @alex's comment.

encrypted with ``pbeWithSHA1And128BitRC4``. The password is ``password``.
* ``asymmetric/PKCS8/enc-rsa-pkcs8-pbkdf2-0iter.pem`` a PKCS8 encoded
structure with an invalid PBKDF2 iteration count (zero).
* ``asymmetric/MLDSA/mldsa44_pub.der`` and ``asymmetric/MLDSA/mldsa44_priv.der``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mldsa44_priv.der appears to contain both seed and pub/priv so this is the OpenSSL "kitchen sink" format I think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I decode it I see this, which only contains the seed?

The OCTET STRING has tag 0, which should mean that it's the seed variant from the ML-DSA-44-PrivateKey CHOICE:

ML-DSA-44-PrivateKey ::= CHOICE {
  seed [0] OCTET STRING (SIZE (32)),
  expandedKey OCTET STRING (SIZE (2560)),
  both SEQUENCE {
      seed OCTET STRING (SIZE (32)),
      expandedKey OCTET STRING (SIZE (2560))
      }
  }

structure with an invalid PBKDF2 iteration count (zero).
* ``asymmetric/MLDSA/mldsa44_pub.der`` and ``asymmetric/MLDSA/mldsa44_priv.der``
a PKCS8 encoded key pair for ML-DSA-44 generated by OpenSSL.
* ``asymmetric/MLDSA/mldsa65_noseed_priv.der`` a PKCS8 encoded ML-DSA-65 private
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to have serialized nothing:

SEQUENCE {
  INTEGER { 0 }
  SEQUENCE {
    # ml-dsa-65
    OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.3.18 }
  }
  OCTET_STRING {
    SEQUENCE {}
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's intended, it's for a test for an invalid key:

def generate_mldsa65_noseed(output_dir: str) -> None:
    # ML-DSA-65 OID: 2.16.840.1.101.3.4.3.18
    # Generate an ML-DSA-65 PKCS#8 key whose inner privateKey is an
    # empty SEQUENCE (0x30 0x00) — i.e. the "both" SEQUENCE form with
    # no seed present. This exercises the InvalidKey error path in the
    # Rust parser when seed is None.

(from the script used to generate it)

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants