SQL Server
SQL Server
Set the S/MIME Encryption Key Length
See more Email Object Examples
Demonstrates the Chilkat Email.Pkcs7KeyLength property, which sets the key length of the symmetric algorithm used for PKCS#7 (S/MIME) encryption. The allowed values depend on Pkcs7CryptAlg: for aes use 128, 192, or 256; for 3des use 192; for des use 40; for rc2 use 40, 56, 64, or 128. The default is 128, and an unsupported algorithm/key-length combination causes encryption to fail. This example pairs AES with a 192-bit key.
Background: Key length is the size, in bits, of the secret key a symmetric cipher uses — a longer key means exponentially more possible keys and thus more resistance to brute-force attack. But length is only meaningful within a given algorithm: AES-128 is already very strong, and a key size must be one the chosen cipher actually supports, which is why
Pkcs7KeyLength and Pkcs7CryptAlg have to agree.Chilkat SQL Server Downloads
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
-- Demonstrates the Email.Pkcs7KeyLength property, which sets the key length (in bits)
-- of the symmetric algorithm used for PKCS#7 (S/MIME) encryption. The allowed values
-- depend on Pkcs7CryptAlg; for aes they are 128, 192, or 256. The default is 128.
DECLARE @email int
EXEC @hr = sp_OACreate 'Chilkat.Email', @email OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OASetProperty @email, 'Pkcs7CryptAlg', 'aes'
EXEC sp_OASetProperty @email, 'Pkcs7KeyLength', 192
EXEC sp_OAGetProperty @email, 'Pkcs7CryptAlg', @sTmp0 OUT
PRINT 'Pkcs7CryptAlg = ' + @sTmp0
EXEC sp_OAGetProperty @email, 'Pkcs7KeyLength', @iTmp0 OUT
PRINT 'Pkcs7KeyLength = ' + @iTmp0
EXEC @hr = sp_OADestroy @email
END
GO