/* * Cryptographic API. * * DES & Triple DES EDE Cipher Algorithms. * * Originally released as descore by Dana L. How . * Modified by Raimar Falke for the Linux-Kernel. * Derived from Cryptoapi and Nettle implementations, adapted for in-place * scatterlist interface. Changed LGPL to GPL per section 3 of the LGPL. * * Copyright (c) 1992 Dana L. How. * Copyright (c) Raimar Falke * Copyright (c) Gisle Sælensminde * Copyright (C) 2001 Niels Möller. * Copyright (c) 2002 James Morris * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ #ifndef _DES_ #define _DES_ #include "uint.h" #define DES_KEY_SIZE 8 #define DES_EXPKEY_WORDS 32 #define DES_BLOCK_SIZE 8 #define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE) #define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS) #define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE #define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100 #define CRYPTO_TFM_RES_WEAK_KEY 0x00100000 #define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000 struct des_ctx { u8 iv[DES_BLOCK_SIZE]; u32 expkey[DES_EXPKEY_WORDS]; }; struct des3_ede_ctx { u8 iv[DES_BLOCK_SIZE]; u32 expkey[DES3_EDE_EXPKEY_WORDS]; }; int des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags); void des_encrypt(void *ctx, u8 *dst, const u8 *src); void des_decrypt(void *ctx, u8 *dst, const u8 *src); int des3_ede_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags); void des3_ede_encrypt(void *ctx, u8 *dst, const u8 *src); void des3_ede_decrypt(void *ctx, u8 *dst, const u8 *src); #endif