简体   繁体   English

与Zend合作时在数据库中存储加密电子邮件的最佳实践

[英]Best practice for storing emails encrypted in a database when working with Zend

I'm using Zend Framework with a LAMP stack. 我正在使用带有LAMP堆栈的Zend Framework。 The client has requested protection of sensitive data, email included. 客户已要求保护敏感数据,包括电子邮件。 In this project, emails will be used in two ways: for sending automated messages and for sending newsletters. 在这个项目中,电子邮件将以两种方式使用:发送自动消息和发送新闻通讯。

Has anyone worked with this? 有人为此工作吗? What algorithms are fast, reliable and can be used with a variable encryption key? 哪些算法快速,可靠并且可以与可变加密密钥一起使用? Where should I store the encryption key? 我应该在哪里存储加密密钥? What engine should the database table use? 数据库表应使用哪个引擎?

Ok, these are my 2cent. 好的,这些是我的2cent。

For data that needs to be both encrypted and decrypted on the fly, I would suggest symmetric key algorithms, and the first that comes to mind is Blowfish . 对于需要同时进行加密和解密的数据,我建议使用对称密钥算法,首先想到的是Blowfish It is both fast, and relatively safe. 它既快速又相对安全。

As to the variable keys. 至于可变键。 Usually there is little to no merit in having a different key for each entry that needs to be both encrypted and decrypted. 通常,对于需要加密和解密的每个条目使用不同的密钥几乎没有好处。 Thus, I'd recommend using a single key, that is set in config file somewhere. 因此,我建议使用单个密钥,该密钥在配置文件中的某个位置设置。

If you do need to have a key for each of the users/records, I'd recommend not keeping them in the db. 如果确实需要为每个用户/记录提供密钥,则建议不要将其保留在数据库中。 Save them to flat-files on the disk. 将它们保存到磁盘上的平面文件中。

As to table engine, it should not matter which one you choose, as long as it's not memory based. 对于表引擎,选择哪一个都不重要,只要它不是基于内存的即可。


As to merit - I think there is merit, if the client specifically asks for it. 至于优点-如果客户明确要求,我认为是有优点的。 Even if there is technically little reason to create this encryption, this will contribute to the clients feeling of safety. 即使从技术上讲几乎没有理由创建此加密,这也将有助于客户提高安全感。 Sure, it could be a false one, but it does help keep the data a bit more safe, and lets the client sleep more soundly. 当然,这可能是错误的,但是它确实有助于使数据更安全,并使客户端更安全地睡眠。 Therefore, if the client asks for it , go for it! 因此,如果客户要求,那就去做吧!

If you really have to do this, the answer Janis Peisenieks gives is a good starting point. 如果您真的必须这样做,Janis Peisenieks给出的答案是一个很好的起点。

As far as I know, there's no safe way of storing keys in PHP - this means that an attacker who gets a moderate level of control over your system can retrieve the key from a config file, and use that to decrypt the data. 据我所知,还没有安全的方法在PHP中存储密钥-这意味着对您的系统有中等控制权的攻击者可以从配置文件中检索密钥,然后使用该密钥解密数据。

An attacker who wanted to know the email addresses of your users would have several options to retrieve that data - as GordonM writes, if your system sends email to those users, that email is relatively easily to intercept, and whilst the body may be encrypted, to "to address" is not. 想要知道您用户电子邮件地址的攻击者将有几种选择来检索该数据-正如GordonM所写,如果您的系统向这些用户发送电子邮件,则该电子邮件相对容易被拦截,并且尽管主体可以被加密,到“到地址”不是。

Just checking that you will be hashing (not encrypting) passwords (if your system uses these?) 只需检查您将要哈希(不加密)密码(如果您的系统使用了这些密码?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM