ltq-deu: fix temp size exceed in hmac algorithms
authorDaniel Kestrel <kestrel1974@t-online.de>
Tue, 15 Jun 2021 15:23:05 +0000 (17:23 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Wed, 5 Jan 2022 23:22:59 +0000 (00:22 +0100)
commit0470b05b568c9d9b7188e83c1303d0acac64921d
treea7ee4c8a1e8372663b89059edd9b8a66795bd58b
parent85383b311212576e7afd9d01dec49f69ef6fb886
ltq-deu: fix temp size exceed in hmac algorithms

Exceeding the temp array size was not checked and instead storage not
allocated by the driver was used/overwritten which in most cases
resulted in reboots. This patch implements processing the input to the
hash algorithm in tempsize chunks.
The _hmac_final methods were changed to _hmac_final_impl adding a
parameter that indicates intermediate or final processing. The started
variable was added to the context to indicate, if there is an
intermediate result in the context. For sha1_hmac the variable to store
the intermediate hash was added to the context too.
In order to avoid md5_hmac_final_impl being recursively called if the
padding of the input and the resulting last transform during the hmac
algorighms final processing causes the temp array to overflow and to
make sure that there is at least one block in the temp array when the
_hmac_final for final processing is called, the check for exceeding
the temp array in _hmac_transform was moved before copying the block
and incrementing dbn. dbn needs to be at least 1 at final processing
time to let the hash engine apply the opad operation.
To make the hash engine not apply the hmac algorithms final opad
operation, for intermediate processing the dbn in the control register
is set to a higher value than number of dbns are actually processed.

Signed-off-by: Daniel Kestrel <kestrel1974@t-online.de>
package/kernel/lantiq/ltq-deu/src/ifxmips_md5_hmac.c
package/kernel/lantiq/ltq-deu/src/ifxmips_sha1_hmac.c