]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Try to detect AES-NI on Intel and AMD machines only.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 16 Apr 2011 18:10:34 +0000 (20:10 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 16 Apr 2011 18:10:34 +0000 (20:10 +0200)
lib/accelerated/intel/aes-x86.c

index f1a24aa1b6d7d173dde6bfc0b457dd99693ddb8c..101569554b84fd2aec884db491b768cdd6380936 100644 (file)
@@ -155,10 +155,33 @@ check_optimized_aes (void)
   return (c & 0x2000000);
 }
 
+static unsigned
+check_intel_or_amd (void)
+{
+  unsigned int a, b, c, d;
+  cpuid (0, a, b, c, d);
+
+  if ((memcmp(&b, "Genu", 4) == 0 &&
+               memcmp(&d, "ineI", 4) == 0 &&
+               memcmp(&c, "ntel", 4) == 0) ||
+     (memcmp(&b, "Auth", 4) == 0 &&
+               memcmp(&d, "enti", 4) == 0 &&
+               memcmp(&c, "cAMD", 4) == 0))
+    {
+      return 1;
+    }
+
+  return 0;
+}
+
 void
 register_x86_crypto (void)
 {
   int ret;
+
+  if (check_intel_or_amd() == 0)
+    return;
+
   if (check_optimized_aes ())
     {
       fprintf (stderr, "Intel AES accelerator was detected\n");