Commit | Line | Data |
---|---|---|
e6e0e332 MW |
1 | /* -*-c-*- |
2 | * | |
6b2d9d76 | 3 | * $Id: storin.h,v 1.2 2000/07/02 15:21:20 mdw Exp $ |
e6e0e332 MW |
4 | * |
5 | * Block cipher optimized for DSPs | |
6 | * | |
7 | * (c) 2000 Mark Wooding | |
8 | */ | |
9 | ||
10 | /*----- Licensing notice --------------------------------------------------* | |
11 | * | |
12 | * Copyright (c) 2000 Mark Wooding | |
13 | * All rights reserved. | |
14 | * | |
15 | * Redistribution and use in source and binary forms, with or without | |
16 | * modification, are permitted provided that the following conditions are | |
17 | * met: | |
18 | * | |
19 | * 1. Redistributions of source code must retain the above copyright | |
20 | * notice, this list of conditions and the following disclaimer. | |
21 | * | |
22 | * 2, Redistributions in binary form must reproduce the above copyright | |
23 | * notice, this list of conditions and the following disclaimer in the | |
24 | * documentation and/or other materials provided with the distribution. | |
25 | * | |
26 | * 3. The name of the authors may not be used to endorse or promote | |
27 | * products derived from this software without specific prior written | |
28 | * permission. | |
29 | * | |
30 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
31 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
32 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | |
6b2d9d76 | 33 | * NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
e6e0e332 MW |
34 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
35 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
36 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
37 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
38 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
39 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
40 | * POSSIBILITY OF SUCH DAMAGE. | |
41 | * | |
42 | * Instead of accepting the above terms, you may redistribute and/or modify | |
43 | * this software under the terms of either the GNU General Public License, | |
44 | * or the GNU Library General Public License, published by the Free | |
45 | * Software Foundation; either version 2 of the License, or (at your | |
46 | * option) any later version. | |
47 | */ | |
48 | ||
49 | /*----- Revision history --------------------------------------------------* | |
50 | * | |
51 | * $Log: storin.h,v $ | |
6b2d9d76 MW |
52 | * Revision 1.2 2000/07/02 15:21:20 mdw |
53 | * Fix licence text. | |
54 | * | |
e6e0e332 MW |
55 | * Revision 1.1 2000/05/21 11:28:30 mdw |
56 | * Initial check-in. | |
57 | * | |
58 | */ | |
59 | ||
60 | #ifndef STORIN_H | |
61 | #define STORIN_H | |
62 | ||
63 | #ifdef __cplusplus | |
64 | extern "C" { | |
65 | #endif | |
66 | ||
67 | /*----- Header files ------------------------------------------------------*/ | |
68 | ||
69 | #ifndef BITS_H | |
70 | # include "bits.h" | |
71 | #endif | |
72 | ||
73 | /*----- Magic numbers -----------------------------------------------------*/ | |
74 | ||
75 | #define STORIN_BLKSZ 12 | |
76 | #define STORIN_KEYSZ 12 | |
77 | #define STORIN_CLASS (N, L, 96) | |
78 | ||
79 | #define STORIN_ROUNDS 8 | |
80 | ||
81 | /*----- Data structures ---------------------------------------------------*/ | |
82 | ||
83 | typedef struct storin_ctx { | |
84 | uint24 k[4 * (STORIN_ROUNDS + 1)]; | |
85 | } storin_ctx; | |
86 | ||
87 | /*----- Functions provided ------------------------------------------------*/ | |
88 | ||
89 | /* --- @storin_init24@ --- * | |
90 | * | |
91 | * Arguments: @storin_ctx *k@ = pointer to cipher context to initialize | |
92 | * @const uint24 *buf@ = pointer to buffer of key material | |
93 | * @size_t sz@ = size of the key material | |
94 | * | |
95 | * Returns: --- | |
96 | * | |
97 | * Use: Initializes the cipher for use. | |
98 | */ | |
99 | ||
100 | extern void storin_init24(storin_ctx */*k*/, | |
101 | const uint24 */*buf*/, size_t /*sz*/); | |
102 | ||
103 | /* --- @storin_eblk24@, @storin_dblk24@ --- * | |
104 | * | |
105 | * Arguments: @const storin_ctx *k@ = pointer to cipher context | |
106 | * @const uint24 s[4]@ = pointer to source block | |
107 | * @uint24 d[4]@ = pointer to destination block | |
108 | * | |
109 | * Returns: --- | |
110 | * | |
111 | * Use: Low-level block encryption and decryption. | |
112 | */ | |
113 | ||
114 | extern void storin_eblk24(const storin_ctx */*k*/, | |
115 | const uint24 */*s*/, uint24 */*d*/); | |
116 | extern void storin_dblk24(const storin_ctx */*k*/, | |
117 | const uint24 */*s*/, uint24 */*d*/); | |
118 | ||
119 | /*----- That's all, folks -------------------------------------------------*/ | |
120 | ||
121 | #ifdef __cplusplus | |
122 | } | |
123 | #endif | |
124 | ||
125 | #endif |