summaryrefslogtreecommitdiff
path: root/src/abe/test_cpabe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/abe/test_cpabe.c')
-rw-r--r--src/abe/test_cpabe.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/src/abe/test_cpabe.c b/src/abe/test_cpabe.c
index e2c86e986..84b45fc8a 100644
--- a/src/abe/test_cpabe.c
+++ b/src/abe/test_cpabe.c
@@ -11,13 +11,13 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19 19
20*/ 20 */
21/** 21/**
22 * @author Martin Schanzenbach 22 * @author Martin Schanzenbach
23 * @file util/test_crypto_abe.c 23 * @file util/test_crypto_abe.c
@@ -30,7 +30,7 @@
30#define TESTSTRING "Hello World!" 30#define TESTSTRING "Hello World!"
31 31
32static int 32static int
33testAbecipher () 33testAbecipher()
34{ 34{
35 struct GNUNET_ABE_AbeMasterKey *msk; 35 struct GNUNET_ABE_AbeMasterKey *msk;
36 struct GNUNET_ABE_AbeKey *key; 36 struct GNUNET_ABE_AbeKey *key;
@@ -38,49 +38,50 @@ testAbecipher ()
38 char **attrs; 38 char **attrs;
39 int size; 39 int size;
40 char *res; 40 char *res;
41 msk = GNUNET_ABE_cpabe_create_master_key (); 41
42 size = GNUNET_ABE_cpabe_encrypt (TESTSTRING, strlen (TESTSTRING) + 1, 42 msk = GNUNET_ABE_cpabe_create_master_key();
43 "testattr", //Policy 43 size = GNUNET_ABE_cpabe_encrypt(TESTSTRING, strlen(TESTSTRING) + 1,
44 msk, 44 "testattr", //Policy
45 (void*)&result); 45 msk,
46 GNUNET_assert (-1 != size); 46 (void*)&result);
47 attrs = GNUNET_malloc (2 * sizeof (char*)); 47 GNUNET_assert(-1 != size);
48 attrs = GNUNET_malloc(2 * sizeof(char*));
48 attrs[0] = "testattr"; 49 attrs[0] = "testattr";
49 attrs[1] = NULL; 50 attrs[1] = NULL;
50 key = GNUNET_ABE_cpabe_create_key (msk, 51 key = GNUNET_ABE_cpabe_create_key(msk,
51 attrs); 52 attrs);
52 53
53 size = GNUNET_ABE_cpabe_decrypt (result, size, 54 size = GNUNET_ABE_cpabe_decrypt(result, size,
54 key, 55 key,
55 (void*)&res); 56 (void*)&res);
56 if (strlen (TESTSTRING) + 1 != size) 57 if (strlen(TESTSTRING) + 1 != size)
57 { 58 {
58 printf ("abeciphertest failed: decryptBlock returned %d\n", size); 59 printf("abeciphertest failed: decryptBlock returned %d\n", size);
59 return 1; 60 return 1;
60 } 61 }
61 if (0 != strcmp (res, TESTSTRING)) 62 if (0 != strcmp(res, TESTSTRING))
62 { 63 {
63 printf ("abeciphertest failed: %s != %s\n", res, TESTSTRING); 64 printf("abeciphertest failed: %s != %s\n", res, TESTSTRING);
64 return 1; 65 return 1;
65 } 66 }
66 else 67 else
67 return 0; 68 return 0;
68} 69}
69 70
70 71
71int 72int
72main (int argc, char *argv[]) 73main(int argc, char *argv[])
73{ 74{
74 int failureCount = 0; 75 int failureCount = 0;
75 76
76 GNUNET_log_setup ("test-crypto-abe", "WARNING", NULL); 77 GNUNET_log_setup("test-crypto-abe", "WARNING", NULL);
77 failureCount += testAbecipher (); 78 failureCount += testAbecipher();
78 79
79 if (failureCount != 0) 80 if (failureCount != 0)
80 { 81 {
81 printf ("%d TESTS FAILED!\n", failureCount); 82 printf("%d TESTS FAILED!\n", failureCount);
82 return -1; 83 return -1;
83 } 84 }
84 return 0; 85 return 0;
85} 86}
86 87