"Fossies" - the Fresh Open Source Software Archive 
Member "n2n-3.1.1/include/tf.h" (31 Mar 2022, 2939 Bytes) of package /linux/misc/n2n-3.1.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "tf.h" see the
Fossies "Dox" file reference documentation and the latest
Fossies "Diffs" side-by-side code changes report:
3.0_vs_3.1.1.
1 /**
2 * (C) 2007-22 - ntop.org and contributors
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not see see <http://www.gnu.org/licenses/>
16 *
17 */
18
19
20 // taken (and modified) from github/fudanchii/twofish as of August 2020
21 // which itself is a modified copy of Andrew T. Csillag's implementation
22 // published on github/drewcsillag/twofish
23
24
25 /**
26 * The MIT License (MIT)
27 *
28 * Copyright (c) 2015 Andrew T. Csillag
29 *
30 * Permission is hereby granted, free of charge, to any person obtaining a copy
31 * of this software and associated documentation files (the "Software"), to deal
32 * in the Software without restriction, including without limitation the rights
33 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34 * copies of the Software, and to permit persons to whom the Software is
35 * furnished to do so, subject to the following conditions:
36 *
37 * The above copyright notice and this permission notice shall be included in
38 * all copies or substantial portions of the Software.
39 *
40 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
46 * THE SOFTWARE.
47 */
48
49
50 #ifndef TF_H
51 #define TF_H
52
53
54 #include <stdint.h>
55 #include <stdlib.h>
56 #include <string.h>
57
58 #include "portable_endian.h"
59
60
61 #define TF_BLOCK_SIZE 16
62 #define TF_IV_SIZE (TF_BLOCK_SIZE)
63
64
65 typedef struct tf_context_t {
66 int N;
67 uint32_t K[40];
68 uint32_t QF[4][256];
69 } tf_context_t;
70
71
72 int tf_ecb_decrypt (unsigned char *out, const unsigned char *in, tf_context_t *ctx);
73
74 int tf_ecb_encrypt (unsigned char *out, const unsigned char *in, tf_context_t *ctx);
75
76 int tf_cbc_encrypt (unsigned char *out, const unsigned char *in, size_t in_len,
77 const unsigned char *iv, tf_context_t *ctx);
78
79 int tf_cbc_decrypt (unsigned char *out, const unsigned char *in, size_t in_len,
80 const unsigned char *iv, tf_context_t *ctx);
81
82 int tf_init (const unsigned char *key, size_t key_size, tf_context_t **ctx);
83
84 int tf_deinit (tf_context_t *ctx);
85
86
87 #endif // TF_H