[PATCH] tests/basic: add vector cluttering to detect implementation bugs

Jussi Kivilinna jussi.kivilinna at iki.fi
Sun Jan 19 09:27:10 CET 2020


* src/global.c (_gcry_check_version): Fix missing newline.
* src/basic.c (ALWAYS_INLINE, CLUTTER_REGISTER_*, prepare_vector_data)
(clutter_vector_registers): New.
(progress_handler): Make static function.
(check_bulk_cipher_modes, check_one_cipher_core_reset)
(check_one_cipher_core, check_one_md, check_one_md_multi)
(check_one_md_final, check_one_mac): Clutter vector registers before
gcry_* calls to cipher/md/mac algorithms.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 src/global.c  |    3 -
 tests/basic.c |  288 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 288 insertions(+), 3 deletions(-)

diff --git a/src/global.c b/src/global.c
index d82c680a5..be65df54a 100644
--- a/src/global.c
+++ b/src/global.c
@@ -261,7 +261,8 @@ _gcry_check_version (const char *req_version)
     /* Compare version numbers.  */
     if ( my_major > rq_major
 	|| (my_major == rq_major && my_minor > rq_minor)
-	|| (my_major == rq_major && my_minor == rq_minor		                           		 && my_micro > rq_micro)
+	|| (my_major == rq_major && my_minor == rq_minor
+	    && my_micro > rq_micro)
 	|| (my_major == rq_major && my_minor == rq_minor
                                  && my_micro == rq_micro))
       {
diff --git a/tests/basic.c b/tests/basic.c
index 8337bcfb7..71b2aa30f 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -33,6 +33,10 @@
 #define PGM "basic"
 #include "t-common.h"
 
+#if __GNUC__ >= 4
+#  define ALWAYS_INLINE __attribute__((always_inline))
+#endif
+
 typedef struct test_spec_pubkey_key
 {
   const char *secret;
@@ -191,7 +195,7 @@ show_mac_not_available (int algo)
 
 
 
-void
+static void
 progress_handler (void *cb_data, const char *what, int printchar,
 		  int current, int total)
 {
@@ -207,6 +211,237 @@ progress_handler (void *cb_data, const char *what, int printchar,
   fflush (stdout);
 }
 
+
+#if defined(__x86_64__) && defined(HAVE_GCC_INLINE_ASM_SSSE3) && \
+    (defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \
+     defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS))
+# define CLUTTER_VECTOR_REGISTER_AMD64 1
+# define CLUTTER_VECTOR_REGISTER_COUNT 16
+#elif defined(__i386__) && SIZEOF_UNSIGNED_LONG == 4 && __GNUC__ >= 4 && \
+      defined(HAVE_GCC_INLINE_ASM_SSSE3)
+# define CLUTTER_VECTOR_REGISTER_I386 1
+# define CLUTTER_VECTOR_REGISTER_COUNT 8
+#elif defined(HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS) && \
+      defined(HAVE_GCC_INLINE_ASM_AARCH64_NEON) && \
+      (defined(__ARM_FEATURE_SIMD32) || defined(__ARM_NEON))
+# define CLUTTER_VECTOR_REGISTER_AARCH64 1
+# define CLUTTER_VECTOR_REGISTER_COUNT 32
+#elif defined(HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS) && \
+      defined(HAVE_GCC_INLINE_ASM_NEON) && \
+      (defined(__ARM_FEATURE_SIMD32) || defined(__ARM_NEON))
+# define CLUTTER_VECTOR_REGISTER_NEON 1
+# define CLUTTER_VECTOR_REGISTER_COUNT 32
+#endif
+
+
+#ifdef CLUTTER_VECTOR_REGISTER_COUNT
+static void
+prepare_vector_data(unsigned char data[CLUTTER_VECTOR_REGISTER_COUNT][16])
+{
+  static unsigned char basedata[16] =
+  {
+    0xd7, 0xfe, 0x5c, 0x4b, 0x58, 0xfe, 0xf4, 0xb6,
+    0xed, 0x2f, 0x31, 0xc9, 0x1d, 0xd3, 0x62, 0x8d
+  };
+  int j, i;
+
+  for (i = 0; i < CLUTTER_VECTOR_REGISTER_COUNT; i++)
+    {
+      for (j = 0; j < 16; j++)
+	{
+	  data[i][j] = basedata[(i + j) % 16];
+	}
+
+      for (j = 0; j < 16; j++)
+	{
+	  basedata[j] -= j;
+	}
+    }
+}
+#endif
+
+
+static inline ALWAYS_INLINE void
+clutter_vector_registers(void)
+{
+#ifdef CLUTTER_VECTOR_REGISTER_COUNT
+  unsigned char data[CLUTTER_VECTOR_REGISTER_COUNT][16];
+#if defined(CLUTTER_VECTOR_REGISTER_AARCH64) || \
+    defined(CLUTTER_VECTOR_REGISTER_NEON)
+  static int init;
+  static int have_neon;
+
+  if (!init)
+    {
+      char *string;
+
+      string = gcry_get_config (0, "hwflist");
+      if (string)
+	{
+	  have_neon = (strstr(string, "arm-neon:") != NULL);
+	  xfree(string);
+	}
+      init = 1;
+    }
+
+  if (!have_neon)
+    return;
+#elif defined(CLUTTER_VECTOR_REGISTER_I386)
+  static int init;
+  static int have_ssse3;
+
+  if (!init)
+    {
+      char *string;
+
+      string = gcry_get_config (0, "hwflist");
+      if (string)
+	{
+	  have_ssse3 = (strstr(string, "intel-ssse3:") != NULL);
+	  xfree(string);
+	}
+      init = 1;
+    }
+
+  if (!have_ssse3)
+    return;
+#endif
+
+  prepare_vector_data(data);
+
+#if defined(CLUTTER_VECTOR_REGISTER_AMD64)
+  asm volatile("movdqu %[data0], %%xmm0\n"
+	       "movdqu %[data1], %%xmm1\n"
+	       "movdqu %[data2], %%xmm2\n"
+	       "movdqu %[data3], %%xmm3\n"
+	       "movdqu %[data4], %%xmm4\n"
+	       "movdqu %[data5], %%xmm5\n"
+	       "movdqu %[data6], %%xmm6\n"
+	       "movdqu %[data7], %%xmm7\n"
+	       "movdqu %[data8], %%xmm8\n"
+	       "movdqu %[data9], %%xmm9\n"
+	       "movdqu %[data10], %%xmm10\n"
+	       "movdqu %[data11], %%xmm11\n"
+	       "movdqu %[data12], %%xmm12\n"
+	       "movdqu %[data13], %%xmm13\n"
+	       "movdqu %[data14], %%xmm14\n"
+	       "movdqu %[data15], %%xmm15\n"
+	      :
+	      : [data0] "m" (*data[0]),
+	        [data1] "m" (*data[1]),
+	        [data2] "m" (*data[2]),
+	        [data3] "m" (*data[3]),
+	        [data4] "m" (*data[4]),
+	        [data5] "m" (*data[5]),
+	        [data6] "m" (*data[6]),
+	        [data7] "m" (*data[7]),
+	        [data8] "m" (*data[8]),
+	        [data9] "m" (*data[9]),
+	        [data10] "m" (*data[10]),
+	        [data11] "m" (*data[11]),
+	        [data12] "m" (*data[12]),
+	        [data13] "m" (*data[13]),
+	        [data14] "m" (*data[14]),
+	        [data15] "m" (*data[15])
+	      : "memory"
+#ifdef __SSE2__
+	       ,"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
+	        "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14",
+	        "xmm15"
+#endif
+	      );
+#elif defined(CLUTTER_VECTOR_REGISTER_I386)
+  asm volatile("movdqu %[data0], %%xmm0\n"
+	       "movdqu %[data1], %%xmm1\n"
+	       "movdqu %[data2], %%xmm2\n"
+	       "movdqu %[data3], %%xmm3\n"
+	       "movdqu %[data4], %%xmm4\n"
+	       "movdqu %[data5], %%xmm5\n"
+	       "movdqu %[data6], %%xmm6\n"
+	       "movdqu %[data7], %%xmm7\n"
+	      :
+	      : [data0] "m" (*data[0]),
+	        [data1] "m" (*data[1]),
+	        [data2] "m" (*data[2]),
+	        [data3] "m" (*data[3]),
+	        [data4] "m" (*data[4]),
+	        [data5] "m" (*data[5]),
+	        [data6] "m" (*data[6]),
+	        [data7] "m" (*data[7])
+	      : "memory"
+#ifdef __SSE2__
+	       ,"xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
+#endif
+	      );
+#elif defined(CLUTTER_VECTOR_REGISTER_AARCH64)
+  asm volatile("mov x0, %[ptr]\n"
+	       "ld1 {v0.16b}, [x0], #16\n"
+	       "ld1 {v1.16b}, [x0], #16\n"
+	       "ld1 {v2.16b}, [x0], #16\n"
+	       "ld1 {v3.16b}, [x0], #16\n"
+	       "ld1 {v4.16b}, [x0], #16\n"
+	       "ld1 {v5.16b}, [x0], #16\n"
+	       "ld1 {v6.16b}, [x0], #16\n"
+	       "ld1 {v7.16b}, [x0], #16\n"
+	       "ld1 {v8.16b}, [x0], #16\n"
+	       "ld1 {v9.16b}, [x0], #16\n"
+	       "ld1 {v10.16b}, [x0], #16\n"
+	       "ld1 {v11.16b}, [x0], #16\n"
+	       "ld1 {v12.16b}, [x0], #16\n"
+	       "ld1 {v13.16b}, [x0], #16\n"
+	       "ld1 {v14.16b}, [x0], #16\n"
+	       "ld1 {v15.16b}, [x0], #16\n"
+	       "ld1 {v16.16b}, [x0], #16\n"
+	       "ld1 {v17.16b}, [x0], #16\n"
+	       "ld1 {v18.16b}, [x0], #16\n"
+	       "ld1 {v19.16b}, [x0], #16\n"
+	       "ld1 {v20.16b}, [x0], #16\n"
+	       "ld1 {v21.16b}, [x0], #16\n"
+	       "ld1 {v22.16b}, [x0], #16\n"
+	       "ld1 {v23.16b}, [x0], #16\n"
+	       "ld1 {v24.16b}, [x0], #16\n"
+	       "ld1 {v25.16b}, [x0], #16\n"
+	       "ld1 {v26.16b}, [x0], #16\n"
+	       "ld1 {v27.16b}, [x0], #16\n"
+	       "ld1 {v28.16b}, [x0], #16\n"
+	       "ld1 {v29.16b}, [x0], #16\n"
+	       "ld1 {v30.16b}, [x0], #16\n"
+	       "ld1 {v31.16b}, [x0], #16\n"
+	       :
+	       : [ptr] "r" (data)
+	       : "x0", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7",
+	         "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15",
+	         "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23",
+	         "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31");
+#elif defined(CLUTTER_VECTOR_REGISTER_NEON)
+  asm volatile("mov r0, %[ptr]\n"
+	       "vld1.64 {q0}, [r0]!\n"
+	       "vld1.64 {q1}, [r0]!\n"
+	       "vld1.64 {q2}, [r0]!\n"
+	       "vld1.64 {q3}, [r0]!\n"
+	       "vld1.64 {q4}, [r0]!\n"
+	       "vld1.64 {q5}, [r0]!\n"
+	       "vld1.64 {q6}, [r0]!\n"
+	       "vld1.64 {q7}, [r0]!\n"
+	       "vld1.64 {q8}, [r0]!\n"
+	       "vld1.64 {q9}, [r0]!\n"
+	       "vld1.64 {q10}, [r0]!\n"
+	       "vld1.64 {q11}, [r0]!\n"
+	       "vld1.64 {q12}, [r0]!\n"
+	       "vld1.64 {q13}, [r0]!\n"
+	       "vld1.64 {q14}, [r0]!\n"
+	       "vld1.64 {q15}, [r0]!\n"
+	       :
+	       : [ptr] "r" (data)
+	       : "r0", "q0", "q1", "q2", "q3", "q4", "q5", "q6", "q7",
+	         "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15");
+#endif
+
+#endif /* CLUTTER_VECTOR_REGISTER_COUNT */
+}
+
+
+
 static void
 check_cbc_mac_cipher (void)
 {
@@ -8280,7 +8515,9 @@ check_bulk_cipher_modes (void)
           goto leave;
         }
 
+      clutter_vector_registers();
       err = gcry_cipher_setkey (hde, tv[i].key, tv[i].keylen);
+      clutter_vector_registers();
       if (!err)
         err = gcry_cipher_setkey (hdd, tv[i].key, tv[i].keylen);
       if (err)
@@ -8296,7 +8533,9 @@ check_bulk_cipher_modes (void)
           goto leave;
         }
 
+      clutter_vector_registers();
       err = gcry_cipher_setiv (hde, tv[i].iv, tv[i].ivlen);
+      clutter_vector_registers();
       if (!err)
         err = gcry_cipher_setiv (hdd, tv[i].iv,  tv[i].ivlen);
       if (err)
@@ -8309,6 +8548,7 @@ check_bulk_cipher_modes (void)
       for (j=0; j < buflen; j++)
         buffer[j] = ((j & 0xff) ^ ((j >> 8) & 0xff));
 
+      clutter_vector_registers();
       err = gcry_cipher_encrypt (hde, outbuf, buflen, buffer, buflen);
       if (err)
         {
@@ -8330,6 +8570,7 @@ check_bulk_cipher_modes (void)
         fail ("encrypt mismatch (algo %d, mode %d)\n",
               tv[i].algo, tv[i].mode);
 
+      clutter_vector_registers();
       err = gcry_cipher_decrypt (hdd, outbuf, buflen, NULL, 0);
       if (err)
         {
@@ -8409,6 +8650,7 @@ check_one_cipher_core_reset (gcry_cipher_hd_t hd, int algo, int mode, int pass,
 
   if (mode == GCRY_CIPHER_MODE_OCB || mode == GCRY_CIPHER_MODE_CCM)
     {
+      clutter_vector_registers();
       err = gcry_cipher_setiv (hd, iv, sizeof(iv));
       if (err)
         {
@@ -8535,6 +8777,7 @@ check_one_cipher_core (int algo, int mode, int flags,
       goto err_out_free;
     }
 
+  clutter_vector_registers();
   err = gcry_cipher_setkey (hd, key, keylen);
   if (err)
     {
@@ -8547,6 +8790,7 @@ check_one_cipher_core (int algo, int mode, int flags,
   if (check_one_cipher_core_reset (hd, algo, mode, pass, nplain) < 0)
     goto err_out_free;
 
+  clutter_vector_registers();
   err = gcry_cipher_encrypt (hd, out, nplain, plain, nplain);
   if (err)
     {
@@ -8558,6 +8802,7 @@ check_one_cipher_core (int algo, int mode, int flags,
 
   if (taglen > 0)
     {
+      clutter_vector_registers();
       err = gcry_cipher_gettag (hd, tag, taglen);
       if (err)
 	{
@@ -8575,6 +8820,7 @@ check_one_cipher_core (int algo, int mode, int flags,
   if (check_one_cipher_core_reset (hd, algo, mode, pass, nplain) < 0)
     goto err_out_free;
 
+  clutter_vector_registers();
   err = gcry_cipher_decrypt (hd, in, nplain, out, nplain);
   if (err)
     {
@@ -8586,6 +8832,7 @@ check_one_cipher_core (int algo, int mode, int flags,
 
   if (taglen > 0)
     {
+      clutter_vector_registers();
       err = gcry_cipher_checktag (hd, tag_result, taglen);
       if (err)
 	{
@@ -8605,6 +8852,7 @@ check_one_cipher_core (int algo, int mode, int flags,
     goto err_out_free;
 
   memcpy (out, plain, nplain);
+  clutter_vector_registers();
   err = gcry_cipher_encrypt (hd, out, nplain, NULL, 0);
   if (err)
     {
@@ -8639,6 +8887,7 @@ check_one_cipher_core (int algo, int mode, int flags,
   if (check_one_cipher_core_reset (hd, algo, mode, pass, nplain) < 0)
     goto err_out_free;
 
+  clutter_vector_registers();
   err = gcry_cipher_decrypt (hd, out, nplain, NULL, 0);
   if (err)
     {
@@ -8651,6 +8900,7 @@ check_one_cipher_core (int algo, int mode, int flags,
 
   if (taglen > 0)
     {
+      clutter_vector_registers();
       err = gcry_cipher_checktag (hd, tag_result, taglen);
       if (err)
 	{
@@ -8677,6 +8927,7 @@ check_one_cipher_core (int algo, int mode, int flags,
       if (piecelen > nplain - pos)
         piecelen = nplain - pos;
 
+      clutter_vector_registers();
       err = gcry_cipher_encrypt (hd, out + pos, piecelen, plain + pos,
                                  piecelen);
       if (err)
@@ -8694,6 +8945,7 @@ check_one_cipher_core (int algo, int mode, int flags,
 
   if (taglen > 0)
     {
+      clutter_vector_registers();
       err = gcry_cipher_gettag (hd, tag, taglen);
       if (err)
 	{
@@ -8723,6 +8975,7 @@ check_one_cipher_core (int algo, int mode, int flags,
       if (piecelen > nplain - pos)
         piecelen = nplain - pos;
 
+      clutter_vector_registers();
       err = gcry_cipher_decrypt (hd, in + pos, piecelen, out + pos, piecelen);
       if (err)
         {
@@ -8739,6 +8992,7 @@ check_one_cipher_core (int algo, int mode, int flags,
 
   if (taglen > 0)
     {
+      clutter_vector_registers();
       err = gcry_cipher_checktag (hd, tag_result, taglen);
       if (err)
 	{
@@ -8767,6 +9021,7 @@ check_one_cipher_core (int algo, int mode, int flags,
         piecelen = nplain - pos;
 
       memcpy (out + pos, plain + pos, piecelen);
+      clutter_vector_registers();
       err = gcry_cipher_encrypt (hd, out + pos, piecelen, NULL, 0);
       if (err)
         {
@@ -8795,6 +9050,7 @@ check_one_cipher_core (int algo, int mode, int flags,
       if (piecelen > nplain - pos)
         piecelen = nplain - pos;
 
+      clutter_vector_registers();
       err = gcry_cipher_decrypt (hd, out + pos, piecelen, NULL, 0);
       if (err)
         {
@@ -9104,6 +9360,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 
   if (key && klen)
     {
+      clutter_vector_registers();
       err = gcry_md_setkey (hd, key, klen);
       if (err)
 	{
@@ -9131,6 +9388,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 
       if (key && klen)
 	{
+	  clutter_vector_registers();
 	  err = gcry_md_setkey (hd2, key, klen);
 	  if (err)
 	    {
@@ -9149,10 +9407,12 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 	  gcry_md_reset (hd);
 	  gcry_md_reset (hd2);
 
+	  clutter_vector_registers();
           gcry_md_write (hd, buf, i);
 	  for (j = 0; j < i; j++)
 	    gcry_md_write (hd2, &buf[j], 1);
 
+	  clutter_vector_registers();
 	  p1 = gcry_md_read (hd, algo);
 	  p2 = gcry_md_read (hd2, algo);
 	  if (memcmp (p1, p2, mdlen))
@@ -9196,6 +9456,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 	  if (*data == '?')
 	    fillbuf_count(aaa, piecelen, 1000 * 1000 - left);
 
+	  clutter_vector_registers();
           gcry_md_write (hd, aaa, piecelen);
 
           left -= piecelen;
@@ -9212,6 +9473,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 	  if (*data == '?')
 	    fillbuf_count(aaa, piecelen, 1000 * 1000 - left);
 
+	  clutter_vector_registers();
           gcry_md_write (hd, aaa, piecelen);
 
           left -= piecelen;
@@ -9223,8 +9485,12 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
         }
     }
   else
-    gcry_md_write (hd, data, len);
+    {
+      clutter_vector_registers();
+      gcry_md_write (hd, data, len);
+    }
 
+  clutter_vector_registers();
   err = gcry_md_copy (&hd2, hd);
   if (err)
     {
@@ -9235,6 +9501,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 
   if (!xof)
     {
+      clutter_vector_registers();
       p = gcry_md_read (hd2, algo);
 
       if (memcmp (p, expect, mdlen))
@@ -9255,12 +9522,14 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
       char buf[1000];
       int outmax = sizeof(buf) > elen ? elen : sizeof(buf);
 
+      clutter_vector_registers();
       err = gcry_md_copy (&hd, hd2);
       if (err)
 	{
 	  fail ("algo %d, gcry_md_copy failed: %s\n", algo, gpg_strerror (err));
 	}
 
+      clutter_vector_registers();
       err = gcry_md_extract(hd2, algo, buf, outmax);
       if (err)
 	{
@@ -9283,6 +9552,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
       memset(buf, 0, sizeof(buf));
 
       /* Extract one byte at time. */
+      clutter_vector_registers();
       for (i = 0; i < outmax && !err; i++)
 	err = gcry_md_extract(hd, algo, &buf[i], 1);
       if (err)
@@ -9334,6 +9604,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 	  /* Extract large chucks, total 1000000 additional bytes. */
 	  for (i = 0; i < 1000; i++)
 	    {
+	      clutter_vector_registers();
 	      err = gcry_md_extract(hd, algo, buf, 1000);
 	      if (!err)
 		gcry_md_write(crc1, buf, 1000);
@@ -9356,6 +9627,7 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 	      if (piecelen > left)
 		piecelen = left;
 
+	      clutter_vector_registers();
 	      err = gcry_md_extract (hd2, algo, buf, piecelen);
 	      if (!err)
 		gcry_md_write(crc2, buf, piecelen);
@@ -9373,7 +9645,9 @@ check_one_md (int algo, const char *data, int len, const char *expect, int elen,
 		piecelen = piecelen * 2 - ((piecelen != startlen) ? startlen : 0);
 	    }
 
+	  clutter_vector_registers();
 	  p1 = gcry_md_read (crc1, crcalgo);
+	  clutter_vector_registers();
 	  p2 = gcry_md_read (crc2, crcalgo);
 
 	  if (memcmp (p1, p2, crclen))
@@ -9449,6 +9723,7 @@ check_one_md_multi (int algo, const char *data, int len, const char *expect)
   iovcnt++;
   assert (iovcnt <= DIM (iov));
 
+  clutter_vector_registers();
   err = gcry_md_hash_buffers (algo, 0, digest, iov, iovcnt);
   if (err)
     {
@@ -9498,6 +9773,7 @@ check_one_md_final(int algo, const char *expect, unsigned int expectlen)
   for (i = 0; i < sizeof(inbuf); i++)
     inbuf[i] = i;
 
+  clutter_vector_registers();
   gcry_md_hash_buffer (algo, xorbuf, NULL, 0);
   for (i = 1; i < sizeof(inbuf); i++)
     {
@@ -11336,6 +11612,7 @@ check_one_mac (int algo, const char *data, int datalen,
       return;
     }
 
+  clutter_vector_registers();
   err = gcry_mac_setkey (hd, key, keylen);
   if (err)
     fail("algo %d, mac gcry_mac_setkey failed: %s\n", algo, gpg_strerror (err));
@@ -11344,6 +11621,7 @@ check_one_mac (int algo, const char *data, int datalen,
 
   if (ivlen && iv)
     {
+      clutter_vector_registers();
       err = gcry_mac_setiv (hd, iv, ivlen);
       if (err)
         fail("algo %d, mac gcry_mac_ivkey failed: %s\n", algo,
@@ -11356,6 +11634,7 @@ check_one_mac (int algo, const char *data, int datalen,
     {
       for (i = 0; i < datalen; i++)
         {
+	  clutter_vector_registers();
           err = gcry_mac_write (hd, &data[i], 1);
           if (err)
             fail("algo %d, mac gcry_mac_write [buf-offset: %d] failed: %s\n",
@@ -11389,6 +11668,7 @@ check_one_mac (int algo, const char *data, int datalen,
               if (*data == '?')
                 fillbuf_count(aaa, piecelen, 1000 * 1000 - left);
 
+	      clutter_vector_registers();
               gcry_mac_write (hd, aaa, piecelen);
 
               left -= piecelen;
@@ -11405,6 +11685,7 @@ check_one_mac (int algo, const char *data, int datalen,
               if (*data == '?')
                 fillbuf_count(aaa, piecelen, 1000 * 1000 - left);
 
+	      clutter_vector_registers();
               gcry_mac_write (hd, aaa, piecelen);
 
               left -= piecelen;
@@ -11417,6 +11698,7 @@ check_one_mac (int algo, const char *data, int datalen,
         }
       else
         {
+	  clutter_vector_registers();
           err = gcry_mac_write (hd, data, datalen);
         }
 
@@ -11426,11 +11708,13 @@ check_one_mac (int algo, const char *data, int datalen,
         goto out;
     }
 
+  clutter_vector_registers();
   err = gcry_mac_verify (hd, expect, maclen);
   if (err)
     fail("algo %d, mac gcry_mac_verify failed: %s\n", algo, gpg_strerror (err));
 
   macoutlen = maclen;
+  clutter_vector_registers();
   err = gcry_mac_read (hd, p, &macoutlen);
   if (err)
     fail("algo %d, mac gcry_mac_read failed: %s\n", algo, gpg_strerror (err));




More information about the Gcrypt-devel mailing list