| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Encryption</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="env.html" title="Chapter 9. The Berkeley DB Environment" /> |
| 11 | <link rel="prev" href="env_security.html" title="Security" /> |
| 12 | <link rel="next" href="env_remote.html" title="Remote filesystems" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Encryption</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="env_security.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 9. |
| 26 | The Berkeley DB Environment |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="env_remote.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="env_encrypt"></a>Encryption</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p> |
| 42 | Berkeley DB optionally supports encryption using the Rijndael/AES |
| 43 | (also known as the Advanced Encryption Standard and Federal |
| 44 | Information Processing Standard (FIPS) 197) algorithm for |
| 45 | encryption or decryption. The algorithm is configured to use a |
| 46 | 128-bit key. Berkeley DB uses a 16-byte initialization vector |
| 47 | generated using the Mersenne Twister. All encrypted information is |
| 48 | additionally checksummed using the SHA1 Secure Hash Algorithm, |
| 49 | using a 160-bit message digest. |
| 50 | </p> |
| 51 | <p> |
| 52 | The encryption support provided with Berkeley DB is intended to |
| 53 | protect applications from an attacker obtaining physical access to |
| 54 | the media on which a Berkeley DB database is stored, or an attacker |
| 55 | compromising a system on which Berkeley DB is running but who is |
| 56 | unable to read system or process memory on that system. |
| 57 | <span class="bold"><strong> |
| 58 | The encryption support provided with Berkeley DB will not |
| 59 | protect applications from attackers able to read system memory |
| 60 | on the system where Berkeley DB is running. |
| 61 | </strong></span> |
| 62 | </p> |
| 63 | <p> |
| 64 | To encrypt a database, you must configure the database for |
| 65 | encryption prior to creating it. If you are using a database |
| 66 | environment, you must also configure the environment for |
| 67 | encryption. In order to create an encrypted database within an |
| 68 | environment, you: |
| 69 | </p> |
| 70 | <div class="orderedlist"> |
| 71 | <ol type="1"> |
| 72 | <li> |
| 73 | <p> |
| 74 | Configure the environment for encryption using the |
| 75 | <a href="../api_reference/C/envset_encrypt.html" class="olink">DB_ENV->set_encrypt()</a> method. |
| 76 | </p> |
| 77 | </li> |
| 78 | <li> |
| 79 | <p> |
| 80 | Open the database environment. |
| 81 | </p> |
| 82 | </li> |
| 83 | <li> |
| 84 | <p> |
| 85 | Specify the <a href="../api_reference/C/dbset_flags.html#dbset_flags_DB_ENCRYPT" class="olink">DB_ENCRYPT</a> flag to the database handle. |
| 86 | </p> |
| 87 | </li> |
| 88 | <li> |
| 89 | <p> |
| 90 | Open the database. |
| 91 | </p> |
| 92 | </li> |
| 93 | </ol> |
| 94 | </div> |
| 95 | <p> |
| 96 | Once you have done that, all of the databases that you create in |
| 97 | the environment are encrypted/decrypted by the password you specify |
| 98 | using the <a href="../api_reference/C/envset_encrypt.html" class="olink">DB_ENV->set_encrypt()</a> method. |
| 99 | </p> |
| 100 | <p> |
| 101 | For databases not created in an environment: |
| 102 | </p> |
| 103 | <div class="orderedlist"> |
| 104 | <ol type="1"> |
| 105 | <li> |
| 106 | <p> |
| 107 | Specify the <a href="../api_reference/C/dbset_flags.html#dbset_flags_DB_ENCRYPT" class="olink">DB_ENCRYPT</a> flag to the database handle. |
| 108 | </p> |
| 109 | </li> |
| 110 | <li> |
| 111 | <p> |
| 112 | Call the <a href="../api_reference/C/dbset_encrypt.html" class="olink">DB->set_encrypt()</a> method. |
| 113 | </p> |
| 114 | </li> |
| 115 | <li> |
| 116 | <p> |
| 117 | Open the database. |
| 118 | </p> |
| 119 | </li> |
| 120 | </ol> |
| 121 | </div> |
| 122 | <p> |
| 123 | Note that databases cannot be converted to an encrypted |
| 124 | format after they have been created without dumping and re-creating |
| 125 | them. Finally, encrypted databases cannot be read on systems with |
| 126 | a different endianness than the system that created the encrypted |
| 127 | database. |
| 128 | </p> |
| 129 | <p> |
| 130 | Each encrypted database environment (including all its encrypted |
| 131 | databases) is encrypted using a single password and a single |
| 132 | algorithm. Applications wanting to provide a finer granularity of |
| 133 | database access must either use multiple database environments or |
| 134 | implement additional access controls outside of Berkeley DB. |
| 135 | </p> |
| 136 | <p> |
| 137 | The only encrypted parts of a database environment are its |
| 138 | databases and its log files. Specifically, the |
| 139 | <a class="xref" href="env_region.html" title="Shared memory regions">Shared memory regions</a> supporting |
| 140 | the database environment are not encrypted. For this reason, it |
| 141 | may be possible for an attacker to read some or all of an encrypted |
| 142 | database by reading the on-disk files that back these shared memory |
| 143 | regions. To prevent such attacks, applications may want to use |
| 144 | in-memory filesystem support (on systems that support it), or the |
| 145 | <a href="../api_reference/C/envopen.html#envopen_DB_PRIVATE" class="olink">DB_PRIVATE</a> or <a href="../api_reference/C/envopen.html#envopen_DB_SYSTEM_MEM" class="olink">DB_SYSTEM_MEM</a> flags to the <a href="../api_reference/C/envopen.html" class="olink">DB_ENV->open()</a> method, to |
| 146 | place the shared memory regions in memory that is never written to |
| 147 | a disk. As some systems page system memory to a backing disk, it |
| 148 | is important to consider the specific operating system running on |
| 149 | the machine as well. Finally, when backing database environment |
| 150 | shared regions with the filesystem, Berkeley DB can be configured |
| 151 | to overwrite the shared regions before removing them by specifying |
| 152 | the <a href="../api_reference/C/envset_flags.html#set_flags_DB_OVERWRITE" class="olink">DB_OVERWRITE</a> flag. This option is only effective in the |
| 153 | presence of fixed-block filesystems, journaling or logging |
| 154 | filesystems will require operating system support and probably |
| 155 | modification of the Berkeley DB sources. |
| 156 | </p> |
| 157 | <p> |
| 158 | While all user data is encrypted, parts of the databases and log |
| 159 | files in an encrypted environment are maintained in an unencrypted |
| 160 | state. Specifically, log record headers are not encrypted, only |
| 161 | the actual log records. Additionally, database internal page |
| 162 | header fields are not encrypted. These page header fields includes |
| 163 | information such as the page's <a href="../api_reference/C/lsn.html" class="olink">DB_LSN</a> number and position in the |
| 164 | database's sort order. |
| 165 | </p> |
| 166 | <p> |
| 167 | Log records distributed by a replication master to replicated |
| 168 | clients are transmitted to the clients in unencrypted form. If |
| 169 | encryption is desired in a replicated application, the use of a |
| 170 | secure transport is strongly suggested. |
| 171 | </p> |
| 172 | <p> |
| 173 | We gratefully acknowledge: |
| 174 | </p> |
| 175 | <div class="itemizedlist"> |
| 176 | <ul type="disc"> |
| 177 | <li> |
| 178 | Vincent Rijmen, Antoon Bosselaers and Paulo Barreto for writing |
| 179 | the Rijndael/AES code used in Berkeley DB. |
| 180 | </li> |
| 181 | <li> |
| 182 | Steve Reid and James H. Brown for writing the SHA1 checksum |
| 183 | code used in Berkeley DB. |
| 184 | </li> |
| 185 | <li> |
| 186 | Makoto Matsumoto and Takuji Nishimura for writing the Mersenne |
| 187 | Twister code used in Berkeley DB. |
| 188 | </li> |
| 189 | <li> |
| 190 | Adam Stubblefield for integrating the Rijndael/AES, SHA1 |
| 191 | checksum and Mersenne Twister code into Berkeley DB. |
| 192 | </li> |
| 193 | </ul> |
| 194 | </div> |
| 195 | <p> |
| 196 | Berkeley DB 11g Release 2 supports encryption using Intel's |
| 197 | Performance Primitive (IPP) on Linux. This works only on Intel |
| 198 | processors. To use Berkeley DB with IPP encryption, you must have |
| 199 | IPP installed along with the cryptography extension. The IPP |
| 200 | performance is higher in most cases compared to the current AES |
| 201 | implementation. See |
| 202 | <a href="../installation/build_unix_conf.html#build_unix_conf.--with-cryptography" class="olink">--with-cryptography</a> |
| 203 | for more information. See the |
| 204 | <a class="ulink" href="http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-documentation/" target="_top"> |
| 205 | Intel Documenation</a> for more information on IPP. |
| 206 | </p> |
| 207 | </div> |
| 208 | <div class="navfooter"> |
| 209 | <hr /> |
| 210 | <table width="100%" summary="Navigation footer"> |
| 211 | <tr> |
| 212 | <td width="40%" align="left"><a accesskey="p" href="env_security.html">Prev</a> </td> |
| 213 | <td width="20%" align="center"> |
| 214 | <a accesskey="u" href="env.html">Up</a> |
| 215 | </td> |
| 216 | <td width="40%" align="right"> <a accesskey="n" href="env_remote.html">Next</a></td> |
| 217 | </tr> |
| 218 | <tr> |
| 219 | <td width="40%" align="left" valign="top">Security </td> |
| 220 | <td width="20%" align="center"> |
| 221 | <a accesskey="h" href="index.html">Home</a> |
| 222 | </td> |
| 223 | <td width="40%" align="right" valign="top"> Remote filesystems</td> |
| 224 | </tr> |
| 225 | </table> |
| 226 | </div> |
| 227 | </body> |
| 228 | </html> |