2 This file is part of GNUnet.
3 Copyright (C) 2002, 2003, 2004, 2006 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
17 * @author Martin Schanzenbach
18 * @file util/test_crypto_abe.c
19 * @brief test for ABE ciphers
22 #include "gnunet_util_lib.h"
23 #include "gnunet_abe_lib.h"
25 #define TESTSTRING "Hello World!"
30 struct GNUNET_ABE_AbeMasterKey *msk;
31 struct GNUNET_ABE_AbeKey *key;
36 msk = GNUNET_ABE_cpabe_create_master_key ();
37 size = GNUNET_ABE_cpabe_encrypt (TESTSTRING, strlen (TESTSTRING) + 1,
41 GNUNET_assert (-1 != size);
42 attrs = GNUNET_malloc (2 * sizeof (char*));
43 attrs[0] = "testattr";
45 key = GNUNET_ABE_cpabe_create_key (msk,
48 size = GNUNET_ABE_cpabe_decrypt (result, size,
51 if (strlen (TESTSTRING) + 1 != size)
53 printf ("abeciphertest failed: decryptBlock returned %d\n", size);
56 if (0 != strcmp (res, TESTSTRING))
58 printf ("abeciphertest failed: %s != %s\n", res, TESTSTRING);
67 main (int argc, char *argv[])
71 GNUNET_log_setup ("test-crypto-abe", "WARNING", NULL);
72 failureCount += testAbecipher ();
74 if (failureCount != 0)
76 printf ("%d TESTS FAILED!\n", failureCount);
82 /* end of test_crypto_aes.c */