You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2024/09/26 03:27:33 UTC
(doris) branch branch-3.0 updated (472dc904e06 -> 4e9d0fb77f1)
This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a change to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
from 472dc904e06 [fix](cloud) fix incorrect timeout of FE connection pool (#41202)
new f01204da8f2 [test](case) add some test case for encrypt/decrypt functions (#40427)
new 4e9d0fb77f1 [fix](encrypt) wrong mode arg of encrypt and decrypt function make BE crash (#40726)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
be/src/vec/functions/function_encryption.cpp | 9 +-
.../encryption_digest/test_encryption_function.out | 195 +++++++++++++++++++++
.../test_encryption_function.groovy | 138 +++++++++++++++
3 files changed, 339 insertions(+), 3 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
(doris) 01/02: [test](case) add some test case for encrypt/decrypt functions (#40427)
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
commit f01204da8f22cbec7184508896af2f793a59e02e
Author: zhangstar333 <87...@users.noreply.github.com>
AuthorDate: Tue Sep 10 12:05:55 2024 +0800
[test](case) add some test case for encrypt/decrypt functions (#40427)
## Proposed changes
add some test case for encrypt/decrypt functions
---
.../encryption_digest/test_encryption_function.out | 192 +++++++++++++++++++++
.../test_encryption_function.groovy | 135 +++++++++++++++
2 files changed, 327 insertions(+)
diff --git a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
index 9e920596f89..1a46d127eae 100644
--- a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
+++ b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
@@ -140,3 +140,195 @@ text
-- !sql --
aaaaaa
+-- !sql1 --
+aaaaaa
+
+-- !sql2 --
+aaaaaa
+
+-- !sql3 --
+zhang
+
+-- !sql4 --
+zhang
+
+-- !sql5 --
+aaaaaa
+
+-- !sql6 --
+aaaaaa
+
+-- !sql7 --
+zhang
+
+-- !sql8 --
+zhang
+
+-- !sql9 --
+aaaaaa
+
+-- !sql10 --
+aaaaaa
+
+-- !sql11 --
+zhang
+
+-- !sql12 --
+zhang
+
+-- !sql9 --
+aaaaaa
+
+-- !sql10 --
+aaaaaa
+
+-- !sql11 --
+zhang
+
+-- !sql12 --
+zhang
+
+-- !sql13 --
+aaaaaa
+
+-- !sql14 --
+aaaaaa
+
+-- !sql15 --
+zhang
+
+-- !sql16 --
+zhang
+
+-- !sql17 --
+aaaaaa
+
+-- !sql18 --
+aaaaaa
+
+-- !sql19 --
+zhang
+
+-- !sql20 --
+zhang
+
+-- !sql21 --
+aaaaaa
+
+-- !sql22 --
+aaaaaa
+
+-- !sql23 --
+zhang
+
+-- !sql24 --
+zhang
+
+-- !sql25 --
+aaaaaa
+
+-- !sql26 --
+aaaaaa
+
+-- !sql27 --
+zhang
+
+-- !sql28 --
+zhang
+
+-- !sql29 --
+aaaaaa
+
+-- !sql30 --
+aaaaaa
+
+-- !sql31 --
+zhang
+
+-- !sql32 --
+zhang
+
+-- !sql29 --
+aaaaaa
+
+-- !sql30 --
+aaaaaa
+
+-- !sql31 --
+zhang
+
+-- !sql32 --
+zhang
+
+-- !sql33 --
+aaaaaa
+
+-- !sql34 --
+aaaaaa
+
+-- !sql35 --
+zhang
+
+-- !sql36 --
+zhang
+
+-- !sql37 --
+aaaaaa
+
+-- !sql38 --
+aaaaaa
+
+-- !sql39 --
+zhang
+
+-- !sql40 --
+zhang
+
+-- !sql41 --
+aaaaaa
+
+-- !sql42 --
+aaaaaa
+
+-- !sql43 --
+zhang
+
+-- !sql44 --
+zhang
+
+-- !sql45 --
+aaaaaa
+
+-- !sql46 --
+aaaaaa
+
+-- !sql47 --
+zhang
+
+-- !sql48 --
+zhang
+
+-- !sql49 --
+aaaaaa
+
+-- !sql50 --
+aaaaaa
+
+-- !sql51 --
+zhang
+
+-- !sql52 --
+zhang
+
+-- !sql53 --
+aaaaaa
+
+-- !sql54 --
+aaaaaa
+
+-- !sql55 --
+zhang
+
+-- !sql56 --
+zhang
+
diff --git a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
index 4b0fd3d497d..985a2d1b4f7 100644
--- a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
+++ b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
@@ -149,4 +149,139 @@ suite("test_encryption_function") {
"""
sql""" insert into quantile_table values(1,"aaaaaa");"""
qt_sql """ select sm4_decrypt(sm4_encrypt(k,"doris","0123456789abcdef"),"doris","0123456789abcdef") from quantile_table; """
+
+ // sm4_encrypt sm4_decrypt
+ // aes_encrypt aes_decrypt
+ //two arg (column/const)
+ sql "set enable_fold_constant_by_be = false;"
+ sql """ set block_encryption_mode=""; """ // SM4_128_ECB
+ qt_sql1 """ select sm4_decrypt(sm4_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql2 """ select sm4_decrypt(sm4_encrypt(k,k),k) from quantile_table; """
+ qt_sql3 """ select sm4_decrypt(sm4_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql4 """ select sm4_decrypt(sm4_encrypt("zhang",k),k) from quantile_table; """
+
+ sql """ set block_encryption_mode="SM4_128_CBC"; """
+ qt_sql5 """ select sm4_decrypt(sm4_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql6 """ select sm4_decrypt(sm4_encrypt(k,k),k) from quantile_table; """
+ qt_sql7 """ select sm4_decrypt(sm4_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql8 """ select sm4_decrypt(sm4_encrypt("zhang",k),k) from quantile_table; """
+
+ sql """ set block_encryption_mode="SM4_128_OFB"; """
+ qt_sql9 """ select sm4_decrypt(sm4_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql10 """ select sm4_decrypt(sm4_encrypt(k,k),k) from quantile_table; """
+ qt_sql11 """ select sm4_decrypt(sm4_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql12 """ select sm4_decrypt(sm4_encrypt("zhang",k),k) from quantile_table; """
+
+ sql """ set block_encryption_mode="SM4_128_CTR"; """
+ qt_sql9 """ select sm4_decrypt(sm4_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql10 """ select sm4_decrypt(sm4_encrypt(k,k),k) from quantile_table; """
+ qt_sql11 """ select sm4_decrypt(sm4_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql12 """ select sm4_decrypt(sm4_encrypt("zhang",k),k) from quantile_table; """
+
+ sql """ set block_encryption_mode=""; """ // AES_128_ECB
+ qt_sql13 """ select aes_decrypt(aes_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql14 """ select aes_decrypt(aes_encrypt(k,k),k) from quantile_table; """
+ qt_sql15 """ select aes_decrypt(aes_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql16 """ select aes_decrypt(aes_encrypt("zhang",k),k) from quantile_table; """
+
+ sql """ set block_encryption_mode="AES_256_CBC"; """
+ qt_sql17 """ select aes_decrypt(aes_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql18 """ select aes_decrypt(aes_encrypt(k,k),k) from quantile_table; """
+ qt_sql19 """ select aes_decrypt(aes_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql20 """ select aes_decrypt(aes_encrypt("zhang",k),k) from quantile_table; """
+
+
+ sql """ set block_encryption_mode="AES_128_CTR"; """
+ qt_sql21 """ select aes_decrypt(aes_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql22 """ select aes_decrypt(aes_encrypt(k,k),k) from quantile_table; """
+ qt_sql23 """ select aes_decrypt(aes_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql24 """ select aes_decrypt(aes_encrypt("zhang",k),k) from quantile_table; """
+
+
+ sql """ set block_encryption_mode="AES_256_OFB"; """
+ qt_sql25 """ select aes_decrypt(aes_encrypt(k,"doris"),"doris") from quantile_table; """
+ qt_sql26 """ select aes_decrypt(aes_encrypt(k,k),k) from quantile_table; """
+ qt_sql27 """ select aes_decrypt(aes_encrypt("zhang","doris"),"doris") from quantile_table; """
+ qt_sql28 """ select aes_decrypt(aes_encrypt("zhang",k),k) from quantile_table; """
+
+ sql """ set block_encryption_mode=""; """
+
+ sql """ select to_base64(aes_encrypt(k,"doris")) from quantile_table;""" // 3A7GoWeuMNEBWzJx+YefZw==
+ qt_sql29 """ select aes_decrypt(FROM_BASE64("3A7GoWeuMNEBWzJx+YefZw=="),"doris") from quantile_table; """
+
+ sql """ select to_base64(aes_encrypt(k,k)) from quantile_table;""" //ADnRqPtFBjreZu06UTD64g==
+ qt_sql30 """ select aes_decrypt(FROM_BASE64("ADnRqPtFBjreZu06UTD64g=="),k) from quantile_table; """
+
+ sql """ select to_base64(aes_encrypt("zhang","doris")) from quantile_table;""" //fLhlYvn/yZhqd2LTRHImrw==
+ qt_sql31 """ select aes_decrypt(FROM_BASE64("fLhlYvn/yZhqd2LTRHImrw=="),"doris") from quantile_table; """
+
+ sql """ select to_base64(aes_encrypt("zhang",k)) from quantile_table;""" //2C8acACKfoRwHZS5B4juNw==
+ qt_sql32 """ select aes_decrypt(FROM_BASE64("2C8acACKfoRwHZS5B4juNw=="),k) from quantile_table; """
+
+
+
+ sql """ select to_base64(sm4_encrypt(k,"doris")) from quantile_table;""" // 7vSaqYqMl9no8trrzbdAEw==
+ qt_sql29 """ select sm4_decrypt(FROM_BASE64("7vSaqYqMl9no8trrzbdAEw=="),"doris") from quantile_table; """
+
+ sql """ select to_base64(sm4_encrypt(k,k)) from quantile_table;""" // PcPR18T6lhMuFTqQtymb8w==
+ qt_sql30 """ select sm4_decrypt(FROM_BASE64("PcPR18T6lhMuFTqQtymb8w=="),k) from quantile_table; """
+
+ sql """ select to_base64(sm4_encrypt("zhang","doris")) from quantile_table;""" // WY+4o1/cZwAFQ0F6dlyEqQ==
+ qt_sql31 """ select sm4_decrypt(FROM_BASE64("WY+4o1/cZwAFQ0F6dlyEqQ=="),"doris") from quantile_table; """
+
+ sql """ select to_base64(sm4_encrypt("zhang",k)) from quantile_table;""" // lhDiiEnRn3PvY6v4sHES0A==
+ qt_sql32 """ select sm4_decrypt(FROM_BASE64("lhDiiEnRn3PvY6v4sHES0A=="),k) from quantile_table; """
+
+
+ sql "DROP TABLE IF EXISTS quantile_table2"
+ sql"""
+ CREATE TABLE quantile_table2
+ (
+ id int,
+ k string,
+ k1 string,
+ k2 string
+ )
+ ENGINE=OLAP
+ UNIQUE KEY(id)
+ DISTRIBUTED BY HASH(id) BUCKETS 4
+ PROPERTIES (
+ "enable_unique_key_merge_on_write" = "true",
+ "replication_num" = "1"
+ );
+ """
+ sql""" insert into quantile_table2 values(1,"aaaaaa", "key_word", "init_word");"""
+
+ //four arg (column/const)
+ sql """ set block_encryption_mode=""; """ // SM4_128_ECB
+ qt_sql33 """ select sm4_decrypt(sm4_encrypt(k,"doris","abcdefghij", "SM4_128_CBC"),"doris","abcdefghij","SM4_128_CBC") from quantile_table2; """
+ qt_sql34 """ select sm4_decrypt(sm4_encrypt(k,k,"abcdefghij", "SM4_128_CBC"),k,"abcdefghij", "SM4_128_CBC") from quantile_table2; """
+ qt_sql35 """ select sm4_decrypt(sm4_encrypt("zhang","doris","abcdefghij", "SM4_128_CBC"),"doris","abcdefghij", "SM4_128_CBC") from quantile_table2; """
+ qt_sql36 """ select sm4_decrypt(sm4_encrypt("zhang",k,"abcdefghij", "SM4_128_CBC"),k,"abcdefghij", "SM4_128_CBC") from quantile_table2; """
+
+ qt_sql37 """ select sm4_decrypt(sm4_encrypt(k,"doris",k2, "SM4_128_CBC"),"doris",k2,"SM4_128_CBC") from quantile_table2; """
+ qt_sql38 """ select sm4_decrypt(sm4_encrypt(k,k,k2, "SM4_128_CBC"),k,k2, "SM4_128_CBC") from quantile_table2; """
+ qt_sql39 """ select sm4_decrypt(sm4_encrypt("zhang","doris",k2, "SM4_128_CBC"),"doris",k2, "SM4_128_CBC") from quantile_table2; """
+ qt_sql40 """ select sm4_decrypt(sm4_encrypt("zhang",k,k2, "SM4_128_CBC"),k,k2, "SM4_128_CBC") from quantile_table2; """
+
+ qt_sql41 """ select sm4_decrypt(sm4_encrypt(k,k1,k2, "SM4_128_CBC"),k1,k2,"SM4_128_CBC") from quantile_table2; """
+ qt_sql42 """ select sm4_decrypt(sm4_encrypt(k,k1,k2, "SM4_128_CBC"),k1,k2, "SM4_128_CBC") from quantile_table2; """
+ qt_sql43 """ select sm4_decrypt(sm4_encrypt("zhang",k1,k2, "SM4_128_CBC"),k1,k2, "SM4_128_CBC") from quantile_table2; """
+ qt_sql44 """ select sm4_decrypt(sm4_encrypt("zhang",k1,k2, "SM4_128_CBC"),k1,k2, "SM4_128_CBC") from quantile_table2; """
+
+
+ qt_sql45 """ select aes_decrypt(aes_encrypt(k,"doris","abcdefghij", "AES_256_CFB"),"doris","abcdefghij","AES_256_CFB") from quantile_table2; """
+ qt_sql46 """ select aes_decrypt(aes_encrypt(k,k,"abcdefghij", "AES_256_CFB"),k,"abcdefghij", "AES_256_CFB") from quantile_table2; """
+ qt_sql47 """ select aes_decrypt(aes_encrypt("zhang","doris","abcdefghij", "AES_256_CFB"),"doris","abcdefghij", "AES_256_CFB") from quantile_table2; """
+ qt_sql48 """ select aes_decrypt(aes_encrypt("zhang",k,"abcdefghij", "AES_256_CFB"),k,"abcdefghij", "AES_256_CFB") from quantile_table2; """
+
+ qt_sql49 """ select aes_decrypt(aes_encrypt(k,"doris",k2, "AES_256_CFB"),"doris",k2,"AES_256_CFB") from quantile_table2; """
+ qt_sql50 """ select aes_decrypt(aes_encrypt(k,k,k2, "AES_256_CFB"),k,k2, "AES_256_CFB") from quantile_table2; """
+ qt_sql51 """ select aes_decrypt(aes_encrypt("zhang","doris",k2, "AES_256_CFB"),"doris",k2, "AES_256_CFB") from quantile_table2; """
+ qt_sql52 """ select aes_decrypt(aes_encrypt("zhang",k,k2, "AES_256_CFB"),k,k2, "AES_256_CFB") from quantile_table2; """
+
+ qt_sql53 """ select aes_decrypt(aes_encrypt(k,k1,k2, "AES_256_CFB"),k1,k2,"AES_256_CFB") from quantile_table2; """
+ qt_sql54 """ select aes_decrypt(aes_encrypt(k,k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """
+ qt_sql55 """ select aes_decrypt(aes_encrypt("zhang",k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """
+ qt_sql56 """ select aes_decrypt(aes_encrypt("zhang",k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
(doris) 02/02: [fix](encrypt) wrong mode arg of encrypt and decrypt function make BE crash (#40726)
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
commit 4e9d0fb77f187eb549a28982ef8ec6c367aa4d9a
Author: camby <ca...@tencent.com>
AuthorDate: Sat Sep 14 10:18:55 2024 +0800
[fix](encrypt) wrong mode arg of encrypt and decrypt function make BE crash (#40726)
Not supported mode arg in sm4_encrypt and sm4_decrypt make BE crash.
Intro by https://github.com/apache/doris/pull/37194
---
be/src/vec/functions/function_encryption.cpp | 9 ++++++---
.../sql_functions/encryption_digest/test_encryption_function.out | 3 +++
.../encryption_digest/test_encryption_function.groovy | 3 +++
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/functions/function_encryption.cpp b/be/src/vec/functions/function_encryption.cpp
index f63e9bca1b0..06e9efcfea1 100644
--- a/be/src/vec/functions/function_encryption.cpp
+++ b/be/src/vec/functions/function_encryption.cpp
@@ -236,8 +236,9 @@ struct EncryptionAndDecryptTwoImpl {
if (mode_arg.size != 0) {
if (!aes_mode_map.contains(mode_str)) {
all_insert_null = true;
+ } else {
+ encryption_mode = aes_mode_map.at(mode_str);
}
- encryption_mode = aes_mode_map.at(mode_str);
}
const ColumnString::Offsets* offsets_column = &column->get_offsets();
const ColumnString::Chars* chars_column = &column->get_chars();
@@ -346,13 +347,15 @@ struct EncryptionAndDecryptFourImpl {
if constexpr (is_sm_mode) {
if (sm4_mode_map.count(mode_str) == 0) {
all_insert_null = true;
+ } else {
+ encryption_mode = sm4_mode_map.at(mode_str);
}
- encryption_mode = sm4_mode_map.at(mode_str);
} else {
if (aes_mode_map.count(mode_str) == 0) {
all_insert_null = true;
+ } else {
+ encryption_mode = aes_mode_map.at(mode_str);
}
- encryption_mode = aes_mode_map.at(mode_str);
}
}
diff --git a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
index 1a46d127eae..8fafcf22ce0 100644
--- a/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
+++ b/regression-test/data/query_p0/sql_functions/encryption_digest/test_encryption_function.out
@@ -332,3 +332,6 @@ zhang
-- !sql56 --
zhang
+-- !sql57 --
+\N
+
diff --git a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
index 985a2d1b4f7..499bf84936b 100644
--- a/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
+++ b/regression-test/suites/query_p0/sql_functions/encryption_digest/test_encryption_function.groovy
@@ -284,4 +284,7 @@ suite("test_encryption_function") {
qt_sql54 """ select aes_decrypt(aes_encrypt(k,k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """
qt_sql55 """ select aes_decrypt(aes_encrypt("zhang",k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """
qt_sql56 """ select aes_decrypt(aes_encrypt("zhang",k1,k2, "AES_256_CFB"),k1,k2, "AES_256_CFB") from quantile_table2; """
+
+ //four arg (column/const) with wrong mode
+ qt_sql57 """ select sm4_decrypt(sm4_encrypt(k,"doris","abcdefghij", "SM4_128_CBC"),"doris","abcdefghij","SM4_555_CBC") from quantile_table2; """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org