]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
crypto: mediatek - Add empty messages check in GCM mode
authorRyder Lee <ryder.lee@mediatek.com>
Tue, 22 Aug 2017 07:53:39 +0000 (15:53 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Sep 2017 09:43:08 +0000 (17:43 +0800)
Currently, empty messages are not supported in GCM mode, hence add
a check to prevent producing incorrect results.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/mediatek/mtk-aes.c

index 9e845e866dec73a81f546f7956b88d3814f776ed..72e4549ed36b8212c8962068fe4e5252252daa03 100644 (file)
@@ -928,8 +928,13 @@ static int mtk_aes_gcm_start(struct mtk_cryp *cryp, struct mtk_aes_rec *aes)
 static int mtk_aes_gcm_crypt(struct aead_request *req, u64 mode)
 {
        struct mtk_aes_base_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req));
+       struct mtk_aes_gcm_ctx *gctx = mtk_aes_gcm_ctx_cast(ctx);
        struct mtk_aes_reqctx *rctx = aead_request_ctx(req);
 
+       /* Empty messages are not supported yet */
+       if (!gctx->textlen && !req->assoclen)
+               return -EINVAL;
+
        rctx->mode = AES_FLAGS_GCM | mode;
 
        return mtk_aes_handle_queue(ctx->cryp, !!(mode & AES_FLAGS_ENCRYPT),