PKCS#8 or a raw key: which format does your post-quantum private key use?
When a vendor, library or tender names a key format, the question is whether the private key arrives inside a PKCS#8 wrapper or as raw bytes. PKCS#8, now defined as OneAsymmetricKey in RFC 5958, wraps the private key with an algorithm identifier, so a parser can tell which algorithm the key belongs to. Raw formats store the algorithm's key bytes directly with no wrapper, so the algorithm is known only from context. The key format each post-quantum algorithm uses is set by its own RFC, not by PKCS#8 alone, so the same algorithm name can map to different byte layouts in different documents.
PKI engineers, platform engineers and security engineers meet this question at key import, during interoperability testing between products, and when a library upgrade changes the default output. Vendor-risk reviewers meet it in questionnaires asking whether keys are stored in PKCS#8. The answer depends on the algorithm, the RFC and the library version, so confirm it for the exact versions you run.
For ML-DSA, RFC 9881 defines the private key as a CHOICE of a 32-byte seed, an expanded key, or both, and recommends the seed. A recipient should check that a seed and expanded key in the both form are consistent and must reject the key if they are not. For ML-KEM, RFC 9935 defines a DER CHOICE with a 64-octet seed, an expanded key, or both, and says parsers should identify the variant by tag and not by length. For JOSE and COSE, RFC 9964 uses no PKCS#8 wrapper: the priv parameter must be the 32-byte seed. OpenSSL 3.5 accepts several PKCS#8 input formats for ML-DSA and ML-KEM by default, so a key that imports cleanly in one tool may fail in another. Check the ml-dsa.input_formats setting in your OpenSSL build before you rely on it.
A draft, draft-rosomakho-lamps-mldsa-mlkem-seed-only-00, proposes that the 32-octet seed be the only exchanged form and would deprecate the expanded forms. It has not been adopted, so treat it as a signal to watch, not a requirement. Ask your vendor which key formats they import and export, whether they accept the legacy bare formats, and what changed in each library release.
PKCS#8 and raw key formats side by side, attribute by attribute
This table compares the PKCS#8 wrapper with the raw key forms that post-quantum specifications use, one attribute per row. Read each row across to see what the container is, which document defines it, which fields it holds and where a raw form replaces the wrapper. The main takeaway is that ML-DSA in JOSE and COSE and SLH-DSA in PKCS#8 store their keys in different ways, so confirm the format each library and protocol expects before exchanging keys.
| Attribute | PKCS#8 (OneAsymmetricKey) | Raw key form |
|---|---|---|
| Container | ASN.1 structure that wraps the algorithm OID and the algorithm-specific private key bytes | Bytes stored directly, with no ASN.1 wrapper around the key material |
| Defining document and date | RFC 5958, August 2010, Proposed Standard, obsoleting RFC 5208 | RFC 9909 for SLH-DSA, RFC 9964 for JOSE and COSE ML-DSA, both defined in the RFC series |
| Fields held | Version, privateKeyAlgorithm OID, privateKey OCTET STRING, optional attributes, optional publicKey | The key bytes alone, such as the 32-byte ML-DSA seed in the priv member of a JWK |
| Version rule | v1 without publicKey, v2 when publicKey is present | Not applicable, because the format has no version field |
| PEM label | PRIVATE KEY when unencrypted, ENCRYPTED PRIVATE KEY when wrapped in EncryptedPrivateKeyInfo (RFC 7468) | No PEM label defined by these sources, so confirm the encoding the receiving system expects |
| Private key contents for ML-DSA | CHOICE of a 32-byte seed (tag [0]), an expandedKey, or both, with the seed recommended (RFC 9881) | Raw 32-byte seed only, required in the priv parameter (RFC 9964) |
| Private key contents for SLH-DSA | OneAsymmetricKey whose privateKey is the raw concatenation SK.seed, SK.prf, PK.seed and PK.root, totaling 4n bytes (RFC 9909) | Not applicable, because RFC 9909 uses the PKCS#8 wrapper for SLH-DSA |
| Private key contents for ML-KEM | CHOICE of a 64-octet seed, an expandedKey, or both as a SEQUENCE (RFC 9935) | Raw 32-byte seed inside the composite component (RFC 10073) |
What PKCS#8 and raw key formats are, and where practitioners meet them
PKCS #8 is a container format for private keys. RFC 5958 defines the OneAsymmetricKey structure, which replaces the PrivateKeyInfo name used in RFC 5208 and obsoletes that earlier document. A OneAsymmetricKey carries a version, a privateKeyAlgorithm identifier, a privateKey OCTET STRING whose internal layout depends on the algorithm, optional attributes, and an optional publicKey field that is present in version 2. The encrypted form, EncryptedPrivateKeyInfo, wraps the encoded key in an encryption algorithm and encrypted data. RFC 7468 assigns PEM labels to these forms, so an unencrypted key appears as PRIVATE KEY and an encrypted one as ENCRYPTED PRIVATE KEY.
- Defining document: RFC 5958 for the structure, with RFC 7468 governing the PEM labels.
- Where it appears: key files exported by general-purpose libraries and tools that write PEM output.
- Algorithm-specific payload: for SLH-DSA, RFC 9909 stores the concatenated SK.seed, SK.prf, PK.seed and PK.root inside the privateKey field, totaling 4n bytes.
- Seed inside the wrapper: OpenSSL 3.5 accepts several PKCS #8 input layouts for ML-KEM and ML-DSA, including seed-only and priv-only forms, and the ml-dsa.input_formats setting limits which are accepted.
- Legacy forms: some ML-KEM inputs without ASN.1 wrapping are still accepted by OpenSSL 3.5 by default.
Before relying on a file, confirm the library version and the input formats it accepts, since parsers may differ on which layouts they read.
Raw formats carry the seed or key bytes directly, without an ASN.1 wrapper around them. In JOSE and COSE, RFC 9964 defines ML-DSA keys in which the priv member holds the raw 32-byte seed inside a JWK or COSE_Key, and the document requires the seed as the only private key format. RFC 10073 states that the ML-DSA component of a composite private key is a 32-byte seed. RFC 9980 lists secret key sizes for OpenPGP components, including 32 octets for ML-DSA-65 and ML-DSA-87 and 64 octets for ML-KEM-768 and ML-KEM-1024.
- Defining documents: RFC 9964 for JOSE and COSE, RFC 10073 for composite components, and RFC 9980 for OpenPGP sizes.
- Where it appears: JWK and COSE_Key objects, composite key components, and OpenPGP key material.
- Seed-only proposal: draft-rosomakho-lamps-mldsa-mlkem-seed-only-00 would require the 32-octet seed for ML-DSA and ML-KEM exchange and deprecate the expanded and both forms if approved. It is an Internet-Draft dated 21 October 2026 that has not been adopted.
- Seed-only in X.509: RFC 9881 and RFC 9935 recommend the seed for ML-DSA and ML-KEM private keys, while still allowing the expanded form.
- Consistency checks: where a key carries both a seed and an expanded form, RFC 9881 says the recipient should confirm they match and must reject the key if they do not.
Before accepting a raw key, check which parameter set and seed length the consuming system expects, because a key of the wrong size fails silently in some toolchains.
The choice between a wrapped container and a raw value is usually set by the protocol or the tool that consumes the key, not by the team storing it. A certificate workflow that produces PEM files will often expect PKCS #8, while a token or JOSE library will expect the raw seed. Mixing the two is a common source of failures, because a file may parse in one tool and be rejected by another. The sources describe these as separate encodings for the same underlying key material, and they do not establish that one is stronger than the other.
- Match the consumer: identify the format each library, token or verifier accepts before generating keys.
- Check version support: confirm the exact library release, since OpenSSL 3.5 is the release that added ML-KEM, ML-DSA and SLH-DSA.
- Track the seed-only direction: monitor the status of the seed-only draft before fixing a long-term storage format.
- Confirm encryption handling: an EncryptedPrivateKeyInfo file needs a passphrase or key management step that a raw key may not.
- Record the format: note the container and the parameter set in key inventory records so that later migrations can read the file.
Ask each vendor or library maintainer which formats they accept for import and export, and request a test file for the parameter sets in use.
Six differences in how the two formats store a post-quantum key
PKCS#8 and the raw key formats both hold a post-quantum private key, but they store it in different structures. The cards below cover what changes for systems that generate, move, encrypt, parse or audit those keys, and what to confirm before you rely on one format.
Algorithm identifier wrapper or none
A PKCS#8 container carries a privateKeyAlgorithm identifier that names the algorithm, so a parser can read the key type from the structure itself. Raw key formats for some post-quantum algorithms omit that wrapper and rely on the surrounding protocol or file type to name the algorithm. Confirm which form your tooling emits and which form it expects, because a parser built for one will not necessarily read the other.
RFC 5958 textPrivate key field content set by algorithm
Inside a OneAsymmetricKey, the privateKey field is an OCTET STRING whose contents depend on the algorithm. For ML-DSA, RFC 9881 allows a 32-byte seed, an expanded key, or both, and recommends the seed. For SLH-DSA, RFC 9909 stores the raw concatenation of four values. Two keys for the same algorithm can therefore have different lengths and layouts, so check the length and form before passing a key to another system.
RFC 9881 textOptional public key makes version 2
A OneAsymmetricKey carries an optional publicKey BIT STRING. When it is present, the structure is version 2 rather than version 1. A system that accepts only version 1 will reject a key that includes the public key, even when the private key is valid. Check the version your consumers support and whether your export step includes the public key.
Encryption covers the whole container
An EncryptedPrivateKeyInfo places an encryptionAlgorithm and an encryptedData OCTET STRING around the encoded PrivateKeyInfo, so the whole structure is protected together. Raw formats that are encrypted usually protect only the bytes of the serialized key. Passphrase handling, key derivation and the PEM label your tools expect, ENCRYPTED PRIVATE KEY or PRIVATE KEY, all differ between the two, so confirm each step during migration.
RFC 7468 textSeed or expanded form set by standard
The seed and expanded forms of a post-quantum private key differ in size and in what a recipient must check. RFC 9881 says a recipient should verify that a seed and an expanded key in the both form are consistent and must reject the key if they are not. RFC 9964 for JOSE and COSE allows only the 32-byte seed. Which forms you may store or accept depends on the standard that governs your protocol, so confirm it before you choose a format.
Parser detection of input formats
OpenSSL 3.5.0 accepts several PKCS#8 input formats for ML-KEM and ML-DSA by default, including bare forms that omit the ASN.1 wrapping. The ml-dsa.input_formats setting limits which of these are accepted. A key that loads in one tool may fail in another, or load in a form you did not intend, so test each key format against every system that will read it.
OpenSSL ML-DSA docsWhere PKCS#8 and raw private keys appear in practice
Most post-quantum private keys that engineers will handle come in one of two shapes: a PKCS #8 container, which wraps the key in the OneAsymmetricKey structure defined in RFC 5958, or a raw key, where the algorithm's own bytes sit directly in a format-specific field. Which shape you meet depends on the file, library or protocol in front of you. Before deploying, confirm which form each component in your chain produces and which it accepts, because a file that one tool writes may be rejected by another. OpenSSL 3.5.0, released on 8 April 2025, added ML-KEM, ML-DSA and SLH-DSA, and its documentation lists several accepted PKCS #8 input formats for each. The ml-dsa.input_formats setting limits which of those formats the library accepts, so check it when importing keys from other tools.
Private keys for ML-DSA and ML-KEM appear in X.509 and CMS contexts in different forms. RFC 9881, published in October 2025, defines ML-DSA private keys as a CHOICE of a 32-byte seed, an expanded key, or both, and recommends the seed form. RFC 9935, published in March 2026, defines ML-KEM private keys the same way, with a 64-octet seed as the most compact option. In both cases a recipient that receives the both form must check that the seed and expanded key agree and reject the key if they do not. In JOSE and COSE, RFC 9964 takes a different route: the priv parameter of a JWK or COSE_Key holds the raw 32-byte seed with no PKCS #8 wrapper, and RFC 9964 requires that form. Software that round-trips keys between these formats should be tested on both sides.
SLH-DSA and composite formats add their own layouts. RFC 9909 stores an SLH-DSA private key in a OneAsymmetricKey whose privateKey field is the raw concatenation of SK.seed, SK.prf, PK.seed and PK.root, totaling 4n bytes, where n is 16, 24 or 32. For composite signatures, RFC 10073 states that the ML-DSA component of a composite private key is a 32-byte seed, and RFC 9980 gives the OpenPGP secret key sizes for ML-DSA and ML-KEM components. An open Internet-Draft, draft-rosomakho-lamps-mldsa-mlkem-seed-only-00, proposes requiring the seed form and deprecating the expanded forms, but it has not been adopted and would update RFC 9881 and RFC 9935 only if approved. Confirm the status of that draft and the exact version of each library in your environment before relying on any single format.
How to work out which private key format your system needs
This sequence tells you which private key container your system expects, whether the key is wrapped or raw, and whether your library and vendor accept the same format. Working through it before a migration prevents import failures and mismatched keys between components.
Identify the algorithm and parameter set
Start by confirming which algorithm and parameter set your key uses: ML-DSA-65, ML-KEM-768, SLH-DSA, or another variant. The parameter set determines the expected key sizes and the structure the standard defines. Check the key generation settings, the configuration file, or the vendor's key inventory. You are done when you can name the algorithm and parameter set for every key in scope, using the names from NIST FIPS 203 and FIPS 204 or the SLH-DSA standard.
Check the format defined for that algorithm
Find the RFC or vendor document that defines the private key format for your algorithm and protocol. For X.509 certificates, RFC 9881 covers ML-DSA and RFC 9935 covers ML-KEM. For CMS, RFC 9882 applies. For JOSE and COSE, RFC 9964 applies, and for SLH-DSA keys in a OneAsymmetricKey, RFC 9909 applies. Note which private key forms each document allows, such as a seed, an expanded key, or both. You are done when you have written down the permitted forms for your protocol.
Inspect the key file for wrapping
Open the key file in a text editor or use an ASN.1 dump tool to see whether the key is wrapped. A PEM label of PRIVATE KEY indicates an unencrypted PKCS #8 OneAsymmetricKey, and ENCRYPTED PRIVATE KEY indicates an encrypted wrapper, as RFC 5958 and RFC 7468 describe. A raw key will not show an ASN.1 structure with an algorithm OID. You are done when you can state, for each key file, whether it is wrapped and which label or structure it uses.
Check library version and input format settings
Confirm the library version your system runs and the input formats it accepts for the algorithm. OpenSSL 3.5.0 added ML-KEM, ML-DSA and SLH-DSA, and it accepts several PKCS #8 input formats by default. The ml-dsa.input_formats setting limits which of those formats are accepted, so check it in the configuration. Record the version and the setting for each service that loads keys. You are done when you have the exact version string and the list of accepted input formats for each library.
Test a key import in a non-production environment
Import a test key of the same algorithm and parameter set into a non-production copy of the system. Use a key generated for the test, not a production key. Check that the library loads it, signs or decapsulates a test message, and that the peer accepts the result. If the import fails, compare the failure with the input formats recorded in the previous step. You are done when the import and one round trip complete without error in the test environment.
Ask the vendor which formats it accepts and emits
Send the vendor a written question asking which private key formats it accepts on import and which it emits on export, including whether it supports seed-only storage for ML-DSA and ML-KEM. Ask which version each answer applies to. Note that the seed-only approach is still an Internet-Draft and not an adopted standard, so ask whether the vendor plans to support it. You are done when you hold a written answer for each component in scope.
Common mix-ups between PKCS#8 and raw private key formats
Several of the most common errors with post-quantum private keys come from reading one term as another: a container read as an algorithm, a seed read as an expanded key, or a PEM label read as a format. The cards below set out what the sources say about each mix-up and what to check before a key is stored, exchanged or accepted.
PKCS#8 is a container, not an algorithm
PKCS #8 defines a wrapper: in RFC 5958 the OneAsymmetricKey structure holds a privateKeyAlgorithm OID and a privateKey OCTET STRING whose format depends on that algorithm. A file in PKCS#8 form therefore says nothing about which post-quantum algorithm produced it until the OID is read. Check the OID, then check the privateKey contents against the algorithm's own specification.
RFC 5958 textSeed and expanded key are different bytes
For ML-DSA, RFC 9881 defines the private key as a CHOICE: a 32-byte seed, an expandedKey of 2560, 4032 or 4896 bytes for ML-DSA-44, -65 and -87, or both. The seed and the expanded key are not the same bytes, and the recommended form is the seed. Confirm which form a tool emits before comparing key lengths or moving keys between systems.
RFC 9881 textThe PEM label is not the key format
RFC 7468 gives unencrypted PKCS #8 the PEM label PRIVATE KEY and encrypted PKCS #8 the label ENCRYPTED PRIVATE KEY. The label describes the wrapper only. A PRIVATE KEY block can hold an SLH-DSA key in the raw-concatenation form of RFC 9909, or another algorithm's key, so read the algorithm OID and the inner structure rather than trusting the label.
RFC 7468 textInput acceptance is not output form
OpenSSL 3.5 accepts six PKCS#8 input formats for ML-DSA and several for ML-KEM, including legacy bare forms without ASN.1 wrapping. Accepting a format on input does not mean the library writes that same form on output. Test the export path of your own tooling and check the ml-dsa.input_formats setting before assuming round-trip consistency.
OpenSSL ML-DSA docsPKCS#8 support does not cover every format
RFC 9964 uses no PKCS #8 wrapper for JOSE and COSE ML-DSA keys: the priv member holds the raw 32-byte seed inside a JWK or COSE_Key. RFC 10073 also describes the ML-DSA component of a composite as a 32-byte seed. A vendor statement of PKCS#8 support therefore does not show whether JOSE, COSE or composite key formats are handled, so ask for each format by name.
RFC 9964 textQuestions about PKCS#8 and raw private key formats
Are PKCS#8 and raw private keys the same thing?
No. PKCS #8 is a wrapper: it is an ASN.1 structure, now defined as OneAsymmetricKey in RFC 5958, that records the algorithm identifier and then carries the private key inside it. A raw key is the bare key bytes with no such outer structure. The two can hold the same underlying material, but the wrapper adds an algorithm OID and a container around it, so a parser needs to know which form it has received. RFC 5958 obsoletes RFC 5208 and renames the structure from PrivateKeyInfo to OneAsymmetricKey. For the ML-DSA and ML-KEM encodings, the sources describe the privateKey field as holding a format that depends on the algorithm, so the wrapper does not fix what the inner bytes look like.
Which key format does a standard require for ML-DSA or ML-KEM?
The answer depends on the protocol. RFC 9881 defines the ML-DSA private key as a CHOICE of a 32-byte seed, an expanded key, or both, and it recommends the seed form. RFC 9935 defines the ML-KEM private key as a DER CHOICE of a 64-octet seed, an expanded key, or both, and calls the seed the most compact option. RFC 9964 for JOSE and COSE uses only the seed: the priv parameter must be the 32-byte seed. The sources do not say that a PKCS #8 wrapper is mandatory for these algorithms. Confirm the format each specification and library requires for the exact parameter set you deploy, since the expanded key sizes differ between ML-DSA-44, -65 and -87.
Does a system need both a seed and an expanded key?
Usually not. RFC 9881 and RFC 9935 both allow a private key to carry the seed, the expanded key, or both. Where both are present, RFC 9881 says a recipient should check that the seed and expanded key are consistent and must reject the key if they are not. Storing both also increases the size of what has to be protected. The draft draft-rosomakho-lamps-mldsa-mlkem-seed-only-00, dated 21 October 2026 and not adopted, would require the 32-octet seed for exchanged ML-DSA and ML-KEM private keys and would deprecate the expanded and both forms if approved. Treat that as a proposal only and check the current status before relying on it.
What does the PEM label tell you about a private key?
The PEM label names the container. RFC 7468 gives an unencrypted PKCS #8 key the label PRIVATE KEY, and an encrypted one the label ENCRYPTED PRIVATE KEY. A label of PRIVATE KEY therefore indicates a PKCS #8 wrapper, but it does not tell you which algorithm is inside or whether the inner bytes are a seed or an expanded key. You must read the algorithm OID and the privateKey contents to find out. Key files may also use other labels or no wrapper at all, so check the file itself rather than relying on the label alone. Ask any vendor which labels and inner formats its tooling reads and writes.
Why do libraries accept several private key input forms?
Post-quantum key handling has changed during standardization, so libraries have supported more than one encoding. OpenSSL 3.5.0, released on 8 April 2025, accepts six PKCS #8 input formats for ML-DSA, and the ml-dsa.input_formats setting limits which are accepted. For ML-KEM it accepts seed-priv, seed-only, priv-only, and legacy oqskeypair, bare-seed and bare-priv forms that omit the ASN.1 wrapping by default. Accepting several forms helps interoperation with older keys, but each accepted form is a parsing path to test. Restrict accepted formats to the ones your deployment needs, and confirm the behavior for the OpenSSL version you run.
What should I ask a vendor about the private key format it supports?
Ask which private key forms it reads and writes for each algorithm: a PKCS #8 wrapper, a raw seed, an expanded key, or both. Ask whether it accepts legacy or bare encodings and whether that can be disabled. Ask which specification and version it follows, such as RFC 9881, RFC 9935 or RFC 9964 for the relevant parameter set. Ask how it stores and protects keys, including whether a seed-only policy is supported, and how it checks consistency when both forms are present. Request the exact version and a test showing the format it produces. Ask for the vendor's own documentation, since the sources listed here do not say how any product implements these formats.
How DeployOpen works on this
DeployOpen treats the private key container as part of the migration scope, because PKCS #8 wrappers, raw seeds and expanded keys are stored and read differently by each library and deployment. We scope, build, document and support the key handling for the specific algorithms and software versions your systems run, so the format choices are confirmed in your own environment before you rely on them.
How we scope
- We inventory where private keys for ML-KEM, ML-DSA and SLH-DSA are generated, stored, exported and imported across your systems.
- The written scope names the key formats each component reads and writes, including any PKCS #8 wrapping or raw seed handling.
- Engagements are fixed-scope, so the key format questions and the components they touch are agreed in writing before work starts.
How we build
- We configure key generation and import settings for the libraries in use, checking which input formats each version accepts by default.
- Where a component can store a seed or an expanded key, we set the storage form explicitly and document the choice in the configuration.
- We test that keys round-trip correctly between components and that the recipient rejects keys whose seed and expanded forms disagree.
How we hand over
- You receive the configuration, the key format decisions and the reasons for them, written for your security and platform teams.
- The handover lists each key file and container type in use, so reviewers can check it against the standards the components follow.
- We document how to confirm compatibility for the versions you run, since specification support varies between libraries and releases.
How we support
- Ongoing support is available as a retainer, covering library upgrades that change accepted key formats or default behavior.
- We retest key import and export paths after each upgrade, so format changes are caught before they reach production systems.
- Continuous testing can be added to the retainer, so each change to key handling is checked against the documented configuration.

