/* SPDX-License-Identifier: GPL-2.0 */1/*2* DES & Triple DES EDE Cipher Algorithms.3*/45#ifndef __CRYPTO_DES_H6#define __CRYPTO_DES_H78#include <linux/types.h>910#define DES_KEY_SIZE 811#define DES_EXPKEY_WORDS 3212#define DES_BLOCK_SIZE 81314#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)15#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)16#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE1718struct des_ctx {19u32 expkey[DES_EXPKEY_WORDS];20};2122struct des3_ede_ctx {23u32 expkey[DES3_EDE_EXPKEY_WORDS];24};2526void des_encrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src);27void des_decrypt(const struct des_ctx *ctx, u8 *dst, const u8 *src);2829void des3_ede_encrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src);30void des3_ede_decrypt(const struct des3_ede_ctx *dctx, u8 *dst, const u8 *src);3132/**33* des_expand_key - Expand a DES input key into a key schedule34* @ctx: the key schedule35* @key: buffer containing the input key36* @len: size of the buffer contents37*38* Returns 0 on success, -EINVAL if the input key is rejected and -ENOKEY if39* the key is accepted but has been found to be weak.40*/41int des_expand_key(struct des_ctx *ctx, const u8 *key, unsigned int keylen);4243/**44* des3_ede_expand_key - Expand a triple DES input key into a key schedule45* @ctx: the key schedule46* @key: buffer containing the input key47* @len: size of the buffer contents48*49* Returns 0 on success, -EINVAL if the input key is rejected and -ENOKEY if50* the key is accepted but has been found to be weak. Note that weak keys will51* be rejected (and -EINVAL will be returned) when running in FIPS mode.52*/53int des3_ede_expand_key(struct des3_ede_ctx *ctx, const u8 *key,54unsigned int keylen);5556#endif /* __CRYPTO_DES_H */575859