|
@@ -106,14 +106,6 @@ static asmlinkage struct job_sha256* (*sha256_job_mgr_flush)
|
|
static asmlinkage struct job_sha256* (*sha256_job_mgr_get_comp_job)
|
|
static asmlinkage struct job_sha256* (*sha256_job_mgr_get_comp_job)
|
|
(struct sha256_mb_mgr *state);
|
|
(struct sha256_mb_mgr *state);
|
|
|
|
|
|
-inline void sha256_init_digest(uint32_t *digest)
|
|
|
|
-{
|
|
|
|
- static const uint32_t initial_digest[SHA256_DIGEST_LENGTH] = {
|
|
|
|
- SHA256_H0, SHA256_H1, SHA256_H2, SHA256_H3,
|
|
|
|
- SHA256_H4, SHA256_H5, SHA256_H6, SHA256_H7};
|
|
|
|
- memcpy(digest, initial_digest, sizeof(initial_digest));
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
inline uint32_t sha256_pad(uint8_t padblock[SHA256_BLOCK_SIZE * 2],
|
|
inline uint32_t sha256_pad(uint8_t padblock[SHA256_BLOCK_SIZE * 2],
|
|
uint64_t total_len)
|
|
uint64_t total_len)
|
|
{
|
|
{
|
|
@@ -245,10 +237,8 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
|
|
uint32_t len,
|
|
uint32_t len,
|
|
int flags)
|
|
int flags)
|
|
{
|
|
{
|
|
- if (flags & (~HASH_ENTIRE)) {
|
|
|
|
- /* User should not pass anything other than FIRST, UPDATE
|
|
|
|
- * or LAST
|
|
|
|
- */
|
|
|
|
|
|
+ if (flags & ~(HASH_UPDATE | HASH_LAST)) {
|
|
|
|
+ /* User should not pass anything other than UPDATE or LAST */
|
|
ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
|
|
ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
|
|
return ctx;
|
|
return ctx;
|
|
}
|
|
}
|
|
@@ -259,23 +249,12 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr,
|
|
return ctx;
|
|
return ctx;
|
|
}
|
|
}
|
|
|
|
|
|
- if ((ctx->status & HASH_CTX_STS_COMPLETE) && !(flags & HASH_FIRST)) {
|
|
|
|
|
|
+ if (ctx->status & HASH_CTX_STS_COMPLETE) {
|
|
/* Cannot update a finished job. */
|
|
/* Cannot update a finished job. */
|
|
ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED;
|
|
ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED;
|
|
return ctx;
|
|
return ctx;
|
|
}
|
|
}
|
|
|
|
|
|
- if (flags & HASH_FIRST) {
|
|
|
|
- /* Init digest */
|
|
|
|
- sha256_init_digest(ctx->job.result_digest);
|
|
|
|
-
|
|
|
|
- /* Reset byte counter */
|
|
|
|
- ctx->total_length = 0;
|
|
|
|
-
|
|
|
|
- /* Clear extra blocks */
|
|
|
|
- ctx->partial_block_buffer_length = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/* If we made it here, there was no error during this call to submit */
|
|
/* If we made it here, there was no error during this call to submit */
|
|
ctx->error = HASH_CTX_ERROR_NONE;
|
|
ctx->error = HASH_CTX_ERROR_NONE;
|
|
|
|
|