SQL Server
SQL Server
Set the JWE Protected Header
See more JSON Web Encryption (JWE) Examples
Demonstrates Jwe.SetProtectedHeader, which sets the integrity-protected JWE header from a JsonObject. The header specifies the key-management algorithm (alg) and content-encryption algorithm (enc).
Background. The protected header is integrity-protected and applies to all recipients. It is configured before encrypting.
Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @success int
SELECT @success = 0
DECLARE @jwe int
EXEC @hr = sp_OACreate 'Chilkat.Jwe', @jwe OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
-- Build the JWE protected header. The "alg" member names the key-management algorithm and the "enc"
-- member names the content-encryption algorithm.
DECLARE @header int
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @header OUT
EXEC sp_OAMethod @header, 'UpdateString', @success OUT, 'alg', 'A256KW'
EXEC sp_OAMethod @header, 'UpdateString', @success OUT, 'enc', 'A256GCM'
-- Set the protected header on the JWE. The protected header is integrity-protected and applies to
-- all recipients.
EXEC sp_OAMethod @jwe, 'SetProtectedHeader', @success OUT, @header
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @jwe, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @jwe
EXEC @hr = sp_OADestroy @header
RETURN
END
PRINT 'Protected header set.'
EXEC @hr = sp_OADestroy @jwe
EXEC @hr = sp_OADestroy @header
END
GO