diff options
author | Ruan HE <ruan.he@orange.com> | 2015-09-04 07:35:06 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2015-09-04 07:35:06 +0000 |
commit | ca6aa8198d2335f8c326c3dd4d26bf5899064214 (patch) | |
tree | 6274a2d971fc0cac0896efe8583927d0190e3d20 /moon-abe/cpabe-0.11/attrList.c | |
parent | 92fd2dbfb672d7b2b1cdfd5dd5cf89f7716b3e12 (diff) | |
parent | 3baeb11a8fbcfcdbc31976d421f17b85503b3ecd (diff) |
Merge "init attribute-based encryption"
Diffstat (limited to 'moon-abe/cpabe-0.11/attrList.c')
-rw-r--r-- | moon-abe/cpabe-0.11/attrList.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/moon-abe/cpabe-0.11/attrList.c b/moon-abe/cpabe-0.11/attrList.c new file mode 100644 index 00000000..1d514493 --- /dev/null +++ b/moon-abe/cpabe-0.11/attrList.c @@ -0,0 +1,82 @@ +#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-attrList [OPTION ...] PUB_KEY PRV_KEY\n" +"\n" +"Print the attributes of a private key PRV_KEY\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* pub_file = 0; +char* prv_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( !prv_file ) + { + prv_file = argv[i]; + } + else + die(usage); +} + +int +main( int argc, char** argv ) +{ + + bswabe_prv_t* prv; + bswabe_pub_t* pub; + char** attrList; + int i; + + parse_args(argc, argv); + + pub = bswabe_pub_unserialize(suck_file(pub_file), 1); + prv = bswabe_prv_unserialize(pub, suck_file(prv_file), 1); + + attrList = bswabe_attrList(prv); + + i = 0; + + while(attrList[i]) + { + printf("%s ",attrList[i]); + i++; + } + printf("\n"); + return 0; +} |