TDB Architecture
Overview
This architecture illustrates how the TAKAKRYPT Database Encryption Plugin (TDB) works inside a database and how it communicates with TAKAKRYPT. TDB is installed in the database engine as a set of TDP functions. The database calls these functions in its SQL, and the functions get the configuration and keys they need from TAKAKRYPT.
The following is a detailed explanation of the TDB architecture:
Main Components
This architecture consists of several main components as follows:
Database
The database is where the data lives, and where TDB runs. The application or client connects to it as usual.
Main functions:
- Call the TDP functions in its SQL
- Store protected columns as ciphertext at rest
TDP Function
The TDP functions are installed in the database engine. In MySQL they are registered as User Defined Functions (UDFs), and in PostgreSQL they are created as the tdp extension. Either way, 11 functions are added to the database.
Main functions:
- Connect the database to TAKAKRYPT
- Encrypt, decrypt, tokenize, detokenize, and mask values
- Get the configuration and keys from TAKAKRYPT
The functions shown in the diagram:
| Function | Arguments | Purpose |
|---|---|---|
tdp_configure | TAKAKRYPT address, access token, user key, tenant | Connects the database to TAKAKRYPT |
tdp_encrypt | plain, id | Encrypts a value |
tdp_decrypt | cipher, id | Decrypts a value |
tdp_tokenize | data, id | Replaces a value with a token |
tdp_detokenize | token, id | Turns a token back into the original value |
tdp_mask | data, id | Masks a value |
TAKAKRYPT
TAKAKRYPT is the platform the functions get their configuration and keys from.
Main functions:
- Provide the configuration and the keys the functions need
- Manage the whole key lifecycle in one place, so no key is hard-coded in the database
System Communication Flow
1. Connecting the Database
The database runs tdp_configure with the address of TAKAKRYPT, an access token, a user key, and the tenant. The database server needs to reach TAKAKRYPT over HTTPS on port 443.
2. Calling a Function
The application or client sends its SQL to the database as usual. In that SQL, the database calls a TDP function, either directly or through a view that wraps the call.
3. Getting the Configuration and Keys
On first use, the TDP function gets the configuration and the key from TAKAKRYPT over HTTPS, then keeps the key in the memory of the database process.
4. Performing the Operation
The function does the work inside the database engine: encrypt, decrypt, tokenize, detokenize, or mask, along with the validation of the configuration.
5. Returning the Result
The function returns the result to the database. Protected columns stay as ciphertext at rest, and an authorized query gets the decrypted value on access.
Key Handling
The keys live in TAKAKRYPT. The plugin fetches them per policy, and nothing is hard-coded in the database. The plugin gets the key so that it can encrypt and decrypt inside the engine, which is similar to the TFE agent. See How Keys Reach the Agent for how that works in TFE.
Cached keys don't expire (except on ClickHouse). If you revoke access or rotate a key, the database only sees the change after a restart or after running tdp_clear_all_cache. TAKAKRYPT only returns the latest key version, so after a rotation, data encrypted with an older version can't be read once that version leaves the cache, for example after a restart. Re-encrypt your data before rotating, or don't rotate keys the plugin uses.
For the full product introduction, see Overview. To install TDB, see the Prerequisites, then the guide for MySQL or PostgreSQL.