Storing the Keys
Storing the keys is the most crucial part of the encryption exercise. If you don’t do this properly, the whole point of safeguarding data by encrypting it becomes moot. There are a variety of storage options:
- In database tables
This approach, illustrated in the example above, is the most convenient way to handle keys. It suffers from a serious drawback, however: it offers no protection from the DBA who is able to access all tables.
- In an operating system file
The file can be created at runtime by the client process via either the built-in package UTL_FILE or external tables, and it can then be used for decryption. After the read, the file can be destroyed. This approach offers protection from all other users, including the DBA.
- Issued by the user
At runtime, the user can provide the key to the function for decryption. This is the most secure, but the most impractical, approach of the three. The disadvantage is that the user may forget the key, which means that it will be impossible to ever decrypt the encrypted data.