ossl: Fix some bugs in the fallback AES-GCM implementation
gcm_*_aesni() are used when the AVX512 implementation is not available.
Fix two bugs which manifest when handling operations spanning multiple
segments:
- Avoid underflow when the length of the input is smaller than the residual.
- In gcm_decrypt_aesni(), ensure that we begin the operation at the right offset into the input and output buffers.
Reviewed by: jhb
Fixes: 9b1d87286c78 ("ossl: Add a fallback AES-GCM implementation using AES-NI")
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42838
Approved by: so
Security: FreeBSD-EN-23:17.ossl
(cherry picked from commit 47d767dab54895f3ba8abac6ab2295797394659e)
(cherry picked from commit 118b866d9c39da1f5a17680e2034b3eff7337988)