/* SPDX-License-Identifier: GPL-2.0 */1/*2* NH hash function for Adiantum3*/45#ifndef _CRYPTO_NH_H6#define _CRYPTO_NH_H78#include <linux/types.h>910/* NH parameterization: */1112/* Endianness: little */13/* Word size: 32 bits (works well on NEON, SSE2, AVX2) */1415/* Stride: 2 words (optimal on ARM32 NEON; works okay on other CPUs too) */16#define NH_PAIR_STRIDE 217#define NH_MESSAGE_UNIT (NH_PAIR_STRIDE * 2 * sizeof(u32))1819/* Num passes (Toeplitz iteration count): 4, to give ε = 2^{-128} */20#define NH_NUM_PASSES 421#define NH_HASH_BYTES (NH_NUM_PASSES * sizeof(u64))2223/* Max message size: 1024 bytes (32x compression factor) */24#define NH_NUM_STRIDES 6425#define NH_MESSAGE_WORDS (NH_PAIR_STRIDE * 2 * NH_NUM_STRIDES)26#define NH_MESSAGE_BYTES (NH_MESSAGE_WORDS * sizeof(u32))27#define NH_KEY_WORDS (NH_MESSAGE_WORDS + \28NH_PAIR_STRIDE * 2 * (NH_NUM_PASSES - 1))29#define NH_KEY_BYTES (NH_KEY_WORDS * sizeof(u32))3031/**32* nh() - NH hash function for Adiantum33* @key: The key. @message_len + 48 bytes of it are used. This is NH_KEY_BYTES34* if @message_len has its maximum length of NH_MESSAGE_BYTES.35* @message: The message36* @message_len: The message length in bytes. Must be a multiple of 1637* (NH_MESSAGE_UNIT) and at most 1024 (NH_MESSAGE_BYTES).38* @hash: (output) The resulting hash value39*40* Note: the pseudocode for NH in the Adiantum paper iterates over 1024-byte41* segments of the message, computes a 32-byte hash for each, and returns all42* the hashes concatenated together. In contrast, this function just hashes one43* segment and returns one hash. It's the caller's responsibility to call this44* function for each 1024-byte segment and collect all the hashes.45*46* Context: Any context.47*/48void nh(const u32 *key, const u8 *message, size_t message_len,49__le64 hash[NH_NUM_PASSES]);5051#endif /* _CRYPTO_NH_H */525354