VerifySignedByAsymKey (Transact-SQL)
SQL Server 2008
Tests whether digitally signed data has been changed since it was signed.
A. Testing for data with a valid signature
The following example returns 1 if the selected data has not been changed since it was signed with asymmetric key WillisKey74. The example returns 0 if the data has been tampered with.
SELECT Data,
VerifySignedByAsymKey( AsymKey_Id( 'WillisKey74' ), SignedData,
DataSignature ) as IsSignatureValid
FROM [Adventureworks].[SignedData04]
WHERE Description = N'data encrypted by asymmetric key ''WillisKey74'''
GO
RETURN
B. Returning a result set that contains data with a valid signature
The following example returns rows in SignedData04 that contain data that has not been changed since it was signed with asymmetric key WillisKey74. The example calls the function AsymKey_ID to obtain the ID of the asymmetric key from the database.
SELECT Data
FROM [Adventureworks].[SignedData04]
WHERE VerifySignedByAsymKey( AsymKey_Id( 'WillisKey74' ), Data,
DataSignature ) = 1
AND Description = N'data encrypted by asymmetric key ''WillisKey74'''
GO
