| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | =pod | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 NAME | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | EVP_PKEY-ML-KEM, | 
					
						
							|  |  |  | EVP_KEYMGMT-ML-KEM, | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | EVP_PKEY-ML-KEM-512, | 
					
						
							|  |  |  | EVP_PKEY-ML-KEM-768, | 
					
						
							|  |  |  | EVP_PKEY-ML-KEM-1024, | 
					
						
							|  |  |  | EVP_KEYMGMT-ML-KEM-512, | 
					
						
							|  |  |  | EVP_KEYMGMT-ML-KEM-768, | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | EVP_KEYMGMT-ML-KEM-1024 | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | - ML-KEM keytype and algorithm support | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 DESCRIPTION | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-20 00:56:59 +08:00
										 |  |  | The B<ML-KEM-512>, B<ML-KEM-768>, and B<ML-KEM-1024> keytypes are implemented | 
					
						
							| 
									
										
										
										
											2025-01-08 11:17:47 +08:00
										 |  |  | in OpenSSL's default and FIPS providers. | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =head2 Keygen Parameters | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | No mandatory parameters are required for generating a key pair. | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | To set explicit parameters, use EVP_PKEY_CTX_set_params() after calling | 
					
						
							|  |  |  | EVP_PKEY_keygen_init(). | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item "seed" (B<OSSL_PKEY_PARAM_ML_KEM_SEED>) <octet string> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-20 00:56:59 +08:00
										 |  |  | Internally, ML-KEM generates keys using a 64-byte random value (seed), which is | 
					
						
							|  |  |  | the concatenation of the 32-byte I<d> and I<z> parameters described in FIPS 203. | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | This optional parameter can be used to set a pre-determined seed prior to | 
					
						
							| 
									
										
										
										
											2024-12-20 00:56:59 +08:00
										 |  |  | keypair generation. | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | Generated keys default to retaining the seed used. | 
					
						
							|  |  |  | The seed is also by default retained when keys are loaded from B<PKCS#8> files | 
					
						
							|  |  |  | in the seed format. | 
					
						
							|  |  |  | When available, the seed parameter is also used during key export and import, | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | with keys (by default) regenerated from the seed even when also provided on import. | 
					
						
							|  |  |  | See L</Provider configuration parameters> below for related controls. | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | When the seed is retained, it is also available as a B<gettable> parameter, | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | and private key output to B<PKCS#8> files will by default include the seed. | 
					
						
							|  |  |  | When the seed was not initially known, or was not retained, B<PKCS#8> private | 
					
						
							|  |  |  | key files will contain only the private key in FIPS 203 C<dk> format. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item "properties" (B<OSSL_PKEY_PARAM_PROPERTIES>) <UTF8 string> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Sets properties to be used when fetching algorithm implementations used for | 
					
						
							|  |  |  | ML-KEM hashing operations. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Use L<EVP_PKEY_CTX_set_params(3)> after calling L<EVP_PKEY_keygen_init(3)>. | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head2 Common parameters | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | In addition to the common parameters that all keytypes should support (see | 
					
						
							|  |  |  | L<provider-keymgmt(7)/Common Information Parameters>), B<ML-KEM> keys | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | keys support the parameters listed below. | 
					
						
							|  |  |  | These are gettable using | 
					
						
							|  |  |  | L<EVP_PKEY_get_octet_string_param(3)> or L<EVP_PKEY_get_params(3)>. | 
					
						
							|  |  |  | They can be initialised via L<EVP_PKEY_fromdata(3)>, and are returned by | 
					
						
							|  |  |  | L<EVP_PKEY_todata(3)> given a suitable I<selection>. | 
					
						
							|  |  |  | Once a public or private key is configured, it can no longer be modified, | 
					
						
							|  |  |  | nor can another key component be added. | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item "pub" (B<OSSL_PKEY_PARAM_PUB_KEY>) <octet string> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The public key value. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This parameter is used when importing or exporting the public key value with | 
					
						
							|  |  |  | the EVP_PKEY_fromdata() and EVP_PKEY_todata() functions. | 
					
						
							|  |  |  | The key length and content is that of the FIPS 203 (Algorithm 16: | 
					
						
							|  |  |  | B<ML-KEM.KeyGen_internal>) B<ek> public key for the given ML-KEM variant. | 
					
						
							|  |  |  | Initial import aside, this parameter is otherwise only gettable. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item "priv" (B<OSSL_PKEY_PARAM_PRIV_KEY>) <octet string> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The private key value. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This parameter is used when importing or exporting the private key value with | 
					
						
							|  |  |  | the EVP_PKEY_fromdata() and EVP_PKEY_todata() functions. | 
					
						
							|  |  |  | The key length and content is that of the FIPS 203 (Algorithm 16: | 
					
						
							|  |  |  | B<ML-KEM.KeyGen_internal>) B<dk> private key for the given ML-KEM variant. | 
					
						
							|  |  |  | Initial import aside, this parameter is otherwise only gettable. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item "encoded-pub-key" (B<OSSL_PKEY_PARAM_ENCODED_PUBLIC_KEY>) <octet string> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Used for getting and setting the encoding of a public key. | 
					
						
							|  |  |  | The key format is that of B<ek> in FIPS 203, Algorithm 16: | 
					
						
							|  |  |  | B<ML-KEM.KeyGen_internal>. | 
					
						
							|  |  |  | Updates of the public and private key components are only allowed on keys that | 
					
						
							|  |  |  | are empty. | 
					
						
							|  |  |  | Once a public or private key component is set, no further changes are allowed. | 
					
						
							|  |  |  | This parameter is gettable and settable (once only). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head2 Provider configuration parameters | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | See the description of the B<-provparam> option in L<openssl(1)> to learn | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | how to set provider configuration parameters in the command line tools. | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | See L<OSSL_PROVIDER_add_conf_parameter(3)> to learn how to set provider | 
					
						
							|  |  |  | configuration options programmatically. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-15 01:36:25 +08:00
										 |  |  | =item C<ml-kem.import_pct_type> (B<OSSL_PKEY_PARAM_ML_KEM_IMPORT_PCT_TYPE>) <UTF8 string> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | When an B<ML-KEM> key is imported as an explict FIPS 203 B<dk> decapsulation | 
					
						
							|  |  |  | key, rather than a seed, a pairwise consistency test (PCT) is optionally | 
					
						
							|  |  |  | performed. | 
					
						
							|  |  |  | By default, or when this parameter is set explicitly to C<random>, the PCT | 
					
						
							|  |  |  | is performed with a random entropy value for the encapsulation step. | 
					
						
							|  |  |  | Setting the parameter to C<fixed>, still runs the test, but the encapsulation | 
					
						
							|  |  |  | entropy is a fixed 32 byte value. | 
					
						
							|  |  |  | Specifying any other value of the parameter, e.g. C<none>, skips the test. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | =item C<ml-kem.retain_seed> (B<OSSL_PKEY_PARAM_ML_KEM_RETAIN_SEED>) <UTF8 string> | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | When set to a string representing a false boolean value (see | 
					
						
							|  |  |  | L<OSSL_PROVIDER_conf_get_bool(3)>), the seed will not be retained after key | 
					
						
							|  |  |  | generation or key import from a seed value. | 
					
						
							|  |  |  | If the resulting key is then written to a PKCS#8 object, it will contain | 
					
						
							|  |  |  | only the FIPS 203 C<dk> key. | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | =item C<ml-kem.prefer_seed> (B<OSSL_PKEY_PARAM_ML_KEM_PREFER_SEED>) <UTF8 string> | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | When decoding PKCS#8 objects that contain both a seed and the FIPS 203 C<dk> | 
					
						
							|  |  |  | private key, the seed is by default used to regenerate the key, and the | 
					
						
							|  |  |  | companion key is ignored. | 
					
						
							|  |  |  | When this configuration parameter is set to a string representing a false | 
					
						
							|  |  |  | boolean value (see L<OSSL_PROVIDER_conf_get_bool(3)>), the seed is ignored | 
					
						
							|  |  |  | (neither used to regenerate the key, nor retained), and the companion key is | 
					
						
							|  |  |  | used instead. | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | =item C<ml-kem.input_formats> (B<OSSL_PKEY_PARAM_ML_KEM_INPUT_FORMATS>) <UTF8 string> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | List of enabled private key input formats when parsing PKCS#8 objects. | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | List elements are separated by commas and/or spaces or tabs. | 
					
						
							|  |  |  | The list of enabled formats can be specified in the configuration file, as seen | 
					
						
							|  |  |  | in the L</EXAMPLES> section below, or the via the B<-provparam> command-line | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | option (see also L<OSSL_PROVIDER_add_conf_parameter(3)>). | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Values specified on the command-line override any configuration file settings. | 
					
						
							|  |  |  | By default all the supported formats are enabled. | 
					
						
							|  |  |  | The supported formats are: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item C<seed-priv>: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | This format represents B<PKCS#8> objects in which both the FIPS 203 64-byte | 
					
						
							|  |  |  | B<(d, z)> seed and the decapsulation key B<dk> are present in the private key | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | as part of the DER encoding of the ASN.1 sequence: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-07 16:16:33 +08:00
										 |  |  |     ML-KEM-PrivateKey ::= CHOICE { | 
					
						
							|  |  |  |       seed [0] IMPLICIT OCTET STRING (SIZE (64)), | 
					
						
							|  |  |  |       expandedKey OCTET STRING (SIZE (1632 | 2400 | 3168)), | 
					
						
							|  |  |  |       both SEQUENCE { | 
					
						
							|  |  |  |         seed OCTET STRING (SIZE (64)), | 
					
						
							|  |  |  |         expandedKey OCTET STRING (SIZE (1632 | 2400 | 3168)) } } | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | If the C<seed-priv> format is not included in the list, this format will not be | 
					
						
							|  |  |  | recognised on input. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item C<seed-only>: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | This format represents B<PKCS#8> objects in which only the 64-byte B<(d, z)> | 
					
						
							|  |  |  | seed is present in the above sequence. | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | If the C<seed-only> format is not included in the list, this format will not be | 
					
						
							|  |  |  | recognised on input. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item C<priv-only>: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | This format represents B<PKCS#8> objects in which only the FIPS 203 | 
					
						
							|  |  |  | decapsulation key B<dk> is present in the above sequence. | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | If the C<priv-only> format is not included in the list, this format will not be | 
					
						
							|  |  |  | recognised on input. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-05 13:30:15 +08:00
										 |  |  | =item C<oqskeypair>: | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | This format represents B<PKCS#8> objects in which the private key is a DER | 
					
						
							|  |  |  | encoding of an octet string containing the concatenaton of the FIPS 203 | 
					
						
							|  |  |  | decapsulation key B<dk> and the encapsulation key B<ek>. | 
					
						
							|  |  |  | This encoding is used in some builds of the C<oqsprovider>. | 
					
						
							| 
									
										
										
										
											2025-02-05 13:30:15 +08:00
										 |  |  | If the C<oqskeypair> format is not included in the list, this format will not be | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | recognised on input. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | =item C<bare-seed>: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This format represents B<PKCS#8> objects in which the private key contains | 
					
						
							|  |  |  | the 64-byte FIPS 204 seed B<(d, z)> without any ASN.1 encapsulation. | 
					
						
							|  |  |  | If the C<bare-seed> format is not included in the list, this format will not be | 
					
						
							|  |  |  | recognised on input. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item C<bare-priv>: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This format represents B<PKCS#8> objects in which the private key contains | 
					
						
							|  |  |  | the FIPS 204 decapsulation key B<dk> without any ASN.1 encapsulation. | 
					
						
							|  |  |  | If the C<bare-priv> format is not included in the list, this format will not be | 
					
						
							|  |  |  | recognised on input. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | =item C<ml-kem.output_formats> (B<OSSL_PKEY_PARAM_ML_KEM_OUTPUT_FORMATS>) <UTF8 string> | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | Ordered list of enabled private key output formats when writing B<PKCS#8> files. | 
					
						
							|  |  |  | List elements are separated by commas, spaces or tabs. | 
					
						
							| 
									
										
										
										
											2025-01-19 07:48:01 +08:00
										 |  |  | The list of enabled formats can be specified in the configuration file, as seen | 
					
						
							|  |  |  | in the L</EXAMPLES> section below, or the via the B<-provparam> command-line | 
					
						
							|  |  |  | option. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This supports the same set of formats as described under C<ml-kem.input_formats> | 
					
						
							|  |  |  | above. | 
					
						
							|  |  |  | The order in which elements are listed is important, the selected format will be | 
					
						
							|  |  |  | the first one that is possible to output. | 
					
						
							|  |  |  | If the key seed is known, the first listed format will be selected. | 
					
						
							|  |  |  | If the key seed is not known, the first format that omits the seed will be selected. | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | The default order is equivalent to C<seed-priv> first and C<priv-only> second, with | 
					
						
							|  |  |  | both seed and key output when the seed is available, and just the | 
					
						
							|  |  |  | key otherwise. | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | If C<seed-only> is listed first, then the seed will be output without the key | 
					
						
							|  |  |  | when available, otherwise the output will have just the key. | 
					
						
							|  |  |  | If C<priv-only> is listed first, then just the key is output regardless of | 
					
						
							|  |  |  | whether the seed is present. | 
					
						
							| 
									
										
										
										
											2025-02-05 13:30:15 +08:00
										 |  |  | The legacy C<oqskeypair>, C<bare-seed> and C<bare-priv> formats can also be | 
					
						
							|  |  |  | output, by listing those first. | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 CONFORMING TO | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =over 4 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =item FIPS 203 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =back | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 EXAMPLES | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | An B<EVP_PKEY> context can be obtained by calling: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     EVP_PKEY_CTX *pctx = | 
					
						
							|  |  |  |         EVP_PKEY_CTX_new_from_name(NULL, "ML-KEM-768", NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | An B<ML-KEM-768> key can be generated like this: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pkey = EVP_PKEY_Q_keygen(NULL, NULL, "ML-KEM-768"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | An B<ML-KEM> private key in seed format can be converted to a key in the FIPS | 
					
						
							|  |  |  | 203 B<dk> format by running: | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     $ openssl pkey -provparam ml-kem.retain_seed=no \ | 
					
						
							|  |  |  |         -in seed-only.pem -out priv-only.pem | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | To generate an, e.g., B<ML-KEM-768> key, in FIPS 203 B<dk> format, you can run: | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     $ openssl genpkey -provparam ml-kem.retain_seed=no \ | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  |         -algorithm ml-kem-768 -out priv-only.pem | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | If you have a B<PKCS#8> file with both a seed and a key, and prefer to import the | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  | companion key rather than the seed, you can run: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $ openssl pkey -provparam ml-kem.prefer_seed=no \ | 
					
						
							|  |  |  |         -in seed-priv.pem -out priv-only.pem | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | In the B<openssl.cnf> file, this looks like: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     openssl_conf = openssl_init | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     [openssl_init] | 
					
						
							|  |  |  |     providers = providers_sect | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     # Can be referenced in one or more provider sections | 
					
						
							|  |  |  |     [ml_kem_sect] | 
					
						
							|  |  |  |     prefer_seed = yes | 
					
						
							|  |  |  |     retain_seed = yes | 
					
						
							|  |  |  |     # OQS legacy formats disabled | 
					
						
							|  |  |  |     input_formats = seed-priv, seed-only, priv-only | 
					
						
							|  |  |  |     # Output either the seed alone, or else the key alone | 
					
						
							|  |  |  |     output_formats = seed-only, priv-only | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     [providers_sect] | 
					
						
							|  |  |  |     default = default_sect | 
					
						
							|  |  |  |     # Or perhaps just: base = default_sect | 
					
						
							|  |  |  |     base = base_sect | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     [default_sect] | 
					
						
							|  |  |  |     ml-kem = ml_kem_sect | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-28 00:12:47 +08:00
										 |  |  |     [base_sect] | 
					
						
							|  |  |  |     ml-kem = ml_kem_sect | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | =head1 SEE ALSO | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | L<openssl(1)>, | 
					
						
							|  |  |  | L<openssl-pkey(1)>, | 
					
						
							|  |  |  | L<openssl-genpkey(1)>, | 
					
						
							| 
									
										
										
										
											2024-12-20 00:56:59 +08:00
										 |  |  | L<EVP_KEYMGMT(3)>, | 
					
						
							|  |  |  | L<EVP_PKEY(3)>, | 
					
						
							| 
									
										
										
										
											2025-01-18 00:28:51 +08:00
										 |  |  | L<EVP_PKEY_get_raw_private_key(3)>, | 
					
						
							|  |  |  | L<EVP_PKEY_get_raw_public_key(3)>, | 
					
						
							|  |  |  | L<EVP_PKEY_get1_encoded_public_key(3)>, | 
					
						
							| 
									
										
										
										
											2025-03-17 16:57:40 +08:00
										 |  |  | L<OSSL_PROVIDER_add_conf_parameter(3)>, | 
					
						
							| 
									
										
										
										
											2024-12-20 00:56:59 +08:00
										 |  |  | L<provider-keymgmt(7)>, | 
					
						
							| 
									
										
										
										
											2025-02-04 03:02:20 +08:00
										 |  |  | L<EVP_KEM-ML-KEM(7)> | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | =head1 HISTORY | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This functionality was added in OpenSSL 3.5. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =head1 COPYRIGHT | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-13 23:07:14 +08:00
										 |  |  | Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved. | 
					
						
							| 
									
										
										
										
											2024-12-05 18:27:49 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Licensed under the Apache License 2.0 (the "License").  You may not use | 
					
						
							|  |  |  | this file except in compliance with the License.  You can obtain a copy | 
					
						
							|  |  |  | in the file LICENSE in the source distribution or at | 
					
						
							|  |  |  | L<https://www.openssl.org/source/license.html>. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | =cut |