Showing posts with label objects. Show all posts
Showing posts with label objects. Show all posts

Tuesday, March 27, 2012

Encryption Performance

Hi

I am trying to encrypt data using a symmetric key which is encrypted by certificate. I do not want grant control on these objects to the users who wants to decrypt this data. Instead I have created a udf with execute context as "dbo" and used DecryptByKeyAutoCert built-in function.

Now this works fine but large data operations this is extremely slow. It takes around 10 minutes to select decrypted data whic in comparision takes 11 seconds when DecryptByKey function is used.

But I am not sure when DecryptByKey is used, whether the symmetric key is decrypted by the private key of the certificate or not. Can somebody give some explanation of this ?

Also, I can not have a UDF with these following steps

1. Open symmetric key

2. Convert secretdata using DecryptByKey

3. Close Symmetric Key.

4. return decrypted value.

Can some one give some insights on this ?

Can you show the way you call the DecryptByKeyAutoCert and DecryptByKey builtins? Also, how much data are you decrypting - what are the number of rows you select and the size of encrypted data per row?

You cannot create a function to decrypt, but you can create a procedure to decrypt. For example, see the procedure from http://blogs.msdn.com/lcris/archive/2006/01/13/512829.aspx.

Thanks
Laurentiu

|||

Number of rows that I am decrypting is 10000. The record size is 516 bytes

DecryptByKey code:

OPEN SYMMETRIC KEY [Cert_Account_Data_Key] DECRYPTION by certificate [cert_Account_Data]

-- Account table has 10000 records

select account_id,

convert( nvarchar(100), decryptbykey(account_number)) as 'Decrypted Account Number',

convert( nvarchar(100), decryptbykey(account_ssn)) as 'Decrypted Account SSN'

from account_t

CLOSE SYMMETRIC KEY [Cert_Account_Data_Key]

DecryptByCert code:

-- 1. create udf

CREATE FUNCTION [dbo].[udf_Decrypt_Account_Data] (@.Secret_Data VARBINARY(256)) returns nvarchar(100)

WITH EXECUTE AS 'DBO'

AS

begin

-- This return decrypted value for the input data using Account Data

return convert( nvarchar(100), decryptbykeyautocert( cert_id( 'cert_Account_Data' ), null, @.Secret_Data))

end

-- selects decrypted data using Account decryption function

select ACCOUNT_ID,

dbo.udf_Decrypt_Account_Data (ACCOUNT_NUMBER) as 'Decrypted Account Number',

dbo.udf_Decrypt_Account_Data (ACCOUNT_SSN) as 'Decrypted Account SSN'

from ACCOUNT_T

thanks

satya

|||

Using decryptbykeyautocert like this will give abysmal performance. The reason for this is that decryptbykeyautocert is efficient if you use it in a query - it will decrypt the key once and it will keep it open for the duration of the query. By putting the builtin call within a function and calling the function from a query, you are basically forcing the builtin to reopen the key each time the function is called - twice per row in your case, and this represents significant overhead.

You don't need to give CONTROL on the encryption key to a user, for him to be able to use it. It is sufficient to grant him VIEW DEFINITION and add another encryption to the key so that the user can access the key through the new encryption. You can add, for example, another certificate encryption using one of the user's certificates. Then the user will be able to just call decryptbykeyautocert directly, instead of this function, and the query will execute much faster.

Thanks
Laurentiu

Wednesday, March 21, 2012

Encrypting DECRYPTED Stored Procedure.....

Hi
At the moment i don't remember but some times back i found an stored procedure that can DECRYPT
all ENCRYPTED objects in sqlServer2000 ( i will try to put URL here) such as stored procedures,Triggers and even View(s).
Now i'm writing a very confidential StoredProcedure and i don't want to be hack in this way.
Is teher any way to prevent this.Has this Bug been fixed by any of Service Packs.?

Thanks in advance.
Kind Regards.

I think you can easily decrypt SQL encryptions because the SQL rand function is not really random this is not just SQL Server because there are infinite numbers between 6 and 13 but all SQL random functions Oracle and MySQL included can only give you whole numbers which makes it easy to be decrypted. And Microsoft tells you it is not deterministic and not to use it to encrypt anything of value.

That said if you don't want your stored proc decrypted go into the first link and download the free book from Microsoft with ready to use encryption code convert that to CLR stored proc so you know the content cannot be decrypted. The second link is a cleaned up version of the free code in Microsoft book, there are encoding problems with the original code. Hope this helps.

http://msdn2.microsoft.com/en-us/library/aa302415.aspx

http://www.obviex.com/Resources/Samples.aspx

Friday, March 9, 2012

Encrypt and save in a file

Hi,
I want to save my business objects in an encrypted XML file. WHat is the
best way to do it? Examples and links are welcome.
Thank you,
SashaWrong group. I am sorry!
"Sasha" <noemail@.noemail.com> wrote in message
news:ub6fKd%23CEHA.3804@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I want to save my business objects in an encrypted XML file. WHat is the
> best way to do it? Examples and links are welcome.
> Thank you,
> Sasha
>

Wednesday, March 7, 2012

Enabling SQL performance monitoring objects

How do I enable the SQL performance monitoring objects to be used by
performance monitor? The objects were in the list at one time but now they
have vanished?
Best regards
Mark Baldwin
Software Developer
"Mark Baldwin" <swozz_@.hotmail.com> wrote in message
news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> How do I enable the SQL performance monitoring objects to be used by
> performance monitor? The objects were in the list at one time but now they
> have vanished?
> --
> Best regards
> Mark Baldwin
> Software Developer
>
>
I have seen this before in prior versions and it was a matter of rerunning a
particular script from setup disk. I don't remember which one and which
version of SQL Server is applied to.
Here is a KB article however that may be of some use:
http://support.microsoft.com/kb/227662
HTH
Rick Sawtell
MCT, MCSD, MCDBA
|||Counters may disappear when you don't close performance monitor before
restarting SQL Server. See MSKB 812915
<http://support.microsoft.com/default...&Product=sql2k>.
This is scheduled to be fixed in SP4, which is currently in beta
http://support.microsoft.com/default...;en-us;888799.
Hope this helps.
Dan Guzman
SQL Server MVP
"Mark Baldwin" <swozz_@.hotmail.com> wrote in message
news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> How do I enable the SQL performance monitoring objects to be used by
> performance monitor? The objects were in the list at one time but now they
> have vanished?
> --
> Best regards
> Mark Baldwin
> Software Developer
>
>
|||Mark
If you are able to do it, the following may fix your problem.
At the command prompt, type in the following:
unlodctr.exe MSSQLServer
Then type in the following:
lodctr.exe <SQL Server path>\binn\sqlctr.ini
Reboot the server
Hope this helps
John
"Dan Guzman" wrote:

> Counters may disappear when you don't close performance monitor before
> restarting SQL Server. See MSKB 812915
> <http://support.microsoft.com/default...&Product=sql2k>.
> This is scheduled to be fixed in SP4, which is currently in beta
> http://support.microsoft.com/default...;en-us;888799.
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Mark Baldwin" <swozz_@.hotmail.com> wrote in message
> news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
>
>

Enabling SQL performance monitoring objects

How do I enable the SQL performance monitoring objects to be used by
performance monitor? The objects were in the list at one time but now they
have vanished?
Best regards
Mark Baldwin
Software Developer"Mark Baldwin" <swozz_@.hotmail.com> wrote in message
news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> How do I enable the SQL performance monitoring objects to be used by
> performance monitor? The objects were in the list at one time but now they
> have vanished?
> --
> Best regards
> Mark Baldwin
> Software Developer
>
>
I have seen this before in prior versions and it was a matter of rerunning a
particular script from setup disk. I don't remember which one and which
version of SQL Server is applied to.
Here is a KB article however that may be of some use:
http://support.microsoft.com/kb/227662
HTH
Rick Sawtell
MCT, MCSD, MCDBA|||Counters may disappear when you don't close performance monitor before
restarting SQL Server. See MSKB 812915
<http://support.microsoft.com/defaul...b;en-us;888799.
Hope this helps.
Dan Guzman
SQL Server MVP
"Mark Baldwin" <swozz_@.hotmail.com> wrote in message
news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> How do I enable the SQL performance monitoring objects to be used by
> performance monitor? The objects were in the list at one time but now they
> have vanished?
> --
> Best regards
> Mark Baldwin
> Software Developer
>
>|||Mark
If you are able to do it, the following may fix your problem.
At the command prompt, type in the following:
unlodctr.exe MSSQLServer
Then type in the following:
lodctr.exe <SQL Server path>\binn\sqlctr.ini
Reboot the server
Hope this helps
John
"Dan Guzman" wrote:

> Counters may disappear when you don't close performance monitor before
> restarting SQL Server. See MSKB 812915
> <http://support.microsoft.com/defaul...b;en-us;888799.
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Mark Baldwin" <swozz_@.hotmail.com> wrote in message
> news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
>
>

Enabling SQL performance monitoring objects

How do I enable the SQL performance monitoring objects to be used by
performance monitor? The objects were in the list at one time but now they
have vanished?
--
Best regards
Mark Baldwin
Software Developer"Mark Baldwin" <swozz_@.hotmail.com> wrote in message
news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> How do I enable the SQL performance monitoring objects to be used by
> performance monitor? The objects were in the list at one time but now they
> have vanished?
> --
> Best regards
> Mark Baldwin
> Software Developer
>
>
I have seen this before in prior versions and it was a matter of rerunning a
particular script from setup disk. I don't remember which one and which
version of SQL Server is applied to.
Here is a KB article however that may be of some use:
http://support.microsoft.com/kb/227662
HTH
Rick Sawtell
MCT, MCSD, MCDBA|||Counters may disappear when you don't close performance monitor before
restarting SQL Server. See MSKB 812915
<http://support.microsoft.com/default.aspx?scid=kb;en-us;812915&Product=sql2k>.
This is scheduled to be fixed in SP4, which is currently in beta
http://support.microsoft.com/default.aspx?scid=kb;en-us;888799.
Hope this helps.
Dan Guzman
SQL Server MVP
"Mark Baldwin" <swozz_@.hotmail.com> wrote in message
news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> How do I enable the SQL performance monitoring objects to be used by
> performance monitor? The objects were in the list at one time but now they
> have vanished?
> --
> Best regards
> Mark Baldwin
> Software Developer
>
>|||Mark
If you are able to do it, the following may fix your problem.
At the command prompt, type in the following:
unlodctr.exe MSSQLServer
Then type in the following:
lodctr.exe <SQL Server path>\binn\sqlctr.ini
Reboot the server
Hope this helps
John
"Dan Guzman" wrote:
> Counters may disappear when you don't close performance monitor before
> restarting SQL Server. See MSKB 812915
> <http://support.microsoft.com/default.aspx?scid=kb;en-us;812915&Product=sql2k>.
> This is scheduled to be fixed in SP4, which is currently in beta
> http://support.microsoft.com/default.aspx?scid=kb;en-us;888799.
>
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Mark Baldwin" <swozz_@.hotmail.com> wrote in message
> news:XMSdnaHx_r0qLnLcRVn-hQ@.giganews.com...
> > How do I enable the SQL performance monitoring objects to be used by
> > performance monitor? The objects were in the list at one time but now they
> > have vanished?
> >
> > --
> > Best regards
> > Mark Baldwin
> > Software Developer
> >
> >
> >
>
>