3 The des block cipher. And triple des.
5 Copyright (C) 1992 Dana L. How
6 Copyright (C) 2001 Niels Möller
8 This file is part of GNU Nettle.
10 GNU Nettle is free software: you can redistribute it and/or
11 modify it under the terms of either:
13 * the GNU Lesser General Public License as published by the Free
14 Software Foundation; either version 3 of the License, or (at your
15 option) any later version.
19 * the GNU General Public License as published by the Free
20 Software Foundation; either version 2 of the License, or (at your
21 option) any later version.
23 or both in parallel, as here.
25 GNU Nettle is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 General Public License for more details.
30 You should have received copies of the GNU General Public License and
31 the GNU Lesser General Public License along with this program. If
32 not, see http://www.gnu.org/licenses/.
36 * des - fast & portable DES encryption & decryption.
37 * Copyright (C) 1992 Dana L. How
38 * Please see the file `../lib/descore.README' for the complete copyright
41 * Slightly edited by Niels Möller, 1997
44 #ifndef NETTLE_DES_H_INCLUDED
45 #define NETTLE_DES_H_INCLUDED
47 #include "nettle-types.h"
53 /* Namespace mangling */
54 #define des_set_key nettle_des_set_key
55 #define des_encrypt nettle_des_encrypt
56 #define des_decrypt nettle_des_decrypt
57 #define des_check_parity nettle_des_check_parity
58 #define des_fix_parity nettle_des_fix_parity
59 #define des3_set_key nettle_des3_set_key
60 #define des3_encrypt nettle_des3_encrypt
61 #define des3_decrypt nettle_des3_decrypt
63 #define DES_KEY_SIZE 8
64 #define DES_BLOCK_SIZE 8
66 /* Expanded key length */
67 #define _DES_KEY_LENGTH 32
71 uint32_t key[_DES_KEY_LENGTH];
74 /* Returns 1 for good keys and 0 for weak keys. */
76 des_set_key(struct des_ctx *ctx, const uint8_t *key);
79 des_encrypt(const struct des_ctx *ctx,
80 size_t length, uint8_t *dst,
83 des_decrypt(const struct des_ctx *ctx,
84 size_t length, uint8_t *dst,
88 des_check_parity(size_t length, const uint8_t *key);
91 des_fix_parity(size_t length, uint8_t *dst,
94 #define DES3_KEY_SIZE 24
95 #define DES3_BLOCK_SIZE DES_BLOCK_SIZE
99 struct des_ctx des[3];
103 /* Returns 1 for good keys and 0 for weak keys. */
105 des3_set_key(struct des3_ctx *ctx, const uint8_t *key);
108 des3_encrypt(const struct des3_ctx *ctx,
109 size_t length, uint8_t *dst,
112 des3_decrypt(const struct des3_ctx *ctx,
113 size_t length, uint8_t *dst,
120 #endif /* NETTLE_DES_H_INCLUDED */