summaryrefslogtreecommitdiffstats
path: root/src/plugins/crypto_native/ghash.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-02-24 14:26:08 +0100
committerDamjan Marion <damarion@cisco.com>2020-02-24 14:29:54 +0100
commita2e56ee4d89ff1342d277747b97d44469f578407 (patch)
treead99a51057b0bd548c8b557bdcfd255e07cabcb5 /src/plugins/crypto_native/ghash.h
parentbc50a665148a8d326157723cbc1933920b5604b1 (diff)
crypto-native: inverse Hi so it naturally fits into 512-bit register
Type: refactor Change-Id: I0c6ca9356af179abd0a414b356dea7e3a3eb0dd6 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/crypto_native/ghash.h')
-rw-r--r--src/plugins/crypto_native/ghash.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/plugins/crypto_native/ghash.h b/src/plugins/crypto_native/ghash.h
index abbfd2856f0..f389d11cfe7 100644
--- a/src/plugins/crypto_native/ghash.h
+++ b/src/plugins/crypto_native/ghash.h
@@ -384,7 +384,7 @@ ghash4_final (ghash4_data_t * gd)
#endif
static_always_inline void
-ghash_precompute (u8x16 H, u8x16 * Hi, int count)
+ghash_precompute (u8x16 H, u8x16 * Hi, int n)
{
u8x16 r8;
u32x4 r32;
@@ -401,11 +401,11 @@ ghash_precompute (u8x16 H, u8x16 * Hi, int count)
/* *INDENT-OFF* */
r32 = r32 == (u32x4) {1, 0, 0, 1};
/* *INDENT-ON* */
- Hi[0] = H ^ ((u8x16) r32 & ghash_poly);
+ Hi[n - 1] = H = H ^ ((u8x16) r32 & ghash_poly);
/* calculate H^(i + 1) */
- for (int i = 1; i < count; i++)
- Hi[i] = ghash_mul (Hi[0], Hi[i - 1]);
+ for (int i = n - 2; i >= 0; i--)
+ Hi[i] = ghash_mul (H, Hi[i + 1]);
}
#endif /* __ghash_h__ */