Add automatic data decryption to ckm_db_tool 31/238831/14
authorMateusz Cegielka <m.cegielka@samsung.com>
Fri, 17 Jul 2020 15:30:16 +0000 (17:30 +0200)
committerMateusz Cegielka <m.cegielka@samsung.com>
Fri, 28 Aug 2020 13:46:58 +0000 (15:46 +0200)
commit831d82cd099fb16f6c65c84527447867137a6f89
tree356c06be5aeda1ee8a583c4196af91776e50cad2
parent9ea674f06681e732d98be7b433ce8db7a9ee7b05
Add automatic data decryption to ckm_db_tool

The key manager stores key data in an encrypted database. The project
also contains a ckm_db_tool CLI utility, which decrypts the database and
launches an interactive SQL shell. However, inside the decrypted
database, the data column is still encrypted with application-specific
keys. This is inconvenient during debugging, as there is no easy way to
see the data. Also, decrypting some objects' data may require
object-specific passwords.

This patch adds a --decrypt flag, which automatically decrypts contents
of any column called "data" in all SQL query results. Additionally, if
decryption of an object requires a password, it prompts the user to
enter the password and uses it to decrypt the object's data.

The implementation finds "data", "dataType" and "idx" columns in the
output, assumes they come from the "objects" table, and uses the three
values to fetch and decrypt object data with existing CKM APIs. All rows
are prefixed with a message detailing whether the decryption was
successful.

Change-Id: I01462c5d3b24a0d7a2fea92446c4e46949b1b4f4
misc/ckm_db_tool/CMakeLists.txt
misc/ckm_db_tool/ckm-logic-ext.cpp
misc/ckm_db_tool/ckm-logic-ext.h
misc/ckm_db_tool/ckm_db_tool.cpp
misc/ckm_db_tool/db-wrapper.cpp
misc/ckm_db_tool/db-wrapper.h
misc/ckm_db_tool/decrypt.cpp [new file with mode: 0644]
misc/ckm_db_tool/decrypt.h [new file with mode: 0644]
src/manager/service/ckm-logic.h