diff options
author | 2015-09-04 09:25:34 +0200 | |
---|---|---|
committer | 2015-09-04 09:25:34 +0200 | |
commit | 3baeb11a8fbcfcdbc31976d421f17b85503b3ecd (patch) | |
tree | 04891d88c1127148f1b390b5a24414e85b270aee /moon-abe/cpabe-0.11/policyList.c | |
parent | 67c5b73910f5fc437429c356978081b252a59480 (diff) |
init attribute-based encryption
Change-Id: Iba1a3d722110abf747a0fba366f3ebc911d25b25
Diffstat (limited to 'moon-abe/cpabe-0.11/policyList.c')
-rw-r--r-- | moon-abe/cpabe-0.11/policyList.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/moon-abe/cpabe-0.11/policyList.c b/moon-abe/cpabe-0.11/policyList.c new file mode 100644 index 00000000..644e3282 --- /dev/null +++ b/moon-abe/cpabe-0.11/policyList.c @@ -0,0 +1,79 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <glib.h> +#include <pbc.h> +#include <pbc_random.h> + +#include "bswabe.h" +#include "common.h" + +char* usage = +"Usage: cpabe-policyList [OPTION ...] PUB_KEY CIPHERTEXT \n" +"\n" +"Print the access policy of a ciphertext CIPHERTEXT\n" +"Mandatory arguments to long options are mandatory for short options too.\n\n" +" -h, --help print this message\n\n" +" -v, --version print version information\n\n" +" -d, --deterministic use deterministic \"random\" numbers\n" +" (only for debugging)\n\n"; + +char* in_file = 0; +char* pub_file = 0; + +void +parse_args( int argc, char** argv ) +{ + int i; + + for( i = 1; i < argc; i++ ) + if( !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help") ) + { + printf("%s", usage); + exit(0); + } + else if( !strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ) + { + printf(CPABE_VERSION, "-setup"); + exit(0); + } + else if( !strcmp(argv[i], "-d") || !strcmp(argv[i], "--deterministic") ) + { + pbc_random_set_deterministic(0); + } + else if( !pub_file ) + { + pub_file = argv[i]; + } + + else if( !in_file ) + { + in_file = argv[i]; + } + + else + die(usage); +} + +int +main( int argc, char** argv ) +{ + + bswabe_cph_t* cph; + bswabe_pub_t* pub; + int file_len; + GByteArray* cph_buf; + GByteArray* aes_buf; + + parse_args(argc, argv); + + pub = bswabe_pub_unserialize(suck_file(pub_file), 1); + read_cpabe_file(in_file, &cph_buf, &file_len, &aes_buf); + + cph = bswabe_cph_unserialize(pub, cph_buf, 1); + + printf("%s\n",bswabe_policyList(cph)); + + return 0; +} |