Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 99281
b: refs/heads/master
c: 0f923a2
h: refs/heads/master
i:
  99279: 52bb6fc
v: v3
  • Loading branch information
Adrian-Ken Rueegsegger authored and Herbert Xu committed Jul 10, 2008
1 parent 4dd05ea commit df1b8a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0bea3dc1e2d85deb9e0bc523949d5c812f65b556
refs/heads/master: 0f923a2aab7baa94c5fef498384151af1cd72cba
37 changes: 9 additions & 28 deletions trunk/crypto/rmd128.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct rmd128_ctx {
#define F4(x, y, z) (y ^ (z & (x ^ y))) /* z ? x : y */

#define ROUND(a, b, c, d, f, k, x, s) { \
(a) += f((b), (c), (d)) + (x) + (k); \
(a) += f((b), (c), (d)) + le32_to_cpu(x) + (k); \
(a) = rol32((a), (s)); \
}

Expand Down Expand Up @@ -218,28 +218,6 @@ static void rmd128_transform(u32 *state, u32 const *in)
return;
}

static inline void le32_to_cpu_array(u32 *buf, unsigned int words)
{
while (words--) {
le32_to_cpus(buf);
buf++;
}
}

static inline void cpu_to_le32_array(u32 *buf, unsigned int words)
{
while (words--) {
cpu_to_le32s(buf);
buf++;
}
}

static inline void rmd128_transform_helper(struct rmd128_ctx *ctx)
{
le32_to_cpu_array(ctx->buffer, sizeof(ctx->buffer) / sizeof(u32));
rmd128_transform(ctx->state, ctx->buffer);
}

static void rmd128_init(struct crypto_tfm *tfm)
{
struct rmd128_ctx *rctx = crypto_tfm_ctx(tfm);
Expand Down Expand Up @@ -272,13 +250,13 @@ static void rmd128_update(struct crypto_tfm *tfm, const u8 *data,
memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail),
data, avail);

rmd128_transform_helper(rctx);
rmd128_transform(rctx->state, rctx->buffer);
data += avail;
len -= avail;

while (len >= sizeof(rctx->buffer)) {
memcpy(rctx->buffer, data, sizeof(rctx->buffer));
rmd128_transform_helper(rctx);
rmd128_transform(rctx->state, rctx->buffer);
data += sizeof(rctx->buffer);
len -= sizeof(rctx->buffer);
}
Expand All @@ -290,10 +268,12 @@ static void rmd128_update(struct crypto_tfm *tfm, const u8 *data,
static void rmd128_final(struct crypto_tfm *tfm, u8 *out)
{
struct rmd128_ctx *rctx = crypto_tfm_ctx(tfm);
u32 index, padlen;
u32 i, index, padlen;
u64 bits;
u32 *dst = (u32 *)out;
static const u8 padding[64] = { 0x80, };
bits = rctx->byte_count << 3;

bits = cpu_to_le64(rctx->byte_count << 3);

/* Pad out to 56 mod 64 */
index = rctx->byte_count & 0x3f;
Expand All @@ -304,7 +284,8 @@ static void rmd128_final(struct crypto_tfm *tfm, u8 *out)
rmd128_update(tfm, (const u8 *)&bits, sizeof(bits));

/* Store state in digest */
memcpy(out, rctx->state, sizeof(rctx->state));
for (i = 0; i < 4; i++)
dst[i] = cpu_to_le32(rctx->state[i]);

/* Wipe context */
memset(rctx, 0, sizeof(*rctx));
Expand Down

0 comments on commit df1b8a9

Please sign in to comment.