diff options
author | Kai Michaelis <[email protected]> | 2016-08-10 17:51:42 +0200 |
---|---|---|
committer | seu <[email protected]> | 2016-10-02 18:10:32 +0200 |
commit | cc5bca63e7e7b4ae1650e9f468e3c1a00623579f (patch) | |
tree | 1777abf62fc7e3e4a2dce8d3c8c87449f9b46816 /src/lib/utils | |
parent | 9ba36a7097f29ee54a88e34f38e3bc9842accea6 (diff) |
Certificate store using SQLite
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/database.h | 2 | ||||
-rw-r--r-- | src/lib/utils/sqlite3/sqlite3.cpp | 7 | ||||
-rw-r--r-- | src/lib/utils/sqlite3/sqlite3.h | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/utils/database.h b/src/lib/utils/database.h index 4cc0989b1..0cd45dac0 100644 --- a/src/lib/utils/database.h +++ b/src/lib/utils/database.h @@ -38,6 +38,8 @@ class BOTAN_DLL SQL_Database virtual void bind(int column, const std::vector<byte>& blob) = 0; + virtual void bind(int column, const byte* data, size_t len) = 0; + /* Get output */ virtual std::pair<const byte*, size_t> get_blob(int column) = 0; diff --git a/src/lib/utils/sqlite3/sqlite3.cpp b/src/lib/utils/sqlite3/sqlite3.cpp index 77b4c0d10..251cbcdf5 100644 --- a/src/lib/utils/sqlite3/sqlite3.cpp +++ b/src/lib/utils/sqlite3/sqlite3.cpp @@ -99,6 +99,13 @@ void Sqlite3_Database::Sqlite3_Statement::bind(int column, const std::vector<byt throw SQL_DB_Error("sqlite3_bind_text failed, code " + std::to_string(rc)); } +void Sqlite3_Database::Sqlite3_Statement::bind(int column, const byte* p, size_t len) + { + int rc = ::sqlite3_bind_blob(m_stmt, column, p, len, SQLITE_TRANSIENT); + if(rc != SQLITE_OK) + throw SQL_DB_Error("sqlite3_bind_text failed, code " + std::to_string(rc)); + } + std::pair<const byte*, size_t> Sqlite3_Database::Sqlite3_Statement::get_blob(int column) { BOTAN_ASSERT(::sqlite3_column_type(m_stmt, 0) == SQLITE_BLOB, diff --git a/src/lib/utils/sqlite3/sqlite3.h b/src/lib/utils/sqlite3/sqlite3.h index 067b94e85..659e1c487 100644 --- a/src/lib/utils/sqlite3/sqlite3.h +++ b/src/lib/utils/sqlite3/sqlite3.h @@ -35,6 +35,7 @@ class BOTAN_DLL Sqlite3_Database : public SQL_Database void bind(int column, size_t val) override; void bind(int column, std::chrono::system_clock::time_point time) override; void bind(int column, const std::vector<byte>& val) override; + void bind(int column, const byte* data, size_t len) override; std::pair<const byte*, size_t> get_blob(int column) override; size_t get_size_t(int column) override; |