存储密钥的最佳实践 [英] Best Practice for storing keys

查看:56
本文介绍了存储密钥的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到存储用于加密的密钥的最佳程序。


这也是数据库连接字符串的问题。在

,这一刻保存在web.info文件中。


这似乎是所有关于构建Web应用程序的书籍的标准。这个问题不是因为web.info是明文的吗?我认为拥有

键(你要存储/加密并从数据库中获取/解密)
以这种方式
将是危险的。


我试图找出其他人如何处理这件事。另外,我需要在同一台机器上为我的应用程序提供

相同的信息。


谢谢,


汤姆

解决方案

你好


听起来像RSA encription。

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


注意示例中有一个错误。


< configProtectedData>

< providers>

< add name =" MyProvider"

type =" System.Configuration.RsaProtectedConfigurati onProvider,

System.Configuration,版本= 2.0。 0.0,

Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,

processorArchitecture = MSIL"

keyContainerName =" MyKeys"

useMachineContainer =" true" />

< / providers>

< / configProtectedData>


2.0。 0.0应该是2.0.0.0。


如果您成功编写了配置的某些部分,则使用NTFS访问控制列表确保密钥为

。祝你好运。


" tshad" < ts ********** @ ftsolutions.comwrote in message

news:%2 **************** @ TK2MSFTNGP03。 phx.gbl ...


>我正在尝试找到用于存储用于加密的密钥的最佳程序。

这也是数据库连接字符串的问题。

此时

,这保存在web.info文件中。


这似乎是关于构建Web应用程序的所有书籍的标准。这个问题不是因为web.info是明文的吗?我认为拥有

键(你要存储/加密并从数据库中获取/解密)
以这种方式
将是危险的。


我试图找出其他人如何处理这件事。另外,我需要在同一台机器上为我的应用程序提供

相同的信息。


谢谢,


Tom



" tshad" < ts ********** @ ftsolutions.comwrote in message

news:%2 **************** @ TK2MSFTNGP03。 phx.gbl ...


>我正在尝试找到存储用于
加密的密钥的最佳程序。



一般来说,根本不存储它们 - 设计一个机制,每当你需要它时会产生相同的密钥。 。
http:/ /msdn.microsoft.com/msdnmag/is...efault.aspx#S9


这似乎是关于建立你的所有书籍的标准网络应用。这个问题不是因为web.info是明文的吗?我认为拥有

键(你要存储/加密并从数据库中获取/解密)
以这种方式
将是危险的。



我认为有很多FUD(恐惧,不确定和怀疑)围绕

这个......


首先,问问自己是谁隐藏了这把钥匙......?你的

同事......?你的老板...?办公室清洁工......?如果你担心你的同事是否值得信赖,那么你有一个更大的问题然后是密钥加密......

其次,你的网站的安全性如此宽松,以至于你的web.config是可见的

对外界......?再说一遍,如果是这样的话,那么你有一个比密钥加密更基本的问题...


你是否担心专业? ;黑客...?再说一次,如果一个黑客

足够聪明,可以绕过你所有的安全保护并且能够获得对你的网络服务器的访问权限,那么你的网络服务器是否可能无关紧要关键是

加密与否 - 他们会破解它...


我试图找出别人如何处理这个问题。另外,我需要在同一台机器上为我的应用程序提供相同的

信息。



我有一个加密基类,可以进行TripleDES加密。它有两个

方法:Encrypt()和Decrypt()。所有项目和客户都共享这个课程,就像我所有的其他基础

课程一样。


我还有一个密钥生成类,它有一个方法: GenerateKey()。这个

生成对称加密所需的密钥,并且对于每个客户来说都是不同的
- 有时在项目基础上不同的

同一个客户,如果那是他们想要的。


这样,实际的密钥不会被存储。任何地方。您可能会说通过反汇编可以找到

键 - 或者至少可以通过disassenbly找到生成密钥的机制来生成密钥 - 但我认为那个

如果一个黑客确定已经拆解了我的代码,那么他们就会很快就能找到钥匙......


必须有一个足够安全的地方,否则你将永远不会...... b $ b得到任何东西...... :-)

例如你可以解密这个吗:


HgyxhIIBwBb7zY7GBH4xlQ ==




" Mark Rae < ma ** @ markNOSPAMrae.com写信息

news:ut ************** @ TK2MSFTNGP03.phx.gbl ...
< blockquote class =post_quotes>
" tshad" < ts ********** @ ftsolutions.comwrote in message

news:%2 **************** @ TK2MSFTNGP03。 phx.gbl ...


>>我正在尝试找到用于存储用于加密的密钥的最佳程序。



一般来说,根本不存储它们 - 设计一个机制,以便

在需要时生成相同的密钥。 。
http:/ /msdn.microsoft.com/msdnmag/is...efault.aspx#S9


>这似乎是所有书籍的标准构建您的Web应用程序。
这不是一个问题,因为web.info是明文的吗?我认为以这种方式拥有
密钥(你将用你的数据库存储/加密和获取/解密)这将是危险的。



我认为周围有很多FUD(恐惧,不确定和怀疑)

这个......



是。


但是如果你存储信用卡或社会保障等信息

信息 - 你想要的。


>

首先,问问自己是谁隐藏了这把钥匙......?你的

同事......?你的老板...?办公室清洁工......?



是。


>如果您担心您的同事是否值得信赖或者是/>不,那么你有一个更大的问题然后是密钥加密...


其次,你的网站的安全性如此松懈,你的web.config是

对外界可见......?再说一次,如果是这种情况,那么你有比基本加密更基本的问题...



即使你的安全是好的 - 人们确实进去了。我们非常安全,但是如下所述,专业黑客可能会找到一个方法。


> ;

您是否担心专业?黑客...?再说一次,如果一个

的黑客足够聪明,可以绕过你所有的安全保护,并且能够获得访问你的网络服务器,那么它是否可能无关紧要br />
你的钥匙是否加密 - 他们会破解它......


>我试图找出其他人的交易方式有了这个。另外,我需要在同一台机器上为我的应用程序提供相同的信息。



我有一个加密基类,可以进行TripleDES加密。它有两个方法:加密()和解密()。所有项目和客户都共享这个课程,就像我所有的其他基础

课程一样。



这就是我的工作。 />


我还有一个密钥生成类,它有一个方法:GenerateKey()。

这会生成对称加密所需的密钥,并且

每个客户都有所不同 - 有时项目项目不同

同一客户的基础,如果这是他们想要的。


目前,我正在为所有客户创建一个密钥。只是一组随机的

字母,数字和特殊字符。这被传递给Encrypt

和Decrypt函数。


我只会生成一次密钥(否则我永远无法

解密数据)。您必须在某处为某个地方存储某些内容才能使用它(从中生成密钥的数据或者密钥

本身)。


这样,实际的密钥不会被存储。任何地方。您可以说

密钥可以通过反汇编找到 - 或者,至少可以通过disassenbly找到生成密钥的
的机制 - 但我认为

,如果一个黑客确定已经拆解了我的代码,那么他们无论如何都会很快找到钥匙...


必须有一个足够安全的地方,否则你将会b / b
永远不会做任何事情... :-)


我同意这里。


我只想找到一个非常合理的解决方案。


谢谢,


Tom


>

Eg你可以解密这个吗:


HgyxhIIBwBb7zY7GBH4xlQ ==





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

解决方案

Hello

Sounds like RSA encription.

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

Note there is one mistake in the example.

<configProtectedData>
<providers>
<add name="MyProvider"
type="System.Configuration.RsaProtectedConfigurati onProvider,
System.Configuration, Version=2.0. 0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeys"
useMachineContainer="true" />
</providers>
</configProtectedData>

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**********@ftsolutions.comwrote in message
news:%2****************@TK2MSFTNGP03.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



"tshad" <ts**********@ftsolutions.comwrote in message
news:%2****************@TK2MSFTNGP03.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 "professional" 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:

HgyxhIIBwBb7zY7GBH4xlQ==

?


"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:ut**************@TK2MSFTNGP03.phx.gbl...

"tshad" <ts**********@ftsolutions.comwrote in message
news:%2****************@TK2MSFTNGP03.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 "professional" 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:

HgyxhIIBwBb7zY7GBH4xlQ==

?



这篇关于存储密钥的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆