| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Cryptographic API. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Driver for EIP97 SHA1/SHA2(HMAC) acceleration. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Copyright (c) 2016 Ryder Lee <ryder.lee@mediatek.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | 8 | * |
|---|
| 12 | 9 | * Some ideas are from atmel-sha.c and omap-sham.c drivers. |
|---|
| 13 | 10 | */ |
|---|
| .. | .. |
|---|
| 110 | 107 | u8 id; |
|---|
| 111 | 108 | u8 buf[SHA_BUF_SIZE] __aligned(sizeof(u32)); |
|---|
| 112 | 109 | |
|---|
| 113 | | - struct mtk_sha_hmac_ctx base[0]; |
|---|
| 110 | + struct mtk_sha_hmac_ctx base[]; |
|---|
| 114 | 111 | }; |
|---|
| 115 | 112 | |
|---|
| 116 | 113 | struct mtk_sha_drv { |
|---|
| .. | .. |
|---|
| 242 | 239 | static void mtk_sha_fill_padding(struct mtk_sha_reqctx *ctx, u32 len) |
|---|
| 243 | 240 | { |
|---|
| 244 | 241 | u32 index, padlen; |
|---|
| 245 | | - u64 bits[2]; |
|---|
| 242 | + __be64 bits[2]; |
|---|
| 246 | 243 | u64 size = ctx->digcnt; |
|---|
| 247 | 244 | |
|---|
| 248 | 245 | size += ctx->bufcnt; |
|---|
| .. | .. |
|---|
| 365 | 362 | SHASH_DESC_ON_STACK(shash, bctx->shash); |
|---|
| 366 | 363 | |
|---|
| 367 | 364 | shash->tfm = bctx->shash; |
|---|
| 368 | | - shash->flags = 0; /* not CRYPTO_TFM_REQ_MAY_SLEEP */ |
|---|
| 369 | 365 | |
|---|
| 370 | 366 | return crypto_shash_init(shash) ?: |
|---|
| 371 | 367 | crypto_shash_update(shash, bctx->opad, ctx->bs) ?: |
|---|
| .. | .. |
|---|
| 782 | 778 | ctx->flags |= SHA_FLAGS_FINUP; |
|---|
| 783 | 779 | |
|---|
| 784 | 780 | err1 = mtk_sha_update(req); |
|---|
| 785 | | - if (err1 == -EINPROGRESS || err1 == -EBUSY) |
|---|
| 781 | + if (err1 == -EINPROGRESS || |
|---|
| 782 | + (err1 == -EBUSY && (ahash_request_flags(req) & |
|---|
| 783 | + CRYPTO_TFM_REQ_MAY_BACKLOG))) |
|---|
| 786 | 784 | return err1; |
|---|
| 787 | 785 | /* |
|---|
| 788 | 786 | * final() has to be always called to cleanup resources |
|---|
| .. | .. |
|---|
| 807 | 805 | size_t ds = crypto_shash_digestsize(bctx->shash); |
|---|
| 808 | 806 | int err, i; |
|---|
| 809 | 807 | |
|---|
| 810 | | - SHASH_DESC_ON_STACK(shash, bctx->shash); |
|---|
| 811 | | - |
|---|
| 812 | | - shash->tfm = bctx->shash; |
|---|
| 813 | | - shash->flags = crypto_shash_get_flags(bctx->shash) & |
|---|
| 814 | | - CRYPTO_TFM_REQ_MAY_SLEEP; |
|---|
| 815 | | - |
|---|
| 816 | 808 | if (keylen > bs) { |
|---|
| 817 | | - err = crypto_shash_digest(shash, key, keylen, bctx->ipad); |
|---|
| 809 | + err = crypto_shash_tfm_digest(bctx->shash, key, keylen, |
|---|
| 810 | + bctx->ipad); |
|---|
| 818 | 811 | if (err) |
|---|
| 819 | 812 | return err; |
|---|
| 820 | 813 | keylen = ds; |
|---|