Skip to content

Commit 8da9604

Browse files
committed
unconditionally include vector
1 parent e072f46 commit 8da9604

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

src/ncrypto.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717

1818
#if OPENSSL_VERSION_NUMBER >= 0x30200000L
1919
#include <openssl/thread.h>
20-
#ifndef OPENSSL_NO_ARGON2
21-
#include <vector>
22-
#endif
2320
#endif
2421

2522
#include <algorithm>
2623
#include <array>
2724
#include <cstring>
2825
#include <string_view>
26+
#include <vector>
2927
#if OPENSSL_VERSION_MAJOR >= 3
3028
#include <openssl/core_names.h>
3129
#include <openssl/params.h>

tests/basic.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,44 @@ TEST(Ec, getCurve) {
215215
ASSERT_EQ(curve, NID_X9_62_prime256v1);
216216
}
217217

218+
#ifndef OPENSSL_IS_BORINGSSL
219+
TEST(Ec, GetCurves) {
220+
std::vector<std::string> curves;
221+
222+
bool result = Ec::GetCurves([&](const char* name) {
223+
curves.push_back(name);
224+
return true;
225+
});
226+
227+
ASSERT_TRUE(result);
228+
// OpenSSL should have at least some built-in curves
229+
ASSERT_GT(curves.size(), 0u);
230+
231+
// Check that common curves are present
232+
bool hasP256 = false;
233+
bool hasP384 = false;
234+
for (const auto& curve : curves) {
235+
if (curve == "prime256v1" || curve == "P-256") hasP256 = true;
236+
if (curve == "secp384r1" || curve == "P-384") hasP384 = true;
237+
}
238+
ASSERT_TRUE(hasP256);
239+
ASSERT_TRUE(hasP384);
240+
}
241+
242+
TEST(Ec, GetCurves_early_exit) {
243+
int count = 0;
244+
245+
// Test that returning false stops iteration
246+
bool result = Ec::GetCurves([&](const char* name) {
247+
count++;
248+
return count < 3; // Stop after 2 curves
249+
});
250+
251+
ASSERT_FALSE(result);
252+
ASSERT_EQ(count, 3);
253+
}
254+
#endif // OPENSSL_IS_BORINGSSL
255+
218256
// ============================================================================
219257
// EVPKeyPointer tests
220258

0 commit comments

Comments
 (0)