]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/crypto/ccp/ccp-crypto-aes-galois.c
crypto: ccp - Add support for valid authsize values less than 16
[mirror_ubuntu-bionic-kernel.git] / drivers / crypto / ccp / ccp-crypto-aes-galois.c
index ff02b713c6f6605c874def99e052e50ec30f344a..7a26ee7417cfba612d03f724a2e2d67061512fc5 100644 (file)
@@ -62,6 +62,19 @@ static int ccp_aes_gcm_setkey(struct crypto_aead *tfm, const u8 *key,
 static int ccp_aes_gcm_setauthsize(struct crypto_aead *tfm,
                                   unsigned int authsize)
 {
+       switch (authsize) {
+       case 16:
+       case 15:
+       case 14:
+       case 13:
+       case 12:
+       case 8:
+       case 4:
+               break;
+       default:
+               return -EINVAL;
+       }
+
        return 0;
 }
 
@@ -108,6 +121,7 @@ static int ccp_aes_gcm_crypt(struct aead_request *req, bool encrypt)
        memset(&rctx->cmd, 0, sizeof(rctx->cmd));
        INIT_LIST_HEAD(&rctx->cmd.entry);
        rctx->cmd.engine = CCP_ENGINE_AES;
+       rctx->cmd.u.aes.authsize = crypto_aead_authsize(tfm);
        rctx->cmd.u.aes.type = ctx->u.aes.type;
        rctx->cmd.u.aes.mode = ctx->u.aes.mode;
        rctx->cmd.u.aes.action = encrypt;