static double perf_ccccm_finalize(unsigned long loops, unsigned long size CC_UNUSED, const void *arg) { const struct ccccm_perf_test *test=arg; const struct ccmode_ccm *ccm=test->ccm; size_t keylen=test->keylen; unsigned char keyd[keylen]; unsigned char nonced[13]; unsigned char tag[16]={0}; unsigned char data[16]={0}; cc_zero(keylen,keyd); cc_zero(sizeof(nonced),nonced); ccccm_ctx_decl(ccm->size, key); ccccm_nonce_decl(ccm->nonce_size, nonce); ccccm_init(ccm, key, keylen, keyd); ccccm_set_iv(ccm,key, nonce, sizeof(nonced), nonced,sizeof(tag),size,0); ccccm_cbcmac(ccm,key, nonce, 0, NULL); ccccm_update(ccm,key, nonce, sizeof(data), data, data); perf_start(); while(loops--) ccccm_finalize(ccm, key, nonce, tag); return perf_time(); }
static double perf_ccccm_update(unsigned long loops, unsigned long size, const void *arg) { const struct ccccm_perf_test *test=arg; const struct ccmode_ccm *ccm=test->ccm; size_t keylen=test->keylen; unsigned long nblocks=size/ccm->block_size; unsigned char keyd[keylen]; unsigned char nonced[13]; unsigned char temp[nblocks*ccm->block_size]; cc_zero(keylen,keyd); cc_zero(sizeof(nonced),nonced); ccccm_ctx_decl(ccm->size, key); ccccm_nonce_decl(ccm->nonce_size, nonce); ccccm_init(ccm, key, keylen, keyd); ccccm_set_iv(ccm,key, nonce, sizeof(nonced), nonced,16,size,0); ccccm_cbcmac(ccm,key, nonce, size, temp); perf_start(); while(loops--) ccccm_update(ccm,key, nonce, size, temp, temp); return perf_time(); }
static double perf_ccccm_one_shot(unsigned long loops, unsigned long size, const void *arg) { const struct ccccm_perf_test *test=arg; const struct ccmode_ccm *ccm=test->ccm; size_t keylen=test->keylen; unsigned long nblocks=size/ccm->block_size; unsigned char temp[nblocks*ccm->block_size]; unsigned char keyd[keylen]; unsigned char tag[16]={0}; unsigned char nonced[13]; cc_zero(keylen,keyd); cc_zero(sizeof(nonced),nonced); perf_start(); while(loops--) { ccccm_one_shot(ccm, keylen,keyd, // Key sizeof(nonced),nonced, // Nonce size, temp, temp, // Data in/out 0, NULL, // Authenticated data sizeof(tag), tag); // Tag } return perf_time(); }
static double perf_ccxts_update(unsigned long loops, unsigned long size, const void *arg) { const struct ccxts_perf_test *test=arg; const struct ccmode_xts *xts=test->xts; size_t keylen=test->keylen; unsigned long nblocks=size/xts->block_size; unsigned char keyd[keylen]; unsigned char tweakkeyd[keylen]; unsigned char tweakd[xts->block_size]; unsigned char temp[nblocks*xts->block_size]; cc_zero(keylen,keyd); cc_zero(sizeof(tweakd),tweakd); ccxts_ctx_decl(xts->size, key); ccxts_tweak_decl(xts->tweak_size, tweak); ccxts_init(xts, key, keylen, keyd, tweakkeyd); ccxts_set_tweak(xts, key, tweak, tweakd); perf_start(); while(loops--) ccxts_update(xts, key, tweak, nblocks, temp, temp); return perf_time(); }
static double perf_ccn_cmp(unsigned long loops, cc_size count) { cc_unit s[count]; cc_unit t[count]; ccn_random(count, s, rng); ccn_set(count, t, s); perf_start(); do { r_for_cmp=ccn_cmp(count, s, t); } while (--loops != 0); return perf_time(); }
static double perf_cced25519_make_key_pair(unsigned long loops, CC_UNUSED unsigned long size, const struct ccdigest_info *di) { ccec25519secretkey sk; ccec25519pubkey pk; perf_start(); do { cced25519_make_key_pair(di, rng, pk, sk); } while (--loops != 0); return perf_time(); }
static double perf_cccurve25519_make_pub(unsigned long loops, CC_UNUSED unsigned long size, CC_UNUSED const struct ccdigest_info *di) { ccec25519secretkey sk; ccec25519pubkey pk; cccurve25519_make_priv(rng, sk); perf_start(); do { cccurve25519_make_pub(pk, sk); } while (--loops != 0); return perf_time(); }
static void performance(const char *family, const char *name, unsigned long trimCounter, size_t blocksize, void func(void *context), void *context) { /* first trim */ unsigned long bytes; unsigned long count; double t; /* * First figure out a good counter for about 10s worth of runtime */ count = trimCounter; { perf_start(); while (count-- > 1) func(context); t = perf_time(); } count = RUNTIME * trimCounter / t; bytes = count * blocksize; { perf_start(); while (count-- > 1) func(context); t = perf_time(); } printf("%-15s%-20s\tblocksize %8zd\ttime: %8.4lfs\tbyte/s: %12.0lf\n", family, name, blocksize, t, ((double)bytes) / RUNTIME); }
static double perf_ccecb_init(unsigned long loops, unsigned long size CC_UNUSED, const void *arg) { const struct ccecb_perf_test *test=arg; const struct ccmode_ecb *ecb=test->ecb; size_t keylen=test->keylen; unsigned char keyd[keylen]; cc_zero(keylen,keyd); ccecb_ctx_decl(ecb->size, key); perf_start(); while(loops--) ccecb_init(ecb, key, keylen, keyd); return perf_time(); }
static double perf_ccrng_CommonCrypto_generate(unsigned long loops, size_t nbytes) { uint8_t results[nbytes]; CC_UNUSED int status; double time; perf_start(); do { status = ccrng_generate((struct ccrng_state *)&nist_ctx, nbytes, results); cc_assert(status==0); } while (--loops != 0); time=perf_time(); return time; }
static double perf_cccmac(unsigned long loops, unsigned long size, const void *arg) { const struct cccmac_perf_test *test=arg; unsigned char mac[test->cbc->block_size]; unsigned char key[test->keylen]; unsigned char data[size]; cc_zero(test->keylen,key); perf_start(); do { cccmac(test->cbc, key, size, data, mac); } while (--loops != 0); return perf_time(); }
static double perf_cccbc_init(unsigned long loops, unsigned long size CC_UNUSED, const void *arg) { const struct cccbc_perf_test *test=arg; const struct ccmode_cbc *cbc=test->cbc; size_t keylen=test->keylen; unsigned char keyd[keylen]; cc_zero(keylen,keyd); cccbc_ctx_decl(cbc->size, key); perf_start(); while(loops--) cccbc_init(cbc, key, keylen, keyd); return perf_time(); }
static double perf_cced25519_sign(unsigned long loops, unsigned long size, const struct ccdigest_info *di) { ccec25519secretkey sk; ccec25519pubkey pk; cced25519_make_key_pair(di, rng, pk, sk); ccec25519signature sig; uint8_t msg[size]; memset(msg,0xaa,size); perf_start(); do { cced25519_sign(di, sig, sizeof(msg), msg, pk, sk); } while (--loops != 0); return perf_time(); }
static double perf_ccansikdf(unsigned long loops, unsigned long size, const void *arg) { const struct ccansikdf_perf_test *test=arg; unsigned long Zlen=test->Zlen; unsigned char Z[Zlen]; unsigned long sharedInfoLen=0; unsigned char *sharedInfo=NULL; unsigned long outputLen=size; unsigned char output[outputLen]; ccrng_generate(rng, Zlen, Z); perf_start(); do { ccansikdf_x963(test->di, Zlen, Z, sharedInfoLen, sharedInfo, outputLen, output); } while (--loops != 0); return perf_time(); }
static double perf_cccbc_one_shot(unsigned long loops, unsigned long size, const void *arg) { const struct cccbc_perf_test *test=arg; const struct ccmode_cbc *cbc=test->cbc; size_t keylen=test->keylen; unsigned long nblocks=size/cbc->block_size; unsigned char keyd[keylen]; unsigned char temp[nblocks*cbc->block_size]; cc_zero(keylen,keyd); perf_start(); while(loops--) { cccbc_one_shot(cbc,keylen,keyd,NULL,nblocks,temp, temp); } return perf_time(); }
static double perf_ccxts_init(unsigned long loops, unsigned long size CC_UNUSED, const void *arg) { const struct ccxts_perf_test *test=arg; const struct ccmode_xts *xts=test->xts; size_t keylen=test->keylen; unsigned char keyd[keylen]; unsigned char tweakkeyd[keylen]; cc_zero(keylen,keyd); ccxts_ctx_decl(xts->size, key); perf_start(); while(loops--) ccxts_init(xts, key, keylen, keyd, tweakkeyd); return perf_time(); }
static double perf_ccrng_system_oneshot(unsigned long loops, size_t nbytes) { struct ccrng_system_state system_ctx; CC_UNUSED int status; uint8_t results[nbytes]; double time; perf_start(); do { status = ccrng_system_init(&system_ctx); cc_assert(status==0); status = ccrng_generate((struct ccrng_state *)&system_ctx, nbytes, results); cc_assert(status==0); ccrng_system_done(&system_ctx); } while (--loops != 0); time=perf_time(); return time; }
static double perf_ccecb_one_shot(unsigned long loops, unsigned long size, const void *arg) { const struct ccecb_perf_test *test=arg; const struct ccmode_ecb *ecb=test->ecb; size_t keylen=test->keylen; unsigned long nblocks=size/ecb->block_size; unsigned char keyd[keylen]; unsigned char temp[nblocks*ecb->block_size]; cc_zero(keylen,keyd); perf_start(); while(loops--) { ccecb_one_shot(ecb,keylen, keyd, nblocks, temp, temp); } return perf_time(); }
static double perf_ccccm_set_iv(unsigned long loops, unsigned long size CC_UNUSED, const void *arg) { const struct ccccm_perf_test *test=arg; const struct ccmode_ccm *ccm=test->ccm; size_t keylen=test->keylen; unsigned char keyd[keylen]; unsigned char nonced[7]; cc_zero(keylen,keyd); cc_zero(sizeof(nonced),nonced); ccccm_ctx_decl(ccm->size, key); ccccm_nonce_decl(ccm->nonce_size, nonce); ccccm_init(ccm, key, keylen, keyd); perf_start(); while(loops--) ccccm_set_iv(ccm,key, nonce, sizeof(nonced), nonced,16,16,16); return perf_time(); }
static double perf_ccxts_one_shot(unsigned long loops, unsigned long size, const void *arg) { const struct ccxts_perf_test *test=arg; const struct ccmode_xts *xts=test->xts; size_t keylen=test->keylen; unsigned long nblocks=size/xts->block_size; unsigned char keyd[keylen]; unsigned char tweakkeyd[keylen]; unsigned char tweakd[xts->block_size]; unsigned char temp[nblocks*xts->block_size]; cc_zero(keylen,keyd); cc_zero(sizeof(tweakd),tweakd); perf_start(); while(loops--) { ccxts_one_shot(xts, keylen, keyd, tweakkeyd, tweakd, nblocks, temp, temp); } return perf_time(); }
static double perf_cccbc_update(unsigned long loops, unsigned long size, const void *arg) { const struct cccbc_perf_test *test=arg; const struct ccmode_cbc *cbc=test->cbc; size_t keylen=test->keylen; unsigned long nblocks=size/cbc->block_size; unsigned char keyd[keylen]; unsigned char temp[nblocks*cbc->block_size]; cc_zero(keylen,keyd); cccbc_ctx_decl(cbc->size, key); cccbc_iv_decl(cbc->block_size, iv); cccbc_init(cbc, key, keylen, keyd); cccbc_set_iv(cbc, iv, NULL); perf_start(); while(loops--) cccbc_update(cbc, key, iv, nblocks, temp, temp); return perf_time(); }