[PATCH] gcm: do not pass extra key pointer for setupM/fillM
Jussi Kivilinna
jussi.kivilinna at iki.fi
Sat Dec 20 16:21:29 CET 2014
* cipher/cipher-gcm-intel-pclmul.c
(_gcry_ghash_setup_intel_pclmul): Remove 'h' parameter.
* cipher/cipher-gcm.c (_gcry_ghash_setup_intel_pclmul): Ditto.
(fillM): Get 'h' pointer from 'c'.
(setupM): Remome 'h' parameter.
(_gcry_cipher_gcm_setkey): Only pass 'c' to setupM.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
cipher/cipher-gcm-intel-pclmul.c | 2 +-
cipher/cipher-gcm.c | 15 ++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/cipher/cipher-gcm-intel-pclmul.c b/cipher/cipher-gcm-intel-pclmul.c
index 02e7701..0314458 100644
--- a/cipher/cipher-gcm-intel-pclmul.c
+++ b/cipher/cipher-gcm-intel-pclmul.c
@@ -239,7 +239,7 @@ static inline void gfmul_pclmul_aggr4(void)
void
-_gcry_ghash_setup_intel_pclmul (gcry_cipher_hd_t c, byte *h)
+_gcry_ghash_setup_intel_pclmul (gcry_cipher_hd_t c)
{
u64 tmp[2];
diff --git a/cipher/cipher-gcm.c b/cipher/cipher-gcm.c
index f89b81e..6b13fc5 100644
--- a/cipher/cipher-gcm.c
+++ b/cipher/cipher-gcm.c
@@ -31,7 +31,7 @@
#ifdef GCM_USE_INTEL_PCLMUL
-extern void _gcry_ghash_setup_intel_pclmul (gcry_cipher_hd_t c, byte *h);
+extern void _gcry_ghash_setup_intel_pclmul (gcry_cipher_hd_t c);
extern unsigned int _gcry_ghash_intel_pclmul (gcry_cipher_hd_t c, byte *result,
const byte *buf, size_t nblocks);
@@ -286,7 +286,8 @@ do_ghash (unsigned char *result, const unsigned char *buf, const u32 *gcmM)
}
#endif /* !HAVE_U64_TYPEDEF || SIZEOF_UNSIGNED_LONG != 8 */
-#define fillM(c, h) do_fillM (h, c->u_mode.gcm.gcm_table)
+#define fillM(c) \
+ do_fillM (c->u_mode.gcm.u_ghash_key.key, c->u_mode.gcm.gcm_table)
#define GHASH(c, result, buf) do_ghash (result, buf, c->u_mode.gcm.gcm_table)
#else
@@ -351,7 +352,7 @@ do_ghash (unsigned char *hsub, unsigned char *result, const unsigned char *buf)
return (sizeof(V) + sizeof(T) + sizeof(int)*2 + sizeof(void*)*5);
}
-#define fillM(c, h) do { } while (0)
+#define fillM(c) do { } while (0)
#define GHASH(c, result, buf) do_ghash (c->u_mode.gcm.u_ghash_key.key, result, buf)
#endif /* !GCM_USE_TABLES */
@@ -376,7 +377,7 @@ ghash_internal (gcry_cipher_hd_t c, byte *result, const byte *buf,
static void
-setupM (gcry_cipher_hd_t c, byte *h)
+setupM (gcry_cipher_hd_t c)
{
if (0)
;
@@ -384,13 +385,13 @@ setupM (gcry_cipher_hd_t c, byte *h)
else if (_gcry_get_hw_features () & HWF_INTEL_PCLMUL)
{
c->u_mode.gcm.ghash_fn = _gcry_ghash_intel_pclmul;
- _gcry_ghash_setup_intel_pclmul(c, h);
+ _gcry_ghash_setup_intel_pclmul (c);
}
#endif
else
{
c->u_mode.gcm.ghash_fn = ghash_internal;
- fillM (c, h);
+ fillM (c);
}
}
@@ -643,7 +644,7 @@ _gcry_cipher_gcm_setkey (gcry_cipher_hd_t c)
c->spec->encrypt (&c->context.c, c->u_mode.gcm.u_ghash_key.key,
c->u_mode.gcm.u_ghash_key.key);
- setupM (c, c->u_mode.gcm.u_ghash_key.key);
+ setupM (c);
}
More information about the Gcrypt-devel
mailing list