#CRYPT_VERIFY
CRYPT_VERIFY函数以expr3为签名者需要提供的公钥、以expr4为签名公钥的算法类型、以expr5为签名者的签名ID对expr1的数据和expr2的签名进行验签,返回验签的结果TRUE或FALSE。
返回结果为TRUE表示验签通过,为FALSE则表示验签失败。
本函数遵循如下规则:
expr1数据只支持VARCHAR/CHAR类型。
expr2是CRYPT_SIGN函数的输出结果。
expr3是HEX格式的签名公钥,可以通过CRYPT_KEY函数创建相应的公私钥对。若不指定则函数报错。
expr4是验签的算法类型,目前仅支持SM2类型的签名和验签。
expr1或expr2为null时验签失败,返回FALSE。
示例
SELECT CRYPT_KEY('sm2') FROM dual;
CRYPT_KEY('SM2')
----------------------------------------------------------------
PUBLIC:7CB4E274EC64D0AC2BBEC9641731E3A88BF1959572BCDB19C7A3574FC0A6C0DEF3F12B4273F1085EFA96E22415869358EA04DC49590E3464DF6DC85898E38271;PRIVATE:7048688F3345C89E90F5B1E99DED97B5901A01F1C650A99CA752088E1CE22CAA
SELECT CRYPT_SIGN('how are you? I am fine, thank you', '7048688F3345C89E90F5B1E99DED97B5901A01F1C650A99CA752088E1CE22CAA', 'sm2', 'lilei') signature FROM dual;
SIGNATURE
----------------------------------------------------------------
3046022100B8D8BF5A2E44575BE2B02AC0BE904867D61A605981E5AE324FF79A47C68C55DA022100B6F690EC9DBC64C68AEBF46D0A4383D99D12B516BF297E7A248AD2B9624709D7
SELECT CRYPT_VERIFY('how are you? I am fine, thank you', '3046022100B8D8BF5A2E44575BE2B02AC0BE904867D61A605981E5AE324FF79A47C68C55DA022100B6F690EC9DBC64C68AEBF46D0A4383D99D12B516BF297E7A248AD2B9624709D7', '7CB4E274EC64D0AC2BBEC9641731E3A88BF1959572BCDB19C7A3574FC0A6C0DEF3F12B4273F1085EFA96E22415869358EA04DC49590E3464DF6DC85898E38271', 'sm2', 'lilei') verify_result FROM dual;
VERIFY_RESULT
-------------
true
SELECT CRYPT_VERIFY('how are you? I am fine, thank you', '3046022100B8D8BF5A2E44575BE2B02AC0BE904867D61A605981E5AE324FF79A47C68C55DA022100B6F690EC9DBC64C68AEBF46D0A4383D99D12B516BF297E7A248AD2B9624709D7', '7CB4E274EC64D0AC2BBEC9641731E3A88BF1959572BCDB19C7A3574FC0A6C0DEF3F12B4273F1085EFA96E22415869358EA04DC49590E3464DF6DC85898E38271', 'sm2', 'hanmeimei') verify_result FROM dual;
VERIFY_RESULT
-------------
false