X.509 private key encoding and PEM conversion interface. More...
Go to the source code of this file.
Macros | |
| #define | QSC_X509_KEY_WRITE_MAX 16384U |
| The maximum number of octets used by key writer scratch and output buffers. | |
Functions | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_sec1_der (const qsc_x509_private_key *key, bool includeparameters, bool includepublickey, uint8_t *output, size_t *outputlen) |
| Encode a normalized private key object as SEC 1 DER. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_sec1_pem (const qsc_x509_private_key *key, bool includeparameters, bool includepublickey, char *output, size_t *outputlen) |
| Encode a normalized private key object as SEC 1 PEM. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_der (const qsc_x509_private_key *key, bool includepublickey, uint8_t *output, size_t *outputlen) |
| Encode a normalized private key object as PKCS #8 DER. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_pem (const qsc_x509_private_key *key, bool includepublickey, char *output, size_t *outputlen) |
| Encode a normalized private key object as PKCS #8 PEM. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_der_ex (const qsc_x509_algorithm_identifier *algorithm, const uint8_t *privatekey, size_t privatekeylen, const uint8_t *publickey, size_t publickeylen, bool publickeypresent, uint8_t *output, size_t *outputlen) |
| Encode raw private key material as PKCS #8 DER. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_pem_ex (const qsc_x509_algorithm_identifier *algorithm, const uint8_t *privatekey, size_t privatekeylen, const uint8_t *publickey, size_t publickeylen, bool publickeypresent, char *output, size_t *outputlen) |
| Encode raw private key material as PKCS #8 PEM. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_ml_dsa_der (qsc_x509_pqc_parameter_set parameter, const uint8_t *privatekey, size_t privatekeylen, const uint8_t *publickey, size_t publickeylen, bool publickeypresent, uint8_t *output, size_t *outputlen) |
| Encode an ML-DSA private key as PKCS #8 DER. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_ml_dsa_pem (qsc_x509_pqc_parameter_set parameter, const uint8_t *privatekey, size_t privatekeylen, const uint8_t *publickey, size_t publickeylen, bool publickeypresent, char *output, size_t *outputlen) |
| Encode an ML-DSA private key as PKCS #8 PEM. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_ml_kem_der (qsc_x509_pqc_parameter_set parameter, const uint8_t *privatekey, size_t privatekeylen, const uint8_t *publickey, size_t publickeylen, bool publickeypresent, uint8_t *output, size_t *outputlen) |
| Encode an ML-KEM private key as PKCS #8 DER. | |
| QSC_EXPORT_API qsc_asn1_status | qsc_x509_private_key_encode_pkcs8_ml_kem_pem (qsc_x509_pqc_parameter_set parameter, const uint8_t *privatekey, size_t privatekeylen, const uint8_t *publickey, size_t publickeylen, bool publickeypresent, char *output, size_t *outputlen) |
| Encode an ML-KEM private key as PKCS #8 PEM. | |
X.509 private key encoding and PEM conversion interface.
This header defines the public interface used to encode normalized private key objects into SEC 1 and PKCS #8 representations in both DER and PEM forms. The interface supports generic encoding from a qsc_x509_private_key container, caller-supplied raw key material and algorithm identifiers, and convenience wrappers for ML-DSA and ML-KEM parameter-set specific PKCS #8 emission. For EC keys, the PKCS #8 encoder normalizes the AlgorithmIdentifier parameters to a namedCurve OID when the caller supplies only the curve selector.
The PKCS #8 helpers support optional inclusion of the embedded public key when the underlying format and algorithm permit its representation. The SEC 1 helpers additionally provide control over whether algorithm parameters and public key fields are emitted.
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_der | ( | const qsc_x509_private_key * | key, |
| bool | includepublickey, | ||
| uint8_t * | output, | ||
| size_t * | outputlen ) |
Encode a normalized private key object as PKCS #8 DER.
Serializes the supplied private-key container to DER encoded PKCS #8 format. The caller may request inclusion of the optional embedded public key.
| key | [const][struct] The source private-key container. |
| includepublickey | Includes the optional embedded public key when set to true. |
| output | The destination buffer receiving the DER encoding. |
| outputlen | The input capacity of the output buffer and, on success, the number of bytes written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_der_ex | ( | const qsc_x509_algorithm_identifier * | algorithm, |
| const uint8_t * | privatekey, | ||
| size_t | privatekeylen, | ||
| const uint8_t * | publickey, | ||
| size_t | publickeylen, | ||
| bool | publickeypresent, | ||
| uint8_t * | output, | ||
| size_t * | outputlen ) |
Encode raw private key material as PKCS #8 DER.
Serializes caller-supplied private key bytes, algorithm identifier, and optional public key bytes to DER encoded PKCS #8 format without requiring a qsc_x509_private_key container.
| algorithm | [const][struct] The algorithm identifier to encode. |
| privatekey | [const] The raw private key bytes. |
| privatekeylen | The length of the private key in bytes. |
| publickey | [const] The optional raw public key bytes. |
| publickeylen | The length of the public key in bytes. |
| publickeypresent | Indicates whether the public key input is present. |
| output | The destination buffer receiving the DER encoding. |
| outputlen | The input capacity of the output buffer and, on success, the number of bytes written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_ml_dsa_der | ( | qsc_x509_pqc_parameter_set | parameter, |
| const uint8_t * | privatekey, | ||
| size_t | privatekeylen, | ||
| const uint8_t * | publickey, | ||
| size_t | publickeylen, | ||
| bool | publickeypresent, | ||
| uint8_t * | output, | ||
| size_t * | outputlen ) |
Encode an ML-DSA private key as PKCS #8 DER.
Serializes caller-supplied ML-DSA private key material using the selected ML-DSA parameter set and emits DER encoded PKCS #8 output.
| parameter | [enum] The ML-DSA parameter set identifier. |
| privatekey | [const] The raw ML-DSA private key bytes. |
| privatekeylen | The length of the private key in bytes. |
| publickey | [const] The optional raw ML-DSA public key bytes. |
| publickeylen | The length of the public key in bytes. |
| publickeypresent | Indicates whether the public key input is present. |
| output | The destination buffer receiving the DER encoding. |
| outputlen | The input capacity of the output buffer and, on success, the number of bytes written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_ml_dsa_pem | ( | qsc_x509_pqc_parameter_set | parameter, |
| const uint8_t * | privatekey, | ||
| size_t | privatekeylen, | ||
| const uint8_t * | publickey, | ||
| size_t | publickeylen, | ||
| bool | publickeypresent, | ||
| char * | output, | ||
| size_t * | outputlen ) |
Encode an ML-DSA private key as PKCS #8 PEM.
Serializes caller-supplied ML-DSA private key material using the selected ML-DSA parameter set and converts the resulting PKCS #8 object to PEM text.
| parameter | [enum] The ML-DSA parameter set identifier. |
| privatekey | [const] The raw ML-DSA private key bytes. |
| privatekeylen | The length of the private key in bytes. |
| publickey | [const] The optional raw ML-DSA public key bytes. |
| publickeylen | The length of the public key in bytes. |
| publickeypresent | Indicates whether the public key input is present. |
| output | The destination character buffer receiving the PEM text. |
| outputlen | The input capacity of the output buffer and, on success, the number of characters written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_ml_kem_der | ( | qsc_x509_pqc_parameter_set | parameter, |
| const uint8_t * | privatekey, | ||
| size_t | privatekeylen, | ||
| const uint8_t * | publickey, | ||
| size_t | publickeylen, | ||
| bool | publickeypresent, | ||
| uint8_t * | output, | ||
| size_t * | outputlen ) |
Encode an ML-KEM private key as PKCS #8 DER.
Serializes caller-supplied ML-KEM private key material using the selected ML-KEM parameter set and emits DER encoded PKCS #8 output.
| parameter | [enum] The ML-KEM parameter set identifier. |
| privatekey | [const] The raw ML-KEM private key bytes. |
| privatekeylen | The length of the private key in bytes. |
| publickey | [const] The optional raw ML-KEM public key bytes. |
| publickeylen | The length of the public key in bytes. |
| publickeypresent | Indicates whether the public key input is present. |
| output | The destination buffer receiving the DER encoding. |
| outputlen | The input capacity of the output buffer and, on success, the number of bytes written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_ml_kem_pem | ( | qsc_x509_pqc_parameter_set | parameter, |
| const uint8_t * | privatekey, | ||
| size_t | privatekeylen, | ||
| const uint8_t * | publickey, | ||
| size_t | publickeylen, | ||
| bool | publickeypresent, | ||
| char * | output, | ||
| size_t * | outputlen ) |
Encode an ML-KEM private key as PKCS #8 PEM.
Serializes caller-supplied ML-KEM private key material using the selected ML-KEM parameter set and converts the resulting PKCS #8 object to PEM text.
| parameter | [enum] The ML-KEM parameter set identifier. |
| privatekey | [const] The raw ML-KEM private key bytes. |
| privatekeylen | The length of the private key in bytes. |
| publickey | [const] The optional raw ML-KEM public key bytes. |
| publickeylen | The length of the public key in bytes. |
| publickeypresent | Indicates whether the public key input is present. |
| output | The destination character buffer receiving the PEM text. |
| outputlen | The input capacity of the output buffer and, on success, the number of characters written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_pem | ( | const qsc_x509_private_key * | key, |
| bool | includepublickey, | ||
| char * | output, | ||
| size_t * | outputlen ) |
Encode a normalized private key object as PKCS #8 PEM.
Serializes the supplied private-key container to PKCS #8 DER and converts the result to PEM text form.
| key | [const][struct] The source private-key container. |
| includepublickey | Includes the optional embedded public key when set to true. |
| output | The destination character buffer receiving the PEM text. |
| outputlen | The input capacity of the output buffer and, on success, the number of characters written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_pkcs8_pem_ex | ( | const qsc_x509_algorithm_identifier * | algorithm, |
| const uint8_t * | privatekey, | ||
| size_t | privatekeylen, | ||
| const uint8_t * | publickey, | ||
| size_t | publickeylen, | ||
| bool | publickeypresent, | ||
| char * | output, | ||
| size_t * | outputlen ) |
Encode raw private key material as PKCS #8 PEM.
Serializes caller-supplied private key bytes, algorithm identifier, and optional public key bytes to PKCS #8 DER and converts the result to PEM text form.
| algorithm | [const][struct] The algorithm identifier to encode. |
| privatekey | [const] The raw private key bytes. |
| privatekeylen | The length of the private key in bytes. |
| publickey | [const] The optional raw public key bytes. |
| publickeylen | The length of the public key in bytes. |
| publickeypresent | Indicates whether the public key input is present. |
| output | The destination character buffer receiving the PEM text. |
| outputlen | The input capacity of the output buffer and, on success, the number of characters written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_sec1_der | ( | const qsc_x509_private_key * | key, |
| bool | includeparameters, | ||
| bool | includepublickey, | ||
| uint8_t * | output, | ||
| size_t * | outputlen ) |
Encode a normalized private key object as SEC 1 DER.
Serializes the supplied private-key container to DER encoded SEC 1 format. The caller may request inclusion of algorithm parameters and an embedded public key when supported by the underlying key representation.
| key | [const][struct] The source private-key container. |
| includeparameters | Includes algorithm parameters when set to true. |
| includepublickey | Includes the optional embedded public key when set to true. |
| output | The destination buffer receiving the DER encoding. |
| outputlen | The input capacity of the output buffer and, on success, the number of bytes written. |
| QSC_EXPORT_API qsc_asn1_status qsc_x509_private_key_encode_sec1_pem | ( | const qsc_x509_private_key * | key, |
| bool | includeparameters, | ||
| bool | includepublickey, | ||
| char * | output, | ||
| size_t * | outputlen ) |
Encode a normalized private key object as SEC 1 PEM.
Serializes the supplied private-key container to SEC 1 DER and converts the result to PEM text form.
| key | [const][struct] The source private-key container. |
| includeparameters | Includes algorithm parameters when set to true. |
| includepublickey | Includes the optional embedded public key when set to true. |
| output | The destination character buffer receiving the PEM text. |
| outputlen | The input capacity of the output buffer and, on success, the number of characters written. |