diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2016-12-10 13:59:29 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2016-12-10 19:39:31 +0000 |
commit | c6720f816f4c9373890939d6ec63a7dc29835fdd (patch) | |
tree | c831514c3f4530dcedda4947fa85a374c90b58f9 /test/evp_test.c | |
parent | fad4832a121cde93a126a2a3f9b336c439d1749d (diff) |
Additional error tests in evp_test.c
Support checking for errors during test initialisation and parsing.
Add errors and tests for key operation initalisation and ctrl errors.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit cce65266299e2e89303a90c131e8171225a1bf88)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 907e083c9f..9dfd4a1719 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -354,8 +354,7 @@ static int setup_test(struct evp_test *t, const struct evp_test_method *tmeth) t->nskip++; } else { /* run the test */ - t->err = NULL; - if (t->meth->run_test(t) != 1) { + if (t->err == NULL && t->meth->run_test(t) != 1) { fprintf(stderr, "%s test error line %d\n", t->meth->name, t->start_line); return 0; @@ -567,6 +566,7 @@ int main(int argc, char **argv) return 1; } t.in = in; + t.err = NULL; while (BIO_gets(in, buf, sizeof(buf))) { t.line++; if (!process_test(&t, buf, 0)) @@ -1234,7 +1234,7 @@ static int pkey_test_init(struct evp_test *t, const char *name, if (!kdata->ctx) return 0; if (keyopinit(kdata->ctx) <= 0) - return 0; + t->err = "KEYOP_INIT_ERROR"; return 1; } @@ -1260,11 +1260,21 @@ static int pkey_test_ctrl(struct evp_test *t, EVP_PKEY_CTX *pctx, if (p != NULL) *p++ = 0; rv = EVP_PKEY_CTX_ctrl_str(pctx, tmpval, p); - if (p != NULL && rv <= 0 && rv != -2) { - /* If p has an OID assume disabled algorithm */ - if (OBJ_sn2nid(p) != NID_undef || OBJ_ln2nid(p) != NID_undef) { + if (rv == -2) { + t->err = "PKEY_CTRL_INVALID"; + rv = 1; + } else if (p != NULL && rv <= 0) { + /* If p has an OID and lookup fails assume disabled algorithm */ + int nid = OBJ_sn2nid(p); + if (nid == NID_undef) + nid = OBJ_ln2nid(p); + if ((nid != NID_undef) && EVP_get_digestbynid(nid) == NULL && + EVP_get_cipherbynid(nid) == NULL) { t->skip = 1; rv = 1; + } else { + t->err = "PKEY_CTRL_ERROR"; + rv = 1; } } OPENSSL_free(tmpval); |