diff --git a/e2e_test/streaming/encrypt.slt b/e2e_test/streaming/encrypt.slt index e69de29bb2d1d..cc2cb3b09ff6b 100644 --- a/e2e_test/streaming/encrypt.slt +++ b/e2e_test/streaming/encrypt.slt @@ -0,0 +1,26 @@ +query T +SELECT encrypt('\x00112233445566778899aabbccddeeff','\x000102030405060708090a0b0c0d0e0f','aes-ecb/pad:none') +---- +\x69c4e0d86a7b0430d8cdb78070b4c55a + +query T +SELECT encrypt('\x00112233445566778899aabbccddeeff','\x000102030405060708090a0b0c0d0e0f1011121314151617','aes-ecb/pad:none'); +---- +\xdda97ca4864cdfe06eaf70a0ec0d7191 + +query T +SELECT encrypt('\x00112233445566778899aabbccddeeff','\x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f','aes-ecb/pad:none') +---- +\x8ea2b7ca516745bfeafc49904b496089 + +query T +SELECT encrypt('\x00112233445566778899aabbccddeeff','\x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f','aes-cbc/pad:none') +---- +\x8ea2b7ca516745bfeafc49904b496089 + +# input not multiple of block size when not allowing padding +statement error +SELECT encrypt('\x00112233445566778899aabbccddeeff00','\x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f','aes-cbc/pad:none') + + + diff --git a/src/expr/impl/src/scalar/encrypt.rs b/src/expr/impl/src/scalar/encrypt.rs index d54a07cb06b2b..0603733c47cc1 100644 --- a/src/expr/impl/src/scalar/encrypt.rs +++ b/src/expr/impl/src/scalar/encrypt.rs @@ -230,20 +230,16 @@ mod test { let config = CipherConfig::parse_cipher_config(key, mode)?; decrypt(data, &config) }; + let key = b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"; let encrypted = encrypt_wrapper( b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + key, "aes-ecb/pad:none", ) .unwrap(); - let decrypted = decrypt_wrapper( - &encrypted, - b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0e", - "aes-ecb/pad:none", - ) - .unwrap(); + let decrypted = decrypt_wrapper(&encrypted, key, "aes-ecb/pad:none").unwrap(); assert_eq!( decrypted, (*b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff").into() diff --git a/src/frontend/src/binder/expr/function.rs b/src/frontend/src/binder/expr/function.rs index ddc2100db0ffe..36bf9b32ce039 100644 --- a/src/frontend/src/binder/expr/function.rs +++ b/src/frontend/src/binder/expr/function.rs @@ -873,6 +873,8 @@ impl Binder { ("sha256", raw_call(ExprType::Sha256)), ("sha384", raw_call(ExprType::Sha384)), ("sha512", raw_call(ExprType::Sha512)), + ("encrypt", raw_call(ExprType::Encrypt)), + ("decrypt", raw_call(ExprType::Decrypt)), ("left", raw_call(ExprType::Left)), ("right", raw_call(ExprType::Right)), ("int8send", raw_call(ExprType::PgwireSend)),