summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-06-07 10:52:25 +0200
committerRichard Levitte <levitte@openssl.org>2019-09-12 13:19:40 +0200
commit022351fdc3b01cfcb6c1b064c56d8a1393ed0ec8 (patch)
treed56dcfd29a467efc3385cd1606e61d2c7374e45b /test
parentUpdate the bundled external perl module Text-Template to version 1.56 (diff)
downloadopenssl-022351fdc3b01cfcb6c1b064c56d8a1393ed0ec8.tar.xz
openssl-022351fdc3b01cfcb6c1b064c56d8a1393ed0ec8.zip
test/evp_test.c: try fetching algorithms
Instead of relying on implicit fetches, try explicit fetches when available. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/9121)
Diffstat (limited to 'test')
-rw-r--r--test/evp_test.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index 69ccb9739e..b1194d2bc9 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -325,6 +325,7 @@ static int parse_bin(const char *value, unsigned char **buf, size_t *buflen)
typedef struct digest_data_st {
/* Digest this test is for */
const EVP_MD *digest;
+ EVP_MD *fetched_digest;
/* Input to digest */
STACK_OF(EVP_TEST_BUFFER) *input;
/* Expected output */
@@ -336,8 +337,10 @@ static int digest_test_init(EVP_TEST *t, const char *alg)
{
DIGEST_DATA *mdat;
const EVP_MD *digest;
+ EVP_MD *fetched_digest;
- if ((digest = EVP_get_digestbyname(alg)) == NULL) {
+ if ((digest = fetched_digest = EVP_MD_fetch(NULL, alg, NULL)) == NULL
+ && (digest = EVP_get_digestbyname(alg)) == NULL) {
/* If alg has an OID assume disabled algorithm */
if (OBJ_sn2nid(alg) != NID_undef || OBJ_ln2nid(alg) != NID_undef) {
t->skip = 1;
@@ -349,6 +352,9 @@ static int digest_test_init(EVP_TEST *t, const char *alg)
return 0;
t->data = mdat;
mdat->digest = digest;
+ mdat->fetched_digest = fetched_digest;
+ if (fetched_digest != NULL)
+ TEST_info("%s is fetched", alg);
return 1;
}
@@ -358,6 +364,7 @@ static void digest_test_cleanup(EVP_TEST *t)
sk_EVP_TEST_BUFFER_pop_free(mdat->input, evp_test_buffer_free);
OPENSSL_free(mdat->output);
+ EVP_MD_meth_free(mdat->fetched_digest);
}
static int digest_test_parse(EVP_TEST *t,
@@ -472,6 +479,7 @@ static const EVP_TEST_METHOD digest_test_method = {
typedef struct cipher_data_st {
const EVP_CIPHER *cipher;
+ EVP_CIPHER *fetched_cipher;
int enc;
/* EVP_CIPH_GCM_MODE, EVP_CIPH_CCM_MODE or EVP_CIPH_OCB_MODE if AEAD */
int aead;
@@ -494,10 +502,12 @@ typedef struct cipher_data_st {
static int cipher_test_init(EVP_TEST *t, const char *alg)
{
const EVP_CIPHER *cipher;
+ EVP_CIPHER *fetched_cipher;
CIPHER_DATA *cdat;
int m;
- if ((cipher = EVP_get_cipherbyname(alg)) == NULL) {
+ if ((cipher = fetched_cipher = EVP_CIPHER_fetch(NULL, alg, NULL)) == NULL
+ && (cipher = EVP_get_cipherbyname(alg)) == NULL) {
/* If alg has an OID assume disabled algorithm */
if (OBJ_sn2nid(alg) != NID_undef || OBJ_ln2nid(alg) != NID_undef) {
t->skip = 1;
@@ -507,6 +517,7 @@ static int cipher_test_init(EVP_TEST *t, const char *alg)
}
cdat = OPENSSL_zalloc(sizeof(*cdat));
cdat->cipher = cipher;
+ cdat->fetched_cipher = fetched_cipher;
cdat->enc = -1;
m = EVP_CIPHER_mode(cipher);
if (m == EVP_CIPH_GCM_MODE
@@ -520,6 +531,8 @@ static int cipher_test_init(EVP_TEST *t, const char *alg)
cdat->aead = 0;
t->data = cdat;
+ if (fetched_cipher != NULL)
+ TEST_info("%s is fetched", alg);
return 1;
}
@@ -535,6 +548,7 @@ static void cipher_test_cleanup(EVP_TEST *t)
for (i = 0; i < AAD_NUM; i++)
OPENSSL_free(cdat->aad[i]);
OPENSSL_free(cdat->tag);
+ EVP_CIPHER_meth_free(cdat->fetched_cipher);
}
static int cipher_test_parse(EVP_TEST *t, const char *keyword,