3
* Things that are used only by the testsuite and benchmark, and
7
/* nettle, low-level cryptographics library
9
* Copyright (C) 2002 Niels M�ller
11
* The nettle library is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation; either version 2.1 of the License, or (at your
14
* option) any later version.
16
* The nettle library is distributed in the hope that it will be useful, but
17
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19
* License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with the nettle library; see the file COPYING.LIB. If not, write to
23
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34
#include "nettle-internal.h"
38
/* DES uses a different signature for the key set function.
39
* And we have to adjust parity. */
41
des_set_key_hack(void *c, unsigned length, const uint8_t *key)
43
struct des_ctx *ctx = c;
44
uint8_t pkey[DES_KEY_SIZE];
46
assert(length == DES_KEY_SIZE);
47
des_fix_parity(DES_KEY_SIZE, pkey, key);
48
if (!des_set_key(ctx, pkey))
53
des3_set_key_hack(void *c, unsigned length, const uint8_t *key)
55
struct des3_ctx *ctx = c;
56
uint8_t pkey[DES3_KEY_SIZE];
58
assert(length == DES3_KEY_SIZE);
59
des_fix_parity(DES3_KEY_SIZE, pkey, key);
60
if (!des3_set_key(ctx, pkey))
64
const struct nettle_cipher
66
"des", sizeof(struct des_ctx),
67
DES_BLOCK_SIZE, DES_KEY_SIZE,
68
des_set_key_hack, des_set_key_hack,
69
(nettle_crypt_func) des_encrypt,
70
(nettle_crypt_func) des_decrypt
73
const struct nettle_cipher
75
"des3", sizeof(struct des3_ctx),
76
DES3_BLOCK_SIZE, DES3_KEY_SIZE,
77
des3_set_key_hack, des3_set_key_hack,
78
(nettle_crypt_func) des3_encrypt,
79
(nettle_crypt_func) des3_decrypt
82
/* NOTE: This is not as nice as one might think, as it will crash if
83
* we try to encrypt something with a weak key. */
84
const struct nettle_cipher
85
nettle_blowfish128 = _NETTLE_CIPHER(blowfish, BLOWFISH, 128);