summaryrefslogtreecommitdiffstats
path: root/doc/man7
diff options
context:
space:
mode:
authorslontis <shane.lontis@oracle.com>2022-08-26 11:54:35 +1000
committerHugo Landau <hlandau@openssl.org>2022-09-23 09:24:47 +0100
commit78c44b05945be07eae86f0164b9b777e2de2295b (patch)
tree1c2f721a3bc8405b86f6aac30326265609de7968 /doc/man7
parent257cade411ef9217305c5db47f40e5dacdb99c71 (diff)
Add HPKE DHKEM provider support for EC, X25519 and X448.
The code is derived from @sftcd's work in PR #17172. This PR puts the DHKEM algorithms into the provider layer as KEM algorithms for EC and ECX. This PR only implements the DHKEM component of HPKE as specified in RFC 9180. crypto/hpke/hpke_util.c has been added for fuctions that will be shared between DHKEM and HPKE. API's for EVP_PKEY_auth_encapsulate_init() and EVP_PKEY_auth_decapsulate_init() have been added to support authenticated encapsulation. auth_init() functions were chosen rather that a EVP_PKEY_KEM_set_auth() interface to support future algorithms that could possibly need different init functions. Internal code has been refactored, so that it can be shared between the DHKEM and other systems. Since DHKEM operates on low level keys it needs to be able to do low level ECDH and ECXDH calls without converting the keys back into EVP_PKEY/EVP_PKEY_CTX form. See ossl_ecx_compute_key(), ossl_ec_public_from_private() DHKEM requires API's to derive a key using a seed (IKM). This did not sit well inside the DHKEM itself as dispatch functions. This functionality fits better inside the EC and ECX keymanagers keygen, since they are just variations of keygen where the private key is generated in a different manner. This should mainly be used for testing purposes. See ossl_ec_generate_key_dhkem(). It supports this by allowing a settable param to be passed to keygen (See OSSL_PKEY_PARAM_DHKEM_IKM). The keygen calls code within ec and ecx dhkem implementation to handle this. See ossl_ecx_dhkem_derive_private() and ossl_ec_dhkem_derive_private(). These 2 functions are also used by the EC/ECX DHKEM implementations to generate the sender ephemeral keys. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19068)
Diffstat (limited to 'doc/man7')
-rw-r--r--doc/man7/EVP_KEM-EC.pod78
-rw-r--r--doc/man7/EVP_KEM-X25519.pod77
-rw-r--r--doc/man7/EVP_PKEY-EC.pod8
-rw-r--r--doc/man7/EVP_PKEY-X25519.pod16
-rw-r--r--doc/man7/OSSL_PROVIDER-default.pod4
-rw-r--r--doc/man7/provider-kem.pod51
6 files changed, 218 insertions, 16 deletions
diff --git a/doc/man7/EVP_KEM-EC.pod b/doc/man7/EVP_KEM-EC.pod
new file mode 100644
index 0000000000..6e88d1354f
--- /dev/null
+++ b/doc/man7/EVP_KEM-EC.pod
@@ -0,0 +1,78 @@
+=pod
+
+=head1 NAME
+
+EVP_KEM-EC
+- EVP_KEM EC keytype and algorithm support
+
+=head1 DESCRIPTION
+
+The B<EC> keytype and its parameters are described in L<EVP_PKEY-EC(7)>.
+See L<EVP_PKEY_encapsulate(3)> and L<EVP_PKEY_decapsulate(3)> for more info.
+
+=head2 EC KEM parameters
+
+=over 4
+
+=item "operation" (B<OSSL_KEM_PARAM_OPERATION>)<UTF8 string>
+
+The OpenSSL EC Key Encapsulation Mechanisms only supports the
+following operation:
+
+=over 4
+
+=item "DHKEM" (B<OSSL_KEM_PARAM_OPERATION_DHKEM>)
+
+The encapsulate function generates an ephemeral keypair. It produces keymaterial
+by doing an ECDH key exchange using the ephemeral private key and a supplied
+recipient public key. A HKDF operation using the keymaterial and a kem context
+then produces a shared secret. The shared secret and the ephemeral public key
+are returned.
+The decapsulate function uses the recipient private key and the
+ephemeral public key to produce the same keymaterial, which can then be used to
+produce the same shared secret.
+See L<https://www.rfc-editor.org/rfc/rfc9180.html#name-dh-based-kem-dhkem>
+
+=back
+
+This can be set using either EVP_PKEY_CTX_set_kem_op() or
+EVP_PKEY_CTX_set_params().
+
+=item "ikme" (B<OSSL_KEM_PARAM_IKME>) <octet string>
+
+Used to specify the key material used for generation of the ephemeral key.
+This value should not be reused for other purposes.
+It can only be used for the curves "P-256", "P-384" and "P-521" and should
+have a length of at least the size of the encoded private key
+(i.e. 32, 48 and 66 for the listed curves).
+If this value is not set, then a random ikm is used.
+
+=back
+
+=head1 CONFORMING TO
+
+=over 4
+
+=item RFC9180
+
+=back
+
+=head1 SEE ALSO
+
+L<EVP_PKEY_CTX_set_kem_op(3)>,
+L<EVP_PKEY_encapsulate(3)>,
+L<EVP_PKEY_decapsulate(3)>
+L<EVP_KEYMGMT(3)>,
+L<EVP_PKEY(3)>,
+L<provider-keymgmt(7)>
+
+=head1 COPYRIGHT
+
+Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+
+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
diff --git a/doc/man7/EVP_KEM-X25519.pod b/doc/man7/EVP_KEM-X25519.pod
new file mode 100644
index 0000000000..faf464e093
--- /dev/null
+++ b/doc/man7/EVP_KEM-X25519.pod
@@ -0,0 +1,77 @@
+=pod
+
+=head1 NAME
+
+EVP_KEM-X25519, EVP_KEM-X448
+- EVP_KEM X25519 and EVP_KEM X448 keytype and algorithm support
+
+=head1 DESCRIPTION
+
+The B<X25519> and <X448> keytype and its parameters are described in
+L<EVP_PKEY-X25519(7)>.
+See L<EVP_PKEY_encapsulate(3)> and L<EVP_PKEY_decapsulate(3)> for more info.
+
+=head2 X25519 and X448 KEM parameters
+
+=over 4
+
+=item "operation" (B<OSSL_KEM_PARAM_OPERATION>)<UTF8 string>
+
+The OpenSSL X25519 and X448 Key Encapsulation Mechanisms only support the
+following operation:
+
+=over 4
+
+=item "DHKEM" (B<OSSL_KEM_PARAM_OPERATION_DHKEM>)
+
+The encapsulate function generates an ephemeral keypair. It produces keymaterial
+by doing an X25519 or X448 key exchange using the ephemeral private key and a
+supplied recipient public key. A HKDF operation using the keymaterial and a kem
+context then produces a shared secret. The shared secret and the ephemeral
+public key are returned.
+The decapsulate function uses the recipient private key and the
+ephemeral public key to produce the same keymaterial, which can then be used to
+produce the same shared secret.
+See L<https://www.rfc-editor.org/rfc/rfc9180.html#name-dh-based-kem-dhkem>
+
+=back
+
+This can be set using either EVP_PKEY_CTX_set_kem_op() or
+EVP_PKEY_CTX_set_params().
+
+=item "ikme" (B<OSSL_KEM_PARAM_IKME>) <octet string>
+
+Used to specify the key material used for generation of the ephemeral key.
+This value should not be reused for other purposes.
+It should have a length of at least 32 for X25519, and 56 for X448.
+If this value is not set, then a random ikm is used.
+
+=back
+
+=head1 CONFORMING TO
+
+=over 4
+
+=item RFC9180
+
+=back
+
+=head1 SEE ALSO
+
+L<EVP_PKEY_CTX_set_kem_op(3)>,
+L<EVP_PKEY_encapsulate(3)>,
+L<EVP_PKEY_decapsulate(3)>
+L<EVP_KEYMGMT(3)>,
+L<EVP_PKEY(3)>,
+L<provider-keymgmt(7)>
+
+=head1 COPYRIGHT
+
+Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+
+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
diff --git a/doc/man7/EVP_PKEY-EC.pod b/doc/man7/EVP_PKEY-EC.pod
index d4c8d9e36e..0d32c67b43 100644
--- a/doc/man7/EVP_PKEY-EC.pod
+++ b/doc/man7/EVP_PKEY-EC.pod
@@ -137,6 +137,14 @@ Used for getting the EC public key Y component.
Getter that returns the default digest name.
(Currently returns "SHA256" as of OpenSSL 3.0).
+=item "dhkem-ikm" (B<OSSL_PKEY_PARAM_DHKEM_IKM>) <octet string>
+
+DHKEM requires the generation of a keypair using an input key material (seed).
+Use this to specify the key material used for generation of the private key.
+This value should not be reused for other purposes. It can only be used
+for the curves "P-256", "P-384" and "P-521" and should have a length of at least
+the size of the encoded private key (i.e. 32, 48 and 66 for the listed curves).
+
=back
The following Gettable types are also available for the built-in EC algorithm:
diff --git a/doc/man7/EVP_PKEY-X25519.pod b/doc/man7/EVP_PKEY-X25519.pod
index 9e13e15f7f..a63e50baa8 100644
--- a/doc/man7/EVP_PKEY-X25519.pod
+++ b/doc/man7/EVP_PKEY-X25519.pod
@@ -13,8 +13,22 @@ implemented in OpenSSL's default and FIPS providers. These implementations
support the associated key, containing the public key I<pub> and the
private key I<priv>.
-No additional parameters can be set during key generation.
+=head2 Keygen Parameters
+=over 4
+
+=item "dhkem-ikm" (B<OSSL_PKEY_PARAM_DHKEM_IKM>) <octet string>
+
+DHKEM requires the generation of a keypair using an input key material (seed).
+Use this to specify the key material used for generation of the private key.
+This value should not be reused for other purposes.
+It should have a length of at least 32 for X25519, and 56 for X448.
+
+This is only supported by X25519 and X448.
+
+=back
+
+Use EVP_PKEY_CTX_set_params() after calling EVP_PKEY_keygen_init().
=head2 Common X25519, X448, ED25519 and ED448 parameters
diff --git a/doc/man7/OSSL_PROVIDER-default.pod b/doc/man7/OSSL_PROVIDER-default.pod
index 7126f9ca37..43dc8c3302 100644
--- a/doc/man7/OSSL_PROVIDER-default.pod
+++ b/doc/man7/OSSL_PROVIDER-default.pod
@@ -194,6 +194,10 @@ The OpenSSL default provider supports these operations and algorithms:
=item RSA, see L<EVP_KEM-RSA(7)>
+=item X25519, see L<EVP_KEM-X25519(7)>
+
+=item EC, see L<EVP_KEM-EC(7)>
+
=back
=head2 Asymmetric Key Management
diff --git a/doc/man7/provider-kem.pod b/doc/man7/provider-kem.pod
index f7476e5e9d..4e80e5beb7 100644
--- a/doc/man7/provider-kem.pod
+++ b/doc/man7/provider-kem.pod
@@ -23,13 +23,19 @@ provider-kem - The kem library E<lt>-E<gt> provider functions
void *OSSL_FUNC_kem_dupctx(void *ctx);
/* Encapsulation */
- int OSSL_FUNC_kem_encapsulate_init(void *ctx, void *provkey, const char *name,
+ int OSSL_FUNC_kem_encapsulate_init(void *ctx, void *provkey,
const OSSL_PARAM params[]);
+ int OSSL_FUNC_kem_auth_encapsulate_init(void *ctx, void *provkey,
+ void *provauthkey,
+ const OSSL_PARAM params[]);
int OSSL_FUNC_kem_encapsulate(void *ctx, unsigned char *out, size_t *outlen,
unsigned char *secret, size_t *secretlen);
/* Decapsulation */
- int OSSL_FUNC_kem_decapsulate_init(void *ctx, void *provkey, const char *name);
+ int OSSL_FUNC_kem_decapsulate_init(void *ctx, void *provkey);
+ int OSSL_FUNC_kem_auth_decapsulate_init(void *ctx, void *provkey,
+ void *provauthkey,
+ const OSSL_PARAM params[]);
int OSSL_FUNC_kem_decapsulate(void *ctx, unsigned char *out, size_t *outlen,
const unsigned char *in, size_t inlen);
@@ -68,20 +74,22 @@ For example, the "function" OSSL_FUNC_kem_newctx() has these:
B<OSSL_DISPATCH> arrays are indexed by numbers that are provided as
macros in L<openssl-core_dispatch.h(7)>, as follows:
- OSSL_FUNC_kem_newctx OSSL_FUNC_KEM_NEWCTX
- OSSL_FUNC_kem_freectx OSSL_FUNC_KEM_FREECTX
- OSSL_FUNC_kem_dupctx OSSL_FUNC_KEM_DUPCTX
+ OSSL_FUNC_kem_newctx OSSL_FUNC_KEM_NEWCTX
+ OSSL_FUNC_kem_freectx OSSL_FUNC_KEM_FREECTX
+ OSSL_FUNC_kem_dupctx OSSL_FUNC_KEM_DUPCTX
- OSSL_FUNC_kem_encapsulate_init OSSL_FUNC_KEM_ENCAPSULATE_INIT
- OSSL_FUNC_kem_encapsulate OSSL_FUNC_KEM_ENCAPSULATE
+ OSSL_FUNC_kem_encapsulate_init OSSL_FUNC_KEM_ENCAPSULATE_INIT
+ OSSL_FUNC_kem_auth_encapsulate_init OSSL_FUNC_KEM_AUTH_ENCAPSULATE_INIT
+ OSSL_FUNC_kem_encapsulate OSSL_FUNC_KEM_ENCAPSULATE
- OSSL_FUNC_kem_decapsulate_init OSSL_FUNC_KEM_DECAPSULATE_INIT
- OSSL_FUNC_kem_decapsulate OSSL_FUNC_KEM_DECAPSULATE
+ OSSL_FUNC_kem_decapsulate_init OSSL_FUNC_KEM_DECAPSULATE_INIT
+ OSSL_FUNC_kem_auth_decapsulate_init OSSL_FUNC_KEM_AUTH_DECAPSULATE_INIT
+ OSSL_FUNC_kem_decapsulate OSSL_FUNC_KEM_DECAPSULATE
- OSSL_FUNC_kem_get_ctx_params OSSL_FUNC_KEM_GET_CTX_PARAMS
- OSSL_FUNC_kem_gettable_ctx_params OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS
- OSSL_FUNC_kem_set_ctx_params OSSL_FUNC_KEM_SET_CTX_PARAMS
- OSSL_FUNC_kem_settable_ctx_params OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS
+ OSSL_FUNC_kem_get_ctx_params OSSL_FUNC_KEM_GET_CTX_PARAMS
+ OSSL_FUNC_kem_gettable_ctx_params OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS
+ OSSL_FUNC_kem_set_ctx_params OSSL_FUNC_KEM_SET_CTX_PARAMS
+ OSSL_FUNC_kem_settable_ctx_params OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS
An asymmetric kem algorithm implementation may not implement all of these
functions.
@@ -90,10 +98,12 @@ OSSL_FUNC_kem_newctx and OSSL_FUNC_kem_freectx.
It must also implement both of OSSL_FUNC_kem_encapsulate_init and
OSSL_FUNC_kem_encapsulate, or both of OSSL_FUNC_kem_decapsulate_init and
OSSL_FUNC_kem_decapsulate.
+OSSL_FUNC_kem_auth_encapsulate_init is optional but if it is present then so
+must OSSL_FUNC_kem_auth_decapsulate_init.
OSSL_FUNC_kem_get_ctx_params is optional but if it is present then so must
OSSL_FUNC_kem_gettable_ctx_params.
Similarly, OSSL_FUNC_kem_set_ctx_params is optional but if it is present then
-so must OSSL_FUNC_kem_settable_ctx_params.
+OSSL_FUNC_kem_settable_ctx_params must also be present.
An asymmetric kem algorithm must also implement some mechanism for generating,
loading or importing keys via the key management (OSSL_OP_KEYMGMT) operation.
@@ -127,6 +137,10 @@ The key object should have been previously generated, loaded or imported into
the provider using the key management (OSSL_OP_KEYMGMT) operation (see
provider-keymgmt(7)>.
+OSSL_FUNC_kem_auth_encapsulate_init() is similiar to
+OSSL_FUNC_kem_encapsulate_init(), but also passes an additional authentication
+key I<provauthkey> which cannot be NULL.
+
OSSL_FUNC_kem_encapsulate() performs the actual encapsulation itself.
A previously initialised asymmetric kem context is passed in the I<ctx>
parameter.
@@ -151,6 +165,10 @@ The key object should have been previously generated, loaded or imported into
the provider using the key management (OSSL_OP_KEYMGMT) operation (see
provider-keymgmt(7)>.
+OSSL_FUNC_kem_auth_decapsulate_init() is similiar to
+OSSL_FUNC_kem_decapsulate_init(), but also passes an additional authentication
+key I<provauthkey> which cannot be NULL.
+
OSSL_FUNC_kem_decapsulate() performs the actual decapsulation itself.
A previously initialised asymmetric kem context is passed in the I<ctx>
parameter.
@@ -201,9 +219,12 @@ L<provider(7)>
The provider KEM interface was introduced in OpenSSL 3.0.
+OSSL_FUNC_kem_auth_encapsulate_init() and OSSL_FUNC_kem_auth_decapsulate_init()
+were added in OpenSSL 3.1.
+
=head1 COPYRIGHT
-Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
+Copyright 2020-2022 The OpenSSL Project Authors. All Rights Reserved.
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