void test_pass(void) { #ifdef COLOR util_print("[%c[%d;%dm", CMD_SET, CMD_ATTR, PASS_COLOR); util_print("PASS"); util_print("%c[%dm]\n", CMD_SET, CMD_RESET); #else util_print("[PASS]\n"); #endif }
void test_fail(void) { #ifdef COLOR util_print("[%c[%d;%dm", CMD_SET, CMD_ATTR, FAIL_COLOR); util_print("FAIL"); util_print("%c[%dm]\n", CMD_SET, CMD_RESET); #else util_print("[FAIL]\n"); #endif }
void dv_print(dv_t a, int digits) { int i; /* Suppress possible unused parameter warning. */ (void) a; for (i = digits - 1; i >= 0; i--) { util_print("%.*lX", (int)(2 * sizeof(dig_t)), (unsigned long int)a[i]); } util_print("\n"); return; }
void fb_param_print(void) { int fa, fb, fc; fb_poly_get_rdc(&fa, &fb, &fc); if (fb == 0) { util_banner("Irreducible trinomial:", 0); util_print(" z^%d + z^%d + 1\n", FB_BITS, fa); } else { util_banner("Irreducible pentanomial:", 0); util_print(" z^%d + z^%d + z^%d + z^%d + 1\n", FB_BITS, fa, fb, fc); } }
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"); } }
void dv_print(dig_t *a, int digits) { int i; /* Suppress possible unused parameter warning. */ (void)a; for (i = digits - 1; i >= 0; i--) { #if WORD == 64 util_print("%.*" PRIX64, (int)(2 * (DIGIT / 8)), (uint64_t)a[i]); #else util_print("%.*" PRIX32, (int)(2 * (DIGIT / 8)), (uint32_t)a[i]); #endif } util_print("\n"); return; }
void fp_param_print(void) { util_banner("Prime modulus:", 0); util_print(" "); #if ALLOC == AUTO fp_print(fp_prime_get()); #else fp_print((const fp_t)fp_prime_get()); #endif }
void dv_print(dig_t *a, int digits) { int i; /* Suppress possible unused parameter warning. */ (void)a; for (i = digits - 1; i >= 0; i--) { util_print_dig(a[i], 1); } util_print("\n"); return; }
void bn_print(const bn_t a) { int i; if (a->sign == BN_NEG) { util_print("-"); } if (a->used == 0) { util_print("0\n"); } else { #if WORD == 64 util_print_dig(a->dp[a->used - 1], 0); for (i = a->used - 2; i >= 0; i--) { util_print_dig(a->dp[i], 1); } #else util_print_dig(a->dp[a->used - 1], 0); for (i = a->used - 2; i >= 0; i--) { util_print_dig(a->dp[i], 1); } #endif util_print("\n"); } }
void fp_print(const fp_t a) { int i; bn_t t; bn_null(t); TRY { bn_new(t); #if FP_RDC == MONTY if (a != fp_prime_get()) { fp_prime_back(t, a); } else { bn_read_raw(t, a, RLC_FP_DIGS); } #else bn_read_raw(t, a, RLC_FP_DIGS); #endif for (i = RLC_FP_DIGS - 1; i > 0; i--) { if (i >= t->used) { util_print_dig(0, 1); } else { util_print_dig(t->dp[i], 1); } util_print(" "); } util_print_dig(t->dp[0], 1); util_print("\n"); } CATCH_ANY { THROW(ERR_CAUGHT); } FINALLY { bn_free(t); } }
void conf_print(void) { #ifndef QUIET util_print("-- RELIC " VERSION " configuration:\n\n"); #if ALLOC == STATIC util_print("** Allocation mode: STATIC\n\n"); #elif ALLOC == DYNAMIC util_print("** Allocation mode: DYNAMIC\n\n"); #elif ALLOC == STACK util_print("** Allocation mode: STACK\n\n"); #elif ALLOC == AUTO util_print("** Allocation mode: AUTO\n\n"); #endif #if ARITH == EASY util_print("** Arithmetic backend: easy\n\n"); #elif ARITH == GMP util_print("** Arithmetic backend: gmp\n\n"); #else util_print("** Arithmetic backend: " QUOTE(ARITH) "\n\n"); #endif #ifdef LABEL util_print("** Configured label: " QUOTE(LABEL) "\n\n"); #endif #if BENCH > 1 util_print("** Benchmarking options:\n"); util_print(" Number of times: %d\n", BENCH * BENCH); #ifdef OVERH util_print(" Estimated overhead: "); bench_overhead(); #endif util_print("\n"); #endif #ifdef WITH_BN util_print("** Multiple precision module options:\n"); util_print(" Precision: %d bits, %d words\n", BN_BITS, BN_DIGS); util_print(" Arithmetic method: " BN_METHD "\n\n"); #endif #ifdef WITH_FP util_print("** Prime field module options:\n"); util_print(" Prime size: %d bits, %d words\n", FP_BITS, FP_DIGS); util_print(" Arithmetic method: " FP_METHD "\n\n"); #endif #ifdef WITH_FPX util_print("** Prime field extension module options:\n"); util_print(" Arithmetic method: " FPX_METHD "\n\n"); #endif #ifdef WITH_EP util_print("** Prime elliptic curve module options:\n"); util_print(" Arithmetic method: " EP_METHD "\n\n"); #endif #ifdef WITH_PP util_print("** Bilinear pairing module options:\n"); util_print(" Arithmetic method: " PP_METHD "\n\n"); #endif #ifdef WITH_FB util_print("** Binary field module options:\n"); util_print(" Polynomial size: %d bits, %d words\n", FB_BITS, FB_DIGS); util_print(" Arithmetic method: " FB_METHD "\n\n"); #endif #ifdef WITH_EB util_print("** Binary elliptic curve module options:\n"); util_print(" Arithmetic method: " EB_METHD "\n\n"); #endif #ifdef WITH_EC util_print("** Elliptic Curve Cryptography module options:\n"); util_print(" Arithmetic method: " EC_METHD "\n\n"); #endif #ifdef WITH_ED util_print("** Edwards Curve Cryptography module options:\n"); util_print(" Arithmetic method: " ED_METHD "\n\n"); #endif #ifdef WITH_MD util_print("** Hash function module options:\n"); util_print(" Chosen method: " MD_METHD "\n\n"); #endif #endif }