1 /* Copyright (c) 2021, Google Inc.
2 *
3 * Permission to use, copy, modify, and/or distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15 #include <gtest/gtest.h>
16
17 #include <openssl/cipher.h>
18 #include <openssl/digest.h>
19 #include <openssl/evp.h>
20
21
22 // Node.js assumes every cipher in |EVP_CIPHER_do_all_sorted| is accessible via
23 // |EVP_get_cipherby*|.
TEST(EVPTest,CipherDoAll)24 TEST(EVPTest, CipherDoAll) {
25 EVP_CIPHER_do_all_sorted(
26 [](const EVP_CIPHER *cipher, const char *name, const char *unused,
27 void *arg) {
28 SCOPED_TRACE(name);
29 EXPECT_EQ(cipher, EVP_get_cipherbyname(name));
30 EXPECT_EQ(cipher, EVP_get_cipherbynid(EVP_CIPHER_nid(cipher)));
31 },
32 nullptr);
33 }
34
35 // Node.js assumes every digest in |EVP_MD_do_all_sorted| is accessible via
36 // |EVP_get_digestby*|.
TEST(EVPTest,MDDoAll)37 TEST(EVPTest, MDDoAll) {
38 EVP_MD_do_all_sorted(
39 [](const EVP_MD *md, const char *name, const char *unused, void *arg) {
40 SCOPED_TRACE(name);
41 EXPECT_EQ(md, EVP_get_digestbyname(name));
42 EXPECT_EQ(md, EVP_get_digestbynid(EVP_MD_nid(md)));
43 },
44 nullptr);
45 }
46