Skip to content

Commit 5bdb71e

Browse files
WIP
1 parent e67dac8 commit 5bdb71e

5 files changed

Lines changed: 303 additions & 448 deletions

File tree

cpp/src/gandiva/encrypt_mode_dispatcher.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525

2626
namespace gandiva {
2727

28-
int32_t EncryptModeDispatcher::encrypt(const char* plaintext, int32_t plaintext_len,
29-
const char* key, int32_t key_len,
30-
const char* mode, int32_t mode_len,
31-
const char* iv, int32_t iv_len,
32-
const char* fifth_argument, int32_t fifth_argument_len,
33-
unsigned char* cipher) {
34-
std::string mode_str = arrow::AsciiToUpper(std::string_view(mode, mode_len));
28+
int32_t EncryptModeDispatcher::encrypt(
29+
const char* plaintext, int32_t plaintext_len, const char* key,
30+
int32_t key_len, const char* mode, int32_t mode_len, const char* iv,
31+
int32_t iv_len, const char* fifth_argument, int32_t fifth_argument_len,
32+
unsigned char* cipher) {
33+
std::string mode_str =
34+
arrow::internal::AsciiToUpper(std::string_view(mode, mode_len));
3535

3636
if (mode_str == "AES-ECB") {
3737
return aes_encrypt_ecb(plaintext, plaintext_len, key, key_len, cipher);
@@ -46,18 +46,18 @@ int32_t EncryptModeDispatcher::encrypt(const char* plaintext, int32_t plaintext_
4646
} else {
4747
std::ostringstream oss;
4848
oss << "Unsupported encryption mode: " << mode_str
49-
<< ". Supported modes: AES-ECB, AES-CBC-PKCS7, AES-CBC-NONE (AES-GCM coming soon)";
49+
<< ". Supported modes: AES-ECB, AES-CBC-PKCS7, AES-CBC-NONE";
5050
throw std::runtime_error(oss.str());
5151
}
5252
}
5353

54-
int32_t EncryptModeDispatcher::decrypt(const char* ciphertext, int32_t ciphertext_len,
55-
const char* key, int32_t key_len,
56-
const char* mode, int32_t mode_len,
57-
const char* iv, int32_t iv_len,
58-
const char* fifth_argument, int32_t fifth_argument_len,
59-
unsigned char* plaintext) {
60-
std::string mode_str = arrow::AsciiToUpper(std::string_view(mode, mode_len));
54+
int32_t EncryptModeDispatcher::decrypt(
55+
const char* ciphertext, int32_t ciphertext_len, const char* key,
56+
int32_t key_len, const char* mode, int32_t mode_len, const char* iv,
57+
int32_t iv_len, const char* fifth_argument, int32_t fifth_argument_len,
58+
unsigned char* plaintext) {
59+
std::string mode_str =
60+
arrow::internal::AsciiToUpper(std::string_view(mode, mode_len));
6161

6262
if (mode_str == "AES-ECB") {
6363
return aes_decrypt_ecb(ciphertext, ciphertext_len, key, key_len, plaintext);
@@ -72,7 +72,7 @@ int32_t EncryptModeDispatcher::decrypt(const char* ciphertext, int32_t ciphertex
7272
} else {
7373
std::ostringstream oss;
7474
oss << "Unsupported decryption mode: " << mode_str
75-
<< ". Supported modes: AES-ECB, AES-CBC-PKCS7, AES-CBC-NONE (AES-GCM coming soon)";
75+
<< ". Supported modes: AES-ECB, AES-CBC-PKCS7, AES-CBC-NONE";
7676
throw std::runtime_error(oss.str());
7777
}
7878
}

cpp/src/gandiva/function_registry_string.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ std::vector<NativeFunction> GetStringFunctionRegistry() {
504504
kResultNullIfNull, "gdv_fn_aes_decrypt_ecb_legacy",
505505
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors),
506506

507-
// Signature 1: (VARBINARY, VARBINARY, UTF8) -> VARBINARY
508507
// Parameters: data, key, mode (e.g. ECB mode)
509508
NativeFunction("aes_encrypt", {}, DataTypeVector{binary(), binary(), utf8()}, binary(),
510509
kResultNullIfNull, "gdv_fn_aes_encrypt_dispatcher_3args",
@@ -514,7 +513,6 @@ std::vector<NativeFunction> GetStringFunctionRegistry() {
514513
kResultNullIfNull, "gdv_fn_aes_decrypt_dispatcher_3args",
515514
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors),
516515

517-
// Signature 2: (VARBINARY, VARBINARY, UTF8, VARBINARY) -> VARBINARY
518516
// Parameters: data, key, mode, iv (e.g. CBC mode)
519517
NativeFunction("aes_encrypt", {}, DataTypeVector{binary(), binary(), utf8(), binary()}, binary(),
520518
kResultNullIfNull, "gdv_fn_aes_encrypt_dispatcher_4args",
@@ -524,7 +522,6 @@ std::vector<NativeFunction> GetStringFunctionRegistry() {
524522
kResultNullIfNull, "gdv_fn_aes_decrypt_dispatcher_4args",
525523
NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors),
526524

527-
// Signature 3: (VARBINARY, VARBINARY, UTF8, VARBINARY, VARBINARY) -> VARBINARY
528525
// Parameters: data, key, mode, iv, fifth_argument (e.g. GCM mode)
529526
NativeFunction("aes_encrypt", {}, DataTypeVector{binary(), binary(), utf8(), binary(), binary()}, binary(),
530527
kResultNullIfNull, "gdv_fn_aes_encrypt_dispatcher_5args",

0 commit comments

Comments
 (0)