d03ab969 |
1 | /* -*-c-*- |
d03ab969 |
2 | * |
3 | * The RC5-32/12 block cipher |
4 | * |
5 | * (c) 1999 Straylight/Edgeware |
6 | */ |
7 | |
45c0fd36 |
8 | /*----- Licensing notice --------------------------------------------------* |
d03ab969 |
9 | * |
10 | * This file is part of Catacomb. |
11 | * |
12 | * Catacomb is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU Library General Public License as |
14 | * published by the Free Software Foundation; either version 2 of the |
15 | * License, or (at your option) any later version. |
45c0fd36 |
16 | * |
d03ab969 |
17 | * Catacomb is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | * GNU Library General Public License for more details. |
45c0fd36 |
21 | * |
d03ab969 |
22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with Catacomb; if not, write to the Free |
24 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
25 | * MA 02111-1307, USA. |
26 | */ |
27 | |
a3ba8531 |
28 | /*----- Notes on the RC5 block cipher -------------------------------------* |
29 | * |
30 | * RC5 was designed by Ron Rivest as a test vehicle for the use of data- |
31 | * dependent rotations in cryptographic transformations. The algorithm is |
32 | * covered by a patent held by RSA Security Inc. (US Patent# 5,724,428). |
33 | * It's vulnerable to some clever differential attacks, which can break it in |
34 | * about %$2^{44}$% chosen plaintexts. I don't recommend the use of this |
35 | * cipher. |
36 | */ |
37 | |
b3f05084 |
38 | #ifndef CATACOMB_RC5_H |
39 | #define CATACOMB_RC5_H |
d03ab969 |
40 | |
41 | #ifdef __cplusplus |
42 | extern "C" { |
43 | #endif |
44 | |
45 | /*----- Header files ------------------------------------------------------*/ |
46 | |
47 | #include <mLib/bits.h> |
48 | |
49 | /*----- Magic numbers -----------------------------------------------------*/ |
50 | |
51 | #define RC5_ROUNDS 12 |
a3ba8531 |
52 | #define RC5_KEYSZ 10 |
d03ab969 |
53 | #define RC5_BLKSZ 8 |
54 | #define RC5_CLASS (N, L, 64) |
55 | |
a3ba8531 |
56 | extern const octet rc5_keysz[]; |
57 | |
d03ab969 |
58 | /*----- Data structures ---------------------------------------------------*/ |
59 | |
60 | typedef struct rc5_ctx { |
61 | uint32 s[2 * (RC5_ROUNDS + 1)]; |
62 | } rc5_ctx; |
63 | |
64 | /*----- Functions provided ------------------------------------------------*/ |
65 | |
66 | /* --- @rc5_init@ --- * |
67 | * |
68 | * Arguments: @rc5_ctx *k@ = pointer to a key block |
69 | * @const void *sbuf@ = pointer to key material |
70 | * @size_t sz@ = size of the key material |
71 | * |
72 | * Returns: --- |
73 | * |
74 | * Use: Initializes an RC5 key block. |
75 | */ |
76 | |
77 | extern void rc5_init(rc5_ctx */*k*/, const void */*sbuf*/, size_t /*sz*/); |
78 | |
79 | /* --- @rc5_eblk@, @rc5_dblk@ --- * |
80 | * |
81 | * Arguments: @const rc5_ctx *k@ = pointer to RC5 context block |
82 | * @const uint32 s[2]@ = pointer to source block |
83 | * @uint32 *d[2]@ = pointer to destination block |
84 | * |
85 | * Returns: --- |
86 | * |
87 | * Use: Low level block encryption and decryption. |
88 | */ |
89 | |
90 | extern void rc5_eblk(const rc5_ctx */*k*/, |
91 | const uint32 */*s*/, uint32 */*d*/); |
92 | extern void rc5_dblk(const rc5_ctx */*k*/, |
93 | const uint32 */*s*/, uint32 */*d*/); |
94 | |
95 | /*----- That's all, folks -------------------------------------------------*/ |
96 | |
97 | #ifdef __cplusplus |
98 | } |
99 | #endif |
100 | |
101 | #endif |