-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Encrypting Confidential data with EncryptByKey
PostPosted: Thu Jun 02, 2011 5:05 pm 
Newbie

Joined: Thu Jun 02, 2011 4:36 pm
Posts: 2
Hi,

I am working on an change where I need to encrypt the values being stored to a SQL Server DB. For that I have changed the column 'credit_score' in the DB to varbinary(max) and created certificate and symmetric key like this:

Code:
IF NOT EXISTS (SELECT * FROM sys.symmetric_keys WHERE symmetric_key_id = 101)
    CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'XXXXXXXX'
GO

CREATE CERTIFICATE customer_crypt_cert
   WITH SUBJECT = 'Customer Personal Data Encryption';
GO

CREATE SYMMETRIC KEY customer_value_crypto_key
    WITH ALGORITHM = AES_256
    ENCRYPTION BY CERTIFICATE customer_crypt_cert;
GO


My c# mapping code looks like this:
Code:
base.Map(x => x.CreditScore).Formula(
                "(open symmetric key cim_customer_value_crypto_key decryption by certificate cim_customer_crypt_cert; select encryptbykey(key_guid('cim_customer_value_crypto_key'),credit_score);)");


The mapping hbm files has this code:
Code:
<property name="CreditScore" type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=XXXXXXXX">
      <column name="credit_score" />
    </property>


When I execute the operation, it fails with the message "could not execute batch command.[SQL: SQL not available]". I turned on the sql tracer and the Insert statement was issued, but the credit score value was not in encrypted form.

Where am I going wrong?

Sandeep


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.