本文整理汇总了C++中core_get函数的典型用法代码示例。如果您正苦于以下问题:C++ core_get函数的具体用法?C++ core_get怎么用?C++ core_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了core_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ep2_curve_clean
void ep2_curve_clean(void) {
ctx_t *ctx = core_get();
#ifdef EP_PRECO
for (int i = 0; i < EP_TABLE; i++) {
fp2_free(ctx->ep2_pre[i].x);
fp2_free(ctx->ep2_pre[i].y);
fp2_free(ctx->ep2_pre[i].z);
}
#endif
bn_clean(&(ctx->ep2_r));
bn_clean(&(ctx->ep2_h));
}
开发者ID:enascimento,项目名称:relic-git-avr,代码行数:12,代码来源:relic_ep2_curve.c
示例2: bench_compute
void bench_compute(int benches) {
ctx_t *ctx = core_get();
#if TIMER != NONE
ctx->total = ctx->total / benches;
#ifdef OVERH
ctx->total = ctx->total - ctx->over;
#endif /* OVERH */
#else
(void)benches;
(void)ctx;
#endif /* TIMER != NONE */
}
开发者ID:ekr,项目名称:hacrypto,代码行数:12,代码来源:relic_bench.c
示例3: find_trace
/**
* Find non-zero bits for fast trace computation.
*
* @throw ERR_NO_MEMORY if there is no available memory.
* @throw ERR_NO_VALID if the polynomial is invalid.
*/
static void find_trace() {
fb_t t0, t1;
int counter;
ctx_t *ctx = core_get();
fb_null(t0);
fb_null(t1);
ctx->fb_ta = ctx->fb_tb = ctx->fb_tc = -1;
TRY {
fb_new(t0);
fb_new(t1);
counter = 0;
for (int i = 0; i < FB_BITS; i++) {
fb_zero(t0);
fb_set_bit(t0, i, 1);
fb_copy(t1, t0);
for (int j = 1; j < FB_BITS; j++) {
fb_sqr(t1, t1);
fb_add(t0, t0, t1);
}
if (!fb_is_zero(t0)) {
switch (counter) {
case 0:
ctx->fb_ta = i;
ctx->fb_tb = ctx->fb_tc = -1;
break;
case 1:
ctx->fb_tb = i;
ctx->fb_tc = -1;
break;
case 2:
ctx->fb_tc = i;
break;
default:
THROW(ERR_NO_VALID);
break;
}
counter++;
}
}
}
CATCH_ANY {
THROW(ERR_CAUGHT);
}
FINALLY {
fb_free(t0);
fb_free(t1);
}
}
开发者ID:Arash-Afshar,项目名称:relic,代码行数:58,代码来源:relic_fb_poly.c
示例4: fp_prime_clean
void fp_prime_clean() {
ctx_t *ctx = core_get();
ctx->fp_id = 0;
#if FP_RDC == QUICK || !defined(STRIP)
ctx->sps_len = 0;
memset(ctx->sps, 0, sizeof(ctx->sps));
#endif
#if FP_RDC == MONTY || !defined(STRIP)
bn_clean(&(ctx->one));
bn_clean(&(ctx->conv));
#endif
bn_clean(&(ctx->prime));
}
开发者ID:ace0,项目名称:relic,代码行数:13,代码来源:relic_fp_prime.c
示例5: core_get
const dig_t *fb_poly_tab_srz(int i) {
#if FB_SRT == QUICK || !defined(STRIP)
#ifdef FB_PRECO
return core_get()->fb_tab_srz[i];
#else
return NULL;
#endif
#else
return NULL;
#endif
}
开发者ID:Arash-Afshar,项目名称:relic,代码行数:13,代码来源:relic_fb_poly.c
示例6: ed_affine_is_valid
int ed_affine_is_valid(const fp_t x, const fp_t y) {
fp_t tmpFP0;
fp_t tmpFP1;
fp_t tmpFP2;
fp_null(tmpFP0);
fp_null(tmpFP1);
fp_null(tmpFP2);
int r = 0;
TRY {
fp_new(tmpFP0);
fp_new(tmpFP1);
fp_new(tmpFP2);
// a * X^2 + Y^2 - 1 - d * X^2 * Y^2 =?= 0
fp_sqr(tmpFP0, x);
fp_mul(tmpFP0, core_get()->ed_a, tmpFP0);
fp_sqr(tmpFP1, y);
fp_add(tmpFP1, tmpFP0, tmpFP1);
fp_sub_dig(tmpFP1, tmpFP1, 1);
fp_sqr(tmpFP0, x);
fp_mul(tmpFP0, core_get()->ed_d, tmpFP0);
fp_sqr(tmpFP2, y);
fp_mul(tmpFP2, tmpFP0, tmpFP2);
fp_sub(tmpFP0, tmpFP1, tmpFP2);
r = fp_is_zero(tmpFP0);
} CATCH_ANY {
THROW(ERR_CAUGHT);
} FINALLY {
fp_free(tmpFP0);
fp_free(tmpFP1);
fp_free(tmpFP2);
}
return r;
}
开发者ID:Arash-Afshar,项目名称:relic,代码行数:38,代码来源:relic_ed_util.c
示例7: rand_seed
void rand_seed(uint8_t *buf, int size) {
int i;
ctx_t *ctx = core_get();
if (size < MD_LEN_SHONE) {
THROW(ERR_NO_VALID);
}
/* XKEY = SEED, throws away additional bytes. */
for (i = 0; i < MD_LEN_SHONE; i++) {
ctx->rand[i] = buf[i];
}
ctx->seeded = 1;
}
开发者ID:Gesine,项目名称:relic,代码行数:14,代码来源:relic_rand_fips.c
示例8: core_get
const int *fp_prime_get_sps(int *len) {
ctx_t *ctx = core_get();
if (ctx->sps_len > 0 && ctx->sps_len < MAX_TERMS) {
if (len != NULL) {
*len = ctx->sps_len;
}
return ctx->sps;
} else {
if (len != NULL) {
*len = 0;
}
return NULL;
}
}
开发者ID:enascimento,项目名称:relic-git-avr,代码行数:14,代码来源:relic_fp_prime.c
示例9: fp_prime_set_pmers
void fp_prime_set_pmers(const int *f, int len) {
bn_t p, t;
bn_null(p);
bn_null(t);
TRY {
bn_new(p);
bn_new(t);
if (len >= MAX_TERMS) {
THROW(ERR_NO_VALID);
}
bn_set_2b(p, f[len - 1]);
for (int i = len - 2; i > 0; i--) {
if (f[i] > 0) {
bn_set_2b(t, f[i]);
bn_add(p, p, t);
} else {
bn_set_2b(t, -f[i]);
bn_sub(p, p, t);
}
}
if (f[0] > 0) {
bn_add_dig(p, p, f[0]);
} else {
bn_sub_dig(p, p, -f[0]);
}
#if FP_RDC == QUICK || !defined(STRIP)
ctx_t *ctx = core_get();
for (int i = 0; i < len; i++) {
ctx->sps[i] = f[i];
}
ctx->sps[len] = 0;
ctx->sps_len = len;
#endif /* FP_RDC == QUICK */
fp_prime_set(p);
}
CATCH_ANY {
THROW(ERR_CAUGHT);
}
FINALLY {
bn_free(p);
bn_free(t);
}
}
开发者ID:ace0,项目名称:relic,代码行数:49,代码来源:relic_fp_prime.c
示例10: find_srz
/**
* Precomputes the square root of z.
*/
static void find_srz() {
ctx_t *ctx = core_get();
fb_set_dig(ctx->fb_srz, 2);
for (int i = 1; i < FB_BITS; i++) {
fb_sqr(ctx->fb_srz, ctx->fb_srz);
}
#ifdef FB_PRECO
for (int i = 0; i <= 255; i++) {
fb_mul_dig(ctx->fb_tab_srz[i], ctx->fb_srz, i);
}
#endif
}
开发者ID:Arash-Afshar,项目名称:relic,代码行数:18,代码来源:relic_fb_poly.c
示例11: ep2_curve_set
void ep2_curve_set(fp2_t a, fp2_t b, ep2_t g, bn_t r, bn_t h) {
ctx_t *ctx = core_get();
ctx->ep2_is_twist = 0;
fp2_copy(ctx->ep2_a, a);
fp2_copy(ctx->ep2_b, b);
ep2_norm(&(ctx->ep2_g), g);
bn_copy(&(ctx->ep2_r), r);
bn_copy(&(ctx->ep2_h), h);
#if defined(EP_PRECO)
ep2_mul_pre((ep2_t *)ep2_curve_get_tab(), &(ctx->ep2_g));
#endif
}
开发者ID:enascimento,项目名称:relic-git-avr,代码行数:15,代码来源:relic_ep2_curve.c
示例12: fb_poly_set
/**
* Configures the irreducible polynomial of the binary field.
*
* @param[in] f - the new irreducible polynomial.
*/
static void fb_poly_set(const fb_t f) {
fb_copy(core_get()->fb_poly, f);
#if FB_TRC == QUICK || !defined(STRIP)
find_trace();
#endif
#if FB_SLV == QUICK || !defined(STRIP)
find_solve();
#endif
#if FB_SRT == QUICK || !defined(STRIP)
find_srz();
#endif
#if FB_INV == ITOHT || !defined(STRIP)
find_chain();
#endif
}
开发者ID:Arash-Afshar,项目名称:relic,代码行数:20,代码来源:relic_fb_poly.c
示例13: bench_print
void bench_print(void) {
ctx_t *ctx = core_get();
#if TIMER == POSIX || TIMER == ANSI || (OPSYS == DUINO && TIMER == HREAL)
util_print("%lld microsec", ctx->total);
#elif TIMER == CYCLE
util_print("%lld cycles", ctx->total);
#else
util_print("%lld nanosec", ctx->total);
#endif
if (ctx->total < 0) {
util_print(" (overflow or bad overhead estimation)\n");
} else {
util_print("\n");
}
}
开发者ID:relic-toolkit,项目名称:relic,代码行数:16,代码来源:relic_bench.c
示例14: bench_overhead
void bench_overhead(void) {
ctx_t *ctx = core_get();
int a[BENCH + 1];
int *tmpa;
do {
ctx->over = 0;
for (int l = 0; l < BENCH; l++) {
ctx->total = 0;
/* Measure the cost of (n^2 + over). */
bench_before();
for (int i = 0; i < BENCH; i++) {
tmpa = a;
for (int j = 0; j < BENCH; j++) {
empty(tmpa++);
}
}
bench_after();
/* Add the cost of (n^2 + over). */
ctx->over += ctx->total;
}
/* Overhead stores the cost of n*(n^2 + over) = n^3 + n*over. */
ctx->total = 0;
/* Measure the cost of (n^3 + over). */
bench_before();
for (int i = 0; i < BENCH; i++) {
for (int k = 0; k < BENCH; k++) {
tmpa = a;
for (int j = 0; j < BENCH; j++) {
empty(tmpa++);
}
}
}
bench_after();
/* Subtract the cost of (n^3 + over). */
ctx->over -= ctx->total;
/* Now overhead stores (n - 1)*over, so take the average to obtain the
* overhead to execute BENCH operations inside a benchmark. */
ctx->over /= (BENCH - 1);
/* Divide to obtain the overhead of one operation pair. */
ctx->over /= BENCH;
} while (ctx->over < 0);
ctx->total = ctx->over;
bench_print();
}
开发者ID:relic-toolkit,项目名称:relic,代码行数:45,代码来源:relic_bench.c
示例15: core_get
const int *fp_prime_get_sps(int *len) {
#if FP_RDC == QUICK || !defined(STRIP)
ctx_t *ctx = core_get();
if (ctx->sps_len > 0 && ctx->sps_len < MAX_TERMS) {
if (len != NULL) {
*len = ctx->sps_len;
}
return ctx->sps;
} else {
if (len != NULL) {
*len = 0;
}
return NULL;
}
#else
return NULL;
#endif
}
开发者ID:ace0,项目名称:relic,代码行数:18,代码来源:relic_fp_prime.c
示例16: rand_gen
/**
* Generates pseudo-random bytes by iterating the hash function.
*
* @param[out] out - the buffer to write.
* @param[in] out_len - the number of bytes to write.
*/
static void rand_gen(uint8_t *out, int out_len) {
int m = CEIL(out_len, MD_LEN);
uint8_t hash[MD_LEN], data[(RAND_SIZE - 1)/2];
ctx_t *ctx = core_get();
/* data = V */
memcpy(data, ctx->rand + 1, (RAND_SIZE - 1)/2);
for (int i = 0; i < m; i++) {
/* w_i = Hash(data) */
md_map(hash, data, sizeof(data));
/* W = W || w_i */
memcpy(out, hash, MIN(MD_LEN, out_len));
out += MD_LEN;
out_len -= MD_LEN;
/* data = data + 1 mod 2^b. */
rand_inc(data, (RAND_SIZE - 1)/2, 1);
}
}
开发者ID:Arash-Afshar,项目名称:relic,代码行数:24,代码来源:relic_rand_hash.c
示例17: eb_param_print
void eb_param_print() {
switch (core_get()->eb_id) {
case NIST_B163:
util_banner("Curve NIST-B163:", 0);
break;
case NIST_K163:
util_banner("Curve NIST-K163:", 0);
break;
case NIST_B233:
util_banner("Curve NIST-B233:", 0);
break;
case NIST_K233:
util_banner("Curve NIST-K233:", 0);
break;
case SECG_K239:
util_banner("Curve SECG-K239:", 0);
break;
case EBACS_B251:
util_banner("Curve EBACS-B251:", 0);
break;
case HALVE_B257:
util_banner("Curve HALVE-B257:", 0);
break;
case NIST_B283:
util_banner("Curve NIST-B283:", 0);
break;
case NIST_K283:
util_banner("Curve NIST-K283:", 0);
break;
case NIST_B409:
util_banner("Curve NIST-B409:", 0);
break;
case NIST_K409:
util_banner("Curve NIST-K409:", 0);
break;
case NIST_B571:
util_banner("Curve NIST-B571:", 0);
break;
case NIST_K571:
util_banner("Curve NIST-K571:", 0);
break;
}
}
开发者ID:Gesine,项目名称:relic,代码行数:43,代码来源:relic_eb_param.c
示例18: eb_curve_clean
void eb_curve_clean(void) {
ctx_t *ctx = core_get();
#if ALLOC == STATIC
fb_free(ctx->eb_g.x);
fb_free(ctx->eb_g.y);
fb_free(ctx->eb_g.z);
for (int i = 0; i < EB_TABLE; i++) {
fb_free(ctx->eb_pre[i].x);
fb_free(ctx->eb_pre[i].y);
fb_free(ctx->eb_pre[i].z);
}
#endif
bn_clean(&(ctx->eb_r));
bn_clean(&(ctx->eb_h));
#if defined(EB_KBLTZ) && (EB_MUL == LWNAF || !defined(STRIP))
bn_clean(&(ctx->eb_vm));
bn_clean(&(ctx->eb_s0));
bn_clean(&(ctx->eb_s1));
#endif
}
开发者ID:ekr,项目名称:hacrypto,代码行数:20,代码来源:relic_eb_curve.c
示例19: ep_curve_set_super
void ep_curve_set_super(const fp_t a, const fp_t b, const ep_t g, const bn_t r,
const bn_t h) {
ctx_t *ctx = core_get();
ctx->ep_is_endom = 0;
ctx->ep_is_super = 1;
fp_copy(ctx->ep_a, a);
fp_copy(ctx->ep_b, b);
detect_opt(&(ctx->ep_opt_a), ctx->ep_a);
detect_opt(&(ctx->ep_opt_b), ctx->ep_b);
ep_norm(&(ctx->ep_g), g);
bn_copy(&(ctx->ep_r), r);
bn_copy(&(ctx->ep_h), h);
#if defined(EP_PRECO)
ep_mul_pre((ep_t *)ep_curve_get_tab(), &(ctx->ep_g));
#endif
}
开发者ID:cryptobiu,项目名称:libscapi,代码行数:20,代码来源:relic_ep_curve.c
示例20: rand_clean
void rand_clean() {
#if RAND == UDEV
int *fd = (int *)&(core_get()->rand);
close(*fd);
#endif
#if RAND != CALL
memset(core_get()->rand, 0, sizeof(core_get()->rand));
#else
core_get()->rand_call = NULL;
core_get()->rand_args = NULL;
#endif
core_get()->seeded = 0;
}
开发者ID:enascimento,项目名称:relic-git-avr,代码行数:15,代码来源:relic_rand_core.c
注:本文中的core_get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论