Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««678910»»»

Encrypt SSN Example (TDE) Expand / Collapse
Author
Message
Posted Thursday, July 17, 2014 1:08 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 10:57 PM
Points: 4,241, Visits: 4,290
Why is it necessary to open a new session?

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1593805
Posted Thursday, July 17, 2014 1:16 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 6:33 AM
Points: 2,003, Visits: 5,470
[quote]Welsh Corgi (7/17/2014)
Why is it necessary to open a new session?[/quote

To make certain it works across sessions, logins etc.. The solution is no good if it doesn't


Just a word of advice, read all the comments and posts posted so far and raise questions on any issue where in doubt, we certainly do not want to find you in the situation where you have encrypted all the values, overwritten the clear text and not being able to decrypt/read the values!
Post #1593807
Posted Thursday, July 17, 2014 1:43 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 10:57 PM
Points: 4,241, Visits: 4,290
Thanks for the advise.


I will do so.

In this case I'm Truncating and re-loading the Data from an AS400 nightly.

Thanks again.


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1593817
Posted Friday, July 18, 2014 4:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:24 AM
Points: 7,740, Visits: 9,488
Welsh Corgi (7/16/2014)
I need to add to a Data Transformation task to Load to Staging.

I need o update the existing record to the encrypted value so I need to add an addition column.


Can I use that simple Update statement to do a mass update?

Yes.


Tom
Post #1593966
Posted Friday, July 18, 2014 4:12 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:24 AM
Points: 7,740, Visits: 9,488
Ed Wagner (7/16/2014)
The encryption part stands alone. Once you have it working and understand it, then add in the other parts you need in your solution. This is the "divide and conquer" approach of problem-solving.

Encrypted data works like any other data, so you can do your update and be done with it. You can still manipulate your table like any other table, but you have to allow for the encryption if you copy it across different servers. That's the part about knowing the big picture.

What's next? If you want to do something in SSIS, I'm going to bow out quickly. I can't do much beyond spelling it, and I've gotten that wrong a couple of times.

But the one thing to remember is not to encrypt in place: if you have teh unencrypted SSNs, the first step is to add a column for the encrypted SSNs. Next put the encrypted SSNs in the new column without changing the old column, then check that everything works using the encrypted column, and when it does all work (and not before) delete the old column.


Tom
Post #1593968
Posted Friday, July 18, 2014 4:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:24 AM
Points: 7,740, Visits: 9,488
Welsh Corgi (7/17/2014)
I recreated and opened the key. It decrypts from the same session but when I go to another session it list null.

Every time you create a key, you get a different one. So don't delete it except when you are intentionally replacing it, and even then proceed with caution - perhaps as described below.

If your stuff is encrypted and you lose the key, you can't decrypt it; if you are changing your key and/or your certificate make sure you have the new key, update by decrypting with the old key and encrypting with the new key (and then checking it's all ok) before dropping the old one. And again, add a column so you don't do it in place, then rename the columns so that the old one has a different name and the new one has the name the old one used to have, and check that everything still works; if it does, then you can delete the (renamed) old column and the old key and certificate.


Tom
Post #1593973
Posted Friday, July 18, 2014 6:13 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 10:57 PM
Points: 4,241, Visits: 4,290
Thank you Tom for all of your advise, very much appreciated.

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1594004
Posted Friday, July 18, 2014 10:36 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 10:57 PM
Points: 4,241, Visits: 4,290
I'm having a weird problem.

I do not have it in one AS400 Library within SSIS but when I go to another I get an error that the column does not exist. The column exist.

[quote][/
[Execute SQL Task] Error: Executing the query "IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WH..." failed with the following error: "Invalid column name 'ENCR_TAX_ID_NUMBER'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
quote]

I execute the code in SSMS and no errors.

IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE name = 'AES257SecureSymmetricKey')
BEGIN
CREATE SYMMETRIC KEY AES257SecureSymmetricKey
WITH ALGORITHM = AES_256
ENCRYPTION BY PASSWORD = N'StrongP@ssw0rd!';
END


OPEN SYMMETRIC KEY AES257SecureSymmetricKey
DECRYPTION BY PASSWORD = N'StrongP@ssw0rd!';

UPDATE POINT_CYP.AGENT_SUPPORT
SET ENCR_TAX_ID_NUMBER = EncryptByKey(Key_GUID('AES257SecureSymmetricKey'), convert(varbinary(68), TAX_ID_NUMBER))
,TAX_ID_NUMBER = '**********';

CLOSE SYMMETRIC KEY AES257SecureSymmetricKey;

No comprede?





For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1594152
Posted Friday, July 18, 2014 10:53 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 10:57 PM
Points: 4,241, Visits: 4,290
It was not but is now returning null values from SSMS. I did was change the encryption key.


For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1594160
Posted Friday, July 18, 2014 5:54 PM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 10:57 PM
Points: 4,241, Visits: 4,290
s soon as I open The key it fails in SSIS but it works inSSMS?

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

Post #1594274
« Prev Topic | Next Topic »

Add to briefcase «««678910»»»

Permissions Expand / Collapse