diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-07-11 15:50:46 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2008-07-11 15:50:46 +0000 |
commit | 14c7f45cdae826f88dc539c8c38dd95caf305731 (patch) | |
tree | 832da054b7cfb2dc6fd63339af736625f31d21aa /utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h | |
parent | 7c84ede3781c27db73403bd6302f320c76a58c8c (diff) | |
download | rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.tar.gz rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.zip |
Add zook's ZenUtils to SVN
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h')
-rwxr-xr-x | utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h new file mode 100755 index 0000000000..1d95ddb4f2 --- /dev/null +++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h | |||
@@ -0,0 +1,132 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V. | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library 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 GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | * | ||
18 | */ | ||
19 | |||
20 | /*!\file blowfish.h | ||
21 | * \brief Blowfish block cipher. | ||
22 | * | ||
23 | * For more information on this blockcipher, see: | ||
24 | * "Applied Cryptography", second edition | ||
25 | * Bruce Schneier | ||
26 | * Wiley & Sons | ||
27 | * | ||
28 | * Also see http://www.counterpane.com/blowfish.html | ||
29 | * | ||
30 | * \author Bob Deblier <bob.deblier@pandora.be> | ||
31 | * \ingroup BC_m BC_blowfish_m | ||
32 | */ | ||
33 | |||
34 | #ifndef _BLOWFISH_H | ||
35 | #define _BLOWFISH_H | ||
36 | |||
37 | #include "beecrypt/beecrypt.h" | ||
38 | #include "beecrypt/blowfishopt.h" | ||
39 | |||
40 | #define BLOWFISHROUNDS 16 | ||
41 | #define BLOWFISHPSIZE (BLOWFISHROUNDS+2) | ||
42 | |||
43 | /*!\brief Holds all the parameters necessary for the Blowfish cipher. | ||
44 | * \ingroup BC_blowfish_m | ||
45 | */ | ||
46 | #ifdef __cplusplus | ||
47 | struct BEECRYPTAPI blowfishParam | ||
48 | #else | ||
49 | struct _blowfishParam | ||
50 | #endif | ||
51 | { | ||
52 | /*!\var p | ||
53 | * \brief Holds the key expansion. | ||
54 | */ | ||
55 | uint32_t p[BLOWFISHPSIZE]; | ||
56 | /*!\var s | ||
57 | * \brief Holds the s-boxes. | ||
58 | */ | ||
59 | uint32_t s[1024]; | ||
60 | /*!\var fdback | ||
61 | * \brief Buffer to be used by block chaining or feedback modes. | ||
62 | */ | ||
63 | uint32_t fdback[2]; | ||
64 | }; | ||
65 | |||
66 | #ifndef __cplusplus | ||
67 | typedef struct _blowfishParam blowfishParam; | ||
68 | #endif | ||
69 | |||
70 | #ifdef __cplusplus | ||
71 | extern "C" { | ||
72 | #endif | ||
73 | |||
74 | /*!\var blowfish | ||
75 | * \brief Holds the full API description of the Blowfish algorithm. | ||
76 | */ | ||
77 | extern const BEECRYPTAPI blockCipher blowfish; | ||
78 | |||
79 | /*!\fn int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation | ||
80 | op) | ||
81 | * \brief The function performs the cipher's key expansion. | ||
82 | * \param bp The cipher's parameter block. | ||
83 | * \param key The key value. | ||
84 | * \param keybits The number of bits in the key; legal values are: 32 to 448, | ||
85 | * in multiples of 8. | ||
86 | * \param op ENCRYPT or DECRYPT. | ||
87 | * \retval 0 on success. | ||
88 | * \retval -1 on failure. | ||
89 | */ | ||
90 | BEECRYPTAPI | ||
91 | int blowfishSetup (blowfishParam*, const byte*, size_t, cipherOperation); | ||
92 | |||
93 | /*!\fn int blowfishSetIV(blowfishParam* bp, const byte* iv) | ||
94 | * \brief This function sets the Initialization Vector. | ||
95 | * \note This function is only useful in block chaining or feedback modes. | ||
96 | * \param bp The cipher's parameter block. | ||
97 | * \param iv The initialization vector; may be null. | ||
98 | * \retval 0 on success. | ||
99 | */ | ||
100 | BEECRYPTAPI | ||
101 | int blowfishSetIV (blowfishParam*, const byte*); | ||
102 | |||
103 | /*!\fn blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src) | ||
104 | * \brief This function performs the Blowfish encryption; it encrypts one block | ||
105 | * of 64 bits. | ||
106 | * \param bp The cipher's parameter block. | ||
107 | * \param dst The ciphertext; should be aligned on 32-bit boundary. | ||
108 | * \param src The cleartext; should be aligned on 32-bit boundary. | ||
109 | * \retval 0 on success. | ||
110 | */ | ||
111 | BEECRYPTAPI | ||
112 | int blowfishEncrypt (blowfishParam*, uint32_t*, const uint32_t*); | ||
113 | |||
114 | /*!\fn blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src) | ||
115 | * \brief This function performs the Blowfish decryption; it Rderypts one block | ||
116 | * of 64 bits. | ||
117 | * \param bp The cipher's parameter block. | ||
118 | * \param dst The cleartext; should be aligned on 32-bit boundary. | ||
119 | * \param src The ciphertext; should be aligned on 32-bit boundary. | ||
120 | * \retval 0 on success. | ||
121 | */ | ||
122 | BEECRYPTAPI | ||
123 | int blowfishDecrypt (blowfishParam*, uint32_t*, const uint32_t*); | ||
124 | |||
125 | BEECRYPTAPI | ||
126 | uint32_t* blowfishFeedback(blowfishParam*); | ||
127 | |||
128 | #ifdef __cplusplus | ||
129 | } | ||
130 | #endif | ||
131 | |||
132 | #endif | ||