#define cDBLUE "\033[0;34m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED "Test FAILED\n" cNORM); \
+ printf(cRED "Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN "Test passed\n" cNORM);}
+ printf(cGREEN "Test passed" cNORM "\n");}
/* Pragma to allow commenting out some tests. */
#pragma GCC diagnostic ignored "-Wunused-const-variable"
const EVP_CIPHER *type = EVP_get_cipherbynid(t->nid);
const char *name = EVP_CIPHER_name(type);
- printf(cBLUE "# Tests for %s [%s]\n" cNORM, name, standard);
+ printf(cBLUE "# Tests for %s [%s]" cNORM "\n", name, standard);
for (inplace = 0; inplace <= 1; inplace++)
ret |= test_block(type, name, t->block,
t->plaintext, t->key, t->expected, t->size,
if (t->nid == nids[k])
break;
if (!t->nid)
- printf(cMAGENT "Cipher %s is untested!\n" cNORM, OBJ_nid2sn(nids[k]));
+ printf(cMAGENT "Cipher %s is untested!" cNORM "\n", OBJ_nid2sn(nids[k]));
}
ENGINE_finish(eng);
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}
#define cDBLUE "\033[0;34m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM);}
+ printf(cGREEN " Test passed" cNORM "\n");}
static void hexdump(const void *ptr, size_t len)
{
const EVP_CIPHER *type = EVP_get_cipherbynid(nid);
const char *name = EVP_CIPHER_name(type);
- printf(cBLUE "%s test for %s (nid %d)\n" cNORM,
+ printf(cBLUE "%s test for %s (nid %d)" cNORM "\n",
enc ? "Encryption" : "Decryption", name, nid);
/* produce base encryption */
const EVP_MD *type = EVP_get_digestbynid(nid);
const char *name = EVP_MD_name(type);
- printf(cBLUE "Digest test for %s (nid %d)\n" cNORM, name, nid);
+ printf(cBLUE "Digest test for %s (nid %d)" cNORM "\n", name, nid);
/* produce base digest */
EVP_MD_CTX *ctx, *save;
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}
#define TEST_ASSERT(e) { \
test = e; \
if (test) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM); \
+ printf(cGREEN " Test passed" cNORM "\n"); \
}
struct test_curve {
printf("\n");
if (!OBJ_nid2obj(nid)) {
- printf(cRED "NID %d not found\n" cNORM, nid);
+ printf(cRED "NID %d not found" cNORM "\n", nid);
return 1;
}
EC_KEY *ec;
T(ec = EC_KEY_new());
if (!fill_GOST_EC_params(ec, nid)) {
- printf(cRED "fill_GOST_EC_params FAIL\n" cNORM);
+ printf(cRED "fill_GOST_EC_params FAIL" cNORM "\n");
ERR_print_errors_fp(stderr);
return 1;
}
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}
#define cCYAN "\033[1;36m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM);}
+ printf(cGREEN " Test passed" cNORM "\n");}
#ifndef OSSL_NELEM
# define OSSL_NELEM(x) (sizeof(x)/sizeof((x)[0]))
printf("Public key %08x matches private key %08x\n",
*(int *)pub, *(int *)pk);
else {
- printf(cRED "Public key mismatch!\n" cNORM);
+ printf(cRED "Public key mismatch!" cNORM "\n");
exit(1);
}
EC_POINT_free(xy);
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}
/* vim: set expandtab cinoptions=\:0,l1,t0,g0,(0 sw=4 : */
#define cMAGENT "\033[1;35m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM);}
+ printf(cGREEN " Test passed" cNORM "\n");}
/* To test older APIs. */
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if (t->mdsize)
T(len == t->mdsize);
if (memcmp(md, t->hmac, len) != 0) {
- printf(cRED "hmac mismatch\n" cNORM);
+ printf(cRED "hmac mismatch" cNORM "\n");
hexdump(t->hmac, len);
hexdump(md, len);
return 1;
if (t->mdsize)
T(len == t->mdsize);
if (memcmp(md, t->hmac, len) != 0) {
- printf(cRED "hmac mismatch\n" cNORM);
+ printf(cRED "hmac mismatch" cNORM "\n");
hexdump(t->hmac, len);
hexdump(md, len);
return 1;
* So, just compare until what we need. */
T(mdsize <= len);
if (memcmp(md, t->digest, mdsize) != 0) {
- printf(cRED "cmac mismatch\n" cNORM);
+ printf(cRED "cmac mismatch" cNORM "\n");
hexdump(t->digest, mdsize);
hexdump(md, len);
return 1;
EVP_MD_CTX_free(ctx);
T(len == mdsize);
if (memcmp(md, t->digest, mdsize) != 0) {
- printf(cRED "digest mismatch\n" cNORM);
+ printf(cRED "digest mismatch" cNORM "\n");
hexdump(t->digest, mdsize);
hexdump(md, mdsize);
return 1;
OPENSSL_free(buf);
if (!ret)
- printf(cGREEN "success\n" cNORM);
+ printf(cGREEN "success" cNORM "\n");
else
- printf(cRED "fail\n" cNORM);
+ printf(cRED "fail" cNORM "\n");
return ret;
}
EVP_MD_CTX_free(ctx2);
if (len != mdlen) {
- printf(cRED "digest output len mismatch %u != %u (expected)\n" cNORM,
+ printf(cRED "digest output len mismatch %u != %u (expected)" cNORM "\n",
len, mdlen);
goto err;
}
if (memcmp(md, tv->digest, mdlen) != 0) {
- printf(cRED "digest mismatch\n" cNORM);
+ printf(cRED "digest mismatch" cNORM "\n");
unsigned int i;
printf(" Expected value is: ");
ret |= do_synthetic_once(tv, shifts);
if (!ret)
- printf(cGREEN "success\n" cNORM);
+ printf(cGREEN "success" cNORM "\n");
else
- printf(cRED "fail\n" cNORM);
+ printf(cRED "fail" cNORM "\n");
return 0;
}
if (tv->nid == nids[k])
break;
if (!tv->nid)
- printf(cMAGENT "Digest %s is untested!\n" cNORM, OBJ_nid2sn(nids[k]));
+ printf(cMAGENT "Digest %s is untested!" cNORM "\n", OBJ_nid2sn(nids[k]));
}
ENGINE_finish(eng);
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}
#define cDBLUE "\033[0;34m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM);}
+ printf(cGREEN " Test passed" cNORM "\n");}
struct test_param {
unsigned int param; /* NID of EC parameters */
static void print_test_result(int err)
{
if (err == 1)
- printf(cGREEN "correct\n" cNORM);
+ printf(cGREEN "correct" cNORM "\n");
else if (err == 0)
- printf(cRED "incorrect\n" cNORM);
+ printf(cRED "incorrect" cNORM "\n");
else
ERR_print_errors_fp(stderr);
}
int hash_nid = 0;
const char *sn = OBJ_nid2sn(t->param);
- printf(cBLUE "Test %s (cp):\n" cNORM, sn);
+ printf(cBLUE "Test %s (cp):" cNORM "\n", sn);
switch (t->len) {
case 256 / 8:
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}
#define cCYAN "\033[1;36m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM);}
+ printf(cGREEN " Test passed" cNORM "\n");}
struct test_sign {
const char *name;
static void print_test_tf(int err, int val, const char *t, const char *f)
{
if (err == 1)
- printf(cGREEN "%s\n" cNORM, t);
+ printf(cGREEN "%s" cNORM "\n", t);
else
- printf(cRED "%s [%d]\n" cNORM, f, val);
+ printf(cRED "%s [%d]" cNORM "\n", f, val);
}
static void print_test_result(int err)
{
if (err == 1)
- printf(cGREEN "success\n" cNORM);
+ printf(cGREEN "success" cNORM "\n");
else if (err == 0)
- printf(cRED "failure\n" cNORM);
+ printf(cRED "failure" cNORM "\n");
else
ERR_print_errors_fp(stderr);
}
int ret = 0, err;
size_t len = t->bits / 8;
- printf(cBLUE "Test %s:\n" cNORM, t->name);
+ printf(cBLUE "Test %s:" cNORM "\n", t->name);
/* Signature type from size. */
int type = 0;
ret |= err;
EVP_PKEY_free(pkey);
} else
- printf(cCYAN "skipped\n" cNORM);
+ printf(cCYAN "skipped" cNORM "\n");
BIO_free(bp);
/* Convert to DER and back, using memory API. */
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}