int main( int argc, char** argv ) { kpabe_pub_t* pub; kpabe_msk_t* msk; kpabe_prv_t* prv; parse_args(argc, argv); pub = kpabe_pub_unserialize(suck_file(pub_file), 1); msk = kpabe_msk_unserialize(pub, suck_file(msk_file), 1); struct timespec start,d,end; clock_gettime(CLOCK_REALTIME,&start); if( !(prv = kpabe_keygen(pub, msk, policy)) ) { die("%s", kpabe_error()); } clock_gettime(CLOCK_REALTIME,&end); diff(&d,&start,&end); printf("%lf", to_milliseconds(&d)); free(policy); spit_file(out_file, kpabe_prv_serialize(prv), 1); return 0; }
int main( int argc, char** argv ) { kpabe_pub_t* pub; kpabe_cph_t* cph; int file_len; GByteArray* plt; GByteArray* cph_buf; GByteArray* aes_buf; element_t m; parse_args(argc, argv); pub = kpabe_pub_unserialize(suck_file(pub_file), 1); if( !(cph = kpabe_enc(pub, m, attrs)) ) die("%s", kpabe_error()); free(attrs); cph_buf = kpabe_cph_serialize(cph); kpabe_cph_free(cph); plt = suck_file(in_file); file_len = plt->len; aes_buf = aes_128_cbc_encrypt(plt, m); g_byte_array_free(plt, 1); element_clear(m); write_kpabe_file(out_file, cph_buf, file_len, aes_buf); g_byte_array_free(cph_buf, 1); g_byte_array_free(aes_buf, 1); if( !keep ) unlink(in_file); return 0; }