@@ -645,11 +645,7 @@ private String paramsToSql() {
645
645
&& (fnName .getFunction ().equalsIgnoreCase ("aes_decrypt" )
646
646
|| fnName .getFunction ().equalsIgnoreCase ("aes_encrypt" )
647
647
|| fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt" )
648
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )
649
- || fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )
650
- || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )
651
- || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )
652
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" ))) {
648
+ || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" ))) {
653
649
sb .append ("\' ***\' " );
654
650
} else if (orderByElements .size () > 0 && i == len - orderByElements .size ()) {
655
651
sb .append ("ORDER BY " );
@@ -734,22 +730,13 @@ private String paramsToDigest() {
734
730
if (fnName .getFunction ().equalsIgnoreCase ("aes_decrypt" )
735
731
|| fnName .getFunction ().equalsIgnoreCase ("aes_encrypt" )
736
732
|| fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt" )
737
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )
738
- || fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )
739
- || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )
740
- || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )
741
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" )) {
733
+ || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )) {
742
734
len = len - 1 ;
743
735
}
744
736
for (int i = 0 ; i < len ; ++i ) {
745
737
if (i == 1 && (fnName .getFunction ().equalsIgnoreCase ("aes_decrypt" )
746
738
|| fnName .getFunction ().equalsIgnoreCase ("aes_encrypt" )
747
- || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt" )
748
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )
749
- || fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )
750
- || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )
751
- || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )
752
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" ))) {
739
+ || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt" ))) {
753
740
result .add ("\' ***\' " );
754
741
} else {
755
742
result .add (children .get (i ).toDigest ());
@@ -1152,13 +1139,8 @@ private void analyzeBuiltinAggFunction(Analyzer analyzer) throws AnalysisExcepti
1152
1139
if ((fnName .getFunction ().equalsIgnoreCase ("aes_decrypt" )
1153
1140
|| fnName .getFunction ().equalsIgnoreCase ("aes_encrypt" )
1154
1141
|| fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt" )
1155
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )
1156
- || fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )
1157
- || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )
1158
- || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )
1159
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" ))
1142
+ || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" ))
1160
1143
&& (children .size () == 2 || children .size () == 3 )) {
1161
- String blockEncryptionMode = "" ;
1162
1144
Set <String > aesModes = new HashSet <>(Arrays .asList (
1163
1145
"AES_128_ECB" ,
1164
1146
"AES_192_ECB" ,
@@ -1192,80 +1174,33 @@ private void analyzeBuiltinAggFunction(Analyzer analyzer) throws AnalysisExcepti
1192
1174
"SM4_128_OFB" ,
1193
1175
"SM4_128_CTR" ));
1194
1176
1177
+ String blockEncryptionMode = "" ;
1195
1178
if (ConnectContext .get () != null ) {
1196
1179
blockEncryptionMode = ConnectContext .get ().getSessionVariable ().getBlockEncryptionMode ();
1197
1180
if (fnName .getFunction ().equalsIgnoreCase ("aes_decrypt" )
1198
- || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt" )
1199
- || fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )
1200
- || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )) {
1181
+ || fnName .getFunction ().equalsIgnoreCase ("aes_encrypt" )) {
1201
1182
if (StringUtils .isAllBlank (blockEncryptionMode )) {
1202
1183
blockEncryptionMode = "AES_128_ECB" ;
1203
1184
}
1204
1185
if (!aesModes .contains (blockEncryptionMode .toUpperCase ())) {
1205
1186
throw new AnalysisException ("session variable block_encryption_mode is invalid with aes" );
1206
1187
}
1207
- if (children .size () == 2 ) {
1208
- boolean isECB = blockEncryptionMode .equalsIgnoreCase ("AES_128_ECB" )
1209
- || blockEncryptionMode .equalsIgnoreCase ("AES_192_ECB" )
1210
- || blockEncryptionMode .equalsIgnoreCase ("AES_256_ECB" );
1211
- if (fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )) {
1212
- if (!isECB ) {
1213
- throw new AnalysisException (
1214
- "Incorrect parameter count in the call to native function 'aes_decrypt'" );
1215
- }
1216
- } else if (fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )) {
1217
- if (!isECB ) {
1218
- throw new AnalysisException (
1219
- "Incorrect parameter count in the call to native function 'aes_encrypt'" );
1220
- }
1221
- } else {
1222
- // if there are only 2 params, we need set encryption mode to AES_128_ECB
1223
- // this keeps the behavior consistent with old doris ver.
1224
- blockEncryptionMode = "AES_128_ECB" ;
1225
- }
1226
- }
1227
1188
}
1228
1189
if (fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt" )
1229
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )
1230
- || fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )
1231
- || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" )) {
1190
+ || fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt" )) {
1232
1191
if (StringUtils .isAllBlank (blockEncryptionMode )) {
1233
1192
blockEncryptionMode = "SM4_128_ECB" ;
1234
1193
}
1235
1194
if (!sm4Modes .contains (blockEncryptionMode .toUpperCase ())) {
1236
1195
throw new AnalysisException (
1237
1196
"session variable block_encryption_mode is invalid with sm4" );
1238
1197
}
1239
- if (children .size () == 2 ) {
1240
- if (fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )) {
1241
- throw new AnalysisException (
1242
- "Incorrect parameter count in the call to native function 'sm4_decrypt'" );
1243
- } else if (fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" )) {
1244
- throw new AnalysisException (
1245
- "Incorrect parameter count in the call to native function 'sm4_encrypt'" );
1246
- } else {
1247
- // if there are only 2 params, we need add an empty string as the third param
1248
- // and set encryption mode to SM4_128_ECB
1249
- // this keeps the behavior consistent with old doris ver.
1250
- children .add (new StringLiteral ("" ));
1251
- blockEncryptionMode = "SM4_128_ECB" ;
1252
- }
1253
- }
1254
1198
}
1199
+ } else {
1200
+ throw new AnalysisException ("cannot get session variable `block_encryption_mode`, "
1201
+ + "please explicitly specify by using 4-args function" );
1255
1202
}
1256
- if (!blockEncryptionMode .equals (children .get (children .size () - 1 ).toString ())) {
1257
- children .add (new StringLiteral (blockEncryptionMode ));
1258
- }
1259
-
1260
- if (fnName .getFunction ().equalsIgnoreCase ("aes_decrypt_v2" )) {
1261
- fnName = FunctionName .createBuiltinName ("aes_decrypt" );
1262
- } else if (fnName .getFunction ().equalsIgnoreCase ("aes_encrypt_v2" )) {
1263
- fnName = FunctionName .createBuiltinName ("aes_encrypt" );
1264
- } else if (fnName .getFunction ().equalsIgnoreCase ("sm4_decrypt_v2" )) {
1265
- fnName = FunctionName .createBuiltinName ("sm4_decrypt" );
1266
- } else if (fnName .getFunction ().equalsIgnoreCase ("sm4_encrypt_v2" )) {
1267
- fnName = FunctionName .createBuiltinName ("sm4_encrypt" );
1268
- }
1203
+ children .add (new StringLiteral (blockEncryptionMode ));
1269
1204
}
1270
1205
}
1271
1206
0 commit comments