Download and try the Encryption Plugin for Firebird
Try the Encryption Plugin for Firebird v2027R1
Download the package with a trial license and encrypt a test database. All functions work. Use the ready example, or do the eight steps on your own Firebird.
- Firebird 5.0 · 4.0 · 3.0 (from 3.0.3)
- Windows and Linux · x64 servers · 32- and 64-bit clients
- Trial license in each archive
- 8 steps from the archive to an encrypted backup
- 10 minutes for the ready example
Start
Choose your way
All three ways use the same plugin and give the same result: an encrypted database and a server that keeps no key.
Run the ready example
The scripts install a separate test server on its own port. They do not change your Firebird. You get an encrypted database and an application that opens it.
The commandsInstall with a script or by hand
The script for Windows or Linux downloads the archive, copies the files and runs the tests. Or copy the files yourself and do the eight steps.
The eight stepsNothing to download
HQbird contains the server plugins, the client files and the utilities. You add the license file and the line KeyHolderPlugin = KeyHolder.
| Firebird | Windows: server x64, clients 32- and 64-bit | Linux x64 |
|---|---|---|
| 5.0 | CryptPlugin-FB_50_WINDOWS_64bit.zip 37 MB | CryptPlugin-FB_50_LINUX_64bit.tar.xz 2.8 MB |
| 4.0 | CryptPlugin-FB_40_WINDOWS_64bit.zip 36 MB | CryptPlugin-FB_40_LINUX_64bit.tar.xz 2.7 MB |
| 3.0 | CryptPlugin-FB_30_WINDOWS_64bit.zip 16 MB | CryptPlugin-FB_30_LINUX_64bit.tar.xz 1.3 MB |
One archive has all you need: the server plugins, the client files for applications, the utilities and a test database.
The server part is 64-bit. The client part has 32-bit and 64-bit files: take the bitness of your application. The script run-tests.ps1 encrypts the test database, makes a backup and a restore, and checks the result.
FB_50_WINDOWS_64bit ├── Server extract into the Firebird root folder │ ├── plugins dbcrypt.dll, keyholder.dll, DbCrypt.conf (trial license) │ ├── fbclient.dll, fbcrypt.dll, OpenSSL libraries │ └── decrypt.exe └── Client ├── 32bit, 64bit client files and gbak, nbackup, isql, gfix │ ├── plugins dbcrypt.dll, keyholder.dll, DbCrypt.conf │ └── key-plugins KeySource.dll (test keys), keyholderstdin.dll └── db-crypt EMPLOYEE.FDB and run-tests.ps1
The trial license DbCrypt.conf has a limited period. With a purchased license, replace this file and restart Firebird: the encrypted databases stay as they are.
- 1Installthe plugin files
- 2Configurelicense and
KeyHolderPlugin - 3Make a keyor a pass phrase
- 4Encrypt
ALTER DATABASE - 5Check
gstat -h - 6Remove the keyfrom the server
- 7Give the keyto each application
- 8✓ Back upencrypted
gbak
Each step is short. The link under a step opens the full chapter of the guide.
Install the plugin files
Stop the Firebird service. Extract the Server folder of the archive into the Firebird root folder. Some Firebird files are replaced.
Or use the installation script. It finds Firebird, downloads the archive, changes the configuration and runs the tests.
Windows, cmd as administrator: install-Firebird-encryption-plugin.bat Linux, into an installed Firebird: sudo ./fb_vanilla-50.sh --crypt-only=/opt/firebird
Linux with Firebird 3.0 or 4.0 also needs the OpenSSL 1.1 library (libcrypto.so.1.1).
Put the license file and turn on the plugin
The license file DbCrypt.conf must be in the plugins folder. The archive has a trial license. Then turn on the key holder plugin and restart Firebird.
# firebird.conf: for all databases KeyHolderPlugin = KeyHolder # or databases.conf: for one alias crypt = C:\Temp\EMPLOYEE.FDB { KeyHolderPlugin = KeyHolder }
Make a key
A key is 32 random bytes (AES-256). You can also use a pass phrase: the plugin calculates the key from it.
aesKeyGen.exe
or, without the utility:
openssl rand -hex 32 | sed 's/../0x&,/g'
For the first test, write the key into plugins/KeyHolder.conf on the server:
Key=Red 0xec,0xa1,0x52,0xf6, ... ,0x04,0xdc,0x75,
# or a pass phrase
Password=Red my long pass phrase
Keep a copy of the key in a safe place apart from the server. A lost key cannot be restored.
Encrypt the database
Make a backup first, and do the first test on a copy. Connect over TCP/IP: write the server name.
isql localhost:C:\Temp\EMPLOYEE.FDB -user SYSDBA -password masterkey
SQL> ALTER DATABASE ENCRYPT WITH "DbCrypt" KEY Red;
SQL> COMMIT;
The statement only starts the encryption. A background thread of the server encrypts the pages. You can work with the database during this time. Keep one connection open until the encryption is complete.
Check the result
The header must show the attribute encrypted and the key name. The switch -e counts the pages.
gstat -h EMPLOYEE.FDB
Attributes encrypted, plugin DbCrypt
Encryption key name: RED
gstat -e EMPLOYEE.FDB
Data pages: total 116, encrypted 116, non-crypted 0
Progress for a large database (the field is 0 when the encryption is complete):
select mon$crypt_page * 100.0 / mon$pages as percent from mon$database;
Remove the key from the server
Delete or rename the file plugins/KeyHolder.conf with the key and restart Firebird. The server works without this file. Then check that a connection without the key fails:
isql localhost:C:\Temp\EMPLOYEE.FDB -user SYSDBA -password masterkey Statement failed, SQLSTATE = 08006 Invalid crypt key RED -Key not set
From this moment each connection must bring the key. The server does not share the key between connections.
Give the key to each application
Select the way for each program that connects to the database: the application, reports, services and backup jobs.
| Program | Way to send the key | Full description |
|---|---|---|
| Application without source code | KeySource.dll near fbclient.dll | No code changes · guide |
| Application with source code: Delphi, Lazarus, C++ and others | fbcrypt library: three calls before the connection | Native applications |
| Java (Jaybird) and .NET | connection property; needs UnsafeClient = true and wire encryption | Java · .NET |
gbak, nbackup, isql, gfix, scripts | KeyHolderStdin plugin: the key comes from the input stream | KeyHolderStdin |
| A person types the key or the pass phrase | line Prompt in the client KeyHolder.conf | Key request to the user |
The client must use fbclient and the plugins from the same package as the server. The bitness of the client files is the bitness of the application.
Make an encrypted backup
gbak encrypts the backup only with the switch -KeyHolder. Without this switch the .fbk file has the data in plain form.
Firebird 4.0 and 5.0: the key comes from a file with limited access type C:\Secure\dbkey.txt | gbak -b localhost:D:\DB\app.fdb E:\Backup\app.fbk -KeyHolder KeyHolderStdin -user SYSDBA -password ******** check: an encrypted backup has no table names in plain text, so this prints nothing findstr /m CUSTOMER E:\Backup\app.fbk
Near gbak there must be the plugins folder with DbCrypt, KeyHolder, KeyHolderStdin and the license file. An nbackup copy stays encrypted with the key of the database. Firebird 3.0 has different switches: -KEYFILE, -KEYNAME, -KEY.
The example does all eight steps for you on a separate test server. It downloads the official Firebird and the plugin package with a trial license. The application has no code for the key: it gets the key from KeySource.dll.
PS> git clone https://github.com/IBSurgeon/FirebirdEncryptionGuide PS> cd FirebirdEncryptionGuide\examples\closed-gui\deploy PS> .\05-download-example.ps1 # ready programs of the example PS> .\run-all.ps1 -Version 5 # server, encrypted database, workstation folder PS> ..\work\fb5\remote\EmployeeRemote.exe PS> .\50-backup.ps1 -Version 5 # encrypted backup and a test restore

- Command-line utilities
gbak,nbackup,isqlandgfixfrom the folderClienthave the switch-KeyHolder(Firebird 4.0 and 5.0). - Administration toolsA tool that loads
fbclient.dllworks as an application without source code: put the client files and a key source into its folder. Take the bitness of the tool. - TCP/IP connectionThe server asks the client for the key only on a TCP/IP connection. On XNET the key must be on the server.
- Examples for your languageDelphi and Lazarus, Python, Java, .NET, PHP, C++: ready projects with a description. The list.
- The same package everywhereClient and server libraries from different packages cannot exchange the key.
- If something failsThe guide has a chapter with error messages and their causes: Troubleshooting. Or write to [email protected].
| Language | Encryption plugin guide | Applications without source code |
|---|---|---|
| English | Read online · PDF | Read online · PDF |
| Portuguese (Brazil) | Read online · PDF | Read online · PDF |
| Polish | Read online · PDF | Read online · PDF |
| German | Read online · PDF | Read online · PDF |
| Russian | Read online · PDF | Read online · PDF |
The sources of the guides are in the same repository, folder doc. The PDF files are built from them for each release.