}
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
fail ("extended selftest for %s (%d) failed: %s",
gcry_md_algo_name (algo), algo, gpg_strerror (err));
else if (err && verbose)
- show ("extended selftest for %s (%d) not implemented",
+ info ("extended selftest for %s (%d) not implemented",
gcry_md_algo_name (algo), algo);
else if (verbose)
- show ("extended selftest for %s (%d) passed",
+ info ("extended selftest for %s (%d) passed",
gcry_md_algo_name (algo), algo);
}
}
if (!testvectors[idx].algo)
{
- show ("%d GiB %+3d %-10s warning: %s",
+ info ("%d GiB %+3d %-10s warning: %s",
gigs, bytes, gcry_md_algo_name (algo), "no test vector");
missing_test_vectors++;
return 1;
fail ("Some test vectors are missing");
if (verbose)
- show ("All tests completed in %s. Errors: %d\n",
+ info ("All tests completed in %s. Errors: %d\n",
elapsed_time (1), error_count);
return !!error_count;
}
}
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
int rc;
if (verbose)
- show ("creating 2048 bit RSA key\n");
+ info ("creating 2048 bit RSA key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (rsa\n"
die ("error generating RSA key: %s\n", gpg_strerror (rc));
if (verbose)
- show ("creating 1024 bit RSA key\n");
+ info ("creating 1024 bit RSA key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (rsa\n"
gcry_sexp_release (key);
if (verbose)
- show ("creating 2048 bit RSA key with e=65539\n");
+ info ("creating 2048 bit RSA key with e=65539\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (rsa\n"
if (verbose)
- show ("creating 512 bit RSA key with e=257\n");
+ info ("creating 512 bit RSA key with e=257\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (rsa\n"
fail ("generating 512 bit RSA key must not work!");
if (verbose && rc && in_fips_mode)
- show ("... correctly rejected key creation in FIPS mode (%s)\n",
+ info ("... correctly rejected key creation in FIPS mode (%s)\n",
gpg_strerror (rc));
if (!rc)
gcry_sexp_release (key);
if (verbose)
- show ("creating 512 bit RSA key with default e\n");
+ info ("creating 512 bit RSA key with default e\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (rsa\n"
fail ("generating 512 bit RSA key must not work!");
if (verbose && rc && in_fips_mode)
- show ("... correctly rejected key creation in FIPS mode (%s)\n",
+ info ("... correctly rejected key creation in FIPS mode (%s)\n",
gpg_strerror (rc));
int rc;
if (verbose)
- show ("creating 1024 bit Elgamal key\n");
+ info ("creating 1024 bit Elgamal key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (elg\n"
/* Check that DSA generation works and that it can grok the qbits
argument. */
if (verbose)
- show ("creating 5 1024 bit DSA keys\n");
+ info ("creating 5 1024 bit DSA keys\n");
for (i=0; i < 5; i++)
{
rc = gcry_sexp_new (&keyparm,
}
if (verbose)
- show ("creating 1536 bit DSA key\n");
+ info ("creating 1536 bit DSA key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (dsa\n"
gcry_sexp_release (key);
if (verbose)
- show ("creating 3072 bit DSA key\n");
+ info ("creating 3072 bit DSA key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (dsa\n"
gcry_sexp_release (key);
if (verbose)
- show ("creating 2048/256 bit DSA key\n");
+ info ("creating 2048/256 bit DSA key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (dsa\n"
gcry_sexp_release (key);
if (verbose)
- show ("creating 2048/224 bit DSA key\n");
+ info ("creating 2048/224 bit DSA key\n");
rc = gcry_sexp_new (&keyparm,
"(genkey\n"
" (dsa\n"
for (testno=0; curves[testno]; testno++)
{
if (verbose)
- show ("creating ECC key using curve %s\n", curves[testno]);
+ info ("creating ECC key using curve %s\n", curves[testno]);
if (!strcmp (curves[testno], "Ed25519"))
{
/* Ed25519 isn't allowed in fips mode */
}
if (verbose)
- show ("creating ECC key using curve Ed25519 for ECDSA\n");
+ info ("creating ECC key using curve Ed25519 for ECDSA\n");
rc = gcry_sexp_build (&keyparm, NULL, "(genkey(ecc(curve Ed25519)))");
if (rc)
die ("error creating S-expression: %s\n", gpg_strerror (rc));
fail ("generating Ed25519 key must not work!");
if (verbose && rc && in_fips_mode)
- show ("... correctly rejected key creation in FIPS mode (%s)\n",
+ info ("... correctly rejected key creation in FIPS mode (%s)\n",
gpg_strerror (rc));
if (!rc)
gcry_sexp_release (key);
if (verbose)
- show ("creating ECC key using curve Ed25519 for ECDSA (nocomp)\n");
+ info ("creating ECC key using curve Ed25519 for ECDSA (nocomp)\n");
rc = gcry_sexp_build (&keyparm, NULL,
"(genkey(ecc(curve Ed25519)(flags nocomp)))");
if (rc)
fail ("generating Ed25519 key must not work in FIPS mode!");
if (verbose && rc && in_fips_mode)
- show ("... correctly rejected key creation in FIPS mode (%s)\n",
+ info ("... correctly rejected key creation in FIPS mode (%s)\n",
gpg_strerror (rc));
gcry_sexp_release (key);
if (verbose)
- show ("creating ECC key using curve NIST P-384 for ECDSA\n");
+ info ("creating ECC key using curve NIST P-384 for ECDSA\n");
/* Must be specified as nistp384 (one word), because ecc_generate
* uses _gcry_sexp_nth_string which takes the first word of the name
gcry_sexp_release (key);
if (verbose)
- show ("creating ECC key using curve NIST P-384 for ECDSA (nocomp)\n");
+ info ("creating ECC key using curve NIST P-384 for ECDSA (nocomp)\n");
rc = gcry_sexp_build (&keyparm, NULL,
"(genkey(ecc(curve nistp384)(flags nocomp)))");
if (rc)
if (verbose)
- show ("creating ECC key using curve Ed25519 for ECDSA (transient-key)\n");
+ info ("creating ECC key using curve Ed25519 for ECDSA (transient-key)\n");
rc = gcry_sexp_build (&keyparm, NULL,
"(genkey(ecc(curve Ed25519)(flags transient-key)))");
if (rc)
fail ("generating Ed25519 key must not work in FIPS mode!");
if (verbose && rc && in_fips_mode)
- show ("... correctly rejected key creation in FIPS mode (%s)\n",
+ info ("... correctly rejected key creation in FIPS mode (%s)\n",
gpg_strerror (rc));
if (!rc)
gcry_sexp_release (key);
if (verbose)
- show ("creating ECC key using curve Ed25519 for ECDSA "
+ info ("creating ECC key using curve Ed25519 for ECDSA "
"(transient-key no-keytest)\n");
rc = gcry_sexp_build (&keyparm, NULL,
"(genkey(ecc(curve Ed25519)"
fail ("generating Ed25519 key must not work in FIPS mode!");
if (verbose && rc && in_fips_mode)
- show ("... correctly rejected key creation in FIPS mode (%s)\n",
+ info ("... correctly rejected key creation in FIPS mode (%s)\n",
gpg_strerror (rc));
if (!rc)
int oops=0;
if (verbose)
- show ("checking gcry_create_nonce\n");
+ info ("checking gcry_create_nonce\n");
gcry_create_nonce (a, sizeof a);
for (i=0; i < 10; i++)
/* If we have a decent libgpg-error we can use some gcc attributes. */
#ifdef GPGRT_ATTR_NORETURN
static void die (const char *format, ...) GPGRT_ATTR_NR_PRINTF(1,2);
-static void inf (const char *format, ...) GPGRT_ATTR_PRINTF(1,2);
+static void info (const char *format, ...) GPGRT_ATTR_PRINTF(1,2);
#endif /*GPGRT_ATTR_NORETURN*/
static void
-inf (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
{
const unsigned char *p = buf;
- inf ("%s", text);
+ info ("%s", text);
for (; n; n--, p++)
fprintf (stderr, "%02X", *p);
putc ('\n', stderr);
{
(void)cb_data;
- inf ("progress (%s %c %d %d)\n", what, printchar, current, total);
+ info ("progress (%s %c %d %d)\n", what, printchar, current, total);
fflush (stderr);
}
{
#ifdef HAVE_W32_SYSTEM
if (verbose)
- inf ("check_forking skipped: not applicable on Windows\n");
+ info ("check_forking skipped: not applicable on Windows\n");
#else /*!HAVE_W32_SYSTEM*/
pid_t pid;
int rp[2];
char tmp1[16], tmp1c[16], tmp1p[16];
if (verbose)
- inf ("checking that a fork won't cause the same random output\n");
+ info ("checking that a fork won't cause the same random output\n");
/* We better make sure that the RNG has been initialzied. */
gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM);
{
#ifdef HAVE_W32_SYSTEM
if (verbose)
- inf ("check_nonce_forking skipped: not applicable on Windows\n");
+ info ("check_nonce_forking skipped: not applicable on Windows\n");
#else /*!HAVE_W32_SYSTEM*/
pid_t pid;
int rp[2];
char nonce1[10], nonce1c[10], nonce1p[10];
if (verbose)
- inf ("checking that a fork won't cause the same nonce output\n");
+ info ("checking that a fork won't cause the same nonce output\n");
/* We won't get the same nonce back if we never initialized the
nonce subsystem, thus we get one nonce here and forget about
{
#ifdef HAVE_W32_SYSTEM
if (verbose)
- inf ("check_close_random_device skipped: not applicable on Windows\n");
+ info ("check_close_random_device skipped: not applicable on Windows\n");
#else /*!HAVE_W32_SYSTEM*/
pid_t pid;
int i, status;
char buf[4];
if (verbose)
- inf ("checking that close_random_device works\n");
+ info ("checking that close_random_device works\n");
gcry_randomize (buf, sizeof buf, GCRY_STRONG_RANDOM);
if (verbose)
char tmp1[4];
if (verbose)
- inf ("checking whether RNG type switching works\n");
+ info ("checking whether RNG type switching works\n");
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
initial = rngtype;
gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM);
if (debug)
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
if (rngtype != initial)
die ("switching to System RNG unexpectedly succeeded\n");
gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM);
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
if (rngtype != initial)
die ("switching to FIPS RNG unexpectedly succeeded\n");
gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM);
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
if (rngtype != GCRY_RNG_TYPE_STANDARD)
die ("switching to standard RNG failed\n");
gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM);
int rngtype, initial;
if (verbose)
- inf ("checking whether RNG type switching works in the early stage\n");
+ info ("checking whether RNG type switching works in the early stage\n");
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
initial = rngtype;
gcry_control (GCRYCTL_SET_PREFERRED_RNG_TYPE, GCRY_RNG_TYPE_SYSTEM);
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
if (initial >= GCRY_RNG_TYPE_SYSTEM && rngtype != GCRY_RNG_TYPE_SYSTEM)
die ("switching to System RNG failed\n");
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
if (initial >= GCRY_RNG_TYPE_FIPS && rngtype != GCRY_RNG_TYPE_FIPS)
die ("switching to FIPS RNG failed\n");
rngtype = rng_type ();
if (debug)
- inf ("rng type: %d\n", rngtype);
+ info ("rng type: %d\n", rngtype);
if (rngtype != GCRY_RNG_TYPE_STANDARD)
die ("switching to standard RNG failed\n");
}
gcry_buffer_t pers[1];
if (verbose)
- inf ("checking DRBG_REINIT\n");
+ info ("checking DRBG_REINIT\n");
memset (pers, 0, sizeof pers);
pers[0].data = pers_string;
for (idx=0; options[idx]; idx++)
{
if (verbose)
- inf ("now running with options '%s'\n", options[idx]);
+ info ("now running with options '%s'\n", options[idx]);
strcpy (cmdline, program);
strcat (cmdline, " --in-recursion");
if (verbose)
#define pass() do { ; } while (0)
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
int i;
if (debug)
- show ("negative zero printing\n");
+ info ("negative zero printing\n");
a = gcry_mpi_new (0);
for (i=0; fmts[i].name; i++)
for (idx=0; idx < DIM(data); idx++)
{
if (debug)
- show ("print test %d\n", data[idx].value);
+ info ("print test %d\n", data[idx].value);
if (data[idx].value < 0)
{
{
fail ("error printing value %d as %s: %s\n",
data[idx].value, "HEX", "wrong result");
- show ("expected: '%s'\n", data[idx].a.hex);
- show (" got: '%s'\n", buf);
+ info ("expected: '%s'\n", data[idx].a.hex);
+ info (" got: '%s'\n", buf);
}
gcry_free (buf);
}
for (idx=0; idx < DIM(data); idx++)
{
if (debug)
- show ("scan test %d\n", data[idx].value);
+ info ("scan test %d\n", data[idx].value);
if (data[idx].value < 0)
{
negative_zero ();
check_formats ();
- show ("All tests completed. Errors: %d\n", error_count);
+ info ("All tests completed. Errors: %d\n", error_count);
return error_count ? 1 : 0;
}
}
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
size_t res_len;
if (verbose > 1)
- show ("Running test %d\n", testno);
+ info ("Running test %d\n", testno);
if (!(buffer = hex2buffer (k_str, &buflen)) || buflen != 32)
{
{
fail ("gcry_pk_encrypt failed for test %d: %s",
testno, "wrong value returned");
- show (" expected: '%s'", result_str);
- show (" got: '%s'", r0);
+ info (" expected: '%s'", result_str);
+ info (" got: '%s'", r0);
}
xfree (r0);
}
gcry_mpi_t mpi_kk = NULL;
if (verbose > 1)
- show ("Running test %d: iteration=%d\n", testno, iter);
+ info ("Running test %d: iteration=%d\n", testno, iter);
gcry_mpi_ec_new (&ctx, NULL, "Curve25519");
Q = gcry_mpi_point_new (0);
{
fail ("curv25519 failed for test %d: %s",
testno, "wrong value returned");
- show (" expected: '%s'", result_str);
- show (" got: '%s'", r0);
+ info (" expected: '%s'", result_str);
+ info (" got: '%s'", r0);
}
xfree (r0);
}
{
int ntests;
- show ("Checking Curve25519.\n");
+ info ("Checking Curve25519.\n");
ntests = 0;
check_cv25519 ();
stop_timer ();
- show ("All tests completed in %s. Errors: %d\n",
+ info ("All tests completed in %s. Errors: %d\n",
elapsed_time (1), error_count);
return !!error_count;
}
}
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
}
while (!*line || *line == '#');
/* if (debug) */
- /* show ("read line: '%s'\n", line); */
+ /* info ("read line: '%s'\n", line); */
return xstrdup (line);
}
size_t sig_r_len, sig_s_len;
if (verbose > 1)
- show ("Running test %d\n", testno);
+ info ("Running test %d\n", testno);
if (!(buffer = hex2buffer (sk, &buflen)))
{
{
fail ("gcry_pk_sign failed for test %d: %s",
testno, "wrong value returned");
- show (" expected: '%s'", sig);
- show (" got: '%s'", sig_rs_string);
+ info (" expected: '%s'", sig);
+ info (" got: '%s'", sig_rs_string);
}
}
int testno;
char *sk, *pk, *msg, *sig;
- show ("Checking Ed25519.\n");
+ info ("Checking Ed25519.\n");
fp = fopen (fname, "r");
if (!fp)
xfree (fname);
- show ("All tests completed in %s. Errors: %d\n",
+ info ("All tests completed in %s. Errors: %d\n",
elapsed_time (1), error_count);
return !!error_count;
}
#define pass() do { ; } while (0)
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
int i;
wherestr = "one_bit_only";
- show ("checking that set_%sbit does only set one bit\n", highbit?"high":"");
+ info ("checking that set_%sbit does only set one bit\n", highbit?"high":"");
a = gcry_mpi_new (0);
gcry_mpi_randomize (a, 70, GCRY_WEAK_RANDOM);
int i;
wherestr = "test_rshift";
- show ("checking that rshift works as expected (pass %d)\n", pass);
+ info ("checking that rshift works as expected (pass %d)\n", pass);
a = gcry_mpi_new (0);
b = gcry_mpi_new (0);
rshiftbitstring (result2, i);
if (strcmp (result, result2))
{
- show ("got =%s\n", result);
- show ("want=%s\n", result2);
+ info ("got =%s\n", result);
+ info ("want=%s\n", result2);
fail ("rshift by %d failed\n", i);
}
xfree (result);
rshiftbitstring (result2, i);
if (strcmp (result, result2))
{
- show ("got =%s\n", result);
- show ("want=%s\n", result2);
+ info ("got =%s\n", result);
+ info ("want=%s\n", result2);
fail ("in-place rshift by %d failed\n", i);
}
xfree (result2);
int i;
wherestr = "test_lshift";
- show ("checking that lshift works as expected (pass %d)\n", pass);
+ info ("checking that lshift works as expected (pass %d)\n", pass);
for (size_idx=0; size_list[size_idx]; size_idx++)
{
xfree (tmpstr);
if (strcmp (result, result2))
{
- show ("got =%s\n", result);
- show ("want=%s\n", result2);
+ info ("got =%s\n", result);
+ info ("want=%s\n", result2);
fail ("lshift by %d failed\n", i);
}
xfree (result);
xfree (tmpstr);
if (strcmp (result, result2))
{
- show ("got =%s\n", result);
- show ("want=%s\n", result2);
+ info ("got =%s\n", result);
+ info ("want=%s\n", result2);
fail ("in-place lshift by %d failed\n", i);
}
xfree (result2);
int i;
wherestr = "set_bit_with_resize";
- show ("checking that set_bit initializes all limbs\n");
+ info ("checking that set_bit initializes all limbs\n");
a = gcry_mpi_new (1536);
gcry_mpi_set_bit (a, 1536);
gcry_mpi_release (a);
wherestr = "set_highbit_with_resize";
- show ("checking that set_highbit initializes all limbs\n");
+ info ("checking that set_highbit initializes all limbs\n");
a = gcry_mpi_new (1536);
gcry_mpi_set_highbit (a, 1536);
set_bit_with_resize ();
- show ("All tests completed. Errors: %d\n", error_count);
+ info ("All tests completed. Errors: %d\n", error_count);
return error_count ? 1 : 0;
}
static void
-show (const char *format, ...)
+info (const char *format, ...)
{
va_list arg_ptr;
gcry_mpi_t x, y, z;
wherestr = "set_get_point";
- show ("checking point setting functions\n");
+ info ("checking point setting functions\n");
point = gcry_mpi_point_new (0);
x = gcry_mpi_set_ui (NULL, 17);
gcry_mpi_t p, a;
wherestr = "context_alloc";
- show ("checking context functions\n");
+ info ("checking context functions\n");
p = gcry_mpi_set_ui (NULL, 1);
a = gcry_mpi_set_ui (NULL, 1);
wherestr = "context_param";
- show ("checking standard curves\n");
+ info ("checking standard curves\n");
for (idx=0; test_curve[idx].desc; idx++)
{
/* P-192 and Ed25519 are not supported in fips mode */
if (!strcmp(test_curve[idx].desc, "NIST P-192")
|| !strcmp(test_curve[idx].desc, "Ed25519"))
{
- show("skipping %s in fips mode\n", test_curve[idx].desc );
+ info ("skipping %s in fips mode\n", test_curve[idx].desc );
continue;
}
}
}
- show ("checking sample public key (nistp256)\n");
+ info ("checking sample public key (nistp256)\n");
q = hex2mpi (sample_p256_q);
err = gcry_sexp_build (&keyparam, NULL,
"(public-key(ecc(curve %s)(q %m)))",
if (gcry_fips_mode_active())
goto cleanup;
- show ("checking sample public key (Ed25519)\n");
+ info ("checking sample public key (Ed25519)\n");
q = hex2mpi (sample_ed25519_q);
gcry_sexp_release (keyparam);
err = gcry_sexp_build (&keyparam, NULL,
gcry_mpi_t x, y, z;
wherestr = "basic_ec_math";
- show ("checking basic math functions for EC\n");
+ info ("checking basic math functions for EC\n");
P = hex2mpi ("0xfffffffffffffffffffffffffffffffeffffffffffffffff");
A = hex2mpi ("0xfffffffffffffffffffffffffffffffefffffffffffffffc");
gcry_sexp_t sexp;
wherestr = "basic_ec_math_simplified";
- show ("checking basic math functions for EC (variant)\n");
+ info ("checking basic math functions for EC (variant)\n");
d = hex2mpi ("D4EF27E32F8AD8E2A1C6DDEBB1D235A69E3CEF9BCE90273D");
Q = gcry_mpi_point_new (0);
gcry_mpi_t w, a, x, y, z, p, n, b, I;
wherestr = "twistededwards_math";
- show ("checking basic Twisted Edwards math\n");
+ info ("checking basic Twisted Edwards math\n");
err = gcry_mpi_ec_new (&ctx, NULL, "Ed25519");
if (err)
twistededwards_math ();
}
- show ("All tests completed. Errors: %d\n", error_count);
+ info ("All tests completed. Errors: %d\n", error_count);
return error_count ? 1 : 0;
}