mirror of
https://github.com/openssl/openssl.git
synced 2025-03-25 20:00:44 +08:00
Test EVP_get_[digest|cipher]byname() use the namemap
Following on from the previous commit, we test that if an algorithm has a provider supplied alias in the namemap then EVP_get_digestbyname() and EVP_get_cipherbyname() can still find it. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/10324)
This commit is contained in:
parent
7606bed904
commit
eee5f32f37
@ -7,6 +7,7 @@
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/evp.h>
|
||||
#include "internal/namemap.h"
|
||||
#include "testutil.h"
|
||||
|
||||
@ -55,9 +56,64 @@ static int test_namemap_stored(void)
|
||||
&& test_namemap(nm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that EVP_get_digestbyname() will use the namemap when it can't find
|
||||
* entries in the legacy method database.
|
||||
*/
|
||||
static int test_digestbyname(void)
|
||||
{
|
||||
int id;
|
||||
OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
|
||||
const EVP_MD *sha256, *foo;
|
||||
|
||||
id = ossl_namemap_add(nm, 0, "SHA256");
|
||||
if (!TEST_int_ne(id, 0))
|
||||
return 0;
|
||||
if (!TEST_int_eq(ossl_namemap_add(nm, id, "foo"), id))
|
||||
return 0;
|
||||
|
||||
sha256 = EVP_get_digestbyname("SHA256");
|
||||
if (!TEST_ptr(sha256))
|
||||
return 0;
|
||||
foo = EVP_get_digestbyname("foo");
|
||||
if (!TEST_ptr_eq(sha256, foo))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that EVP_get_cipherbyname() will use the namemap when it can't find
|
||||
* entries in the legacy method database.
|
||||
*/
|
||||
static int test_cipherbyname(void)
|
||||
{
|
||||
int id;
|
||||
OSSL_NAMEMAP *nm = ossl_namemap_stored(NULL);
|
||||
const EVP_CIPHER *aes128, *bar;
|
||||
|
||||
id = ossl_namemap_add(nm, 0, "AES-128-CBC");
|
||||
if (!TEST_int_ne(id, 0))
|
||||
return 0;
|
||||
if (!TEST_int_eq(ossl_namemap_add(nm, id, "bar"), id))
|
||||
return 0;
|
||||
|
||||
aes128 = EVP_get_cipherbyname("AES-128-CBC");
|
||||
if (!TEST_ptr(aes128))
|
||||
return 0;
|
||||
bar = EVP_get_cipherbyname("bar");
|
||||
if (!TEST_ptr_eq(aes128, bar))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int setup_tests(void)
|
||||
{
|
||||
ADD_TEST(test_namemap_independent);
|
||||
ADD_TEST(test_namemap_stored);
|
||||
ADD_TEST(test_digestbyname);
|
||||
ADD_TEST(test_cipherbyname);
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user