-->
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.  [ 5 posts ] 
Author Message
 Post subject: Question regarding native SQL queries
PostPosted: Sat Apr 15, 2006 12:04 pm 
Newbie

Joined: Thu Apr 13, 2006 6:57 pm
Posts: 3
Hi,

In the <sql-insert> and <sql-update> i call the aes_encrypt function in MySQL to encrpt.

<sql-insert>
INSERT INTO user (first_name, userID) VALUES (aes_encrypt(?, 'This is my encryption key'), ?)
</sql-insert>

<sql-update>UPDATE user SET first_name = aes_encrypt(?, 'This is my encryption key') WHERE userID=?</sql-update>

This approach works and i am able to encrpt the data. Now my problem is to move out the key from the mapping file. I have lot of information that needsto be encrypted and also for security reasons.

Is this allowed,

<sql-update>UPDATE user SET first_name = aes_encrypt(?, :key) WHERE userID=?</sql-update>

Iam not sure how to set the parameter value for :key in the code.

I would appreciate any help on this.

Chandrika


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 15, 2006 4:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, that is not directly possible.

...but why not just encrypt the hbm.xml files or something ?
How are you going to ensure the key is "safe" if you could use a parameter?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 12:15 pm 
Newbie

Joined: Thu Apr 13, 2006 6:57 pm
Posts: 3
Hi Max,

Thanks for the reply.


max wrote:
no, that is not directly possible.

...but why not just encrypt the hbm.xml files or something ?
How are you going to ensure the key is "safe" if you could use a parameter?


I have to figure out that yet. May be store the key itself in the database.
There is lot of data in my tables that need to be encrypted I have around 15 columns to encrypt in one table. Also i have to repeat this for both <sql-update> and <sql-insert>. And if we decide to change the key in future. We have to change in all the places.

Can you point to any documentation regarding encrypting the .hbm files. After encrypting the file, how does hibernate read an encrypted .hbm file.

Thanks
Chandrika


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 12:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
just encrypt it with something that you find secure and then decrypt them in memory and add them programmatically to hibernate configuration.

or alternatively just insert some tokenmarkers, e.g. @MY_SECRET_KEY@ and then string-replace them before adding them to hibernate configuration.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 16, 2006 12:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
always remember that you can *always* theroetically crack a system, but it is just not worth it protecting it 150% since it is very seldom that it in practice can be cracked....and why is it you don't just write some insert/update triggers to encrypt/decrypt this ?

_________________
Max
Don't forget to rate


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

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.