Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34223
b: refs/heads/master
c: ee75641
h: refs/heads/master
i:
  34221: b372026
  34219: 797fa2e
  34215: ff5c3fd
  34207: e221678
v: v3
  • Loading branch information
Herbert Xu committed Sep 21, 2006
1 parent 39c064e commit 836e559
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 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: 560c06ae1ab7c677002ea3b6ac83521bf12ee07d
refs/heads/master: ee7564166da9e218c3f605ee78ff16599d4d5a05
16 changes: 10 additions & 6 deletions trunk/crypto/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ static void update(struct crypto_tfm *tfm,
static void final(struct crypto_tfm *tfm, u8 *out)
{
unsigned long alignmask = crypto_tfm_alg_alignmask(tfm);
struct digest_alg *digest = &tfm->__crt_alg->cra_digest;

if (unlikely((unsigned long)out & alignmask)) {
unsigned int size = crypto_tfm_alg_digestsize(tfm);
u8 buffer[size + alignmask];
u8 *dst = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1);
tfm->__crt_alg->cra_digest.dia_final(tfm, dst);
memcpy(out, dst, size);
unsigned long align = alignmask + 1;
unsigned long addr = (unsigned long)crypto_tfm_ctx(tfm);
u8 *dst = (u8 *)ALIGN(addr, align) +
ALIGN(tfm->__crt_alg->cra_ctxsize, align);

digest->dia_final(tfm, dst);
memcpy(out, dst, digest->dia_digestsize);
} else
tfm->__crt_alg->cra_digest.dia_final(tfm, out);
digest->dia_final(tfm, out);
}

static int nosetkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
Expand Down
9 changes: 8 additions & 1 deletion trunk/crypto/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ static inline void crypto_exit_proc(void)
static inline unsigned int crypto_digest_ctxsize(struct crypto_alg *alg,
int flags)
{
return alg->cra_ctxsize;
unsigned int len = alg->cra_ctxsize;

if (alg->cra_alignmask) {
len = ALIGN(len, (unsigned long)alg->cra_alignmask + 1);
len += alg->cra_digest.dia_digestsize;
}

return len;
}

static inline unsigned int crypto_cipher_ctxsize(struct crypto_alg *alg,
Expand Down

0 comments on commit 836e559

Please sign in to comment.