git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A tool to compare kernel config files.
[linux-2.6.git]
/
crypto
/
michael_mic.c
diff --git
a/crypto/michael_mic.c
b/crypto/michael_mic.c
index
08a8dbb
..
d061da2
100644
(file)
--- a/
crypto/michael_mic.c
+++ b/
crypto/michael_mic.c
@@
-10,10
+10,12
@@
* published by the Free Software Foundation.
*/
* published by the Free Software Foundation.
*/
+#include <asm/byteorder.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/crypto.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/crypto.h>
+#include <linux/types.h>
struct michael_mic_ctx {
struct michael_mic_ctx {
@@
-24,18
+26,6
@@
struct michael_mic_ctx {
};
};
-static inline u32 rotl(u32 val, int bits)
-{
- return (val << bits) | (val >> (32 - bits));
-}
-
-
-static inline u32 rotr(u32 val, int bits)
-{
- return (val >> bits) | (val << (32 - bits));
-}
-
-
static inline u32 xswap(u32 val)
{
return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
static inline u32 xswap(u32 val)
{
return ((val & 0x00ff00ff) << 8) | ((val & 0xff00ff00) >> 8);
@@
-44,42
+34,29
@@
static inline u32 xswap(u32 val)
#define michael_block(l, r) \
do { \
#define michael_block(l, r) \
do { \
- r ^= ro
tl(l, 17);
\
+ r ^= ro
l32(l, 17);
\
l += r; \
r ^= xswap(l); \
l += r; \
l += r; \
r ^= xswap(l); \
l += r; \
- r ^= ro
tl(l, 3);
\
+ r ^= ro
l32(l, 3);
\
l += r; \
l += r; \
- r ^= ro
tr(l, 2);
\
+ r ^= ro
r32(l, 2);
\
l += r; \
} while (0)
l += r; \
} while (0)
-static
inline u32 get_le32(const u8 *p
)
+static
void michael_init(struct crypto_tfm *tfm
)
{
{
- return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
-}
-
-
-static inline void put_le32(u8 *p, u32 v)
-{
- p[0] = v;
- p[1] = v >> 8;
- p[2] = v >> 16;
- p[3] = v >> 24;
-}
-
-
-static void michael_init(void *ctx)
-{
- struct michael_mic_ctx *mctx = ctx;
+ struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm);
mctx->pending_len = 0;
}
mctx->pending_len = 0;
}
-static void michael_update(void *ctx, const u8 *data, unsigned int len)
+static void michael_update(struct crypto_tfm *tfm, const u8 *data,
+ unsigned int len)
{
{
- struct michael_mic_ctx *mctx = ctx;
+ struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm);
+ const __le32 *src;
if (mctx->pending_len) {
int flen = 4 - mctx->pending_len;
if (mctx->pending_len) {
int flen = 4 - mctx->pending_len;
@@
-93,29
+70,32
@@
static void michael_update(void *ctx, const u8 *data, unsigned int len)
if (mctx->pending_len < 4)
return;
if (mctx->pending_len < 4)
return;
- mctx->l ^= get_le32(mctx->pending);
+ src = (const __le32 *)mctx->pending;
+ mctx->l ^= le32_to_cpup(src);
michael_block(mctx->l, mctx->r);
mctx->pending_len = 0;
}
michael_block(mctx->l, mctx->r);
mctx->pending_len = 0;
}
+ src = (const __le32 *)data;
+
while (len >= 4) {
while (len >= 4) {
- mctx->l ^=
get_le32(data
);
+ mctx->l ^=
le32_to_cpup(src++
);
michael_block(mctx->l, mctx->r);
michael_block(mctx->l, mctx->r);
- data += 4;
len -= 4;
}
if (len > 0) {
mctx->pending_len = len;
len -= 4;
}
if (len > 0) {
mctx->pending_len = len;
- memcpy(mctx->pending,
data
, len);
+ memcpy(mctx->pending,
src
, len);
}
}
}
}
-static void michael_final(
void *ctx
, u8 *out)
+static void michael_final(
struct crypto_tfm *tfm
, u8 *out)
{
{
- struct michael_mic_ctx *mctx = c
tx
;
+ struct michael_mic_ctx *mctx = c
rypto_tfm_ctx(tfm)
;
u8 *data = mctx->pending;
u8 *data = mctx->pending;
+ __le32 *dst = (__le32 *)out;
/* Last block and padding (0x5a, 4..7 x 0) */
switch (mctx->pending_len) {
/* Last block and padding (0x5a, 4..7 x 0) */
switch (mctx->pending_len) {
@@
-137,22
+117,25
@@
static void michael_final(void *ctx, u8 *out)
/* l ^= 0; */
michael_block(mctx->l, mctx->r);
/* l ^= 0; */
michael_block(mctx->l, mctx->r);
-
put_le32(out,
mctx->l);
-
put_le32(out + 4,
mctx->r);
+
dst[0] = cpu_to_le32(
mctx->l);
+
dst[1] = cpu_to_le32(
mctx->r);
}
}
-static int michael_setkey(
void *ctx, const u8 *key, unsigned int keylen
,
- u32 *flags)
+static int michael_setkey(
struct crypto_tfm *tfm, const u8 *key
,
+ u
nsigned int keylen, u
32 *flags)
{
{
- struct michael_mic_ctx *mctx = ctx;
+ struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm);
+ const __le32 *data = (const __le32 *)key;
+
if (keylen != 8) {
if (flags)
*flags = CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
}
if (keylen != 8) {
if (flags)
*flags = CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
}
- mctx->l = get_le32(key);
- mctx->r = get_le32(key + 4);
+
+ mctx->l = le32_to_cpu(data[0]);
+ mctx->r = le32_to_cpu(data[1]);
return 0;
}
return 0;
}
@@
-163,6
+146,7
@@
static struct crypto_alg michael_mic_alg = {
.cra_blocksize = 8,
.cra_ctxsize = sizeof(struct michael_mic_ctx),
.cra_module = THIS_MODULE,
.cra_blocksize = 8,
.cra_ctxsize = sizeof(struct michael_mic_ctx),
.cra_module = THIS_MODULE,
+ .cra_alignmask = 3,
.cra_list = LIST_HEAD_INIT(michael_mic_alg.cra_list),
.cra_u = { .digest = {
.dia_digestsize = 8,
.cra_list = LIST_HEAD_INIT(michael_mic_alg.cra_list),
.cra_u = { .digest = {
.dia_digestsize = 8,