LCOV - code coverage report
Current view: top level - tests - t-kdf.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 53 138 38.4 %
Date: 2016-12-01 18:32:04 Functions: 4 8 50.0 %

          Line data    Source code
       1             : /* t-kdf.c -  KDF regression tests
       2             :  * Copyright (C) 2011 Free Software Foundation, Inc.
       3             :  *
       4             :  * This file is part of Libgcrypt.
       5             :  *
       6             :  * Libgcrypt is free software; you can redistribute it and/or modify
       7             :  * it under the terms of the GNU Lesser General Public License as
       8             :  * published by the Free Software Foundation; either version 2.1 of
       9             :  * the License, or (at your option) any later version.
      10             :  *
      11             :  * Libgcrypt is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  * GNU Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with this program; if not, write to the Free Software
      18             :  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
      19             :  */
      20             : 
      21             : #ifdef HAVE_CONFIG_H
      22             : #include <config.h>
      23             : #endif
      24             : #include <stdio.h>
      25             : #include <stdlib.h>
      26             : #include <string.h>
      27             : #include <stdarg.h>
      28             : #include <assert.h>
      29             : 
      30             : #include "../src/gcrypt-int.h"
      31             : #include "stopwatch.h"
      32             : 
      33             : 
      34             : #ifndef DIM
      35             : # define DIM(v)              (sizeof(v)/sizeof((v)[0]))
      36             : #endif
      37             : 
      38             : /* Program option flags.  */
      39             : static int verbose;
      40             : static int debug;
      41             : static int error_count;
      42             : 
      43             : static void
      44           0 : fail (const char *format, ...)
      45             : {
      46             :   va_list arg_ptr;
      47             : 
      48           0 :   va_start (arg_ptr, format);
      49           0 :   vfprintf (stderr, format, arg_ptr);
      50           0 :   va_end (arg_ptr);
      51           0 :   error_count++;
      52           0 : }
      53             : 
      54             : static void
      55           0 : die (const char *format, ...)
      56             : {
      57             :   va_list arg_ptr;
      58             : 
      59           0 :   va_start (arg_ptr, format);
      60           0 :   vfprintf (stderr, format, arg_ptr);
      61           0 :   va_end (arg_ptr);
      62           0 :   exit (1);
      63             : }
      64             : 
      65             : 
      66             : static void
      67           0 : dummy_consumer (volatile char *buffer, size_t buflen)
      68             : {
      69             :   (void)buffer;
      70             :   (void)buflen;
      71           0 : }
      72             : 
      73             : 
      74             : static void
      75           0 : bench_s2k (unsigned long s2kcount)
      76             : {
      77             :   gpg_error_t err;
      78           0 :   const char passphrase[] = "123456789abcdef0";
      79             :   char keybuf[128/8];
      80           0 :   unsigned int repetitions = 10;
      81             :   unsigned int count;
      82             :   const char *elapsed;
      83           0 :   int pass = 0;
      84             : 
      85             :  again:
      86           0 :   start_timer ();
      87           0 :   for (count = 0; count < repetitions; count++)
      88             :     {
      89           0 :       err = gcry_kdf_derive (passphrase, strlen (passphrase),
      90             :                              GCRY_KDF_ITERSALTED_S2K,
      91             :                              GCRY_MD_SHA1, "saltsalt", 8, s2kcount,
      92             :                              sizeof keybuf, keybuf);
      93           0 :       if (err)
      94           0 :         die ("gcry_kdf_derive failed: %s\n", gpg_strerror (err));
      95           0 :       dummy_consumer (keybuf, sizeof keybuf);
      96             :     }
      97           0 :   stop_timer ();
      98             : 
      99           0 :   elapsed = elapsed_time (repetitions);
     100           0 :   if (!pass++)
     101             :     {
     102           0 :       if (!atoi (elapsed))
     103             :         {
     104           0 :           repetitions = 10000;
     105           0 :           goto again;
     106             :         }
     107           0 :       else if (atoi (elapsed) < 10)
     108             :         {
     109           0 :           repetitions = 100;
     110           0 :           goto again;
     111             :         }
     112             :     }
     113             : 
     114           0 :   printf ("%s\n", elapsed);
     115           0 : }
     116             : 
     117             : 
     118             : static void
     119           1 : check_openpgp (void)
     120             : {
     121             :   /* Test vectors manually created with gpg 1.4 derived code: In
     122             :      passphrase.c:hash_passpharse, add this code to the end of the
     123             :      function:
     124             : 
     125             :        ===8<===
     126             :        printf ("{\n"
     127             :                "  \"");
     128             :        for (i=0; i < pwlen; i++)
     129             :          {
     130             :            if (i && !(i%16))
     131             :              printf ("\"\n  \"");
     132             :            printf ("\\x%02x", ((const unsigned char *)pw)[i]);
     133             :          }
     134             :        printf ("\", %d,\n", pwlen);
     135             : 
     136             :        printf ("  %s, %s,\n",
     137             :                s2k->mode == 0? "GCRY_KDF_SIMPLE_S2K":
     138             :                s2k->mode == 1? "GCRY_KDF_SALTED_S2K":
     139             :                s2k->mode == 3? "GCRY_KDF_ITERSALTED_S2K":"?",
     140             :                s2k->hash_algo == DIGEST_ALGO_MD5   ? "GCRY_MD_MD5" :
     141             :                s2k->hash_algo == DIGEST_ALGO_SHA1  ? "GCRY_MD_SHA1" :
     142             :                s2k->hash_algo == DIGEST_ALGO_RMD160? "GCRY_MD_RMD160" :
     143             :                s2k->hash_algo == DIGEST_ALGO_SHA256? "GCRY_MD_SHA256" :
     144             :                s2k->hash_algo == DIGEST_ALGO_SHA384? "GCRY_MD_SHA384" :
     145             :                s2k->hash_algo == DIGEST_ALGO_SHA512? "GCRY_MD_SHA512" :
     146             :                s2k->hash_algo == DIGEST_ALGO_SHA224? "GCRY_MD_SHA224" : "?");
     147             : 
     148             :        if (s2k->mode == 0)
     149             :          printf ("  NULL, 0,\n");
     150             :        else
     151             :          {
     152             :            printf ("  \"");
     153             :            for (i=0; i < 8; i++)
     154             :              printf ("\\x%02x", (unsigned int)s2k->salt[i]);
     155             :            printf ("\", %d,\n", 8);
     156             :          }
     157             : 
     158             :        if (s2k->mode == 3)
     159             :          printf ("  %lu,\n", (unsigned long)S2K_DECODE_COUNT(s2k->count));
     160             :        else
     161             :          printf ("  0,\n");
     162             : 
     163             :        printf ("  %d,\n", (int)dek->keylen);
     164             : 
     165             :        printf ("  \"");
     166             :        for (i=0; i < dek->keylen; i++)
     167             :          {
     168             :            if (i && !(i%16))
     169             :              printf ("\"\n  \"");
     170             :            printf ("\\x%02x", ((unsigned char *)dek->key)[i]);
     171             :          }
     172             :        printf ("\"\n},\n");
     173             :        ===>8===
     174             : 
     175             :      Then prepare a file x.inp with utf8 encoding:
     176             : 
     177             :        ===8<===
     178             :        0 aes    md5 1024 a
     179             :        0 aes    md5 1024 ab
     180             :        0 aes    md5 1024 abc
     181             :        0 aes    md5 1024 abcd
     182             :        0 aes    md5 1024 abcde
     183             :        0 aes    md5 1024 abcdef
     184             :        0 aes    md5 1024 abcdefg
     185             :        0 aes    md5 1024 abcdefgh
     186             :        0 aes    md5 1024 abcdefghi
     187             :        0 aes    md5 1024 abcdefghijklmno
     188             :        0 aes    md5 1024 abcdefghijklmnop
     189             :        0 aes    md5 1024 abcdefghijklmnopq
     190             :        0 aes    md5 1024 Long_sentence_used_as_passphrase
     191             :        0 aes    md5 1024 With_utf8_umlauts:äüÖß
     192             :        0 aes    sha1 1024 a
     193             :        0 aes    sha1 1024 ab
     194             :        0 aes    sha1 1024 abc
     195             :        0 aes    sha1 1024 abcd
     196             :        0 aes    sha1 1024 abcde
     197             :        0 aes    sha1 1024 abcdef
     198             :        0 aes    sha1 1024 abcdefg
     199             :        0 aes    sha1 1024 abcdefgh
     200             :        0 aes    sha1 1024 abcdefghi
     201             :        0 aes    sha1 1024 abcdefghijklmno
     202             :        0 aes    sha1 1024 abcdefghijklmnop
     203             :        0 aes    sha1 1024 abcdefghijklmnopq
     204             :        0 aes    sha1 1024 abcdefghijklmnopqr
     205             :        0 aes    sha1 1024 abcdefghijklmnopqrs
     206             :        0 aes    sha1 1024 abcdefghijklmnopqrst
     207             :        0 aes    sha1 1024 abcdefghijklmnopqrstu
     208             :        0 aes    sha1 1024 Long_sentence_used_as_passphrase
     209             :        0 aes256 sha1 1024 Long_sentence_used_as_passphrase
     210             :        0 aes    sha1 1024 With_utf8_umlauts:äüÖß
     211             :        3 aes    sha1 1024 a
     212             :        3 aes    sha1 1024 ab
     213             :        3 aes    sha1 1024 abc
     214             :        3 aes    sha1 1024 abcd
     215             :        3 aes    sha1 1024 abcde
     216             :        3 aes    sha1 1024 abcdef
     217             :        3 aes    sha1 1024 abcdefg
     218             :        3 aes    sha1 1024 abcdefgh
     219             :        3 aes    sha1 1024 abcdefghi
     220             :        3 aes    sha1 1024 abcdefghijklmno
     221             :        3 aes    sha1 1024 abcdefghijklmnop
     222             :        3 aes    sha1 1024 abcdefghijklmnopq
     223             :        3 aes    sha1 1024 abcdefghijklmnopqr
     224             :        3 aes    sha1 1024 abcdefghijklmnopqrs
     225             :        3 aes    sha1 1024 abcdefghijklmnopqrst
     226             :        3 aes    sha1 1024 abcdefghijklmnopqrstu
     227             :        3 aes    sha1 1024 With_utf8_umlauts:äüÖß
     228             :        3 aes    sha1 1024 Long_sentence_used_as_passphrase
     229             :        3 aes    sha1 10240 Long_sentence_used_as_passphrase
     230             :        3 aes    sha1 102400 Long_sentence_used_as_passphrase
     231             :        3 aes192 sha1 1024 a
     232             :        3 aes192 sha1 1024 abcdefg
     233             :        3 aes192 sha1 1024 abcdefghi
     234             :        3 aes192 sha1 1024 abcdefghi
     235             :        3 aes192 sha1 1024 Long_sentence_used_as_passphrase
     236             :        3 aes256 sha1 1024 a
     237             :        3 aes256 sha1 1024 abcdefg
     238             :        3 aes256 sha1 1024 abcdefghi
     239             :        3 aes256 sha1 1024 abcdefghi
     240             :        3 aes256 sha1 1024 Long_sentence_used_as_passphrase
     241             :        0 aes    sha256 1024 Long_sentence_used_as_passphrase
     242             :        1 aes    sha256 1024 Long_sentence_used_as_passphrase
     243             :        3 aes    sha256 1024 Long_sentence_used_as_passphrase
     244             :        3 aes    sha256 10240 Long_sentence_used_as_passphrase
     245             :        3 aes    sha384 1024 Long_sentence_used_as_passphrase
     246             :        3 aes    sha512 1024 Long_sentence_used_as_passphrase
     247             :        3 aes256 sha512 1024 Long_sentence_used_as_passphrase
     248             :        3 3des   sha512 1024 Long_sentence_used_as_passphrase
     249             :        ===>8===
     250             : 
     251             :     and finally using a proper utf-8 enabled shell, run:
     252             : 
     253             :        cat x.inp | while read mode cipher digest count pass dummy; do \
     254             :          ./gpg </dev/null -o /dev/null -c  --passphrase "$pass" \
     255             :            --s2k-mode $mode --s2k-digest $digest --s2k-count $count \
     256             :            --cipher-algo $cipher ; done >x.out
     257             :   */
     258             :   static struct {
     259             :     const char *p;   /* Passphrase.  */
     260             :     size_t plen;     /* Length of P. */
     261             :     int algo;
     262             :     int hashalgo;
     263             :     const char *salt;
     264             :     size_t saltlen;
     265             :     unsigned long c; /* Iterations.  */
     266             :     int dklen;       /* Requested key length.  */
     267             :     const char *dk;  /* Derived key.  */
     268             :     int disabled;
     269             :   } tv[] = {
     270             :     {
     271             :       "\x61", 1,
     272             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     273             :       NULL, 0,
     274             :       0,
     275             :       16,
     276             :       "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8\x31\xc3\x99\xe2\x69\x77\x26\x61"
     277             :     },
     278             :     {
     279             :       "\x61\x62", 2,
     280             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     281             :       NULL, 0,
     282             :       0,
     283             :       16,
     284             :       "\x18\x7e\xf4\x43\x61\x22\xd1\xcc\x2f\x40\xdc\x2b\x92\xf0\xeb\xa0"
     285             :     },
     286             :     {
     287             :       "\x61\x62\x63", 3,
     288             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     289             :       NULL, 0,
     290             :       0,
     291             :       16,
     292             :       "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f\x72"
     293             :     },
     294             :     {
     295             :       "\x61\x62\x63\x64", 4,
     296             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     297             :       NULL, 0,
     298             :       0,
     299             :       16,
     300             :       "\xe2\xfc\x71\x4c\x47\x27\xee\x93\x95\xf3\x24\xcd\x2e\x7f\x33\x1f"
     301             :     },
     302             :     {
     303             :       "\x61\x62\x63\x64\x65", 5,
     304             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     305             :       NULL, 0,
     306             :       0,
     307             :       16,
     308             :       "\xab\x56\xb4\xd9\x2b\x40\x71\x3a\xcc\x5a\xf8\x99\x85\xd4\xb7\x86"
     309             :     },
     310             :     {
     311             :       "\x61\x62\x63\x64\x65\x66", 6,
     312             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     313             :       NULL, 0,
     314             :       0,
     315             :       16,
     316             :       "\xe8\x0b\x50\x17\x09\x89\x50\xfc\x58\xaa\xd8\x3c\x8c\x14\x97\x8e"
     317             :     },
     318             :     {
     319             :       "\x61\x62\x63\x64\x65\x66\x67", 7,
     320             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     321             :       NULL, 0,
     322             :       0,
     323             :       16,
     324             :       "\x7a\xc6\x6c\x0f\x14\x8d\xe9\x51\x9b\x8b\xd2\x64\x31\x2c\x4d\x64"
     325             :     },
     326             :     {
     327             :       "\x61\x62\x63\x64\x65\x66\x67\x68", 8,
     328             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     329             :       NULL, 0,
     330             :       0,
     331             :       16,
     332             :       "\xe8\xdc\x40\x81\xb1\x34\x34\xb4\x51\x89\xa7\x20\xb7\x7b\x68\x18"
     333             :     },
     334             :     {
     335             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     336             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     337             :       NULL, 0,
     338             :       0,
     339             :       16,
     340             :       "\x8a\xa9\x9b\x1f\x43\x9f\xf7\x12\x93\xe9\x53\x57\xba\xc6\xfd\x94"
     341             :     },
     342             :     {
     343             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f", 15,
     344             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     345             :       NULL, 0,
     346             :       0,
     347             :       16,
     348             :       "\x8a\x73\x19\xdb\xf6\x54\x4a\x74\x22\xc9\xe2\x54\x52\x58\x0e\xa5"
     349             :     },
     350             :     {
     351             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70", 16,
     352             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     353             :       NULL, 0,
     354             :       0,
     355             :       16,
     356             :       "\x1d\x64\xdc\xe2\x39\xc4\x43\x7b\x77\x36\x04\x1d\xb0\x89\xe1\xb9"
     357             :     },
     358             :     {
     359             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     360             :       "\x71", 17,
     361             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     362             :       NULL, 0,
     363             :       0,
     364             :       16,
     365             :       "\x9a\x8d\x98\x45\xa6\xb4\xd8\x2d\xfc\xb2\xc2\xe3\x51\x62\xc8\x30"
     366             :     },
     367             :     {
     368             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     369             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     370             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     371             :       NULL, 0,
     372             :       0,
     373             :       16,
     374             :       "\x35\x2a\xf0\xfc\xdf\xe9\xbb\x62\x16\xfc\x99\x9d\x8d\x58\x05\xcb"
     375             :     },
     376             :     {
     377             :       "\x57\x69\x74\x68\x5f\x75\x74\x66\x38\x5f\x75\x6d\x6c\x61\x75\x74"
     378             :       "\x73\x3a\xc3\xa4\xc3\xbc\xc3\x96\xc3\x9f", 26,
     379             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_MD5,
     380             :       NULL, 0,
     381             :       0,
     382             :       16,
     383             :       "\x21\xa4\xeb\xd8\xfd\xf0\x59\x25\xd1\x32\x31\xdb\xe7\xf2\x13\x5d"
     384             :     },
     385             :     {
     386             :       "\x61", 1,
     387             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     388             :       NULL, 0,
     389             :       0,
     390             :       16,
     391             :       "\x86\xf7\xe4\x37\xfa\xa5\xa7\xfc\xe1\x5d\x1d\xdc\xb9\xea\xea\xea"
     392             :     },
     393             :     {
     394             :       "\x61\x62", 2,
     395             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     396             :       NULL, 0,
     397             :       0,
     398             :       16,
     399             :       "\xda\x23\x61\x4e\x02\x46\x9a\x0d\x7c\x7b\xd1\xbd\xab\x5c\x9c\x47"
     400             :     },
     401             :     {
     402             :       "\x61\x62\x63", 3,
     403             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     404             :       NULL, 0,
     405             :       0,
     406             :       16,
     407             :       "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e\x25\x71\x78\x50\xc2\x6c"
     408             :     },
     409             :     {
     410             :       "\x61\x62\x63\x64", 4,
     411             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     412             :       NULL, 0,
     413             :       0,
     414             :       16,
     415             :       "\x81\xfe\x8b\xfe\x87\x57\x6c\x3e\xcb\x22\x42\x6f\x8e\x57\x84\x73"
     416             :     },
     417             :     {
     418             :       "\x61\x62\x63\x64\x65", 5,
     419             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     420             :       NULL, 0,
     421             :       0,
     422             :       16,
     423             :       "\x03\xde\x6c\x57\x0b\xfe\x24\xbf\xc3\x28\xcc\xd7\xca\x46\xb7\x6e"
     424             :     },
     425             :     {
     426             :       "\x61\x62\x63\x64\x65\x66", 6,
     427             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     428             :       NULL, 0,
     429             :       0,
     430             :       16,
     431             :       "\x1f\x8a\xc1\x0f\x23\xc5\xb5\xbc\x11\x67\xbd\xa8\x4b\x83\x3e\x5c"
     432             :     },
     433             :     {
     434             :       "\x61\x62\x63\x64\x65\x66\x67", 7,
     435             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     436             :       NULL, 0,
     437             :       0,
     438             :       16,
     439             :       "\x2f\xb5\xe1\x34\x19\xfc\x89\x24\x68\x65\xe7\xa3\x24\xf4\x76\xec"
     440             :     },
     441             :     {
     442             :       "\x61\x62\x63\x64\x65\x66\x67\x68", 8,
     443             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     444             :       NULL, 0,
     445             :       0,
     446             :       16,
     447             :       "\x42\x5a\xf1\x2a\x07\x43\x50\x2b\x32\x2e\x93\xa0\x15\xbc\xf8\x68"
     448             :     },
     449             :     {
     450             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     451             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     452             :       NULL, 0,
     453             :       0,
     454             :       16,
     455             :       "\xc6\x3b\x19\xf1\xe4\xc8\xb5\xf7\x6b\x25\xc4\x9b\x8b\x87\xf5\x7d"
     456             :     },
     457             :     {
     458             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f", 15,
     459             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     460             :       NULL, 0,
     461             :       0,
     462             :       16,
     463             :       "\x29\x38\xdc\xc2\xe3\xaa\x77\x98\x7c\x7e\x5d\x4a\x0f\x26\x96\x67"
     464             :     },
     465             :     {
     466             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70", 16,
     467             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     468             :       NULL, 0,
     469             :       0,
     470             :       16,
     471             :       "\x14\xf3\x99\x52\x88\xac\xd1\x89\xe6\xe5\x0a\x7a\xf4\x7e\xe7\x09"
     472             :     },
     473             :     {
     474             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     475             :       "\x71", 17,
     476             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     477             :       NULL, 0,
     478             :       0,
     479             :       16,
     480             :       "\xd8\x3d\x62\x1f\xcd\x2d\x4d\x29\x85\x54\x70\x43\xa7\xa5\xfd\x4d"
     481             :     },
     482             :     {
     483             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     484             :       "\x71\x72", 18,
     485             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     486             :       NULL, 0,
     487             :       0,
     488             :       16,
     489             :       "\xe3\x81\xfe\x42\xc5\x7e\x48\xa0\x82\x17\x86\x41\xef\xfd\x1c\xb9"
     490             :     },
     491             :     {
     492             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     493             :       "\x71\x72\x73", 19,
     494             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     495             :       NULL, 0,
     496             :       0,
     497             :       16,
     498             :       "\x89\x3e\x69\xff\x01\x09\xf3\x45\x9c\x42\x43\x01\x3b\x3d\xe8\xb1"
     499             :     },
     500             :     {
     501             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     502             :       "\x71\x72\x73\x74", 20,
     503             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     504             :       NULL, 0,
     505             :       0,
     506             :       16,
     507             :       "\x14\xa2\x3a\xd7\x0f\x2a\x5d\xd7\x25\x57\x5d\xe6\xc4\x3e\x1c\xdd"
     508             :     },
     509             :     {
     510             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     511             :       "\x71\x72\x73\x74\x75", 21,
     512             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     513             :       NULL, 0,
     514             :       0,
     515             :       16,
     516             :       "\xec\xa9\x86\xb9\x5d\x58\x7f\x34\xd7\x1c\xa7\x75\x2a\x4e\x00\x10"
     517             :     },
     518             :     {
     519             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     520             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     521             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     522             :       NULL, 0,
     523             :       0,
     524             :       16,
     525             :       "\x3e\x1b\x9a\x50\x7d\x6e\x9a\xd8\x93\x64\x96\x7a\x3f\xcb\x27\x3f"
     526             :     },
     527             :     {
     528             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     529             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     530             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     531             :       NULL, 0,
     532             :       0,
     533             :       32,
     534             :       "\x3e\x1b\x9a\x50\x7d\x6e\x9a\xd8\x93\x64\x96\x7a\x3f\xcb\x27\x3f"
     535             :       "\xc3\x7b\x3a\xb2\xef\x4d\x68\xaa\x9c\xd7\xe4\x88\xee\xd1\x5e\x70"
     536             :     },
     537             :     {
     538             :       "\x57\x69\x74\x68\x5f\x75\x74\x66\x38\x5f\x75\x6d\x6c\x61\x75\x74"
     539             :       "\x73\x3a\xc3\xa4\xc3\xbc\xc3\x96\xc3\x9f", 26,
     540             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA1,
     541             :       NULL, 0,
     542             :       0,
     543             :       16,
     544             :       "\xe0\x4e\x1e\xe3\xad\x0b\x49\x7c\x7a\x5f\x37\x3b\x4d\x90\x3c\x2e"
     545             :     },
     546             :     {
     547             :       "\x61", 1,
     548             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     549             :       "\x6d\x47\xe3\x68\x5d\x2c\x36\x16", 8,
     550             :       1024,
     551             :       16,
     552             :       "\x41\x9f\x48\x6e\xbf\xe6\xdd\x05\x9a\x72\x23\x17\x44\xd8\xd3\xf3"
     553             :     },
     554             :     {
     555             :       "\x61\x62", 2,
     556             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     557             :       "\x7c\x34\x78\xfb\x28\x2d\x25\xc7", 8,
     558             :       1024,
     559             :       16,
     560             :       "\x0a\x9d\x09\x06\x43\x3d\x4f\xf9\x87\xd6\xf7\x48\x90\xde\xd1\x1c"
     561             :     },
     562             :     {
     563             :       "\x61\x62\x63", 3,
     564             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     565             :       "\xc3\x16\x37\x2e\x27\xf6\x9f\x6f", 8,
     566             :       1024,
     567             :       16,
     568             :       "\xf8\x27\xa0\x07\xc6\xcb\xdd\xf1\xfe\x5c\x88\x3a\xfc\xcd\x84\x4d"
     569             :     },
     570             :     {
     571             :       "\x61\x62\x63\x64", 4,
     572             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     573             :       "\xf0\x0c\x73\x38\xb7\xc3\xd5\x14", 8,
     574             :       1024,
     575             :       16,
     576             :       "\x9b\x5f\x26\xba\x52\x3b\xcd\xd9\xa5\x2a\xef\x3c\x03\x4d\xd1\x52"
     577             :     },
     578             :     {
     579             :       "\x61\x62\x63\x64\x65", 5,
     580             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     581             :       "\xe1\x7d\xa2\x36\x09\x59\xee\xc5", 8,
     582             :       1024,
     583             :       16,
     584             :       "\x94\x9d\x5b\x1a\x5a\x66\x8c\xfa\x8f\x6f\x22\xaf\x8b\x60\x9f\xaf"
     585             :     },
     586             :     {
     587             :       "\x61\x62\x63\x64\x65\x66", 6,
     588             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     589             :       "\xaf\xa7\x0c\x68\xdf\x7e\xaa\x27", 8,
     590             :       1024,
     591             :       16,
     592             :       "\xe5\x38\xf4\x39\x62\x27\xcd\xcc\x91\x37\x7f\x1b\xdc\x58\x64\x27"
     593             :     },
     594             :     {
     595             :       "\x61\x62\x63\x64\x65\x66\x67", 7,
     596             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     597             :       "\x40\x57\xb2\x9d\x5f\xbb\x11\x4f", 8,
     598             :       1024,
     599             :       16,
     600             :       "\xad\xa2\x33\xd9\xdd\xe0\xfb\x94\x8e\xcc\xec\xcc\xb3\xa8\x3a\x9e"
     601             :     },
     602             :     {
     603             :       "\x61\x62\x63\x64\x65\x66\x67\x68", 8,
     604             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     605             :       "\x38\xf5\x65\xc5\x0f\x8c\x19\x61", 8,
     606             :       1024,
     607             :       16,
     608             :       "\xa0\xb0\x3e\x29\x76\xe6\x8f\xa0\xd8\x34\x8f\xa4\x2d\xfd\x65\xee"
     609             :     },
     610             :     {
     611             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     612             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     613             :       "\xc3\xb7\x99\xcc\xda\x2d\x05\x7b", 8,
     614             :       1024,
     615             :       16,
     616             :       "\x27\x21\xc8\x99\x5f\xcf\x20\xeb\xf2\xd9\xff\x6a\x69\xff\xad\xe8"
     617             :     },
     618             :     {
     619             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f", 15,
     620             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     621             :       "\x7d\xd8\x68\x8a\x1c\xc5\x47\x22", 8,
     622             :       1024,
     623             :       16,
     624             :       "\x0f\x96\x7a\x12\x23\x54\xf6\x92\x61\x67\x07\xb4\x68\x17\xb8\xaa"
     625             :     },
     626             :     {
     627             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70", 16,
     628             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     629             :       "\x8a\x95\xd4\x88\x0b\xb8\xe9\x9d", 8,
     630             :       1024,
     631             :       16,
     632             :       "\xcc\xe4\xc8\x82\x53\x32\xf1\x93\x5a\x00\xd4\x7f\xd4\x46\xfa\x07"
     633             :     },
     634             :     {
     635             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     636             :       "\x71", 17,
     637             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     638             :       "\xb5\x22\x48\xa6\xc4\xad\x74\x67", 8,
     639             :       1024,
     640             :       16,
     641             :       "\x0c\xe3\xe0\xee\x3d\x8f\x35\xd2\x35\x14\x14\x29\x0c\xf1\xe3\x34"
     642             :     },
     643             :     {
     644             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     645             :       "\x71\x72", 18,
     646             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     647             :       "\xac\x9f\x04\x63\x83\x0e\x3c\x95", 8,
     648             :       1024,
     649             :       16,
     650             :       "\x49\x0a\x04\x68\xa8\x2a\x43\x6f\xb9\x73\x94\xb4\x85\x9a\xaa\x0e"
     651             :     },
     652             :     {
     653             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     654             :       "\x71\x72\x73", 19,
     655             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     656             :       "\x03\x6f\x60\x30\x3a\x19\x61\x0d", 8,
     657             :       1024,
     658             :       16,
     659             :       "\x15\xe5\x9b\xbf\x1c\xf0\xbe\x74\x95\x1a\xb2\xc4\xda\x09\xcd\x99"
     660             :     },
     661             :     {
     662             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     663             :       "\x71\x72\x73\x74", 20,
     664             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     665             :       "\x51\x40\xa5\x57\xf5\x28\xfd\x03", 8,
     666             :       1024,
     667             :       16,
     668             :       "\xa6\xf2\x7e\x6b\x30\x4d\x8d\x67\xd4\xa2\x7f\xa2\x57\x27\xab\x96"
     669             :     },
     670             :     {
     671             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70"
     672             :       "\x71\x72\x73\x74\x75", 21,
     673             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     674             :       "\x4c\xf1\x10\x11\x04\x70\xd3\x6e", 8,
     675             :       1024,
     676             :       16,
     677             :       "\x2c\x50\x79\x8d\x83\x23\xac\xd6\x22\x29\x37\xaf\x15\x0d\xdd\x8f"
     678             :     },
     679             :     {
     680             :       "\x57\x69\x74\x68\x5f\x75\x74\x66\x38\x5f\x75\x6d\x6c\x61\x75\x74"
     681             :       "\x73\x3a\xc3\xa4\xc3\xbc\xc3\x96\xc3\x9f", 26,
     682             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     683             :       "\xfe\x3a\x25\xcb\x78\xef\xe1\x21", 8,
     684             :       1024,
     685             :       16,
     686             :       "\x2a\xb0\x53\x08\xf3\x2f\xd4\x6e\xeb\x01\x49\x5d\x87\xf6\x27\xf6"
     687             :     },
     688             :     {
     689             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     690             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     691             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     692             :       "\x04\x97\xd0\x02\x6a\x44\x2d\xde", 8,
     693             :       1024,
     694             :       16,
     695             :       "\x57\xf5\x70\x41\xa0\x9b\x8c\x09\xca\x74\xa9\x22\xa5\x82\x2d\x17"
     696             :     },
     697             :     {
     698             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     699             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     700             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     701             :       "\xdd\xf3\x31\x7c\xce\xf4\x81\x26", 8,
     702             :       10240,
     703             :       16,
     704             :       "\xc3\xdd\x01\x6d\xaf\xf6\x58\xc8\xd7\x79\xb4\x40\x00\xb5\xe8\x0b"
     705             :     },
     706             :     {
     707             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     708             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     709             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     710             :       "\x95\xd6\x72\x4e\xfb\xe1\xc3\x1a", 8,
     711             :       102400,
     712             :       16,
     713             :       "\xf2\x3f\x36\x7f\xb4\x6a\xd0\x3a\x31\x9e\x65\x11\x8e\x2b\x99\x9b"
     714             :     },
     715             :     {
     716             :       "\x61", 1,
     717             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     718             :       "\x6d\x69\x15\x18\xe4\x13\x42\x82", 8,
     719             :       1024,
     720             :       24,
     721             :       "\x28\x0c\x7e\xf2\x31\xf6\x1c\x6b\x5c\xef\x6a\xd5\x22\x64\x97\x91"
     722             :       "\xe3\x5e\x37\xfd\x50\xe2\xfc\x6c"
     723             :     },
     724             :     {
     725             :       "\x61\x62\x63\x64\x65\x66\x67", 7,
     726             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     727             :       "\x9b\x76\x5e\x81\xde\x13\xdf\x15", 8,
     728             :       1024,
     729             :       24,
     730             :       "\x91\x1b\xa1\xc1\x7b\x4f\xc3\xb1\x80\x61\x26\x08\xbe\x53\xe6\x50"
     731             :       "\x40\x6f\x28\xed\xc6\xe6\x67\x55"
     732             :     },
     733             :     {
     734             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     735             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     736             :       "\x7a\xac\xcc\x6e\x15\x56\xbd\xa1", 8,
     737             :       1024,
     738             :       24,
     739             :       "\xfa\x7e\x20\x07\xb6\x47\xb0\x09\x46\xb8\x38\xfb\xa1\xaf\xf7\x75"
     740             :       "\x2a\xfa\x77\x14\x06\x54\xcb\x34"
     741             :     },
     742             :     {
     743             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     744             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     745             :       "\x1c\x68\xf8\xfb\x98\xf7\x8c\x39", 8,
     746             :       1024,
     747             :       24,
     748             :       "\xcb\x1e\x86\xf5\xe0\xe4\xfb\xbf\x71\x34\x99\x24\xf4\x39\x8c\xc2"
     749             :       "\x8e\x25\x1c\x4c\x96\x47\x22\xe8"
     750             :     },
     751             :     {
     752             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     753             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     754             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     755             :       "\x10\xa9\x4e\xc1\xa5\xec\x17\x52", 8,
     756             :       1024,
     757             :       24,
     758             :       "\x0f\x83\xa2\x77\x92\xbb\xe4\x58\x68\xc5\xf2\x14\x6e\x6e\x2e\x6b"
     759             :       "\x98\x17\x70\x92\x07\x44\xe0\x51"
     760             :     },
     761             :     {
     762             :       "\x61", 1,
     763             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     764             :       "\xef\x8f\x37\x61\x8f\xab\xae\x4f", 8,
     765             :       1024,
     766             :       32,
     767             :       "\x6d\x65\xae\x86\x23\x91\x39\x98\xec\x1c\x23\x44\xb6\x0d\xad\x32"
     768             :       "\x54\x46\xc7\x23\x26\xbb\xdf\x4b\x54\x6e\xd4\xc2\xfa\xc6\x17\x17"
     769             :     },
     770             :     {
     771             :       "\x61\x62\x63\x64\x65\x66\x67", 7,
     772             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     773             :       "\xaa\xfb\xd9\x06\x7d\x7c\x40\xaf", 8,
     774             :       1024,
     775             :       32,
     776             :       "\x7d\x10\x54\x13\x3c\x43\x7a\xb3\x54\x1f\x38\xd4\x8f\x70\x0a\x09"
     777             :       "\xe2\xfa\xab\x97\x9a\x70\x16\xef\x66\x68\xca\x34\x2e\xce\xfa\x1f"
     778             :     },
     779             :     {
     780             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     781             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     782             :       "\x58\x03\x4f\x56\x8b\x97\xd4\x98", 8,
     783             :       1024,
     784             :       32,
     785             :       "\xf7\x40\xb1\x25\x86\x0d\x35\x8f\x9f\x91\x2d\xce\x04\xee\x5a\x04"
     786             :       "\x9d\xbd\x44\x23\x4c\xa6\xbb\xab\xb0\xd0\x56\x82\xa9\xda\x47\x16"
     787             :     },
     788             :     {
     789             :       "\x61\x62\x63\x64\x65\x66\x67\x68\x69", 9,
     790             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     791             :       "\x5d\x41\x3d\xa3\xa7\xfc\x5d\x0c", 8,
     792             :       1024,
     793             :       32,
     794             :       "\x4c\x7a\x86\xed\x81\x8a\x94\x99\x7d\x4a\xc4\xf7\x1c\xf8\x08\xdb"
     795             :       "\x09\x35\xd9\xa3\x2d\x22\xde\x32\x2d\x74\x38\xe5\xc8\xf2\x50\x6e"
     796             :     },
     797             :     {
     798             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     799             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     800             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA1,
     801             :       "\xca\xa7\xdc\x59\xce\x31\xe7\x49", 8,
     802             :       1024,
     803             :       32,
     804             :       "\x67\xe9\xd6\x29\x49\x1c\xb6\xa0\x85\xe8\xf9\x8b\x85\x47\x3a\x7e"
     805             :       "\xa7\xee\x89\x52\x6f\x19\x00\x53\x93\x07\x0a\x8b\xb9\xa8\x86\x94"
     806             :     },
     807             :     {
     808             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     809             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     810             :       GCRY_KDF_SIMPLE_S2K, GCRY_MD_SHA256,
     811             :       NULL, 0,
     812             :       0,
     813             :       16,
     814             :       "\x88\x36\x78\x6b\xd9\x5a\x62\xff\x47\xd3\xfb\x79\xc9\x08\x70\x56"
     815             :     },
     816             :     {
     817             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     818             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     819             :       GCRY_KDF_SALTED_S2K, GCRY_MD_SHA256,
     820             :       "\x05\x8b\xfe\x31\xaa\xf3\x29\x11", 8,
     821             :       0,
     822             :       16,
     823             :       "\xb2\x42\xfe\x5e\x09\x02\xd9\x62\xb9\x35\xf3\xa8\x43\x80\x9f\xb1"
     824             :     },
     825             :     {
     826             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     827             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     828             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA256,
     829             :       "\xd3\x4a\xea\xc9\x97\x1b\xcc\x83", 8,
     830             :       1024,
     831             :       16,
     832             :       "\x35\x37\x99\x62\x07\x26\x68\x23\x05\x47\xb2\xa0\x0b\x2b\x2b\x8d"
     833             :     },
     834             :     {
     835             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     836             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     837             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA256,
     838             :       "\x5e\x71\xbd\x00\x5f\x96\xc4\x23", 8,
     839             :       10240,
     840             :       16,
     841             :       "\xa1\x6a\xee\xba\xde\x73\x25\x25\xd1\xab\xa0\xc5\x7e\xc6\x39\xa7"
     842             :     },
     843             :     {
     844             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     845             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     846             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA384,
     847             :       "\xc3\x08\xeb\x17\x62\x08\x89\xef", 8,
     848             :       1024,
     849             :       16,
     850             :       "\x9b\x7f\x0c\x81\x6f\x71\x59\x9b\xd5\xf6\xbf\x3a\x86\x20\x16\x33"
     851             :     },
     852             :     {
     853             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     854             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     855             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA512,
     856             :       "\xe6\x7d\x13\x6b\x39\xe3\x44\x05", 8,
     857             :       1024,
     858             :       16,
     859             :       "\xc8\xcd\x4b\xa4\xf3\xf1\xd5\xb0\x59\x06\xf0\xbb\x89\x34\x6a\xad"
     860             :     },
     861             :     {
     862             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     863             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     864             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA512,
     865             :       "\xed\x7d\x30\x47\xe4\xc3\xf8\xb6", 8,
     866             :       1024,
     867             :       32,
     868             :       "\x89\x7a\xef\x70\x97\xe7\x10\xdb\x75\xcc\x20\x22\xab\x7b\xf3\x05"
     869             :       "\x4b\xb6\x2e\x17\x11\x9f\xd6\xeb\xbf\xdf\x4d\x70\x59\xf0\xf9\xe5"
     870             :     },
     871             :     {
     872             :       "\x4c\x6f\x6e\x67\x5f\x73\x65\x6e\x74\x65\x6e\x63\x65\x5f\x75\x73"
     873             :       "\x65\x64\x5f\x61\x73\x5f\x70\x61\x73\x73\x70\x68\x72\x61\x73\x65", 32,
     874             :       GCRY_KDF_ITERSALTED_S2K, GCRY_MD_SHA512,
     875             :       "\xbb\x1a\x45\x30\x68\x62\x6d\x63", 8,
     876             :       1024,
     877             :       24,
     878             :       "\xde\x5c\xb8\xd5\x75\xf6\xad\x69\x5b\xc9\xf6\x2f\xba\xeb\xfb\x36"
     879             :       "\x34\xf2\xb8\xee\x3b\x37\x21\xb7"
     880             :     }
     881             :   };
     882             :   int tvidx;
     883             :   gpg_error_t err;
     884             :   unsigned char outbuf[32];
     885             :   int i;
     886             : 
     887          72 :   for (tvidx=0; tvidx < DIM(tv); tvidx++)
     888             :     {
     889          71 :       if (tv[tvidx].disabled)
     890           0 :         continue;
     891             :       /* MD5 isn't supported in fips mode */
     892          71 :       if (gcry_fips_mode_active()
     893           0 :           && tv[tvidx].hashalgo == GCRY_MD_MD5)
     894           0 :         continue;
     895          71 :       if (verbose)
     896           0 :         fprintf (stderr, "checking S2K test vector %d\n", tvidx);
     897          71 :       assert (tv[tvidx].dklen <= sizeof outbuf);
     898         142 :       err = gcry_kdf_derive (tv[tvidx].p, tv[tvidx].plen,
     899             :                              tv[tvidx].algo, tv[tvidx].hashalgo,
     900          71 :                              tv[tvidx].salt, tv[tvidx].saltlen,
     901          71 :                              tv[tvidx].c, tv[tvidx].dklen, outbuf);
     902          71 :       if (err)
     903           0 :         fail ("s2k test %d failed: %s\n", tvidx, gpg_strerror (err));
     904          71 :       else if (memcmp (outbuf, tv[tvidx].dk, tv[tvidx].dklen))
     905             :         {
     906           0 :           fail ("s2k test %d failed: mismatch\n", tvidx);
     907           0 :           fputs ("got:", stderr);
     908           0 :           for (i=0; i < tv[tvidx].dklen; i++)
     909           0 :             fprintf (stderr, " %02x", outbuf[i]);
     910           0 :           putc ('\n', stderr);
     911             :         }
     912             :     }
     913           1 : }
     914             : 
     915             : 
     916             : static void
     917           1 : check_pbkdf2 (void)
     918             : {
     919             :   /* Test vectors are from RFC-6070.  */
     920             :   static struct {
     921             :     const char *p;   /* Passphrase.  */
     922             :     size_t plen;     /* Length of P. */
     923             :     const char *salt;
     924             :     size_t saltlen;
     925             :     int hashalgo;
     926             :     unsigned long c; /* Iterations.  */
     927             :     int dklen;       /* Requested key length.  */
     928             :     const char *dk;  /* Derived key.  */
     929             :     int disabled;
     930             :   } tv[] = {
     931             :     {
     932             :       "password", 8,
     933             :       "salt", 4,
     934             :       GCRY_MD_SHA1,
     935             :       1,
     936             :       20,
     937             :       "\x0c\x60\xc8\x0f\x96\x1f\x0e\x71\xf3\xa9"
     938             :       "\xb5\x24\xaf\x60\x12\x06\x2f\xe0\x37\xa6"
     939             :     },
     940             :     {
     941             :       "password", 8,
     942             :       "salt", 4,
     943             :       GCRY_MD_SHA1,
     944             :       2,
     945             :       20,
     946             :       "\xea\x6c\x01\x4d\xc7\x2d\x6f\x8c\xcd\x1e"
     947             :       "\xd9\x2a\xce\x1d\x41\xf0\xd8\xde\x89\x57"
     948             :     },
     949             :     {
     950             :       "password", 8,
     951             :       "salt", 4,
     952             :       GCRY_MD_SHA1,
     953             :       4096,
     954             :       20,
     955             :       "\x4b\x00\x79\x01\xb7\x65\x48\x9a\xbe\xad"
     956             :       "\x49\xd9\x26\xf7\x21\xd0\x65\xa4\x29\xc1"
     957             :     },
     958             :     {
     959             :       "password", 8,
     960             :       "salt", 4,
     961             :       GCRY_MD_SHA1,
     962             :       16777216,
     963             :       20,
     964             :       "\xee\xfe\x3d\x61\xcd\x4d\xa4\xe4\xe9\x94"
     965             :       "\x5b\x3d\x6b\xa2\x15\x8c\x26\x34\xe9\x84",
     966             :       1 /* This test takes too long.  */
     967             :     },
     968             :     {
     969             :       "passwordPASSWORDpassword", 24,
     970             :       "saltSALTsaltSALTsaltSALTsaltSALTsalt", 36,
     971             :       GCRY_MD_SHA1,
     972             :       4096,
     973             :       25,
     974             :       "\x3d\x2e\xec\x4f\xe4\x1c\x84\x9b\x80\xc8"
     975             :       "\xd8\x36\x62\xc0\xe4\x4a\x8b\x29\x1a\x96"
     976             :       "\x4c\xf2\xf0\x70\x38"
     977             :     },
     978             :     {
     979             :       "pass\0word", 9,
     980             :       "sa\0lt", 5,
     981             :       GCRY_MD_SHA1,
     982             :       4096,
     983             :       16,
     984             :       "\x56\xfa\x6a\xa7\x55\x48\x09\x9d\xcc\x37"
     985             :       "\xd7\xf0\x34\x25\xe0\xc3"
     986             :     },
     987             :     { /* empty password test, not in RFC-6070 */
     988             :       "", 0,
     989             :       "salt", 4,
     990             :       GCRY_MD_SHA1,
     991             :       2,
     992             :       20,
     993             :       "\x13\x3a\x4c\xe8\x37\xb4\xd2\x52\x1e\xe2"
     994             :       "\xbf\x03\xe1\x1c\x71\xca\x79\x4e\x07\x97"
     995             :     },
     996             :     {
     997             :       "password", 8,
     998             :       "salt", 4,
     999             :       GCRY_MD_GOSTR3411_CP,
    1000             :       1,
    1001             :       32,
    1002             :       "\x73\x14\xe7\xc0\x4f\xb2\xe6\x62\xc5\x43\x67\x42\x53\xf6\x8b\xd0"
    1003             :       "\xb7\x34\x45\xd0\x7f\x24\x1b\xed\x87\x28\x82\xda\x21\x66\x2d\x58"
    1004             :     },
    1005             :     {
    1006             :       "password", 8,
    1007             :       "salt", 4,
    1008             :       GCRY_MD_GOSTR3411_CP,
    1009             :       2,
    1010             :       32,
    1011             :       "\x99\x0d\xfa\x2b\xd9\x65\x63\x9b\xa4\x8b\x07\xb7\x92\x77\x5d\xf7"
    1012             :       "\x9f\x2d\xb3\x4f\xef\x25\xf2\x74\x37\x88\x72\xfe\xd7\xed\x1b\xb3"
    1013             :     },
    1014             :     {
    1015             :       "password", 8,
    1016             :       "salt", 4,
    1017             :       GCRY_MD_GOSTR3411_CP,
    1018             :       4096,
    1019             :       32,
    1020             :       "\x1f\x18\x29\xa9\x4b\xdf\xf5\xbe\x10\xd0\xae\xb3\x6a\xf4\x98\xe7"
    1021             :       "\xa9\x74\x67\xf3\xb3\x11\x16\xa5\xa7\xc1\xaf\xff\x9d\xea\xda\xfe"
    1022             :     },
    1023             :     /* { -- takes too long (4-5 min) to calculate
    1024             :       "password", 8,
    1025             :       "salt", 4,
    1026             :       GCRY_MD_GOSTR3411_CP,
    1027             :       16777216,
    1028             :       32,
    1029             :       "\xa5\x7a\xe5\xa6\x08\x83\x96\xd1\x20\x85\x0c\x5c\x09\xde\x0a\x52"
    1030             :       "\x51\x00\x93\x8a\x59\xb1\xb5\xc3\xf7\x81\x09\x10\xd0\x5f\xcd\x97"
    1031             :     }, */
    1032             :     {
    1033             :       "passwordPASSWORDpassword", 24,
    1034             :       "saltSALTsaltSALTsaltSALTsaltSALTsalt", 36,
    1035             :       GCRY_MD_GOSTR3411_CP,
    1036             :       4096,
    1037             :       40,
    1038             :       "\x78\x83\x58\xc6\x9c\xb2\xdb\xe2\x51\xa7\xbb\x17\xd5\xf4\x24\x1f"
    1039             :       "\x26\x5a\x79\x2a\x35\xbe\xcd\xe8\xd5\x6f\x32\x6b\x49\xc8\x50\x47"
    1040             :       "\xb7\x63\x8a\xcb\x47\x64\xb1\xfd"
    1041             :     },
    1042             :     {
    1043             :       "pass\0word", 9,
    1044             :       "sa\0lt", 5,
    1045             :       GCRY_MD_GOSTR3411_CP,
    1046             :       4096,
    1047             :       20,
    1048             :       "\x43\xe0\x6c\x55\x90\xb0\x8c\x02\x25\x24"
    1049             :       "\x23\x73\x12\x7e\xdf\x9c\x8e\x9c\x32\x91"
    1050             :     },
    1051             :     {
    1052             :       "password", 8,
    1053             :       "salt", 4,
    1054             :       GCRY_MD_STRIBOG512,
    1055             :       1,
    1056             :       64,
    1057             :       "\x64\x77\x0a\xf7\xf7\x48\xc3\xb1\xc9\xac\x83\x1d\xbc\xfd\x85\xc2"
    1058             :       "\x61\x11\xb3\x0a\x8a\x65\x7d\xdc\x30\x56\xb8\x0c\xa7\x3e\x04\x0d"
    1059             :       "\x28\x54\xfd\x36\x81\x1f\x6d\x82\x5c\xc4\xab\x66\xec\x0a\x68\xa4"
    1060             :       "\x90\xa9\xe5\xcf\x51\x56\xb3\xa2\xb7\xee\xcd\xdb\xf9\xa1\x6b\x47"
    1061             :     },
    1062             :     {
    1063             :       "password", 8,
    1064             :       "salt", 4,
    1065             :       GCRY_MD_STRIBOG512,
    1066             :       2,
    1067             :       64,
    1068             :       "\x5a\x58\x5b\xaf\xdf\xbb\x6e\x88\x30\xd6\xd6\x8a\xa3\xb4\x3a\xc0"
    1069             :       "\x0d\x2e\x4a\xeb\xce\x01\xc9\xb3\x1c\x2c\xae\xd5\x6f\x02\x36\xd4"
    1070             :       "\xd3\x4b\x2b\x8f\xbd\x2c\x4e\x89\xd5\x4d\x46\xf5\x0e\x47\xd4\x5b"
    1071             :       "\xba\xc3\x01\x57\x17\x43\x11\x9e\x8d\x3c\x42\xba\x66\xd3\x48\xde"
    1072             :     },
    1073             :     {
    1074             :       "password", 8,
    1075             :       "salt", 4,
    1076             :       GCRY_MD_STRIBOG512,
    1077             :       4096,
    1078             :       64,
    1079             :       "\xe5\x2d\xeb\x9a\x2d\x2a\xaf\xf4\xe2\xac\x9d\x47\xa4\x1f\x34\xc2"
    1080             :       "\x03\x76\x59\x1c\x67\x80\x7f\x04\x77\xe3\x25\x49\xdc\x34\x1b\xc7"
    1081             :       "\x86\x7c\x09\x84\x1b\x6d\x58\xe2\x9d\x03\x47\xc9\x96\x30\x1d\x55"
    1082             :       "\xdf\x0d\x34\xe4\x7c\xf6\x8f\x4e\x3c\x2c\xda\xf1\xd9\xab\x86\xc3"
    1083             :     },
    1084             :     /* { -- takes toooo long
    1085             :       "password", 8,
    1086             :       "salt", 4,
    1087             :       GCRY_MD_STRIBOG512,
    1088             :       16777216,
    1089             :       64,
    1090             :       "\x49\xe4\x84\x3b\xba\x76\xe3\x00\xaf\xe2\x4c\x4d\x23\xdc\x73\x92"
    1091             :       "\xde\xf1\x2f\x2c\x0e\x24\x41\x72\x36\x7c\xd7\x0a\x89\x82\xac\x36"
    1092             :       "\x1a\xdb\x60\x1c\x7e\x2a\x31\x4e\x8c\xb7\xb1\xe9\xdf\x84\x0e\x36"
    1093             :       "\xab\x56\x15\xbe\x5d\x74\x2b\x6c\xf2\x03\xfb\x55\xfd\xc4\x80\x71"
    1094             :     }, */
    1095             :     {
    1096             :       "passwordPASSWORDpassword", 24,
    1097             :       "saltSALTsaltSALTsaltSALTsaltSALTsalt", 36,
    1098             :       GCRY_MD_STRIBOG512,
    1099             :       4096,
    1100             :       100,
    1101             :       "\xb2\xd8\xf1\x24\x5f\xc4\xd2\x92\x74\x80\x20\x57\xe4\xb5\x4e\x0a"
    1102             :       "\x07\x53\xaa\x22\xfc\x53\x76\x0b\x30\x1c\xf0\x08\x67\x9e\x58\xfe"
    1103             :       "\x4b\xee\x9a\xdd\xca\xe9\x9b\xa2\xb0\xb2\x0f\x43\x1a\x9c\x5e\x50"
    1104             :       "\xf3\x95\xc8\x93\x87\xd0\x94\x5a\xed\xec\xa6\xeb\x40\x15\xdf\xc2"
    1105             :       "\xbd\x24\x21\xee\x9b\xb7\x11\x83\xba\x88\x2c\xee\xbf\xef\x25\x9f"
    1106             :       "\x33\xf9\xe2\x7d\xc6\x17\x8c\xb8\x9d\xc3\x74\x28\xcf\x9c\xc5\x2a"
    1107             :       "\x2b\xaa\x2d\x3a"
    1108             :     },
    1109             :     {
    1110             :       "pass\0word", 9,
    1111             :       "sa\0lt", 5,
    1112             :       GCRY_MD_STRIBOG512,
    1113             :       4096,
    1114             :       64,
    1115             :       "\x50\xdf\x06\x28\x85\xb6\x98\x01\xa3\xc1\x02\x48\xeb\x0a\x27\xab"
    1116             :       "\x6e\x52\x2f\xfe\xb2\x0c\x99\x1c\x66\x0f\x00\x14\x75\xd7\x3a\x4e"
    1117             :       "\x16\x7f\x78\x2c\x18\xe9\x7e\x92\x97\x6d\x9c\x1d\x97\x08\x31\xea"
    1118             :       "\x78\xcc\xb8\x79\xf6\x70\x68\xcd\xac\x19\x10\x74\x08\x44\xe8\x30"
    1119             :     }
    1120             :   };
    1121             :   int tvidx;
    1122             :   gpg_error_t err;
    1123             :   unsigned char outbuf[100];
    1124             :   int i;
    1125             : 
    1126          18 :   for (tvidx=0; tvidx < DIM(tv); tvidx++)
    1127             :     {
    1128          17 :       if (tv[tvidx].disabled)
    1129           1 :         continue;
    1130          16 :       if (verbose)
    1131           0 :         fprintf (stderr, "checking PBKDF2 test vector %d algo %d\n", tvidx,
    1132             :                  tv[tvidx].hashalgo);
    1133          16 :       assert (tv[tvidx].dklen <= sizeof outbuf);
    1134          32 :       err = gcry_kdf_derive (tv[tvidx].p, tv[tvidx].plen,
    1135             :                              GCRY_KDF_PBKDF2, tv[tvidx].hashalgo,
    1136          16 :                              tv[tvidx].salt, tv[tvidx].saltlen,
    1137          16 :                              tv[tvidx].c, tv[tvidx].dklen, outbuf);
    1138          16 :       if (err)
    1139           0 :         fail ("pbkdf2 test %d failed: %s\n", tvidx, gpg_strerror (err));
    1140          16 :       else if (memcmp (outbuf, tv[tvidx].dk, tv[tvidx].dklen))
    1141             :         {
    1142           0 :           fail ("pbkdf2 test %d failed: mismatch\n", tvidx);
    1143           0 :           fputs ("got:", stderr);
    1144           0 :           for (i=0; i < tv[tvidx].dklen; i++)
    1145           0 :             fprintf (stderr, " %02x", outbuf[i]);
    1146           0 :           putc ('\n', stderr);
    1147             :         }
    1148             :     }
    1149           1 : }
    1150             : 
    1151             : 
    1152             : static void
    1153           1 : check_scrypt (void)
    1154             : {
    1155             :   /* Test vectors are from draft-josefsson-scrypt-kdf-01.  */
    1156             :   static struct {
    1157             :     const char *p;        /* Passphrase.  */
    1158             :     size_t plen;          /* Length of P. */
    1159             :     const char *salt;
    1160             :     size_t saltlen;
    1161             :     int parm_n;           /* CPU/memory cost.  */
    1162             :     int parm_r;           /* blocksize */
    1163             :     unsigned long parm_p; /* parallelization. */
    1164             :     int dklen;            /* Requested key length.  */
    1165             :     const char *dk;       /* Derived key.  */
    1166             :     int disabled;
    1167             :   } tv[] = {
    1168             :     {
    1169             :       "", 0,
    1170             :       "", 0,
    1171             :       16,
    1172             :       1,
    1173             :       1,
    1174             :       64,
    1175             :       "\x77\xd6\x57\x62\x38\x65\x7b\x20\x3b\x19\xca\x42\xc1\x8a\x04\x97"
    1176             :       "\xf1\x6b\x48\x44\xe3\x07\x4a\xe8\xdf\xdf\xfa\x3f\xed\xe2\x14\x42"
    1177             :       "\xfc\xd0\x06\x9d\xed\x09\x48\xf8\x32\x6a\x75\x3a\x0f\xc8\x1f\x17"
    1178             :       "\xe8\xd3\xe0\xfb\x2e\x0d\x36\x28\xcf\x35\xe2\x0c\x38\xd1\x89\x06"
    1179             :     },
    1180             :     {
    1181             :       "password", 8,
    1182             :       "NaCl", 4,
    1183             :       1024,
    1184             :       8,
    1185             :       16,
    1186             :       64,
    1187             :       "\xfd\xba\xbe\x1c\x9d\x34\x72\x00\x78\x56\xe7\x19\x0d\x01\xe9\xfe"
    1188             :       "\x7c\x6a\xd7\xcb\xc8\x23\x78\x30\xe7\x73\x76\x63\x4b\x37\x31\x62"
    1189             :       "\x2e\xaf\x30\xd9\x2e\x22\xa3\x88\x6f\xf1\x09\x27\x9d\x98\x30\xda"
    1190             :       "\xc7\x27\xaf\xb9\x4a\x83\xee\x6d\x83\x60\xcb\xdf\xa2\xcc\x06\x40"
    1191             :     },
    1192             :     {
    1193             :       "pleaseletmein", 13,
    1194             :       "SodiumChloride", 14,
    1195             :       16384,
    1196             :       8,
    1197             :       1,
    1198             :       64,
    1199             :       "\x70\x23\xbd\xcb\x3a\xfd\x73\x48\x46\x1c\x06\xcd\x81\xfd\x38\xeb"
    1200             :       "\xfd\xa8\xfb\xba\x90\x4f\x8e\x3e\xa9\xb5\x43\xf6\x54\x5d\xa1\xf2"
    1201             :       "\xd5\x43\x29\x55\x61\x3f\x0f\xcf\x62\xd4\x97\x05\x24\x2a\x9a\xf9"
    1202             :       "\xe6\x1e\x85\xdc\x0d\x65\x1e\x40\xdf\xcf\x01\x7b\x45\x57\x58\x87"
    1203             :     },
    1204             :     {
    1205             :       "pleaseletmein", 13,
    1206             :       "SodiumChloride", 14,
    1207             :       1048576,
    1208             :       8,
    1209             :       1,
    1210             :       64,
    1211             :       "\x21\x01\xcb\x9b\x6a\x51\x1a\xae\xad\xdb\xbe\x09\xcf\x70\xf8\x81"
    1212             :       "\xec\x56\x8d\x57\x4a\x2f\xfd\x4d\xab\xe5\xee\x98\x20\xad\xaa\x47"
    1213             :       "\x8e\x56\xfd\x8f\x4b\xa5\xd0\x9f\xfa\x1c\x6d\x92\x7c\x40\xf4\xc3"
    1214             :       "\x37\x30\x40\x49\xe8\xa9\x52\xfb\xcb\xf4\x5c\x6f\xa7\x7a\x41\xa4",
    1215             :       2 /* Only in debug mode.  */
    1216             :     }
    1217             :   };
    1218             :   int tvidx;
    1219             :   gpg_error_t err;
    1220             :   unsigned char outbuf[64];
    1221             :   int i;
    1222             : 
    1223           5 :   for (tvidx=0; tvidx < DIM(tv); tvidx++)
    1224             :     {
    1225           4 :       if (tv[tvidx].disabled && !(tv[tvidx].disabled == 2 && debug))
    1226           1 :         continue;
    1227           3 :       if (verbose)
    1228           0 :         fprintf (stderr, "checking SCRYPT test vector %d\n", tvidx);
    1229           3 :       assert (tv[tvidx].dklen <= sizeof outbuf);
    1230           9 :       err = gcry_kdf_derive (tv[tvidx].p, tv[tvidx].plen,
    1231           3 :                              tv[tvidx].parm_r == 1 ? 41 : GCRY_KDF_SCRYPT,
    1232             :                              tv[tvidx].parm_n,
    1233           3 :                              tv[tvidx].salt, tv[tvidx].saltlen,
    1234           3 :                              tv[tvidx].parm_p, tv[tvidx].dklen, outbuf);
    1235           3 :       if (err)
    1236           0 :         fail ("scrypt test %d failed: %s\n", tvidx, gpg_strerror (err));
    1237           3 :       else if (memcmp (outbuf, tv[tvidx].dk, tv[tvidx].dklen))
    1238             :         {
    1239           0 :           fail ("scrypt test %d failed: mismatch\n", tvidx);
    1240           0 :           fputs ("got:", stderr);
    1241           0 :           for (i=0; i < tv[tvidx].dklen; i++)
    1242           0 :             fprintf (stderr, " %02x", outbuf[i]);
    1243           0 :           putc ('\n', stderr);
    1244             :         }
    1245             :     }
    1246           1 : }
    1247             : 
    1248             : 
    1249             : int
    1250           1 : main (int argc, char **argv)
    1251             : {
    1252           1 :   int last_argc = -1;
    1253           1 :   unsigned long s2kcount = 0;
    1254             : 
    1255           1 :   if (argc)
    1256           1 :     { argc--; argv++; }
    1257             : 
    1258           2 :   while (argc && last_argc != argc )
    1259             :     {
    1260           0 :       last_argc = argc;
    1261           0 :       if (!strcmp (*argv, "--"))
    1262             :         {
    1263           0 :           argc--; argv++;
    1264           0 :           break;
    1265             :         }
    1266           0 :       else if (!strcmp (*argv, "--help"))
    1267             :         {
    1268           0 :           fputs ("usage: t-kdf [options]"
    1269             :                  "Options:\n"
    1270             :                  " --verbose    print timinigs etc.\n"
    1271             :                  " --debug      flyswatter\n"
    1272             :                  " --s2k        print the time needed for S2K\n",
    1273             :                  stdout);
    1274           0 :           exit (0);
    1275             :         }
    1276           0 :       else if (!strcmp (*argv, "--verbose"))
    1277             :         {
    1278           0 :           verbose++;
    1279           0 :           argc--; argv++;
    1280             :         }
    1281           0 :       else if (!strcmp (*argv, "--debug"))
    1282             :         {
    1283           0 :           verbose += 2;
    1284           0 :           debug++;
    1285           0 :           argc--; argv++;
    1286             :         }
    1287           0 :       else if (!strcmp (*argv, "--s2k"))
    1288             :         {
    1289           0 :           s2kcount = 1;
    1290           0 :           argc--; argv++;
    1291             :         }
    1292           0 :       else if (!strncmp (*argv, "--", 2))
    1293           0 :         die ("unknown option '%s'\n", *argv);
    1294             :     }
    1295             : 
    1296           1 :   if (s2kcount)
    1297             :     {
    1298           0 :       if (argc != 1)
    1299           0 :         die ("usage: t-kdf --s2k S2KCOUNT\n", stderr );
    1300           0 :       s2kcount = strtoul (*argv, NULL, 10);
    1301           0 :       if (!s2kcount)
    1302           0 :         die ("t-kdf: S2KCOUNT must be positive\n", stderr );
    1303             :     }
    1304             : 
    1305           1 :   if (!gcry_check_version (GCRYPT_VERSION))
    1306           0 :     die ("version mismatch\n");
    1307             : 
    1308           1 :   gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
    1309           1 :   gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
    1310           1 :   if (debug)
    1311           0 :     gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
    1312             : 
    1313           1 :   if (s2kcount)
    1314           0 :     bench_s2k (s2kcount);
    1315             :   else
    1316             :     {
    1317           1 :       check_openpgp ();
    1318           1 :       check_pbkdf2 ();
    1319           1 :       check_scrypt ();
    1320             :     }
    1321             : 
    1322           1 :   return error_count ? 1 : 0;
    1323             : }

Generated by: LCOV version 1.11