tests: Add another test case to keygrip.c
authorWerner Koch <wk@gnupg.org>
Fri, 8 Dec 2017 07:15:42 +0000 (08:15 +0100)
committerWerner Koch <wk@gnupg.org>
Fri, 8 Dec 2017 07:15:42 +0000 (08:15 +0100)
--

This is mainly to answer a question on the ML.

tests/keygrip.c

index f775f7a..73a6f81 100644 (file)
@@ -189,6 +189,26 @@ static struct
       " ))",
       "\x9D\xB6\xC6\x4A\x38\x83\x0F\x49\x60\x70"
       "\x17\x89\x47\x55\x20\xBE\x8C\x82\x1F\x47"
+    },
+    { /* Random key  */
+      GCRY_PK_RSA,
+      "(shadowed-private-key"
+      " (rsa"
+      " (n #00B493C79928398DA9D99AC0E949FE6EB62F683CB974FFFBFBC01066F5C9A89B"
+      "     D3DC48EAD7C65F36EA943C2B2C865C26C4884FF9EDFDA8C99C855B737D77EEF6"
+      "     B85DBC0CCEC0E900C1F89A6893A2A93E8B31028469B6927CEB2F08687E547C68"
+      "     6B0A2F7E50A194FF7AB7637E03DE0912EF7F6E5F1EC37625BD1620CCC2E7A564"
+      "     31E168CDAFBD1D9E61AE47A69A6FA03EF22F844528A710B2392F262B95A3078C"
+      "     F321DC8325F92A5691EF69F34FD0DE0B22C79D29DC87723FCADE463829E8E5F7"
+      "     D196D73D6C9C180F6A6A0DDBF7B9D8F7FA293C36163B12199EF6A1A95CAE4051"
+      "     E3069C522CC6C4A7110F663A5DAD20F66C13A1674D050088208FAE4F33B3AB51"
+      "     03#)"
+      " (e #00010001#)"
+      " (shadowed t1-v1"
+      " (#D2760001240102000005000123350000# OPENPGP.1)"
+      ")))",
+      "\xE5\x6E\xE6\xEE\x5A\x2F\xDC\x3E\x98\x9D"
+      "\xFE\x49\xDA\xF5\x67\x43\xE3\x27\x28\x33"
     }
   };
 
@@ -217,6 +237,9 @@ check (void)
       if (err)
         die ("scanning data %d failed: %s\n", i, gpg_strerror (err));
 
+      if (debug)
+        info ("check(%d): s-exp='%s'\n", i, key_grips[i].key);
+
       for (repn=0; repn < repetitions; repn++)
         {
           ret = gcry_pk_get_keygrip (sexp, buf);
@@ -228,6 +251,8 @@ check (void)
               print_hex ("keygrip: ", buf, sizeof buf);
               die ("keygrip for %d does not match\n", i);
             }
+          else if (debug && !repn)
+            print_hex ("keygrip: ", buf, sizeof buf);
         }
 
       gcry_sexp_release (sexp);