Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / nettle-internal.c
blobf271eac051a20d73738e2c68600aea26e2ff9032
1 /* nettle-internal.c
3 * Things that are used only by the testsuite and benchmark, and
4 * subject to change.
5 */
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., 51 Franklin Street, Fifth Floor, Boston,
24 * MA 02111-1301, USA.
27 #if HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include <assert.h>
32 #include <stdlib.h>
34 #include "nettle-internal.h"
35 #include "blowfish.h"
36 #include "des.h"
37 #include "gcm.h"
38 #include "salsa20.h"
40 /* DES uses a different signature for the key set function. We ignore
41 the return value indicating weak keys. */
42 static void
43 des_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
45 assert(length == DES_KEY_SIZE);
46 des_set_key(ctx, key);
49 static void
50 des3_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
52 assert(length == DES3_KEY_SIZE);
53 des3_set_key(ctx, key);
56 /* NOTE: A bit ugly. Ignores weak keys, and pretends the set:key
57 functions have no return value. */
58 const struct nettle_cipher
59 nettle_des = {
60 "des", sizeof(struct des_ctx),
61 DES_BLOCK_SIZE, DES_KEY_SIZE,
62 des_set_key_hack, des_set_key_hack,
63 (nettle_crypt_func *) des_encrypt,
64 (nettle_crypt_func *) des_decrypt
67 const struct nettle_cipher
68 nettle_des3 = {
69 "des3", sizeof(struct des3_ctx),
70 DES3_BLOCK_SIZE, DES3_KEY_SIZE,
71 des3_set_key_hack, des3_set_key_hack,
72 (nettle_crypt_func *) des3_encrypt,
73 (nettle_crypt_func *) des3_decrypt
76 /* NOTE: This is not as nice as one might think, as we pretend
77 blowfish_set_key has no return value. */
78 const struct nettle_cipher
79 nettle_blowfish128 = _NETTLE_CIPHER(blowfish, BLOWFISH, 128);
81 /* Sets a fix zero iv. For benchmarking only. */
82 static void
83 salsa20_set_key_hack(void *ctx, unsigned length, const uint8_t *key)
85 static const uint8_t iv[SALSA20_IV_SIZE];
86 salsa20_set_key (ctx, length, key);
87 salsa20_set_iv (ctx, iv);
90 /* Claim zero block size, to classify as a stream cipher. */
91 const struct nettle_cipher
92 nettle_salsa20 = {
93 "salsa20", sizeof(struct salsa20_ctx),
94 0, SALSA20_KEY_SIZE,
95 salsa20_set_key_hack, salsa20_set_key_hack,
96 (nettle_crypt_func *) salsa20_crypt,
97 (nettle_crypt_func *) salsa20_crypt
100 const struct nettle_cipher
101 nettle_salsa20r12 = {
102 "salsa20r12", sizeof(struct salsa20_ctx),
103 0, SALSA20_KEY_SIZE,
104 salsa20_set_key_hack, salsa20_set_key_hack,
105 (nettle_crypt_func *) salsa20r12_crypt,
106 (nettle_crypt_func *) salsa20r12_crypt
109 const struct nettle_aead
110 nettle_gcm_aes128 = _NETTLE_AEAD(gcm, GCM, aes, 128);
111 const struct nettle_aead
112 nettle_gcm_aes192 = _NETTLE_AEAD(gcm, GCM, aes, 192);
113 const struct nettle_aead
114 nettle_gcm_aes256 = _NETTLE_AEAD(gcm, GCM, aes, 256);