https://crypto.stanford.edu/pbc/howto.html
pbc环境配置
cpabe依赖pbc,pbc依赖gmp,gmp依赖M4、bison、flex,所以。。
[plain] view plain copy
sudo apt-get install M4
sudo apt-get install flex
sudo apt-get install bison
1 安装gmp
下载https://gmplib.org/
[plain] view plain copy
lzip -d gmp-6.1.0.tar.lz
tar -zxvf gmp-6.1.0.tar
cd gmp-6.1.0
./configure
make
make check
sudo make install
2 安装pbc
下载https://crypto.stanford.edu/pbc/download.html
[plain] view plain copy
tar -zxvf pbc-0.5.14.tar.gz
cd pbc-0.5.14
$ ./configure --prefix=$HOME/.local
$ make
$ make install
#include "pbc.h"
int main(void)
{
/* call PBC functions */
return 0;
}
gcc -o foo foo.c -I ~/.local/include/pbc -L ~/.local/lib -Wl,-rpath ~/.local/lib -l pbc
3 安装openSSL
下载https://www.openssl.org/source/
[plain] view plain copy
tar -zxvf openssl-1.0.1t.tar.gz
cd openssl-1.0.1
./configure
make
sudo make install
4 安装libbswcpabe
下载http://acsc.cs.utexas.edu/cpabe/
[plain] view plain copy
tar -zxvf libbswabe-0.9.tar.gz
cd libbswabe-0.9
[plain] view plain copy
./configure
make
sudo make install
make出现问题
[plain] view plain copy
[plain] view plain copy
sudo apt-get install libglib2.0-dev
重新编译
[plain] view plain copy
./configure
make
sudo make install
5 安装cpabe
下载http://acsc.cs.utexas.edu/cpabe/
[plain] view plain copy
tar -zxvf cpabe-0.11.tar.gz
cd cpabe-0.11/
[plain] view plain copy
./configure
make
sudo make install
make 出现问题
[plain] view plain copy
//usr/local/lib/libgmp.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: * [cpabe-setup] 错误 1
解决:修改Makefile,LDFLAGS最后加入-lgmp
[plain] view plain copy
make
出现以下问题
[plain] view plain copy
policy_lang.y: In function ‘yyparse’:
policy_lang.y:67:38: error: expected ‘;’ before ‘}’ token
result: policy { final_policy = $1 }
^
make: * [policy_lang.o] 错误 1
cpabe-setup -h
- 1
解决:67行 } 前加 ;j即可
64位操作系统还有一些worning
[plain] view plain copy
policy_lang.y: In function ‘eq_policy’:
policy_lang.y:212:4: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
(g_strdup_printf(“%s_flexint_%llu”, attr, n->value));
^
policy_lang.y:215:4: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
(g_strdup_printf(“%s_expint%02d_%llu”, attr, n->bits, n->value));
^
policy_lang.y: In function ‘yylex’:
policy_lang.y:391:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int ’, but argument 3 has type ‘uint64_t ’ [-Wformat=]
sscanf(s->str, “%llu”, &(yylval.nat));
^
policy_lang.y: In function ‘parse_attribute’:
policy_lang.y:577:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int ’, but argument 4 has type ‘uint64_t ’ [-Wformat=]
if( sscanf(a, ” %s = %llu # %u “, s, &value, &bits) == 3 )
^
policy_lang.y:596:5: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
(*l, g_strdup_printf(“%s_expint%02d_%llu”, s, bits, value));
^
policy_lang.y:598:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int ’, but argument 4 has type ‘uint64_t ’ [-Wformat=]
else if( sscanf(a, ” %s = %llu “, s, &value) == 2 )
^
policy_lang.y:612:5: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
(*l, g_strdup_printf(“%s_flexint_%llu”, s, value));
解决:%llu都改为 %lu 即可
[plain] view plain copy
make
sudo make install
编译成功
测试
[plain] view plain copy
cpabe-setup -h
显示
[plain] view plain copy
Usage: cpabe-setup [OPTION …]
Generate system parameters, a public key, and a master secret key
for use with cpabe-keygen, cpabe-enc, and cpabe-dec.
Output will be written to the files “pub_key” and “master_key”
unless the –output-public-key or –output-master-key options are
used.
Mandatory arguments to long options are mandatory for short options too.
-h, –help print this message
-v, –version print version information
-p, –output-public-key FILE write public key to FILE
-m, –output-master-key FILE write master secret key to FILE
-d, –deterministic use deterministic “random” numbers
(only for debugging)
没问题,,成功
还有一个abe更具体的实现 libfenc
6 安装 libenc
下载https://code.google.com/archive/p/libfenc/downloads
[plain] view plain copy
cd libfenc
./configure
make
sudo make install
参阅
http://blog.csdn.net/novostary/article/details/21883537
http://www.cnblogs.com/rockorange/p/3757805.html
http://blog.csdn.net/huifeideyema/article/details/51695231