From f57796ea65ce843621062572daa86f1f25753fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Meusel?= Date: Tue, 3 Dec 2024 09:17:38 +0100 Subject: [PATCH] Update documentation of KDF::derive_key overloads --- doc/api_ref/kdf.rst | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/doc/api_ref/kdf.rst b/doc/api_ref/kdf.rst index fd5df1c5d73..495e8a08d6a 100644 --- a/doc/api_ref/kdf.rst +++ b/doc/api_ref/kdf.rst @@ -34,36 +34,32 @@ two contexts. Create a new KDF object. Throws an exception if the named key derivation function was not available + .. cpp:function:: void KDF::derive_key(std::span key, \ + std::span secret, \ + std::span salt, \ + std::span label) const + + Performs a key derivation using ``secret`` as secret input, and ``salt``, + and ``label`` as deversifiers. The passed ``key`` buffer is fully filled + with key material derived from the inputs. + .. cpp:function:: template> \ - T derive_key(size_t key_len, \ - std::span secret, \ - std::span salt, \ - std::span label) const + T KDF::derive_key(size_t key_len, \ + std::span secret, \ + std::span salt, \ + std::span label) const This version is parameterized to the output buffer type, so it can be used to return a ``std::vector``, a ``secure_vector``, or anything else satisfying the ``resizable_byte_buffer`` concept. - .. cpp:function:: secure_vector derive_key( \ - const uint8_t secret[], \ - size_t secret_len, \ - const uint8_t salt[], \ - size_t salt_len, \ - const uint8_t label[], \ - size_t label_len) const - - .. cpp:function:: secure_vector derive_key( \ - size_t key_len, const std::vector& secret, \ - const std::vector& salt, \ - const std::vector& label) const - - .. cpp:function:: secure_vector derive_key( \ - size_t key_len, const std::vector& secret, \ - const uint8_t* salt, size_t salt_len) const - - .. cpp:function:: secure_vector derive_key( \ - size_t key_len, const uint8_t* secret, size_t secret_len, \ - const std::string& salt) const + .. cpp:function:: template \ + std::array KDF::derive_key(std::span secret, \ + std::span salt, \ + std::span label) const + + This version returns the key material as a std::array<> of ``key_len`` + bytes. All variations on the same theme. Deterministically creates a uniform random value from *secret*, *salt*, and *label*, whose