데이터베이스 암호화 - Data at Rest Encryption

불당   
   조회 586  

mariadb 10.1.3부터 DB 암호화 기능이 들어갔습니다.

https://mariadb.com/kb/en/mariadb/data-at-rest-encryption/


Overview

Having tables encrypted makes it almost impossible for someone to access or steal a hard disk and get access to the original data. This assumes that encryption keys are stored on another system.

Using encryption has an overhead of roughly 3-5%.

Which storage engines does MariaDB encryption support?

MariaDB encryption is fully supported for the XtraDB and InnoDB storage engines. Additionally, encryption is supported for the Aria storage engine, but only for tables created with ROW_FORMAT=PAGE (the default).

MariaDB allows the user to configure flexibly what to encrypt.  In XtraDB or InnoDB, one can choose to encrypt:

  • everything — all tablespaces (with all tables) 
  • individual tables 
  • everything, excluding individual tables 

Additionally, one can choose to encrypt XtraDB/InnoDB log files (recommended).

Limitations

These limitations exist in the data-at-rest encryption implementation in MariaDB 10.1:

  • Only data and only at rest is encrypted. Metadata (for example .frm files) and data sent to the client are not encrypted (but see Secure Connections). 
  • Only the MariaDB server knows how to decrypt the data, in particular 
  • The disk-based Galera gcache is not encrypted (MDEV-9639). 
  • The Audit plugin cannot create encrypted output. Send it to syslog and configure the protection there instead. 
  • File-based general query log and slow query log cannot be encrypted (MDEV-9639). 
  • The Aria log is not encrypted (MDEV-9639). This affects only non-temporary Aria tables though. 
  • The MariaDB error log is not encrypted. The error log can contain query text and data in some cases, including crashes, assertion failures, and cases where InnoDB/XtraDB write monitor output to the log to aid in debugging. It can be sent to syslog too, if needed. 

Encryption key management

MariaDB encryption supports multiple encryption keys, they are identified by a key identifier — a 32-bit integer. To support automatic key rotation every key additionally might have different versions. XtraDB and InnoDB can automatically re-encrypt the data from an older to a newer version of the same key. But how different keys are stored and rotated depends on the key management solution that you choose.

Key management in MariaDB is provided by encryption plugins.  MariaDB includes one such plugin — file_key_management.

file_key_management plugin

The file_key_management plugin is an encryption plugin that reads encryption keys from a file. This plugin has the following configuration options:

  • file_key_management_filename: Where the file is  located. This option is required, the plugin will not work without it. 
  • file_key_management_filekey: An optional key to decrypt the key file. If the key starts with FILE: the rest of the value is interpreted as a path to the file that contains the key. You will most likely want to use the form FILE:/path/to/filekey so that the actual filekey cannot be read by anyone via a SHOW command. Consequently, that file would need the proper permissions so that mysql can read it, but not unauthorized users. 
  • file_key_management_encryption_algorithm: the encryption algorithm to use. 

file_key_management_filename

The key file contains encryption keys identifiers (32-bit numbers) and hex-encoded encryption keys, separated by a semicolon. 128, 192 or 256-bit keys are supported. Comments start from the hash character. An example key file entry:

# this is a comment
1;770A8A65DA156D24EE2A093277530142
18;F5502320F8429037B8DAEF761B189D12F5502320F8429037B8DAEF761B189D12

1 is the key identifier which can be used for table creation, it is followed by the encryption key, in hex.

Key identifiers can be specified per table, but the system XtraDB/InnoDB tablespace and log files always use the key number 1, so it must always exist. Key number 2 is optional, but if it exists, it will be used for temporary tables and temporary files.

This plugin does not support key rotation — all keys always have the version 1.

If the key file can not be read at server startup, for example if the file key is not present, the encryption will not work and encrypted tables will be unreadable.

file_key_management_filekey

The key file (from above) may be encrypted and the key to decrypt the file can be given with the optional file_key_management_filekey parameter.

To encrypt the key file use the The OpenSSL command line utility. For example:

openssl enc -aes-256-cbc -md sha1 -k secret -in keys.txt -out keys.enc

Note, that you must use -aes-256-cbc and sha1 otherwise the plugin won't be able to decrypt the key file.

file_key_management_encryption_algorithm

This plugin supports two encryption algorithms, both use AES but with different block cipher modes.

The file_key_management_encryption_algorithm can be set to AES_CBC or AES_CTR.  The second — AES_CTR — is the recommended one, but it may not always be available (requires a recent OpenSSL). If set to AES_CBC, the plugin will use AES with 128-bit keys in the CBC mode. If set to AES_CTR, the plugin will use AES with the 128-bit keys in the CTR mode for encrypting tablespace pages (InnoDB, XtraDB, and Aria), and it will use AES in the authenticated GCM mode for temporary files (where the cyphertext is allowed to be larger than the plaintext).

Example usage in a my.cnf file:

[mysqld]
file_key_management_encryption_algorithm=aes_cbc
file_key_management_filename = /home/mdb/keys.enc
file_key_management_filekey = secret

eperi Gateway for Databases

eperi provides a key management and encryption solution for MariaDB.

The keys are stored at the key server and optionally all encryption is done on the key server as well. This prevents an attacker with file system access from unauthorized reading the database files (see Why Encrypt MariaDB Data?).

The eperi Gateway for Databases provides the following key benefits:

  • Key management outside the database 
  • No keys on the databases server hard disk 
  • Graphical user interface for configuration 
  • Encryption and decryption outside the database, supporting HSMs for maximum security 

Encrypting data

To enable encryption you have to load an encryption plugin, for example a file_key_management plugin, and configure storage engines to use it. The latter is storage engine specific:

XtraDB and InnoDB

To fine-tune the encryption, you can use following variables:

VariableValueDescription
innodb-encrypt-tablesON, OFF, or FORCEEnable encryption for tables
innodb-encrypt-logBooleanEnable encryption for log files
innodb-encryption-rotate-key-agePositive integerRe-encrypt in background all pages that were encrypted with a key at least that many versions old
innodb-encryption-rotation-iopsPositive integerUse this many Input/Output operations per second for background key rotation
innodb-encryption-threadsPositive integerNumber of threads performing background key rotation and scrubbing

Note, that generally you should not enable only innodb-encrypt-tables while keeping innodb-encrypt-log disabled. In this setup log files will contain your data unencrypted. The opposite case is fine, you may want to enable only innodb-encrypt-log, disable innodb-encrypt-tables, and activate encryption per table with the ENCRYPTED=YES option.

Also it'a good idea to enable encryption for temporary tables (see below).

Example my.cnf to enable XtraDB encryption:

[mysqld]
plugin-load-add=file_key_management.so
file-key-management
file-key-management-filename = /mount/usb1/keys.txt
innodb-encrypt-tables
innodb-encrypt-log
innodb-encryption-threads=4

Specifying which tables to encrypt

You can choose which tables to encrypt.  This allows you to balance security with speed. In order to use these options, innodb_file_per_table must be set to ON (the default).

To encrypt a table use the following options for the CREATE TABLE or ALTER TABLE statement:

Table optionValues
ENCRYPTEDYES or NO
ENCRYPTION_KEY_IDPositive integer

Examples:

CREATE TABLE T (id int, value varchar(255)) ENCRYPTED=YES ENCRYPTION_KEY_ID=17;

This creates table T which is encrypted with key 17.

ALTER TABLE T ENCRYPTED=YES ENCRYPTION_KEY_ID=18;

Alters table T to be encrypted with key 18. If it was encrypted before, it's first decrypted and then re-encrypted.

ALTER TABLE T encrypted=NO;

Disables the encryption of table T. If it was encrypted before, it's decrypted.

If innodb_file_per_table is OFF, or the ENCRYPTION_KEY_ID is not found, these statements will fail with errno: 140 "Wrong create options".

Related configuration variables:

VariableValueDescription
innodb_encrypt_tablesON, OFF, or FORCEWhether to encrypt tables that don't have ENCRYPTED option. If set to FORCE — prevent creation of tables with ENCRYPTED=NO
innodb_default_encryption_key_idPositive integerThe default value of the ENCRYPTION_KEY_ID for all tables that don't have it explicitly

Encryption of Aria tables

Only tables created with ROW_FORMAT=PAGE can be encrypted. This is the default row format for Aria.

You can specify that all Aria tables of the above type are encrypted by specifying:

[mysqld]
aria-encrypt-tables=1

Encryption of Aria temporary tables

MariaDB uses Aria for on-disk temporary tables that don't fit into MEMORY tables.

To ensure that no one can access data stored in temporary tables created as part of query execution, you can encrypt the temporary data by specifying in your my.cnf file:

encrypt-tmp-disk-tables=1

This works by creating and using a random encryption key for every new temporary table.

Encryption of temporary files

MariaDB might create temporary files on disk. For example, temporary files are created for binary log transactional caches and for filesort. Since 10.1.5, these temporary files can also be encrypted if --encrypt-tmp-files is specified on the command line or in the my.cnf file.

Encryption of binary logs

Since 10.1.7, MariaDB can also encrypt binary logs (including relay logs). Binary logs are encrypted if --encrypt-binlog is specified on the command line or in the my.cnf file.

Encryption and compression

Encryption and compression (a feature usable with FusionIO) can be used together. This works by first compressing the data and then encrypting it. In this case you save space and still have your data protected.

Thanks

  • Tablespace encryption was donated to the MariaDB project by Google. 
  • Per-table encryption and key identifier support was donated to the MariaDB project by eperi

We are grateful to these companies for their support of MariaDB!

See Also

- opencode.co.kr -
오픈소스 전문기업 KT DS
MARIADB 오픈소스유통,설치,기술지원,컴플라이언스,거버넌스,상용-오픈소스SW전...
알지오 MARIADB
IT전문교육 실무중심 MARIADB, 원격평생교육시설 정식인가.
C25.KR 아마존 웹서비스
아마존 웹호스팅, 오라클DB호스팅, 오로라DB호스팅등 AWS 운영지원 전문기업
파워링크 AD   클릭초이스등록


제목Page 1/1
     
2014-06   99939   불당
2016-08   17471   불당
2014-05   88789   불당
2011-12   173247   불당
2016-05   30471   불당
05-22   587   불당
2015-10   2826   불당
2015-10   2838   불당
2015-09   2357   불당
2015-09   2161   불당
2015-09   2275   불당
2014-03   4413   불당
2014-03   4082   불당
2014-01   5374   에그당
2014-01   4950   불당
2013-11   5661   불당
2013-06   16778   불당
2013-04   8937   불당
2013-03   18613   불당
2013-02   7206   불당
2013-02   7921   불당
2013-02   9197   불당
2013-02   14749   불당
2013-02   8987   불당
2013-02   9862   불당