@@ -518,9 +518,19 @@ static int vmac_update(struct shash_desc *desc, const u8 *p, unsigned int len)
if (len >= VMAC_NHBYTES) {
n = round_down(len, VMAC_NHBYTES);
- /* TODO: 'p' may be misaligned here */
- vhash_blocks(tctx, dctx, (const __le64 *)p, n / VMAC_NHBYTES);
- p += n;
+ if (!IS_ALIGNED((unsigned long)p, sizeof(__le64))) {
+ /* handle misallignment by copying data to ta temporary buffer */
+ u8 temp_buf[VMAC_NHBYTES];
+ const u8 *end = p + n;
+ while (p < end) {
+ memcpy(temp_buf, p, VMAC_NHBYTES);
+ vhash_blocks(tctx, dctx, (const __le64 *)temp_buf, 1);
+ p += VMAC_NHBYTES;
+ }
+ } else {
+ vhash_blocks(tctx, dctx, (const __le64 *)p, n / VMAC_NHBYTES);
+ p += n;
+ }
len -= n;
}
Handle pontential misalignment of the input pointer(p) in vmac_update by copying the data to a temp buffer before processing. Signed-off-by: Atharva Tiwari <evepolonium@gmail.com> --- crypto/vmac.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)