1 // Copyright 2021 The BoringSSL Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
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