implemented client interactive mode

This commit is contained in:
2025-08-28 19:11:28 +03:00
parent c008d759ae
commit f01c5fc8a9
11 changed files with 234 additions and 105 deletions

View File

@@ -4,13 +4,14 @@
#include "tlibc/string/str.h"
#include "bearssl_block.h"
#include "bearssl_rand.h"
#include "bearssl_rsa.h"
/// @brief hashes password multiple times using its own hash as salt
/// @param password some byte array
/// @param out_buffer u8[hash_password_out_size]
/// @param out_buffer u8[password_hash_size]
/// @param iterations number of iterations
void hash_password(str password, u8* out_buffer, i32 iterations);
#define hash_password_out_size 32
#define password_hash_size 32
typedef struct EncryptedBlockInfo {
@@ -59,7 +60,11 @@ void DecryptorAES_decrypt(DecryptorAES* ptr, Array(u8) src, Array(u8) dst, u32*
typedef struct EncryptorRSA EncryptorRSA;
typedef struct EncryptorRSA {
br_rsa_public_key public_key;
} EncryptorRSA;
typedef struct DecryptorRSA DecryptorRSA;
typedef struct DecryptorRSA {
br_rsa_private_key private_key;
} DecryptorRSA;

View File

@@ -3,7 +3,7 @@
#include "assert.h"
void hash_password(str password, u8* out_buffer, i32 iterations){
assert(hash_password_out_size == br_sha256_SIZE);;
assert(password_hash_size == br_sha256_SIZE);;
memset(out_buffer, 0, br_sha256_SIZE);
br_sha256_context sha256_ctx;
br_sha256_init(&sha256_ctx);
@@ -11,7 +11,7 @@ void hash_password(str password, u8* out_buffer, i32 iterations){
for(i32 i = 0; i < iterations; i++){
br_sha256_update(&sha256_ctx, password.data, password.size);
br_sha256_out(&sha256_ctx, out_buffer);
br_sha256_update(&sha256_ctx, out_buffer, hash_password_out_size);
br_sha256_update(&sha256_ctx, out_buffer, password_hash_size);
}
br_sha256_out(&sha256_ctx, out_buffer);
}