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 13:59:29 +0000 |
commit | cce65266299e2e89303a90c131e8171225a1bf88 (patch) | |
tree | 25b069e55d3b894d294a6d80dd7551c2bc5a38ce /test/evp_test.c | |
parent | c922ebe23247ff9ee07310fa30647623c0547cd9 (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>
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); |