Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18500
b: refs/heads/master
c: 7ffbc9d
h: refs/heads/master
v: v3
  • Loading branch information
Jan Glauber authored and Linus Torvalds committed Jan 15, 2006
1 parent a7c5af1 commit e8fea6d
Show file tree
Hide file tree
Showing 2 changed files with 23 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: fda5e142598341d30006e3715e53b2c983a9fca7
refs/heads/master: 7ffbc9da137ef475afd5e01f72e1ce1ce49668b1
29 changes: 22 additions & 7 deletions trunk/arch/s390/crypto/sha256_s390.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,37 @@ static void sha256_update(void *ctx, const u8 *data, unsigned int len)
{
struct s390_sha256_ctx *sctx = ctx;
unsigned int index;
int ret;

/* how much is already in the buffer? */
index = sctx->count / 8 & 0x3f;

/* update message bit length */
sctx->count += len * 8;

/* process one block */
if ((index + len) >= SHA256_BLOCK_SIZE) {
if ((index + len) < SHA256_BLOCK_SIZE)
goto store;

/* process one stored block */
if (index) {
memcpy(sctx->buf + index, data, SHA256_BLOCK_SIZE - index);
crypt_s390_kimd(KIMD_SHA_256, sctx->state, sctx->buf,
SHA256_BLOCK_SIZE);
ret = crypt_s390_kimd(KIMD_SHA_256, sctx->state, sctx->buf,
SHA256_BLOCK_SIZE);
BUG_ON(ret != SHA256_BLOCK_SIZE);
data += SHA256_BLOCK_SIZE - index;
len -= SHA256_BLOCK_SIZE - index;
}

/* process as many blocks as possible */
if (len >= SHA256_BLOCK_SIZE) {
ret = crypt_s390_kimd(KIMD_SHA_256, sctx->state, data,
len & ~(SHA256_BLOCK_SIZE - 1));
BUG_ON(ret != (len & ~(SHA256_BLOCK_SIZE - 1)));
data += ret;
len -= ret;
}

store:
/* anything left? */
if (len)
memcpy(sctx->buf + index , data, len);
Expand Down Expand Up @@ -119,9 +134,9 @@ static struct crypto_alg alg = {
.cra_list = LIST_HEAD_INIT(alg.cra_list),
.cra_u = { .digest = {
.dia_digestsize = SHA256_DIGEST_SIZE,
.dia_init = sha256_init,
.dia_update = sha256_update,
.dia_final = sha256_final } }
.dia_init = sha256_init,
.dia_update = sha256_update,
.dia_final = sha256_final } }
};

static int init(void)
Expand Down

0 comments on commit e8fea6d

Please sign in to comment.