Skip to content

Commit

Permalink
Extend KMAC maximal key length to 164 bytes
Browse files Browse the repository at this point in the history
Used to support the One-Step KDM of NIST.SP.800-56Cr2.
  • Loading branch information
FAlbertDev committed Jun 10, 2024
1 parent 1a5cf87 commit 01c20cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/mac/kmac/kmac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ Key_Length_Specification KMAC::key_spec() const {
// KMAC supports key lengths from zero up to 2²⁰⁴⁰ (2^(2040)) bits:
// https://nvlpubs.nist.gov/nistpubs/specialpublications/nist.sp.800-185.pdf#page=28
//
// However, we restrict the key length to 64 bytes in order to avoid allocation of overly
// large memory stretches when client code works with the maximal key length.
return Key_Length_Specification(0, 64);
// However, we restrict the key length to 164 bytes in order to avoid allocation of overly
// large memory stretches when client code works with the maximal key length. 164 is the
// length of the default_salt of the one-step KDM with KMAC128
// (see NIST SP 800-56C Rev. 2, Section 4.1, Implementation-Dependent Parameters 3.).
return Key_Length_Specification(0, 164);
}

bool KMAC::has_keying_material() const {
Expand Down

0 comments on commit 01c20cd

Please sign in to comment.