![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 0003 /* 0004 * Copyright (C) 2021, Stephan Mueller <smueller@chronox.de> 0005 */ 0006 0007 #ifndef _CRYPTO_KDF108_H 0008 #define _CRYPTO_KDF108_H 0009 0010 #include <crypto/hash.h> 0011 #include <linux/uio.h> 0012 0013 /** 0014 * Counter KDF generate operation according to SP800-108 section 5.1 0015 * as well as SP800-56A section 5.8.1 (Single-step KDF). 0016 * 0017 * @kmd Keyed message digest whose key was set with crypto_kdf108_setkey or 0018 * unkeyed message digest 0019 * @info optional context and application specific information - this may be 0020 * NULL 0021 * @info_vec number of optional context/application specific information entries 0022 * @dst destination buffer that the caller already allocated 0023 * @dlen length of the destination buffer - the KDF derives that amount of 0024 * bytes. 0025 * 0026 * To comply with SP800-108, the caller must provide Label || 0x00 || Context 0027 * in the info parameter. 0028 * 0029 * @return 0 on success, < 0 on error 0030 */ 0031 int crypto_kdf108_ctr_generate(struct crypto_shash *kmd, 0032 const struct kvec *info, unsigned int info_nvec, 0033 u8 *dst, unsigned int dlen); 0034 0035 /** 0036 * Counter KDF setkey operation 0037 * 0038 * @kmd Keyed message digest allocated by the caller. The key should not have 0039 * been set. 0040 * @key Seed key to be used to initialize the keyed message digest context. 0041 * @keylen This length of the key buffer. 0042 * @ikm The SP800-108 KDF does not support IKM - this parameter must be NULL 0043 * @ikmlen This parameter must be 0. 0044 * 0045 * According to SP800-108 section 7.2, the seed key must be at least as large as 0046 * the message digest size of the used keyed message digest. This limitation 0047 * is enforced by the implementation. 0048 * 0049 * SP800-108 allows the use of either a HMAC or a hash primitive. When 0050 * the caller intends to use a hash primitive, the call to 0051 * crypto_kdf108_setkey is not required and the key derivation operation can 0052 * immediately performed using crypto_kdf108_ctr_generate after allocating 0053 * a handle. 0054 * 0055 * @return 0 on success, < 0 on error 0056 */ 0057 int crypto_kdf108_setkey(struct crypto_shash *kmd, 0058 const u8 *key, size_t keylen, 0059 const u8 *ikm, size_t ikmlen); 0060 0061 #endif /* _CRYPTO_KDF108_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |