Switch to sqlcipher library
[platform/core/security/key-manager.git] / src / manager / dpl / db / src / sql_connection.cpp
index a9ee1b5..3aa5b72 100644 (file)
@@ -76,17 +76,17 @@ SqlConnection::DataCommand::DataCommand(SqlConnection *connection,
        ScopedNotifyAll notifyAll(connection->m_synchronizationObject.get());
 
        for (int i = 0; i < MAX_RETRY; i++) {
-               int ret = sqlcipher3_prepare_v2(connection->m_connection,
+               int ret = sqlite3_prepare_v2(connection->m_connection,
                                                                                buffer, strlen(buffer),
                                                                                &m_stmt, NULL);
 
-               if (ret == SQLCIPHER_OK) {
+               if (ret == SQLITE_OK) {
                        LogPedantic("Prepared data command: " << buffer);
 
                        // Increment stored data command count
                        ++m_masterConnection->m_dataCommandsCount;
                        return;
-               } else if (ret == SQLCIPHER_BUSY) {
+               } else if (ret == SQLITE_BUSY) {
                        LogPedantic("Collision occurred while preparing SQL command");
 
                        // Synchronize if synchronization object is available
@@ -100,7 +100,7 @@ SqlConnection::DataCommand::DataCommand(SqlConnection *connection,
                }
 
                // Fatal error
-               const char *error = sqlcipher3_errmsg(m_masterConnection->m_connection);
+               const char *error = sqlite3_errmsg(m_masterConnection->m_connection);
 
                LogError("SQL prepare data command failed");
                LogError("    Statement: " << buffer);
@@ -117,7 +117,7 @@ SqlConnection::DataCommand::~DataCommand()
 {
        LogPedantic("SQL data command finalizing");
 
-       if (sqlcipher3_finalize(m_stmt) != SQLCIPHER_OK)
+       if (sqlite3_finalize(m_stmt) != SQLITE_OK)
                LogError("Failed to finalize data command");
 
        // Decrement stored data command count
@@ -126,8 +126,8 @@ SqlConnection::DataCommand::~DataCommand()
 
 void SqlConnection::DataCommand::CheckBindResult(int result)
 {
-       if (result != SQLCIPHER_OK) {
-               const char *error = sqlcipher3_errmsg(
+       if (result != SQLITE_OK) {
+               const char *error = sqlite3_errmsg(
                                                                m_masterConnection->m_connection);
 
                LogError("Failed to bind SQL statement parameter");
@@ -141,7 +141,7 @@ void SqlConnection::DataCommand::CheckBindResult(int result)
 void SqlConnection::DataCommand::BindNull(
        SqlConnection::ArgumentIndex position)
 {
-       CheckBindResult(sqlcipher3_bind_null(m_stmt, position));
+       CheckBindResult(sqlite3_bind_null(m_stmt, position));
        LogPedantic("SQL data command bind null: ["
                                << position << "]");
 }
@@ -151,7 +151,7 @@ void SqlConnection::DataCommand::BindInteger(
        SqlConnection::ArgumentIndex position,
        int value)
 {
-       CheckBindResult(sqlcipher3_bind_int(m_stmt, position, value));
+       CheckBindResult(sqlite3_bind_int(m_stmt, position, value));
        LogPedantic("SQL data command bind integer: ["
                                << position << "] -> " << value);
 }
@@ -161,7 +161,7 @@ void SqlConnection::DataCommand::BindInt8(
        SqlConnection::ArgumentIndex position,
        int8_t value)
 {
-       CheckBindResult(sqlcipher3_bind_int(m_stmt, position,
+       CheckBindResult(sqlite3_bind_int(m_stmt, position,
                                                                                static_cast<int>(value)));
        LogPedantic("SQL data command bind int8: ["
                                << position << "] -> " << value);
@@ -171,7 +171,7 @@ void SqlConnection::DataCommand::BindInt16(
        SqlConnection::ArgumentIndex position,
        int16_t value)
 {
-       CheckBindResult(sqlcipher3_bind_int(m_stmt, position,
+       CheckBindResult(sqlite3_bind_int(m_stmt, position,
                                                                                static_cast<int>(value)));
        LogPedantic("SQL data command bind int16: ["
                                << position << "] -> " << value);
@@ -181,7 +181,7 @@ void SqlConnection::DataCommand::BindInt32(
        SqlConnection::ArgumentIndex position,
        int32_t value)
 {
-       CheckBindResult(sqlcipher3_bind_int(m_stmt, position,
+       CheckBindResult(sqlite3_bind_int(m_stmt, position,
                                                                                static_cast<int>(value)));
        LogPedantic("SQL data command bind int32: ["
                                << position << "] -> " << value);
@@ -191,8 +191,8 @@ void SqlConnection::DataCommand::BindInt64(
        SqlConnection::ArgumentIndex position,
        int64_t value)
 {
-       CheckBindResult(sqlcipher3_bind_int64(m_stmt, position,
-                                                                                 static_cast<sqlcipher3_int64>(value)));
+       CheckBindResult(sqlite3_bind_int64(m_stmt, position,
+                                                                                 static_cast<sqlite3_int64>(value)));
        LogPedantic("SQL data command bind int64: ["
                                << position << "] -> " << value);
 }
@@ -201,7 +201,7 @@ void SqlConnection::DataCommand::BindFloat(
        SqlConnection::ArgumentIndex position,
        float value)
 {
-       CheckBindResult(sqlcipher3_bind_double(m_stmt, position,
+       CheckBindResult(sqlite3_bind_double(m_stmt, position,
                                                                                   static_cast<double>(value)));
        LogPedantic("SQL data command bind float: ["
                                << position << "] -> " << value);
@@ -211,7 +211,7 @@ void SqlConnection::DataCommand::BindDouble(
        SqlConnection::ArgumentIndex position,
        double value)
 {
-       CheckBindResult(sqlcipher3_bind_double(m_stmt, position, value));
+       CheckBindResult(sqlite3_bind_double(m_stmt, position, value));
        LogPedantic("SQL data command bind double: ["
                                << position << "] -> " << value);
 }
@@ -227,9 +227,9 @@ void SqlConnection::DataCommand::BindString(
        }
 
        // Assume that text may disappear
-       CheckBindResult(sqlcipher3_bind_text(m_stmt, position,
+       CheckBindResult(sqlite3_bind_text(m_stmt, position,
                                                                                 value, strlen(value),
-                                                                                SQLCIPHER_TRANSIENT));
+                                                                                SQLITE_TRANSIENT));
 
        LogPedantic("SQL data command bind string: ["
                                << position << "] -> " << value);
@@ -245,9 +245,9 @@ void SqlConnection::DataCommand::BindBlob(
        }
 
        // Assume that blob may dissappear
-       CheckBindResult(sqlcipher3_bind_blob(m_stmt, position,
+       CheckBindResult(sqlite3_bind_blob(m_stmt, position,
                                                                                 raw.data(), raw.size(),
-                                                                                SQLCIPHER_TRANSIENT));
+                                                                                SQLITE_TRANSIENT));
        LogPedantic("SQL data command bind blob of size: ["
                                << position << "] -> " << raw.size());
 }
@@ -341,15 +341,15 @@ bool SqlConnection::DataCommand::Step()
                m_masterConnection->m_synchronizationObject.get());
 
        for (int i = 0; i < MAX_RETRY; i++) {
-               int ret = sqlcipher3_step(m_stmt);
+               int ret = sqlite3_step(m_stmt);
 
-               if (ret == SQLCIPHER_ROW) {
+               if (ret == SQLITE_ROW) {
                        LogPedantic("SQL data command step ROW");
                        return true;
-               } else if (ret == SQLCIPHER_DONE) {
+               } else if (ret == SQLITE_DONE) {
                        LogPedantic("SQL data command step DONE");
                        return false;
-               } else if (ret == SQLCIPHER_BUSY) {
+               } else if (ret == SQLITE_BUSY) {
                        LogPedantic("Collision occurred while executing SQL command");
 
                        // Synchronize if synchronization object is available
@@ -366,7 +366,7 @@ bool SqlConnection::DataCommand::Step()
                }
 
                // Fatal error
-               const char *error = sqlcipher3_errmsg(m_masterConnection->m_connection);
+               const char *error = sqlite3_errmsg(m_masterConnection->m_connection);
 
                LogError("SQL step data command failed");
                LogError("    Error: " << error);
@@ -384,11 +384,11 @@ void SqlConnection::DataCommand::Reset()
         * According to:
         * http://www.sqllite.org/c3ref/stmt.html
         *
-        * if last sqlcipher3_step command on this stmt returned an error,
-        * then sqlcipher3_reset will return that error, althought it is not an error.
-        * So sqlcipher3_reset allways succedes.
+        * if last sqlite3_step command on this stmt returned an error,
+        * then sqlite3_reset will return that error, althought it is not an error.
+        * So sqlite3_reset allways succedes.
         */
-       sqlcipher3_reset(m_stmt);
+       sqlite3_reset(m_stmt);
 
        LogPedantic("SQL data command reset");
 }
@@ -396,7 +396,7 @@ void SqlConnection::DataCommand::Reset()
 void SqlConnection::DataCommand::CheckColumnIndex(
        SqlConnection::ColumnIndex column)
 {
-       if (column < 0 || column >= sqlcipher3_column_count(m_stmt))
+       if (column < 0 || column >= sqlite3_column_count(m_stmt))
                ThrowMsg(Exception::InvalidColumn, "Column index is out of bounds");
 }
 
@@ -406,7 +406,7 @@ bool SqlConnection::DataCommand::IsColumnNull(
 {
        LogPedantic("SQL data command get column type: [" << column << "]");
        CheckColumnIndex(column);
-       return sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL;
+       return sqlite3_column_type(m_stmt, column) == SQLITE_NULL;
 }
 //LCOV_EXCL_STOP
 
@@ -415,7 +415,7 @@ int SqlConnection::DataCommand::GetColumnInteger(
 {
        LogPedantic("SQL data command get column integer: [" << column << "]");
        CheckColumnIndex(column);
-       int value = sqlcipher3_column_int(m_stmt, column);
+       int value = sqlite3_column_int(m_stmt, column);
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -426,7 +426,7 @@ int8_t SqlConnection::DataCommand::GetColumnInt8(
 {
        LogPedantic("SQL data command get column int8: [" << column << "]");
        CheckColumnIndex(column);
-       int8_t value = static_cast<int8_t>(sqlcipher3_column_int(m_stmt, column));
+       int8_t value = static_cast<int8_t>(sqlite3_column_int(m_stmt, column));
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -436,7 +436,7 @@ int16_t SqlConnection::DataCommand::GetColumnInt16(
 {
        LogPedantic("SQL data command get column int16: [" << column << "]");
        CheckColumnIndex(column);
-       int16_t value = static_cast<int16_t>(sqlcipher3_column_int(m_stmt, column));
+       int16_t value = static_cast<int16_t>(sqlite3_column_int(m_stmt, column));
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -446,7 +446,7 @@ int32_t SqlConnection::DataCommand::GetColumnInt32(
 {
        LogPedantic("SQL data command get column int32: [" << column << "]");
        CheckColumnIndex(column);
-       int32_t value = static_cast<int32_t>(sqlcipher3_column_int(m_stmt, column));
+       int32_t value = static_cast<int32_t>(sqlite3_column_int(m_stmt, column));
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -456,7 +456,7 @@ int64_t SqlConnection::DataCommand::GetColumnInt64(
 {
        LogPedantic("SQL data command get column int64: [" << column << "]");
        CheckColumnIndex(column);
-       int64_t value = static_cast<int64_t>(sqlcipher3_column_int64(m_stmt, column));
+       int64_t value = static_cast<int64_t>(sqlite3_column_int64(m_stmt, column));
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -466,7 +466,7 @@ float SqlConnection::DataCommand::GetColumnFloat(
 {
        LogPedantic("SQL data command get column float: [" << column << "]");
        CheckColumnIndex(column);
-       float value = static_cast<float>(sqlcipher3_column_double(m_stmt, column));
+       float value = static_cast<float>(sqlite3_column_double(m_stmt, column));
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -476,7 +476,7 @@ double SqlConnection::DataCommand::GetColumnDouble(
 {
        LogPedantic("SQL data command get column double: [" << column << "]");
        CheckColumnIndex(column);
-       double value = sqlcipher3_column_double(m_stmt, column);
+       double value = sqlite3_column_double(m_stmt, column);
        LogPedantic("    Value: " << value);
        return value;
 }
@@ -489,7 +489,7 @@ std::string SqlConnection::DataCommand::GetColumnString(
        CheckColumnIndex(column);
 
        const char *value = reinterpret_cast<const char *>(
-                                                       sqlcipher3_column_text(m_stmt, column));
+                                                       sqlite3_column_text(m_stmt, column));
 
        LogPedantic("Value: " << (value ? value : "NULL"));
 
@@ -506,12 +506,12 @@ RawBuffer SqlConnection::DataCommand::GetColumnBlob(
        CheckColumnIndex(column);
 
        const unsigned char *value = reinterpret_cast<const unsigned char *>(
-                                                                        sqlcipher3_column_blob(m_stmt, column));
+                                                                        sqlite3_column_blob(m_stmt, column));
 
        if (value == NULL)
                return RawBuffer();
 
-       int length = sqlcipher3_column_bytes(m_stmt, column);
+       int length = sqlite3_column_bytes(m_stmt, column);
        LogPedantic("Got blob of length: " << length);
 
        return RawBuffer(value, value + length);
@@ -525,10 +525,10 @@ boost::optional<int> SqlConnection::DataCommand::GetColumnOptionalInteger(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<int>();
 
-       int value = sqlcipher3_column_int(m_stmt, column);
+       int value = sqlite3_column_int(m_stmt, column);
        LogPedantic("    Value: " << value);
        return boost::optional<int>(value);
 }
@@ -540,10 +540,10 @@ boost::optional<int8_t> SqlConnection::DataCommand::GetColumnOptionalInt8(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<int8_t>();
 
-       int8_t value = static_cast<int8_t>(sqlcipher3_column_int(m_stmt, column));
+       int8_t value = static_cast<int8_t>(sqlite3_column_int(m_stmt, column));
        LogPedantic("    Value: " << value);
        return boost::optional<int8_t>(value);
 }
@@ -555,10 +555,10 @@ boost::optional<int16_t> SqlConnection::DataCommand::GetColumnOptionalInt16(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<int16_t>();
 
-       int16_t value = static_cast<int16_t>(sqlcipher3_column_int(m_stmt, column));
+       int16_t value = static_cast<int16_t>(sqlite3_column_int(m_stmt, column));
        LogPedantic("    Value: " << value);
        return boost::optional<int16_t>(value);
 }
@@ -570,10 +570,10 @@ boost::optional<int32_t> SqlConnection::DataCommand::GetColumnOptionalInt32(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<int32_t>();
 
-       int32_t value = static_cast<int32_t>(sqlcipher3_column_int(m_stmt, column));
+       int32_t value = static_cast<int32_t>(sqlite3_column_int(m_stmt, column));
        LogPedantic("    Value: " << value);
        return boost::optional<int32_t>(value);
 }
@@ -585,10 +585,10 @@ boost::optional<int64_t> SqlConnection::DataCommand::GetColumnOptionalInt64(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<int64_t>();
 
-       int64_t value = static_cast<int64_t>(sqlcipher3_column_int64(m_stmt, column));
+       int64_t value = static_cast<int64_t>(sqlite3_column_int64(m_stmt, column));
        LogPedantic("    Value: " << value);
        return boost::optional<int64_t>(value);
 }
@@ -600,10 +600,10 @@ boost::optional<float> SqlConnection::DataCommand::GetColumnOptionalFloat(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<float>();
 
-       float value = static_cast<float>(sqlcipher3_column_double(m_stmt, column));
+       float value = static_cast<float>(sqlite3_column_double(m_stmt, column));
        LogPedantic("    Value: " << value);
        return boost::optional<float>(value);
 }
@@ -615,10 +615,10 @@ boost::optional<double> SqlConnection::DataCommand::GetColumnOptionalDouble(
                                << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<double>();
 
-       double value = sqlcipher3_column_double(m_stmt, column);
+       double value = sqlite3_column_double(m_stmt, column);
        LogPedantic("    Value: " << value);
        return boost::optional<double>(value);
 }
@@ -629,13 +629,13 @@ boost::optional<RawBuffer> SqlConnection::DataCommand::GetColumnOptionalBlob(
        LogPedantic("SQL data command get column blog: [" << column << "]");
        CheckColumnIndex(column);
 
-       if (sqlcipher3_column_type(m_stmt, column) == SQLCIPHER_NULL)
+       if (sqlite3_column_type(m_stmt, column) == SQLITE_NULL)
                return boost::optional<RawBuffer>();
 
        const unsigned char *value = reinterpret_cast<const unsigned char *>(
-                                                                        sqlcipher3_column_blob(m_stmt, column));
+                                                                        sqlite3_column_blob(m_stmt, column));
 
-       int length = sqlcipher3_column_bytes(m_stmt, column);
+       int length = sqlite3_column_bytes(m_stmt, column);
        LogPedantic("Got blob of length: " << length);
 
        RawBuffer temp(value, value + length);
@@ -655,13 +655,13 @@ void SqlConnection::Connect(const std::string &address,
 
        // Connect to database
        int result;
-       result = sqlcipher3_open_v2(
+       result = sqlite3_open_v2(
                                 address.c_str(),
                                 &m_connection,
                                 flag,
                                 NULL);
 
-       if (result == SQLCIPHER_OK) {
+       if (result == SQLITE_OK) {
                LogPedantic("Connected to DB");
        } else {
                LogError("Failed to connect to DB!");
@@ -672,9 +672,9 @@ void SqlConnection::Connect(const std::string &address,
        TurnOnForeignKeys();
 }
 
-const std::string SQLCIPHER_RAW_PREFIX = "x'";
-const std::string SQLCIPHER_RAW_SUFIX = "'";
-const std::size_t SQLCIPHER_RAW_DATA_SIZE = 32;
+const std::string SQLITE_RAW_PREFIX = "x'";
+const std::string SQLITE_RAW_SUFIX = "'";
+const std::size_t SQLITE_RAW_DATA_SIZE = 32;
 
 RawBuffer rawToHexString(const RawBuffer &raw)
 {
@@ -686,7 +686,7 @@ RawBuffer createHexPass(const RawBuffer &rawPass)
        // We are required to pass 64byte long hex password made out of 32byte raw
        // binary data
        RawBuffer output;
-       std::copy(SQLCIPHER_RAW_PREFIX.begin(), SQLCIPHER_RAW_PREFIX.end(),
+       std::copy(SQLITE_RAW_PREFIX.begin(), SQLITE_RAW_PREFIX.end(),
                          std::back_inserter(output));
 
        RawBuffer password = rawToHexString(rawPass);
@@ -694,7 +694,7 @@ RawBuffer createHexPass(const RawBuffer &rawPass)
        std::copy(password.begin(), password.end(),
                          std::back_inserter(output));
 
-       std::copy(SQLCIPHER_RAW_SUFIX.begin(), SQLCIPHER_RAW_SUFIX.end(),
+       std::copy(SQLITE_RAW_SUFIX.begin(), SQLITE_RAW_SUFIX.end(),
                          std::back_inserter(output));
 
        return output;
@@ -707,17 +707,17 @@ void SqlConnection::SetKey(const RawBuffer &rawPass)
                return;
        }
 
-       if (rawPass.size() != SQLCIPHER_RAW_DATA_SIZE)
+       if (rawPass.size() != SQLITE_RAW_DATA_SIZE)
                ThrowMsg(Exception::InvalidArguments,
                                 "Binary data for raw password should be 32 bytes long.");
 
        RawBuffer pass = createHexPass(rawPass);
-       int result = sqlcipher3_key(m_connection, pass.data(), pass.size());
+       int result = sqlite3_key(m_connection, pass.data(), pass.size());
 
-       if (result == SQLCIPHER_OK) {
+       if (result == SQLITE_OK) {
                LogPedantic("Set key on DB");
        } else {
-               //sqlcipher3_key fails only when m_connection == NULL || key == NULL ||
+               //sqlite3_key fails only when m_connection == NULL || key == NULL ||
                //                            key length == 0
                LogError("Failed to set key on DB");
                ThrowMsg(Exception::InvalidArguments, result);
@@ -736,21 +736,20 @@ void SqlConnection::ResetKey(const RawBuffer &rawPassOld,
        }
 
        // Binary data for raw password should be 32 bytes long.
-       assert(rawPassOld.size() == SQLCIPHER_RAW_DATA_SIZE &&
-              rawPassNew.size() == SQLCIPHER_RAW_DATA_SIZE);
+       assert(rawPassOld.size() == SQLITE_RAW_DATA_SIZE &&
+              rawPassNew.size() == SQLITE_RAW_DATA_SIZE);
 
-
-       // sqlcipher3_rekey requires for key to be already set
+       // sqlite3_rekey requires for key to be already set
        if (!m_isKeySet)
                SetKey(rawPassOld);
 
        RawBuffer pass = createHexPass(rawPassNew);
-       int result = sqlcipher3_rekey(m_connection, pass.data(), pass.size());
+       int result = sqlite3_rekey(m_connection, pass.data(), pass.size());
 
-       if (result == SQLCIPHER_OK) {
+       if (result == SQLITE_OK) {
                LogPedantic("Reset key on DB");
        } else {
-               //sqlcipher3_rekey fails only when m_connection == NULL || key == NULL ||
+               //sqlite3_rekey fails only when m_connection == NULL || key == NULL ||
                //                              key length == 0
                LogError("Failed to reset key on DB");
                ThrowMsg(Exception::InvalidArguments, result);
@@ -772,10 +771,10 @@ void SqlConnection::Disconnect()
 
        int result;
 
-       result = sqlcipher3_close(m_connection);
+       result = sqlite3_close(m_connection);
 
-       if (result != SQLCIPHER_OK) {
-               const char *error = sqlcipher3_errmsg(m_connection);
+       if (result != SQLITE_OK) {
+               const char *error = sqlite3_errmsg(m_connection);
                LogError("SQL close failed");
                LogError("    Error: " << error);
                Throw(Exception::InternalError);
@@ -794,7 +793,7 @@ bool SqlConnection::CheckTableExist(const char *tableName)
        }
 
        DataCommandUniquePtr command =
-               PrepareDataCommand("select tbl_name from sqlcipher_master where name=?;");
+               PrepareDataCommand("select tbl_name from sqlite_master where name=?;");
 
        command->BindString(1, tableName);
 
@@ -890,7 +889,7 @@ void SqlConnection::ExecCommandHelper(Output *out, const char *format,
 
        for (int i = 0; i < MAX_RETRY; i++) {
                char *errorBuffer;
-               int ret = sqlcipher3_exec(m_connection,
+               int ret = sqlite3_exec(m_connection,
                                                                  queryPtr.get(),
                                                                  out ? &Output::Callback : NULL,
                                                                  out,
@@ -901,13 +900,13 @@ void SqlConnection::ExecCommandHelper(Output *out, const char *format,
                // Take allocated error buffer
                if (errorBuffer != NULL) {
                        errorMsg = errorBuffer;
-                       sqlcipher3_free(errorBuffer);
+                       sqlite3_free(errorBuffer);
                }
 
-               if (ret == SQLCIPHER_OK)
+               if (ret == SQLITE_OK)
                        return;
 
-               if (ret == SQLCIPHER_BUSY) {
+               if (ret == SQLITE_BUSY) {
                        LogPedantic("Collision occurred while executing SQL command");
 
                        // Synchronize if synchronization object is available
@@ -991,7 +990,7 @@ SqlConnection::DataCommandUniquePtr SqlConnection::PrepareDataCommand(
 //LCOV_EXCL_START
 SqlConnection::RowID SqlConnection::GetLastInsertRowID() const
 {
-       return static_cast<RowID>(sqlcipher3_last_insert_rowid(m_connection));
+       return static_cast<RowID>(sqlite3_last_insert_rowid(m_connection));
 }
 //LCOV_EXCL_STOP