lsd0009

LSD0009: The GNU Taler Protocol
Log | Files | Refs | README

commit 647fde5bc6f043150fa424cf20e977644a308358
parent c19a39d00ad3df61d215792cd7b578758ced5389
Author: Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
Date:   Mon,  8 Jul 2024 10:26:45 +0200

crypto primitives: add HMAC, switch from bits to octets

Diffstat:
Mdraft-guetschow-taler-protocol.md | 46+++++++++++++++++++++++++++++++++-------------
Mdraft-guetschow-taler-protocol.xml | 134++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
2 files changed, 112 insertions(+), 68 deletions(-)

diff --git a/draft-guetschow-taler-protocol.md b/draft-guetschow-taler-protocol.md @@ -66,10 +66,10 @@ Use at your own risk! SHA-256(msg) -> hash Input: - msg input message of length L < 2^64 bits + msg input message of length L < 2^61 octets Output: - hash message digest of fixed length L' = 256 bits + hash message digest of fixed length HashLen = 32 octets ~~~ `hash` is the output of SHA-256 as per Sections 4.1, 5.1, 6.1, and 6.2 of [RFC6234]. @@ -80,10 +80,10 @@ Output: SHA-512(msg) -> hash Input: - msg input message of length L < 2^128 bits + msg input message of length L < 2^125 octets Output: - hash message digest of fixed length L' = 512 bits + hash message digest of fixed length HashLen = 64 octets ~~~ `hash` is the output of SHA-512 as per Sections 4.2, 5.2, 6.3, and 6.4 of [RFC6234]. @@ -94,30 +94,50 @@ Output: SHA-512(msg) -> hash Input: - msg input message of length L < 2^128 bits + msg input message of length L < 2^125 octets Output: - hash message digest of fixed length L' = 256 bits + hash message digest of fixed length HashLen = 32 octets ~~~ -The output `hash` corresponds to the first 256 bit of the output of SHA-512 defined in {{sha512}}: +The output `hash` corresponds to the first 32 octets of the output of SHA-512 defined in {{sha512}}: ~~~ temp = SHA-512(msg) -hash = temp[0:255] +hash = temp[0:31] ~~~ Note that this operation differs from SHA-512/256 as defined in [SHS] in the initial hash value. +## Message Authentication Codes + +### HMAC {#hmac} + +~~~ +HMAC-Hash(key, text) -> out + +Option: + Hash cryptographic hash function with output length HashLen + +Input: + key secret key of length at least HashLen + text input data of arbitary length + +Output: + out output of length HashLen +~~~ + +`out` is calculated as defined in [RFC2104]. + + ## Key Derivation Functions ### HKDF {#hkdf} The Hashed Key Derivation Function (HKDF) used in Taler is an instantiation of [RFC5869] -with two different hash functions for the Extract and Expand step as suggested in [HKDF]. -HMAC-SHA512 (HMAC [RFC2104] instantiated with SHA-512, cf. {{sha512}}) is used for `HKDF-Extract`. -HMAC-SHA256 (HMAC [RFC2104] instantiated with SHA-256, cf. {{sha256}}) is used for `HKDF-Expand`. +with two different hash functions for the Extract and Expand step as suggested in [HKDF]: +`HKDF-Extract` uses `HMAC-SHA512`, while `HKDF-Expand` uses `HMAC-SHA256` (cf. {{hmac}}). ~~~ HKDF(salt, IKM, info, L) -> OKM @@ -138,8 +158,8 @@ Output: The output OKM is calculated as follows: ~~~ -PRK = HKDF-Extract(salt, IKM) with Hash = SHA-512, HashLen = 64 -OKM = HKDF-Expand(PRK, info, L) with Hash = SHA-256, HashLen = 32 +PRK = HKDF-Extract(salt, IKM) with Hash = SHA-512 (HashLen = 64) +OKM = HKDF-Expand(PRK, info, L) with Hash = SHA-256 (HashLen = 32) ~~~ ### HKDF-Mod diff --git a/draft-guetschow-taler-protocol.xml b/draft-guetschow-taler-protocol.xml @@ -80,10 +80,10 @@ Use at your own risk!</t> SHA-256(msg) -> hash Input: - msg input message of length L < 2^64 bits + msg input message of length L < 2^61 octets Output: - hash message digest of fixed length L' = 256 bits + hash message digest of fixed length HashLen = 32 octets ]]></artwork></figure> <t><spanx style="verb">hash</spanx> is the output of SHA-256 as per Sections 4.1, 5.1, 6.1, and 6.2 of <xref target="RFC6234"></xref>.</t> @@ -95,10 +95,10 @@ Output: SHA-512(msg) -> hash Input: - msg input message of length L < 2^128 bits + msg input message of length L < 2^125 octets Output: - hash message digest of fixed length L' = 512 bits + hash message digest of fixed length HashLen = 64 octets ]]></artwork></figure> <t><spanx style="verb">hash</spanx> is the output of SHA-512 as per Sections 4.2, 5.2, 6.3, and 6.4 of <xref target="RFC6234"></xref>.</t> @@ -110,31 +110,52 @@ Output: SHA-512(msg) -> hash Input: - msg input message of length L < 2^128 bits + msg input message of length L < 2^125 octets Output: - hash message digest of fixed length L' = 256 bits + hash message digest of fixed length HashLen = 32 octets ]]></artwork></figure> -<t>The output <spanx style="verb">hash</spanx> corresponds to the first 256 bit of the output of SHA-512 defined in <xref target="sha512"/>:</t> +<t>The output <spanx style="verb">hash</spanx> corresponds to the first 32 octets of the output of SHA-512 defined in <xref target="sha512"/>:</t> <figure><artwork><![CDATA[ temp = SHA-512(msg) -hash = temp[0:255] +hash = temp[0:31] ]]></artwork></figure> <t>Note that this operation differs from SHA-512/256 as defined in <xref target="SHS"></xref> in the initial hash value.</t> </section> </section> +<section anchor="message-authentication-codes"><name>Message Authentication Codes</name> + +<section anchor="hmac"><name>HMAC</name> + +<figure><artwork><![CDATA[ +HMAC-Hash(key, text) -> out + +Option: + Hash cryptographic hash function with output length HashLen + +Input: + key secret key of length at least HashLen + text input data of arbitary length + +Output: + out output of length HashLen +]]></artwork></figure> + +<t><spanx style="verb">out</spanx> is calculated as defined in <xref target="RFC2104"></xref>.</t> + +</section> +</section> <section anchor="key-derivation-functions"><name>Key Derivation Functions</name> <section anchor="hkdf"><name>HKDF</name> <t>The Hashed Key Derivation Function (HKDF) used in Taler is an instantiation of <xref target="RFC5869"></xref> -with two different hash functions for the Extract and Expand step as suggested in <xref target="HKDF"></xref>. -HMAC-SHA512 (HMAC <xref target="RFC2104"></xref> instantiated with SHA-512, cf. <xref target="sha512"/>) is used for <spanx style="verb">HKDF-Extract</spanx>. -HMAC-SHA256 (HMAC <xref target="RFC2104"></xref> instantiated with SHA-256, cf. <xref target="sha256"/>) is used for <spanx style="verb">HKDF-Expand</spanx>.</t> +with two different hash functions for the Extract and Expand step as suggested in <xref target="HKDF"></xref>: +<spanx style="verb">HKDF-Extract</spanx> uses <spanx style="verb">HMAC-SHA512</spanx>, while <spanx style="verb">HKDF-Expand</spanx> uses <spanx style="verb">HMAC-SHA256</spanx> (cf. <xref target="hmac"/>).</t> <figure><artwork><![CDATA[ HKDF(salt, IKM, info, L) -> OKM @@ -155,8 +176,8 @@ Output: <t>The output OKM is calculated as follows:</t> <figure><artwork><![CDATA[ -PRK = HKDF-Extract(salt, IKM) with Hash = SHA-512, HashLen = 64 -OKM = HKDF-Expand(PRK, info, L) with Hash = SHA-256, HashLen = 32 +PRK = HKDF-Extract(salt, IKM) with Hash = SHA-512 (HashLen = 64) +OKM = HKDF-Expand(PRK, info, L) with Hash = SHA-256 (HashLen = 32) ]]></artwork></figure> </section> @@ -313,7 +334,7 @@ while true: -<?line 201?> +<?line 221?> <section anchor="change-log"><name>Change log</name> @@ -331,47 +352,50 @@ Education and Research (BMBF) within the project Concrete Contracts.</t> </back> <!-- ##markdown-source: -H4sIAAAAAAAAA81XbVMbyRH+vr+iY3+IdGGFJEAG3ZEKL8ZQgOwyuO4DR8Jo -d7SaYzWzNTuL0PnwL8u3/LE8PbN6w/aVL1eVhHLJu7P93k/3dMdxHD30aSuK -nHK57NOL67GkN4MPdC1yaemdNc4kJn8RpSbRYgKK1IqRi7NKujIZm2nsmDAu -asIoEU5mxs76pPTIRJEqbJ+crUrXbbf32t1oaux9Zk1VMEUqC4kf7aLSWSkm -62f3cgbqtB8RxeT1+KfEzgpnMiuK8cwfyESUY/9UiNkEnGUUvaQHqSvZxwOR -lYXp09i5ouxvbmbKtTJdaelaxmabeZm2YVoLx5ueOocLpVvSg+AL9JtRJCo3 -NhbmxVBOFOJzqe5NLhS9+dc/Q4T8NzD26frDMR1bWcI5+qDVg7SlcjMyI7qW -yVib3GQzTy2GQysfmGFO7485RhKGncp8Mja5+wUHLeq0/ccEovpr5IlJYc9x -3O60e3v1SaUd5+aNtBOhgzI5ESrv0yTY3Vpk9m+uitMgrpXKKNIGPA5Wcz7e -nxx1O+3t+nFnt7dXP/a6W/709Pz4BMrfnrU6bfxrv9rce7Ubb8W97W7c2QZV -/OofW9sgvDq9WtD12t3d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