Skip to content

Commit 11c2e52

Browse files
committed
Move helper function to anonymous namespace
1 parent 3e67123 commit 11c2e52

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cpp/src/gandiva/encrypt_utils.cc

+15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@
2020

2121
#include <stdexcept>
2222

23+
namespace {
24+
const EVP_CIPHER* get_cipher_algo(int32_t key_length) {
25+
switch (key_length) {
26+
case 16:
27+
return EVP_aes_128_ecb();
28+
case 24:
29+
return EVP_aes_192_ecb();
30+
case 32:
31+
return EVP_aes_256_ecb();
32+
default:
33+
throw std::runtime_error("unsupported key length: " + std::to_string(key_length));
34+
}
35+
}
36+
} // namespace
37+
2338
namespace gandiva {
2439
GANDIVA_EXPORT
2540
int32_t aes_encrypt(const char* plaintext, int32_t plaintext_len, const char* key,

cpp/src/gandiva/encrypt_utils.h

-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,4 @@ GANDIVA_EXPORT
3737
int32_t aes_decrypt(const char* ciphertext, int32_t ciphertext_len, const char* key,
3838
int32_t key_len, unsigned char* plaintext);
3939

40-
const EVP_CIPHER* get_cipher_algo(int32_t key_length);
41-
4240
} // namespace gandiva

0 commit comments

Comments
 (0)