【发布时间】:2014-11-11 23:37:48
【问题描述】:
我成功地将 GCrypt 加密密钥 (0x135aa10) 作为 CassBytes 结构添加到 Cassandra 集群。请参阅 Cassandra C++ 包括:https://github.com/datastax/cpp-driver/blob/1.0/include/cassandra.h。
// Create PSK Blob
CassBytes pskey_blob;
pskey_blob = cass_bytes_init((const cass_byte_t*) pskey, sizeof(pskey));
// Check that key BLOBED correctly
gcry_sexp_t tmpkey = (gcry_sexp_t)pskey_blob.data; //This correctly returns GCrypt Crypto Key (0x135aa10)
// Bind PSK Blob & Execute Statment
cass_statement_bind_bytes(statement, 0, pskey_blob);
future = cass_session_execute(session, statement);
cass_future_wait(future);
然后我从 Cassandra 检索 GCrypt 加密密钥,如下所示:
// Get Payload Secret Key
CassBytes pskey_blob;
cass_value_get_bytes(cass_row_get_column(row, 0), &pskey_blob);
if (pskey_blob.size != 0) {
pskey = (gcry_sexp_t)pskey_blob.data;
std::cout << "pskey: " << pskey << std::endl;
}
blob 数据在 CassBytes 结构 (pskey_blob.data) 中返回为 0x7f7fb00028a4,正确大小为 8 (pskey_blob.size)。似乎 Cassandra 将我的原始 unit8_t 类型 GCrypt 加密密钥 (0x135aa10) 的 HEX 表示形式返回为 HEX (0x7f7fb00028a4)。
有谁知道如何将其从 Cassandra 字节表示形式转换为 GCrypt 加密密钥?
【问题讨论】: