X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Fevp_test.c;h=e42254591fe1ae44ff1671fd0d0c6899df7dc15d;hp=6bc3a8ab39012d25d573c67d7681cfee3b5acb8f;hb=453dfd8d5ee0893146e0fb61a5978ab59ba95c01;hpb=8793f012f11416abd300aa524057c863e8c16dd5 diff --git a/test/evp_test.c b/test/evp_test.c index 6bc3a8ab39..e42254591f 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -209,6 +209,8 @@ static int test_bin(const char *value, unsigned char **buf, size_t *buflen) *buflen = len; return 1; } +#ifndef OPENSSL_NO_SCRYPT +/* Currently only used by scrypt tests */ /* Parse unsigned decimal 64 bit integer value */ static int test_uint64(const char *value, uint64_t *pr) { @@ -233,6 +235,7 @@ static int test_uint64(const char *value, uint64_t *pr) } return 1; } +#endif /* Structure holding test information */ struct evp_test { @@ -1022,11 +1025,16 @@ static int mac_test_init(struct evp_test *t, const char *alg) { int type; struct mac_data *mdat; - if (strcmp(alg, "HMAC") == 0) + if (strcmp(alg, "HMAC") == 0) { type = EVP_PKEY_HMAC; - else if (strcmp(alg, "CMAC") == 0) + } else if (strcmp(alg, "CMAC") == 0) { +#ifndef OPENSSL_NO_CMAC type = EVP_PKEY_CMAC; - else +#else + t->skip = 1; + return 1; +#endif + } else return 0; mdat = OPENSSL_malloc(sizeof(*mdat)); @@ -1078,6 +1086,14 @@ static int mac_test_run(struct evp_test *t) unsigned char *mac = NULL; size_t mac_len; +#ifdef OPENSSL_NO_DES + if (strstr(mdata->alg, "DES") != NULL) { + /* Skip DES */ + err = NULL; + goto err; + } +#endif + err = "MAC_PKEY_CTX_ERROR"; genctx = EVP_PKEY_CTX_new_id(mdata->type, NULL); if (!genctx) @@ -1496,16 +1512,20 @@ static int pbe_test_init(struct evp_test *t, const char *alg) struct pbe_data *pdat; int pbe_type = 0; + if (strcmp(alg, "scrypt") == 0) { #ifndef OPENSSL_NO_SCRYPT - if (strcmp(alg, "scrypt") == 0) pbe_type = PBE_TYPE_SCRYPT; +#else + t->skip = 1; + return 1; #endif - else if (strcmp(alg, "pbkdf2") == 0) + } else if (strcmp(alg, "pbkdf2") == 0) { pbe_type = PBE_TYPE_PBKDF2; - else if (strcmp(alg, "pkcs12") == 0) + } else if (strcmp(alg, "pkcs12") == 0) { pbe_type = PBE_TYPE_PKCS12; - else + } else { fprintf(stderr, "Unknown pbe algorithm %s\n", alg); + } pdat = OPENSSL_malloc(sizeof(*pdat)); pdat->pbe_type = pbe_type; pdat->pass = NULL; @@ -1739,9 +1759,7 @@ static const struct evp_test_method encode_test_method = { encode_test_run, }; -/* - * KDF operations: initially just TLS1 PRF but can be adapted. - */ +/* KDF operations */ struct kdf_data { /* Context for this operation */ @@ -1780,39 +1798,14 @@ static void kdf_test_cleanup(struct evp_test *t) EVP_PKEY_CTX_free(kdata->ctx); } -static int kdf_ctrl(EVP_PKEY_CTX *ctx, int op, const char *value) -{ - unsigned char *buf = NULL; - size_t buf_len; - int rv = 0; - if (test_bin(value, &buf, &buf_len) == 0) - return 0; - if (EVP_PKEY_CTX_ctrl(ctx, -1, -1, op, buf_len, buf) <= 0) - goto err; - rv = 1; - err: - OPENSSL_free(buf); - return rv; -} - static int kdf_test_parse(struct evp_test *t, const char *keyword, const char *value) { struct kdf_data *kdata = t->data; if (strcmp(keyword, "Output") == 0) return test_bin(value, &kdata->output, &kdata->output_len); - else if (strcmp(keyword, "MD") == 0) { - const EVP_MD *md = EVP_get_digestbyname(value); - if (md == NULL) - return 0; - if (EVP_PKEY_CTX_set_tls1_prf_md(kdata->ctx, md) <= 0) - return 0; - return 1; - } else if (strcmp(keyword, "Secret") == 0) { - return kdf_ctrl(kdata->ctx, EVP_PKEY_CTRL_TLS_SECRET, value); - } else if (strncmp("Seed", keyword, 4) == 0) { - return kdf_ctrl(kdata->ctx, EVP_PKEY_CTRL_TLS_SEED, value); - } + if (strncmp(keyword, "Ctrl", 4) == 0) + return pkey_test_ctrl(kdata->ctx, value); return 0; }