Skip to content

Key Management & CSR Operations

This guide covers private key generation, management, and Certificate Signing Request (CSR) operations.

A private key is the cryptographic secret used for signing or decryption. QPKI supports classical (ECDSA, RSA, Ed25519) and post-quantum (ML-DSA, SLH-DSA, ML-KEM) algorithms.

TypePurposeAlgorithms
SignatureSign certificates, CMS, OCSPECDSA, Ed25519, RSA, ML-DSA, SLH-DSA
Key EncapsulationEncrypt session keysML-KEM

A Certificate Signing Request (CSR) is a message sent to a CA to request a certificate. It contains the public key and subject information, signed by the corresponding private key.

QPKI stores private keys in PEM format (Base64-encoded with headers):

-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg...
-----END PRIVATE KEY-----
FormatExtensionDescription
PEM.pem, .keyBase64 with headers (default)
DER.derBinary ASN.1
PKCS#8.p8Standardized private key format

Encrypted keys use PKCS#8 encryption:

-----BEGIN ENCRYPTED PRIVATE KEY-----
...
-----END ENCRYPTED PRIVATE KEY-----

Use qpki key convert to change formats or add passphrase protection.


Generate a private key file.

The output file contains the private key in PEM format. The public key is mathematically derived from the private key and is not stored separately. To extract the public key, use qpki key pub.

Terminal window
qpki key gen [flags]

Flags:

FlagShortDefaultDescription
--algorithm-aecdsa-p256Key algorithm
--out-orequiredOutput key file
--passphrase""Key passphrase

Algorithms:

AlgorithmDescriptionSecurity
ecdsa-p256ECDSA with NIST P-256 curve~128-bit
ecdsa-p384ECDSA with NIST P-384 curve~192-bit
ecdsa-p521ECDSA with NIST P-521 curve~256-bit
ed25519Edwards-curve DSA~128-bit
rsa-2048RSA 2048-bit~112-bit
rsa-4096RSA 4096-bit~140-bit
ml-dsa-44ML-DSA (Dilithium) Level 1NIST Level 1
ml-dsa-65ML-DSA (Dilithium) Level 3NIST Level 3
ml-dsa-87ML-DSA (Dilithium) Level 5NIST Level 5

Examples:

Terminal window
# ECDSA P-256 key (default)
qpki key gen --algorithm ecdsa-p256 --out key.pem
qpki key gen --algorithm ed25519 --out ed25519.key
qpki key gen --algorithm ml-dsa-65 --out pqc.key
qpki key gen --algorithm ecdsa-p384 --out secure.key --passphrase "secret"

Extract the public key from a private key file.

Terminal window
qpki key pub [flags]

Flags:

FlagShortDefaultDescription
--key-krequiredInput private key file
--out-orequiredOutput public key file
--passphrase""Passphrase for encrypted key

Examples:

Terminal window
# Extract public key from ECDSA key
qpki key pub --key private.pem --out public.pem
qpki key pub --key encrypted.key --passphrase "secret" --out public.pem
qpki key pub --key mldsa.key --out mldsa.pub

List private keys in a directory or HSM token.

Terminal window
qpki key list [flags]

Flags:

FlagShortDefaultDescription
--dir-d.Directory to scan
--hsm-configHSM configuration file

Examples:

Terminal window
# List keys in directory
qpki key list --dir ./keys
qpki key list --hsm-config ./hsm.yaml

Display information about a private key file or HSM key.

Terminal window
qpki key info [key-file] [flags]

Flags:

FlagShortDefaultDescription
--passphrase-p""Passphrase for encrypted key
--hsm-configHSM configuration file
--key-labelHSM key label (CKA_LABEL)

Examples:

Terminal window
# File-based key
qpki key info private.key
# Encrypted key
qpki key info encrypted.key --passphrase secret
# HSM key (query by label)
export HSM_PIN="****"
qpki key info --hsm-config ./hsm.yaml --key-label "my-key"

When querying HSM keys, the output shows all keys matching the label, including key ID, algorithm, and capabilities.

Convert a private key to a different format.

Terminal window
qpki key convert [flags]

Flags:

FlagShortDefaultDescription
--key-krequiredInput key file
--out-orequiredOutput key file
--format-fpemOutput format: pem, der, pkcs8
--passphrase""Passphrase for input key
--out-passphrase""Passphrase for output key

Examples:

Terminal window
# Convert PEM to DER
qpki key convert --key private.pem --out private.der --format der
qpki key convert --key private.pem --out encrypted.pem --out-passphrase "secret"

Generate a Certificate Signing Request (CSR) for submission to a CA.

Terminal window
qpki csr gen [flags]

Flags:

FlagShortDefaultDescription
--algorithm-a""Key algorithm for new key
--keyout""Output file for new private key
--key""Existing private key file
--passphrase""Passphrase for existing key
--key-passphrase""Passphrase for new key
--out-orequiredOutput CSR file
--cnrequiredCommon Name
--org-O""Organization
--country-C""Country (2-letter code)
--dns[]DNS SANs
--email[]Email SANs
--ip[]IP SANs
--hybrid""PQC algorithm for hybrid CSR
--hybrid-keyout""Output file for hybrid PQC key
--attest-cert""Attestation certificate (RFC 9883)
--attest-key""Attestation private key (RFC 9883)

Modes:

ModeDescriptionCommand
ClassicalRSA, ECDSA, Ed25519 via Go x509--algorithm ecdsa-p256
PQC SignatureML-DSA, SLH-DSA (custom PKCS#10)--algorithm ml-dsa-65
PQC KEMML-KEM with RFC 9883 attestation--algorithm ml-kem-768 --attest-cert ...
CatalystITU-T X.509 dual signatures--algorithm ecdsa-p384 --hybrid ml-dsa-87
CompositeIETF draft-13 combined signature--algorithm ecdsa-p384 --composite ml-dsa-87

Examples:

Terminal window
# Classical ECDSA CSR
qpki csr gen --algorithm ecdsa-p256 --keyout server.key \
--cn server.example.com --dns server.example.com --out server.csr
qpki csr gen --algorithm ml-dsa-65 --keyout mldsa.key \
--cn alice@example.com --out mldsa.csr
# (requires an existing signature certificate for attestation)
qpki csr gen --algorithm ml-kem-768 --keyout kem.key \
--cn alice@example.com \
--attest-cert sign.crt --attest-key sign.key \
--out kem.csr
qpki csr gen --algorithm ecdsa-p384 --hybrid ml-dsa-87 \
--keyout classical.key --hybrid-keyout pqc.key \
--cn example.com --out catalyst.csr
qpki csr gen --algorithm ecdsa-p384 --composite ml-dsa-87 \
--keyout classical.key --hybrid-keyout pqc.key \
--cn example.com --out composite.csr
qpki csr gen --key existing.key --cn server.example.com --out server.csr

Catalyst Combinations (—algorithm + —hybrid):

Creates a CSR with dual signatures per ITU-T X.509 (2019) Section 9.8. Both classical and PQC signatures are independent, allowing backward compatibility.

—algorithm—hybridSecurity Level
ecdsa-p256ml-dsa-44, ml-dsa-65128-bit
ecdsa-p384ml-dsa-65, ml-dsa-87192-bit
ecdsa-p521ml-dsa-87256-bit
ed25519ml-dsa-44, ml-dsa-65128-bit
ed448ml-dsa-87224-bit

Composite Combinations (—algorithm + —composite):

Creates a CSR with a combined composite signature per IETF draft-ietf-lamps-pq-composite-sigs-13. The signature is atomic - both components must be verified together. Only IANA-allocated OIDs are supported.

—algorithm—compositeOIDSecurity Level
ecdsa-p256ml-dsa-651.3.6.1.5.5.7.6.45Level 3
ecdsa-p384ml-dsa-651.3.6.1.5.5.7.6.46Level 3
ecdsa-p521ml-dsa-871.3.6.1.5.5.7.6.54Level 5

RFC 9883 (ML-KEM Attestation):

ML-KEM keys cannot sign (they’re Key Encapsulation Mechanisms). To prove possession of an ML-KEM private key, RFC 9883 defines the privateKeyPossessionStatement attribute. This requires:

  1. An existing signature certificate (--attest-cert)
  2. The corresponding private key (--attest-key)

The CSR is signed by the attestation key, and includes a reference to the attestation certificate. The CA verifies the attestation chain before issuing the ML-KEM certificate.

Display information about a CSR.

Terminal window
qpki csr info <csr-file>

Example:

Terminal window
qpki csr info server.csr

Verify the signature of a CSR.

Terminal window
qpki csr verify <csr-file>

Example:

Terminal window
qpki csr verify server.csr

AlgorithmTypeKey SizeUse Case
ecdsa-p256Signature256-bitDefault, wide compatibility
ecdsa-p384Signature384-bitRecommended for new deployments
ecdsa-p521Signature521-bitMaximum classical security
ed25519Signature256-bitFast, constant-time
rsa-2048Signature2048-bitLegacy compatibility
rsa-4096Signature4096-bitLegacy with higher security
AlgorithmTypeNIST LevelUse Case
ml-dsa-44SignatureLevel 1~AES-128 equivalent
ml-dsa-65SignatureLevel 3~AES-192 equivalent
ml-dsa-87SignatureLevel 5~AES-256 equivalent
ml-kem-512KEMLevel 1Key encapsulation
ml-kem-768KEMLevel 3Key encapsulation
ml-kem-1024KEMLevel 5Key encapsulation

  • CA - CA initialization and certificate issuance
  • Credentials - Bundled key + certificate lifecycle
  • HSM - Hardware Security Module integration
  • Concepts - PQC and hybrid certificate concepts
  • CLI Reference - Complete command reference