forked from cory/tildefriends
Remove dependency on base64c. Use libsodium's. Also consolidate the calls, as the usage is quite special.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4175 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
11
src/ssb.db.c
11
src/ssb.db.c
@ -5,7 +5,6 @@
|
||||
#include "trace.h"
|
||||
#include "util.js.h"
|
||||
|
||||
#include <base64c.h>
|
||||
#include <sodium/crypto_hash_sha256.h>
|
||||
#include <sodium/crypto_scalarmult.h>
|
||||
#include <sodium/crypto_scalarmult_curve25519.h>
|
||||
@ -434,7 +433,7 @@ bool tf_ssb_db_blob_store(tf_ssb_t* ssb, const uint8_t* blob, size_t size, char*
|
||||
crypto_hash_sha256(hash, blob, size);
|
||||
|
||||
char hash64[256];
|
||||
base64c_encode(hash, sizeof(hash), (uint8_t*)hash64, sizeof(hash64));
|
||||
tf_base64_encode(hash, sizeof(hash), hash64, sizeof(hash64));
|
||||
|
||||
char id[512];
|
||||
snprintf(id, sizeof(id), "&%s.sha256", hash64);
|
||||
@ -965,8 +964,8 @@ bool tf_ssb_db_identity_get_private_key(tf_ssb_t* ssb, const char* user, const c
|
||||
{
|
||||
if (sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
const uint8_t* key = sqlite3_column_text(statement, 0);
|
||||
int r = base64c_decode(key, sqlite3_column_bytes(statement, 0) - strlen(".ed25519"), out_private_key, private_key_size);
|
||||
const char* key = (const char*)sqlite3_column_text(statement, 0);
|
||||
int r = tf_base64_decode(key, sqlite3_column_bytes(statement, 0) - strlen(".ed25519"), out_private_key, private_key_size);
|
||||
success = r > 0;
|
||||
}
|
||||
}
|
||||
@ -1140,7 +1139,7 @@ static void _test_private(sqlite3* db, const uint8_t* private_key)
|
||||
while (sqlite3_step(statement) == SQLITE_ROW)
|
||||
{
|
||||
uint8_t buffer[8192];
|
||||
int r = base64c_decode(sqlite3_column_text(statement, 0) + 1, sqlite3_column_bytes(statement, 0) - strlen("\".box\""), buffer, sizeof(buffer));
|
||||
int r = tf_base64_decode((const char*)sqlite3_column_text(statement, 0) + 1, sqlite3_column_bytes(statement, 0) - strlen("\".box\""), buffer, sizeof(buffer));
|
||||
|
||||
if (r > 1)
|
||||
{
|
||||
@ -1195,7 +1194,7 @@ void tf_ssb_db_private(sqlite3* db)
|
||||
{
|
||||
uint8_t private_key[crypto_sign_SECRETKEYBYTES] = { 0 };
|
||||
printf("-> %s\n", sqlite3_column_text(statement, 0));
|
||||
int r = base64c_decode(sqlite3_column_text(statement, 1), sqlite3_column_bytes(statement, 1) - strlen(".ed25519"), private_key, sizeof(private_key));
|
||||
int r = tf_base64_decode((const char*)sqlite3_column_text(statement, 1), sqlite3_column_bytes(statement, 1) - strlen(".ed25519"), private_key, sizeof(private_key));
|
||||
if (r == sizeof(private_key))
|
||||
{
|
||||
uint8_t key[crypto_sign_SECRETKEYBYTES] = { 0 };
|
||||
|
Reference in New Issue
Block a user