crypto: qat - add check to validate firmware images
authorSrinivas Kerekare <srinivas.kerekare@intel.com>
Mon, 25 Jul 2022 10:40:09 +0000 (11:40 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 19 Aug 2022 10:39:33 +0000 (18:39 +0800)
commit908f24270d9ccbe120b91e7029b372f3dcd18290
tree1da016c502fd195339efbd6d8cb871b448bfda71
parent108586eba094b318e6a831f977f4ddcc403a15da
crypto: qat - add check to validate firmware images

The function qat_uclo_check_image() validates the MMP and AE firmware
images. If the QAT device supports firmware authentication (indicated
by the handle to firmware loader), the input signed binary MMP and AE
images are validated by parsing the following information:
- Header length
- Full size of the binary
- Type of binary image (MMP or AE Firmware)

Firmware binaries use RSA3K for signing and verification.
The header length for the RSA3k is 0x384 bytes.

All the size field values in the binary are quantified
as DWORDS (1 DWORD = 4bytes).

On an invalid value the function prints an error message and returns
with an error code "EINVAL".

Signed-off-by: Srinivas Kerekare <srinivas.kerekare@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Wojciech Ziemba <wojciech.ziemba@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/qat/qat_common/icp_qat_uclo.h
drivers/crypto/qat/qat_common/qat_uclo.c