我有一个具有5个输入变量的存储过程,其中很少的变量用于更新或比较使用“始终加密”特性加密的表中的列。
"sp_describe_parameter_encryption“过程返回除一个参数之外的所有参数的加密信息,对于该参数,它将其称为普通属性。
因此,这些值被作为“纯文本”传递,这反过来会在执行过程中产生错误。
示例代码
create proc Test
@var1 nvarchar(500),
@var2 nvarchar(500),
@var3 nvarchar(500),
@var4 nvarchar(500),
@var5 nvarchar(500),
AS
BEGIN
SELECT * from Sometable where encryptedColumn=@var1 --works well(var1 is passed as encrypted.)
update Sometable2 SET encryptedColumn=@var2 WHERE <SOMECONDITION> --works well(var 2 is passed as encrypted.))
--some code
--some code
select * from sometable2 where encryptedColumn=@var4
--fails with the following error
--Operand type clash: nvarchar is incompatible with nvarchar(500) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEKName, column_encryption_key_database_name = 'DatabaseName')
--if this query is commented, the proc runs fine
END当执行"sp_describe_parameter_encryption“命令时,变量(Var4)的加密被标记为明文,我希望它返回加密信息,因为它是与加密列进行比较的。
有没有人能提供一些线索,或者告诉我我漏掉了什么?
发布于 2020-02-21 00:35:02
确保所有参数的大小写在客户端和服务器之间完全匹配。在我目前的位置实现AE时,我们发现对sp_describe_parameter_encryption的调用显然对参数是大小写敏感的,如果它们不完全匹配,就会抛出一个模糊的错误。我想不出有什么好的理由,所以希望这只是一个bug。
https://stackoverflow.com/questions/53870780
复制相似问题