/* SPDX-License-Identifier: GPL-2.0 */1/*2* CAAM/SEC 4.x definitions for handling key-generation jobs3*4* Copyright 2008-2011 Freescale Semiconductor, Inc.5*6*/78/**9* split_key_len - Compute MDHA split key length for a given algorithm10* @hash: Hashing algorithm selection, one of OP_ALG_ALGSEL_* - MD5, SHA1,11* SHA224, SHA384, SHA512.12*13* Return: MDHA split key length14*/15static inline u32 split_key_len(u32 hash)16{17/* Sizes for MDHA pads (*not* keys): MD5, SHA1, 224, 256, 384, 512 */18static const u8 mdpadlen[] = { 16, 20, 32, 32, 64, 64 };19u32 idx;2021idx = (hash & OP_ALG_ALGSEL_SUBMASK) >> OP_ALG_ALGSEL_SHIFT;2223return (u32)(mdpadlen[idx] * 2);24}2526/**27* split_key_pad_len - Compute MDHA split key pad length for a given algorithm28* @hash: Hashing algorithm selection, one of OP_ALG_ALGSEL_* - MD5, SHA1,29* SHA224, SHA384, SHA512.30*31* Return: MDHA split key pad length32*/33static inline u32 split_key_pad_len(u32 hash)34{35return ALIGN(split_key_len(hash), 16);36}3738struct split_key_result {39struct completion completion;40int err;41};4243void split_key_done(struct device *dev, u32 *desc, u32 err, void *context);4445int gen_split_key(struct device *jrdev, u8 *key_out,46struct alginfo * const adata, const u8 *key_in, u32 keylen,47int max_keylen);484950