1 /* SPDX-License-Identifier: GPL-2.0 */
3 * CAAM/SEC 4.x definitions for handling key-generation jobs
5 * Copyright 2008-2011 Freescale Semiconductor, Inc.
10 * split_key_len - Compute MDHA split key length for a given algorithm
11 * @hash: Hashing algorithm selection, one of OP_ALG_ALGSEL_* - MD5, SHA1,
12 * SHA224, SHA384, SHA512.
14 * Return: MDHA split key length
16 static inline u32
split_key_len(u32 hash
)
18 /* Sizes for MDHA pads (*not* keys): MD5, SHA1, 224, 256, 384, 512 */
19 static const u8 mdpadlen
[] = { 16, 20, 32, 32, 64, 64 };
22 idx
= (hash
& OP_ALG_ALGSEL_SUBMASK
) >> OP_ALG_ALGSEL_SHIFT
;
24 return (u32
)(mdpadlen
[idx
] * 2);
28 * split_key_pad_len - Compute MDHA split key pad length for a given algorithm
29 * @hash: Hashing algorithm selection, one of OP_ALG_ALGSEL_* - MD5, SHA1,
30 * SHA224, SHA384, SHA512.
32 * Return: MDHA split key pad length
34 static inline u32
split_key_pad_len(u32 hash
)
36 return ALIGN(split_key_len(hash
), 16);
39 struct split_key_result
{
40 struct completion completion
;
44 void split_key_done(struct device
*dev
, u32
*desc
, u32 err
, void *context
);
46 int gen_split_key(struct device
*jrdev
, u8
*key_out
,
47 struct alginfo
* const adata
, const u8
*key_in
, u32 keylen
,