| 1 |
|
| 2 |
\chapter{Data Encryption} |
| 3 |
\label{blb:DataEncryption} |
| 4 |
\index[general]{Data Encryption} |
| 5 |
\index[general]{Encryption!Data} |
| 6 |
\index[general]{Data Encryption} |
| 7 |
|
| 8 |
\bacula{} permits file data encryption and signing within the File Daemon (or |
| 9 |
Client) prior to sending data to the Storage Daemon. Upon restoration, |
| 10 |
file signatures are validated and any mismatches are reported. At no time |
| 11 |
does the Director or the Storage Daemon have access to unencrypted file |
| 12 |
contents. |
| 13 |
|
| 14 |
\smallskip |
| 15 |
It is very important to specify what this implementation does NOT do: |
| 16 |
\begin{bitemize} |
| 17 |
\item There is one important restore problem to be aware of, namely, it's |
| 18 |
possible for the director to restore new keys or a \bacula{} configuration |
| 19 |
file to the client, and thus force later backups to be made with a |
| 20 |
compromised key and/or with no encryption at all. You can avoid this by |
| 21 |
not changing the location of the keys in your \bacula{} File daemon |
| 22 |
configuration file, and not changing your File daemon keys. If you do |
| 23 |
change either one, you must ensure that no restore is done that restores |
| 24 |
the old configuration or the old keys. In general, the worst effect of |
| 25 |
this will be that you can no longer connect the File daemon. |
| 26 |
|
| 27 |
\item The implementation does not encrypt file metadata such as file path |
| 28 |
names, permissions, and ownership. Extended attributes are also currently |
| 29 |
not encrypted. However, Mac OSX resource forks are encrypted. |
| 30 |
\end{bitemize} |
| 31 |
|
| 32 |
\smallskip |
| 33 |
Encryption and signing are implemented using \acs{RSA} private keys coupled with |
| 34 |
self-signed X.509 public certificates. This is also sometimes known as \ac{PKI}. |
| 35 |
|
| 36 |
\smallskip |
| 37 |
Each File Daemon should be given its own unique private/public key pair. |
| 38 |
In addition to this key pair, any number of ``Master Keys'' may be specified |
| 39 |
-- these are key pairs that may be used to decrypt any backups should the |
| 40 |
File Daemon key be lost. Only the Master Key's public certificate should |
| 41 |
be made available to the File Daemon. Under no circumstances should the |
| 42 |
Master Private Key be shared or stored on the Client machine. |
| 43 |
|
| 44 |
\smallskip |
| 45 |
The Master Keys should be backed up to a secure location, such as a \acs{CD} |
| 46 |
placed in a in a fire-proof safe or bank safety deposit box. The Master |
| 47 |
Keys should never be kept on the same machine as the Storage Daemon or |
| 48 |
Director if you are worried about an unauthorized party compromising either |
| 49 |
machine and accessing your encrypted backups. |
| 50 |
|
| 51 |
\smallskip |
| 52 |
While less critical than the Master Keys, File Daemon Keys are also a prime |
| 53 |
candidate for off-site backups; burn the key pair to a \acs{CD} and send the \acs{CD} |
| 54 |
home with the owner of the machine. |
| 55 |
|
| 56 |
\smallskip |
| 57 |
NOTE!!! If you lose your encryption keys, backups will be unrecoverable. |
| 58 |
\textbf{ALWAYS} store a copy of your master keys in a secure, off-site location. |
| 59 |
|
| 60 |
\smallskip |
| 61 |
The basic algorithm used for each backup session (Job) is: |
| 62 |
\begin{benumerate} |
| 63 |
\item The File daemon generates a session key. |
| 64 |
\item The \acs{FD} encrypts that session key via \acs{PKE} for all recipients (the file |
| 65 |
daemon, any master keys). |
| 66 |
\item The \acs{FD} uses that session key to perform symmetric encryption on the data. |
| 67 |
\end{benumerate} |
| 68 |
|
| 69 |
|
| 70 |
\section{Building \bacula{} with Encryption Support} |
| 71 |
\index[general]{Building \bacula{} with Encryption Support} |
| 72 |
|
| 73 |
To build \bacula{} with encryption support, you will need |
| 74 |
the Open\acs{SSL} libraries and headers installed. When configuring \bacula{}, use: |
| 75 |
|
| 76 |
\begin{bVerbatim} |
| 77 |
./configure --with-openssl ... |
| 78 |
\end{bVerbatim} |
| 79 |
|
| 80 |
\smallskip |
| 81 |
Please note, the \bacula{} Enterprise binaries are all built with |
| 82 |
encryption enabled. |
| 83 |
|
| 84 |
\section{Encryption Technical Details} |
| 85 |
\index[general]{Encryption Technical Details} |
| 86 |
The implementation uses 128bit \acs{AES}-\acs{CBC}, with \acs{RSA} encrypted symmetric |
| 87 |
session keys. The \acs{RSA} key is user supplied. |
| 88 |
If you are running OpenSSL 0.9.8 or later, the signed file hash uses |
| 89 |
\acs{SHA}-256 -- otherwise, \acs{SHA}-1 is used. |
| 90 |
|
| 91 |
\smallskip |
| 92 |
End-user configuration settings for the algorithms are not currently |
| 93 |
exposed -- only the algorithms listed above are used. However, the |
| 94 |
data written to Volume supports arbitrary symmetric, asymmetric, and |
| 95 |
digest algorithms for future extensibility, and the back-end |
| 96 |
implementation currently supports: |
| 97 |
|
| 98 |
\begin{bitemize} |
| 99 |
\item Symmetric Encryption: |
| 100 |
\begin{bitemize} |
| 101 |
\item 128, 192, and 256-bit AES-CBC |
| 102 |
\item Blowfish-CBC |
| 103 |
\end{bitemize} |
| 104 |
\item Asymmetric Encryption (used to encrypt symmetric session keys): |
| 105 |
\begin{bitemize} |
| 106 |
\item RSA |
| 107 |
\end{bitemize} |
| 108 |
\item Digest Algorithms: |
| 109 |
\begin{bitemize} |
| 110 |
\item MD5 |
| 111 |
\item SHA1 |
| 112 |
\item SHA256 |
| 113 |
\item SHA512 |
| 114 |
\end{bitemize} |
| 115 |
\end{bitemize} |
| 116 |
|
| 117 |
\smallskip |
| 118 |
The various algorithms are exposed via an entirely re-usable, |
| 119 |
OpenSSL-agnostic \acs{API} (ie, it is possible to drop in a new encryption |
| 120 |
backend). The Volume format is \acs{DER}-encoded \acs{ASN.1}, modeled after the |
| 121 |
Cryptographic Message Syntax from \acs{RFC} 3852. Unfortunately, using \acs{CMS} |
| 122 |
directly was not possible, as at the time of coding a free software |
| 123 |
streaming \acs{DER} decoder/encoder was not available. |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
\section{Concepts} |
| 128 |
\index[general]{Encryption Implement Concepts} |
| 129 |
Data encription is configured in \bacula{} only in the File Daemon. |
| 130 |
The Job report that is produced at the end of each job has a |
| 131 |
line indicating whether or not encryption was enabled: |
| 132 |
|
| 133 |
\begin{bVerbatim} |
| 134 |
VSS: no |
| 135 |
Encryption: no/yes <=== |
| 136 |
Accurate: no |
| 137 |
... |
| 138 |
\end{bVerbatim} |
| 139 |
|
| 140 |
|
| 141 |
\section{Generating Private/Public Encryption Keys} |
| 142 |
\index[general]{Generating Private/Public Encryption Keypairs} |
| 143 |
|
| 144 |
Generate a Master Key Pair (once) with: |
| 145 |
|
| 146 |
\begin{bVerbatim} |
| 147 |
openssl genrsa -out master.key 2048 |
| 148 |
openssl req -new -key master.key -x509 -out master.cert |
| 149 |
\end{bVerbatim} |
| 150 |
|
| 151 |
Save these files (\bfilename{master.key} and \bfilename{master.cert}) as you |
| 152 |
will need them to create File Daemon keys or in case |
| 153 |
you loose the File Daemon keys. |
| 154 |
|
| 155 |
\smallskip |
| 156 |
|
| 157 |
Generate a File Daemon Key Pair for each \acs{FD}: |
| 158 |
\begin{bVerbatim} |
| 159 |
openssl genrsa -out fd-example.key 2048 |
| 160 |
openssl req -new -key fd-example.key -x509 -out fd-example.cert |
| 161 |
cat fd-example.key fd-example.cert >fd-example.pem |
| 162 |
\end{bVerbatim} |
| 163 |
|
| 164 |
When configuring the File Daemon (see section \vref{blb:director:configure:filedaemon}), you will need |
| 165 |
the keys you just generated here, so you will need to transmit |
| 166 |
them to the machine where the \acs{FD} is installed. |
| 167 |
|
| 168 |
\smallskip |
| 169 |
Note, there seems to be a lot of confusion around the file extensions given |
| 170 |
to these keys. For example, a \bfilename{.pem} file can contain all the following: |
| 171 |
private keys (\acs{RSA} and \acs{DSA}), public keys (\acs{RSA} and \acs{DSA}) and (X.509) certificates. |
| 172 |
It is the default format for OpenSSL. It stores data Base64 encoded \acs{DER} format, |
| 173 |
surrounded by \acs{ASCII} headers, so is suitable for text mode transfers between |
| 174 |
systems. A \bfilename{.pem} file may contain any number of keys either public or |
| 175 |
private. We use it in cases where there is both a public and a private |
| 176 |
key. |
| 177 |
|
| 178 |
\smallskip |
| 179 |
Typically, above we have used the \bfilename{.cert} extension to refer to X.509 |
| 180 |
certificate encoding that contains only a single public key. |
| 181 |
|
| 182 |
|
| 183 |
\section{Example Data Encryption Configuration} |
| 184 |
\index[general]{Example!File Daemon Configuration File} |
| 185 |
\index[general]{Example!Data Encryption Configuration File} |
| 186 |
\index[general]{Example Data Encryption Configuration} |
| 187 |
|
| 188 |
When configuring the \acs{FD}, use the keys generated above in a |
| 189 |
\acs{FD} configuration file that will look something like the |
| 190 |
following: |
| 191 |
|
| 192 |
\smallskip |
| 193 |
\bfilename{bacula-fd.conf} |
| 194 |
\begin{bVerbatim} |
| 195 |
FileDaemon { |
| 196 |
Name = example-fd |
| 197 |
FDport = 9102 # where we listen for the director |
| 198 |
WorkingDirectory = /opt/bacula/working |
| 199 |
Pid Directory = /var/run |
| 200 |
Maximum Concurrent Jobs = 20 |
| 201 |
|
| 202 |
PKI Signatures = Yes # Enable Data Signing |
| 203 |
PKI Encryption = Yes # Enable Data Encryption |
| 204 |
PKI Keypair = "/opt/bacula/etc/fd-example.pem" # Public and Private Keys |
| 205 |
PKI Master Key = "/opt/bacula/etc/master.cert" # ONLY the Public Key |
| 206 |
} |
| 207 |
\end{bVerbatim} |
| 208 |
|
| 209 |
You must restart your File Daemon after making this change |
| 210 |
to the \bfilename{bacula-fd.conf} file. |
| 211 |
|
| 212 |
\smallskip |
| 213 |
\paragraph{Note}: the PKIMasterKey directive is not mandatory, but if used |
| 214 |
will allow you to decrypt the files if ever the \acs{FD} PKIKeypair is lost. |
| 215 |
If you loose the \acs{FD}'s PKIKeypair, you will not be able to recover |
| 216 |
your data unless you have used a PKIMasterKey. |
| 217 |
|
| 218 |
\section{Decrypting with a Master Key} |
| 219 |
\index[general]{Decrypting with a Master Key} |
| 220 |
It is preferable to retain a secure, non-encrypted copy of the |
| 221 |
client's own encryption keypair. However, should you lose the |
| 222 |
client's keypair, recovery with the master keypair is possible. |
| 223 |
|
| 224 |
\smallskip |
| 225 |
First create a keypair with: |
| 226 |
|
| 227 |
\begin{bVerbatim} |
| 228 |
cat master.key master.cert >master.pem |
| 229 |
\end{bVerbatim} |
| 230 |
|
| 231 |
\smallskip |
| 232 |
Then modify your File Daemons configuration file to use |
| 233 |
the master keypair: |
| 234 |
|
| 235 |
\begin{bVerbatim} |
| 236 |
FileDaemon { |
| 237 |
Name = example-fd |
| 238 |
FDport = 9102 # where we listen for the director |
| 239 |
WorkingDirectory = /opt/bacula/working |
| 240 |
Pid Directory = /var/run |
| 241 |
Maximum Concurrent Jobs = 20 |
| 242 |
|
| 243 |
PKI Signatures = Yes # Enable Data Signing |
| 244 |
PKI Encryption = Yes # Enable Data Encryption |
| 245 |
PKI Keypair = "/opt/bacula/etc/master.pem" # Master Public and Private Keys |
| 246 |
} |
| 247 |
\end{bVerbatim} |
| 248 |
|
| 249 |
\smallskip |
| 250 |
Restart your File Daemon and you should be able to recover your |
| 251 |
lost files. |