LCOV - code coverage report
Current view: top level - g10 - t-rmd160.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 9 10 90.0 %
Date: 2015-11-05 17:10:59 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* t-rmd160.c - Module test for rmd160.c
       2             :  *      Copyright (C) 2008 Free Software Foundation, Inc.
       3             :  *
       4             :  * This file is part of GnuPG.
       5             :  *
       6             :  * GnuPG is free software; you can redistribute it and/or modify
       7             :  * it under the terms of the GNU General Public License as published by
       8             :  * the Free Software Foundation; either version 3 of the License, or
       9             :  * (at your option) any later version.
      10             :  *
      11             :  * GnuPG 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 General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU General Public License
      17             :  * along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #include <config.h>
      21             : #include <stdio.h>
      22             : #include <stdlib.h>
      23             : #include <string.h>
      24             : 
      25             : #include "rmd160.h"
      26             : 
      27             : #define pass()  do { ; } while(0)
      28             : #define fail(a)  do { fprintf (stderr, "%s:%d: test %d failed\n",\
      29             :                                __FILE__,__LINE__, (a));          \
      30             :                        exit (1);                                 \
      31             :                     } while(0)
      32             : 
      33             : static void
      34           1 : run_test (void)
      35             : {
      36             :   static struct
      37             :   {
      38             :     const char *data;
      39             :     const char *expect;
      40             :   } testtbl[] =
      41             :     {
      42             :       { "",
      43             :         "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28"
      44             :         "\x08\x97\x7e\xe8\xf5\x48\xb2\x25\x8d\x31" },
      45             :       { "a",
      46             :         "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae"
      47             :         "\x34\x7b\xe6\xf4\xdc\x83\x5a\x46\x7f\xfe" },
      48             :       { "abc",
      49             :         "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04"
      50             :         "\x4a\x8e\x98\xc6\xb0\x87\xf1\x5a\x0b\xfc" },
      51             :       { "message digest",
      52             :         "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8"
      53             :         "\x81\xb1\x23\xa8\x5f\xfa\x21\x59\x5f\x36" },
      54             :       { "abcdefghijklmnopqrstuvwxyz",
      55             :         "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb"
      56             :         "\xdc\xeb\x5b\x9d\x28\x65\xb3\x70\x8d\xbc" },
      57             :       { "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      58             :         "abcdefghijklmnopqrstuvwxyz"
      59             :         "0123456789",
      60             :         "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed"
      61             :         "\x3a\x87\xa5\x71\x30\x79\xb2\x1f\x51\x89" },
      62             :       { "1234567890" "1234567890" "1234567890" "1234567890"
      63             :         "1234567890" "1234567890" "1234567890" "1234567890",
      64             :         "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb"
      65             :         "\xd3\x32\x3c\xab\x82\xbf\x63\x32\x6b\xfb" },
      66             : 
      67             :       { NULL, NULL }
      68             :     };
      69             :   int idx;
      70             :   char digest[20];
      71             : 
      72           8 :   for (idx=0; testtbl[idx].data; idx++)
      73             :     {
      74          14 :       rmd160_hash_buffer (digest,
      75           7 :                           testtbl[idx].data, strlen(testtbl[idx].data));
      76           7 :       if (memcmp (digest, testtbl[idx].expect, 20))
      77           0 :         fail (idx);
      78             :     }
      79           1 : }
      80             : 
      81             : 
      82             : int
      83           1 : main (int argc, char **argv)
      84             : {
      85             :   (void)argc;
      86             :   (void)argv;
      87             : 
      88           1 :   run_test ();
      89             : 
      90           1 :   return 0;
      91             : }

Generated by: LCOV version 1.11