我应该在哪里存储php的加密密钥? [英] Where should I store an encryption key for php?

查看:166
本文介绍了我应该在哪里存储php的加密密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个接受敏感客户数据的php应用程序,所以我需要在将其存储在mysql数据库之前进行加密。我将使用mysql的内置AES功能进行列级加密。



我想避免在服务器上存储加密密钥,所以我'将提供一个网页供管理员登录,并输入加密密钥。我想在应用程序运行时将该密钥存储在内存中,但永远不会永久存储到磁盘。



最好的方法是什么?



我可以修改$ _SERVER数组来存储请求之间的信息吗?我可以以某种方式用apache存储密钥吗?可能是共享内存?

解决方案

我最终将加密密钥存储在内存表中。通过一组存储过程完成对数据库的所有访问;存储过程包括进行密钥管理的能力(即,将密钥插入记忆表,更改密钥,检查密钥是否已输入等),以及存储/检索应用程序数据。



通过这种设计,应用程序服务器上留下的数据库凭据只能通过一组定义的过程进行查询,无法直接读取加密密钥。



我喜欢这种方法,因为:


  1. 密钥不存储在文件系统上 - 防止出现问题硬件处理在使用寿命终止以及系统管理员的窥视之下

  2. 应用程序代码无法访问密钥(除了进入密钥之外),所以唯一的地方它将永远驻留在数据库进程中。

  3. 加密/解密的所有逻辑嵌入在SQL查询中,因此不需要担心应用程序代码正确执行 - 非常适合维护。


I'm writing a php application that accepts sensitive customer data, and so I need to encrypt it before storing it in a mysql database. I'm going to use mysql's built-in AES functionality to do column-level encryption.

I want to avoid storing the encryption key on the server, and so i'm going to provide a web-page for an administrator to log-in, and enter the encryption key. I want to store this key in memory while the application is running, but never permanently to disk.

What is the best way to do this?

Can I modify the $_SERVER array to store information between requests? Can I store the key with apache in some way? Maybe shared memory?

解决方案

I ended up storing the encryption key in an in-memory table. All access to the database is done through a set of stored procedures; The stored procedures include the ability to do key management (i.e. insert key to memory-table, change keys, check if a key has been entered etc.), as well as store/retrieve application data.

With this design, the database credentials left on the application server only have the authorization to query through the set of defined procedures, and have no way to read the encryption key directly.

I liked this approach because:

  1. The key isn't stored on the file system - preventing issues with hardware disposal at end-of-life, and from prying eyes of system administrators
  2. The application code can't get access to the key (other than while entering it), so the only place it will ever reside is within the database process.
  3. All logic for encryption/decryption is embedded within the SQL queries, so don't need to worry about application code doing it correctly - Nice for maintenance.

这篇关于我应该在哪里存储php的加密密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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