473,664 Members | 3,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Practice for storing keys

I am trying to find the best procedure for storing keys used for encryption.

This would also be a question for the connection string to the database. At
the moment, this is kept in the web.info file.

This seems to be norm from all the books on building your Web Apps. Isn't
this a problem as the web.info is cleartext? I would suppose that having
keys (which you would to store/encrypt and get/decrypt from your database)
in this manner would be dangerous.

I am trying to find out how others deal with this. Also, I would need the
same information for my Apps on the same machine.

Thanks,

Tom
Jan 3 '07 #1
10 2054
Han
Hello

Sounds like RSA encription.

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

Note there is one mistake in the example.

<configProtecte dData>
<providers>
<add name="MyProvide r"
type="System.Co nfiguration.Rsa ProtectedConfig urationProvider ,
System.Configur ation, Version=2.0. 0.0,
Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a,
processorArchit ecture=MSIL"
keyContainerNam e="MyKeys"
useMachineConta iner="true" />
</providers>
</configProtected Data>

2.0. 0.0 should be 2.0.0.0.

If you are successful encripting some part of your configuration, the key is
secured with NTFS Access Control Lists. Good luck.

"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>I am trying to find the best procedure for storing keys used for
encryption.

This would also be a question for the connection string to the database.
At
the moment, this is kept in the web.info file.

This seems to be norm from all the books on building your Web Apps. Isn't
this a problem as the web.info is cleartext? I would suppose that having
keys (which you would to store/encrypt and get/decrypt from your database)
in this manner would be dangerous.

I am trying to find out how others deal with this. Also, I would need the
same information for my Apps on the same machine.

Thanks,

Tom


Jan 3 '07 #2
"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>I am trying to find the best procedure for storing keys used for
encryption.
Generally speaking, don't store them at all - devise a mechanism for
generating the same key whenever you need it...
http://msdn.microsoft.com/msdnmag/is...efault.aspx#S9
This seems to be norm from all the books on building your Web Apps. Isn't
this a problem as the web.info is cleartext? I would suppose that having
keys (which you would to store/encrypt and get/decrypt from your database)
in this manner would be dangerous.
I think there's a lot of FUD (fear, uncertainty and doubt) surrounding
this...

Firstly, ask yourself who are you hiding this key from...? Your
colleagues...? Your boss...? The office cleaner...? If you are worried about
whether your fellow employees are trustworthy or not, then you have a much
bigger problem then key encryption...

Secondly, is your website's security so lax that your web.config is visible
to the outside world...? Again, if that is the case, then you have a much
more fundamental problem than key encryption...

Are you perhaps worried about "profession al" hackers...? Again, if a hacker
is clever enough to bypass all your security protection and is able to gain
access to your webserver, it probably won't matter much whether your key is
encrypted or not - they'll crack it...
I am trying to find out how others deal with this. Also, I would need the
same information for my Apps on the same machine.
I have an encryption base class which does TripleDES encrpytion. It has two
methods: Encrypt() and Decrypt(). This class, like all my other base
classes, is shared across all projects and clients.

I also have a key generation class which has one method: GenerateKey(). This
generates the key required for the symmetric encryption, and is different
for every client - sometimes different on a project by project basis for the
same client, if that's what they want.

In this way the actual key is not "stored" anywhere. You might say that the
key could be found by disassembly - or, at least, the mechanism for
generating the key could be found by disassenbly - but I take the view that
if a hacker is determined enough to have disassembled my code, they would
have found the key soon enough anyway...

There has to come a point where it's "secure enough", otherwise you'll never
get anything done...:-)

E.g. can you decrypt this:

HgyxhIIBwBb7zY7 GBH4xlQ==

?
Jan 3 '07 #3
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:ut******** ******@TK2MSFTN GP03.phx.gbl...
"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
>>I am trying to find the best procedure for storing keys used for
encryption.

Generally speaking, don't store them at all - devise a mechanism for
generating the same key whenever you need it...
http://msdn.microsoft.com/msdnmag/is...efault.aspx#S9
>This seems to be norm from all the books on building your Web Apps.
Isn't
this a problem as the web.info is cleartext? I would suppose that having
keys (which you would to store/encrypt and get/decrypt from your
database)
in this manner would be dangerous.

I think there's a lot of FUD (fear, uncertainty and doubt) surrounding
this...
Yes.

But if you store information such as Credit Card or Social Security
information - you want that.
>
Firstly, ask yourself who are you hiding this key from...? Your
colleagues...? Your boss...? The office cleaner...?
Yes.
>If you are worried about whether your fellow employees are trustworthy or
not, then you have a much bigger problem then key encryption...

Secondly, is your website's security so lax that your web.config is
visible to the outside world...? Again, if that is the case, then you have
a much more fundamental problem than key encryption...
Even if your security is good - people do get in. Ours is pretty secure but
as you mention below the Professional Hackers may find a way in.
>
Are you perhaps worried about "profession al" hackers...? Again, if a
hacker is clever enough to bypass all your security protection and is able
to gain access to your webserver, it probably won't matter much whether
your key is encrypted or not - they'll crack it...
>I am trying to find out how others deal with this. Also, I would need
the
same information for my Apps on the same machine.

I have an encryption base class which does TripleDES encrpytion. It has
two methods: Encrypt() and Decrypt(). This class, like all my other base
classes, is shared across all projects and clients.
This is what I do.
I also have a key generation class which has one method: GenerateKey().
This generates the key required for the symmetric encryption, and is
different for every client - sometimes different on a project by project
basis for the same client, if that's what they want.
At the moment, I am creating one key for all clients. Just a random set of
letters, numbers and special characters. This is passed to both the Encrypt
and Decrypt functions.

I would only be Generating the Key once (or else I would never be able to
decrypt the data). You would have to store something somewhere for the
program to use it (either the data to Generate the Key from or the Key
itself).
In this way the actual key is not "stored" anywhere. You might say that
the key could be found by disassembly - or, at least, the mechanism for
generating the key could be found by disassenbly - but I take the view
that if a hacker is determined enough to have disassembled my code, they
would have found the key soon enough anyway...

There has to come a point where it's "secure enough", otherwise you'll
never get anything done...:-)
I agree here.

I just want to find a pretty reasonable solution.

Thanks,

Tom
>
E.g. can you decrypt this:

HgyxhIIBwBb7zY7 GBH4xlQ==

?

Jan 3 '07 #4
"tshad" <ts**********@f tsolutions.comw rote in message
news:uK******** *****@TK2MSFTNG P03.phx.gbl...
Even if your security is good - people do get in. Ours is pretty secure
but as you mention below the Professional Hackers may find a way in.
And you will never eliminate that threat 100%...
I would only be Generating the Key once (or else I would never be able to
decrypt the data). You would have to store something somewhere for the
program to use it (either the data to Generate the Key from or the Key
itself).
NO! And that's the whole point! You don't "store" anything anywhere - you
just devise a routine / algorithm / whatever which always generates the same
key...
>There has to come a point where it's "secure enough", otherwise you'll
never get anything done...:-)

I agree here.

I just want to find a pretty reasonable solution.
Well, there's an argument which says that there comes a point where your
data is *so* sensitive that access to it over the (public) Internet is
always going to be the wrong solution, irrespective of the technology you
use... That's why e.g. hashes are salted, otherwise I could simply steal
your database, get myself a copy of the Oxford English and use every word in
it as the key until I found a match in your encrypted data. You might think
that's an extreme example (and you'd be right!), but with the power of
computers these days, that might be only a few hours' work...
Jan 3 '07 #5
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:u5******** ******@TK2MSFTN GP04.phx.gbl...
"tshad" <ts**********@f tsolutions.comw rote in message
news:uK******** *****@TK2MSFTNG P03.phx.gbl...
>Even if your security is good - people do get in. Ours is pretty secure
but as you mention below the Professional Hackers may find a way in.

And you will never eliminate that threat 100%...
I'm not trying to do that. Just don't want to do something simple like
base64 :)
>
>I would only be Generating the Key once (or else I would never be able to
decrypt the data). You would have to store something somewhere for the
program to use it (either the data to Generate the Key from or the Key
itself).

NO! And that's the whole point! You don't "store" anything anywhere - you
just devise a routine / algorithm / whatever which always generates the
same key...
But then what are you using to Generate the Key? It needs to come from
somewhere, doesn't it? You need to use the same key to decrypt the data.
In your GenerateKey() don't you pass it something? That would have to be
stored somewhere.

Tom
>>There has to come a point where it's "secure enough", otherwise you'll
never get anything done...:-)

I agree here.

I just want to find a pretty reasonable solution.

Well, there's an argument which says that there comes a point where your
data is *so* sensitive that access to it over the (public) Internet is
always going to be the wrong solution, irrespective of the technology you
use... That's why e.g. hashes are salted, otherwise I could simply steal
your database, get myself a copy of the Oxford English and use every word
in it as the key until I found a match in your encrypted data. You might
think that's an extreme example (and you'd be right!), but with the power
of computers these days, that might be only a few hours' work...

Jan 3 '07 #6
"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** **********@TK2M SFTNGP06.phx.gb l...
>NO! And that's the whole point! You don't "store" anything anywhere - you
just devise a routine / algorithm / whatever which always generates the
same key...
But then what are you using to Generate the Key?
An algorithm which always generates the same string.
It needs to come from somewhere, doesn't it?
Yes - itself.
You need to use the same key to decrypt the data.
That's right.
In your GenerateKey() don't you pass it something?
No.
That would have to be stored somewhere.
I guess it would - if that's actually what I was doing... :-)

E.g.

private string GenerateKey()
{
return (2 + 2).ToString();
}
Jan 3 '07 #7

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:eB******** ********@TK2MSF TNGP06.phx.gbl. ..
"tshad" <ts**********@f tsolutions.comw rote in message
news:%2******** **********@TK2M SFTNGP06.phx.gb l...
>>NO! And that's the whole point! You don't "store" anything anywhere -
you just devise a routine / algorithm / whatever which always generates
the same key...
But then what are you using to Generate the Key?

An algorithm which always generates the same string.
>It needs to come from somewhere, doesn't it?

Yes - itself.
>You need to use the same key to decrypt the data.

That's right.
>In your GenerateKey() don't you pass it something?

No.
>That would have to be stored somewhere.

I guess it would - if that's actually what I was doing... :-)

E.g.

private string GenerateKey()
{
return (2 + 2).ToString();
}
But this wouldn't work for each customer if each customer had to have a
different key, would it?

Tom
Jan 3 '07 #8
"tshad" <ts**********@f tsolutions.comw rote in message
news:un******** *****@TK2MSFTNG P02.phx.gbl...
>private string GenerateKey()
{
return (2 + 2).ToString();
}
But this wouldn't work for each customer if each customer had to have a
different key, would it?
???

The encryption base class is constant across all clients and projects.

The key generation class is specific to each client and/or each project.

Jan 3 '07 #9
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
"tshad" <ts**********@f tsolutions.comw rote in message
news:un******** *****@TK2MSFTNG P02.phx.gbl...
>>private string GenerateKey()
{
return (2 + 2).ToString();
}
But this wouldn't work for each customer if each customer had to have a
different key, would it?

???

The encryption base class is constant across all clients and projects.

The key generation class is specific to each client and/or each project.
So you have a different class for each client/project? Where do you get the
value that you are returning for each client? Is it just some random
number?

Tom
Jan 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3444
by: Harold Crump | last post by:
Greetings, I have a requirement of storing some .xml files on a web server. The files will contain financial information like credit card numbers, so I would like to encrypt them. The files will stay there until another program downloads them and deletes the files. My question is - which of the functions in the mcrypt library provide
2
1474
by: Sjaakie Helderhorst | last post by:
Hi, What's the best way of storing a dataset (+/-1000 rows, 9 columns)? I'm using a session-variable but this seems to have serious impact on performance. It's a shop and I'm using the same dataset (added an 'amount' cell) to generate a dataview for basket Most users will use the shop to order at 5pm (about 800 users), so I want to keep server-stress within acceptable parameters. Any help or suggestion is appreciated.
17
8028
by: | last post by:
I have an app that retrieves data from an Access database. At the moment I have the SQL string as a Const in my app. I understand this is not best practice. I don't want the user to have access to read or modify this string so I don't want to store it in an INI / Text file or in registery. Can someone please tell me the best practice for this. Thanks Mike
0
1693
by: Louis Aslett | last post by:
I hope this is the correct newsgroup for this query (if not please give me a pointer to where is best): I understand the theory of normalisation etc and am trying to follow best practices in the design of the database for a new project, but I am unsure as to the best practice when one wants to store data relating to combinations of arbitrary numbers of sets of data. For example, take the following two groups of sets, each containing...
18
2910
by: Bob Stearns | last post by:
I'm building a web based auction system for multiple clients. I have auctions, items, and invoices I need to assign generated keys for. Since each of these entities is represented by a table, the keys are assigned as GENERATED BY DEFAULT. While this works, and is easy to reference programmatically, I wonder if it is the best technique. All of the keys are drawn from one sequence, not depending on the customer or the specific auction. Would...
9
7287
by: david | last post by:
I have a class with some business-logic and with every roundtrip, I need an instance of this class, so I have to create it, every time again. That doesn't seem very efficient. I thought it would be 'better' to store an instance of this class in a session-variable, so it's available all the time and needs to be instanced only once. Is this, generally speaking, a good idea, storing objects in session-variables ? Do you guys ever use this...
8
7471
by: redeagle | last post by:
I'm wondering what the best practice is for creating a WinApp "wizard" that contains 4 or 5 "steps". Options so far are 1) Single WinForm making various controls visible/non visible at the different steps(although that may get cluttered in the design environment) 2) Create multiple WinForms (don't really know any pros or cons of this method) 3) Use a tabbed page (although I don't want to see any tabs)
7
19726
by: Tzanko | last post by:
As we all know, there is a 8060 bytes size limit on SQL Server rows. I have a table which requires a number of text fields (5 or 6). Each of these text fields should support a max of 4000 characters. We currently store the data in varchar columns, which worked fine untill our appetite for text fields increased to the current requirement of 5, 6 fields of 4000 characters size. I am given to review a design, which esentially suggests moving...
3
4022
by: at_the_gonq | last post by:
Hello, I am hoping to get some guidance on the following scenerio: I have a password protected site where users have various permissions. Are sessions the best way of storing the user's id? And if so, on load of a page should I be hitting the database for their permissions (based on the session stored user id), or should everything I need be stored in session variables to save the trip to the database? I have also wondered about...
0
8437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8861
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7375
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2764
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.