Skip to content

Commit

Permalink
encryption add bind phrase feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Aug 11, 2023
1 parent 2616f7c commit f738e66
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions executables/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ static void test_fec_stream_random_bs_fs_overhead_dropped(){

// Test encryption+packet validation and packet validation only
static void test_encrypt_decrypt_validate(const bool use_key_from_file,bool message_signing_only) {
std::cout << "Using generated keypair (default seed otherwise):" << (use_key_from_file ? "y" : "n") << "\n";
const std::string TEST_TYPE=message_signing_only ? "Sign" : "Encrypt&Sign";
const std::string TEST_KEY_TYPE=use_key_from_file ? "key from file" : "default key";
fmt::print("Testing {} with {}\n",TEST_TYPE,TEST_KEY_TYPE);
const std::string KEY_FILENAME="../example_key/txrx.key";
wb::KeyPairTxRx keyPairTxRx{};
if(use_key_from_file){
Expand All @@ -119,11 +121,6 @@ static void test_encrypt_decrypt_validate(const bool use_key_from_file,bool mess
keyPairTxRx=wb::generate_keypair_from_bind_phrase("openhd");
std::cout<<"Generating keypair from bind phrase took:"<<MyTimeHelper::R(std::chrono::steady_clock::now()-before)<<std::endl;
}
if(message_signing_only){
std::cout<<"Testing message signing\n";
}else{
std::cout<<"Testing encryption & signing\n";
}

wb::Encryptor encryptor{keyPairTxRx.get_tx_key(true)};// We send from air unit
encryptor.set_encryption_enabled(!message_signing_only);
Expand Down Expand Up @@ -177,7 +174,7 @@ static void test_encrypt_decrypt_validate(const bool use_key_from_file,bool mess
nonce, enrypted_wrong_sign->data(), enrypted_wrong_sign->size());
assert(decrypted== nullptr);
}
std::cout << "encryption test passed\n";
fmt::print("Test {} with {} passed\n",TEST_TYPE,TEST_KEY_TYPE);
}


Expand Down

0 comments on commit f738e66

Please sign in to comment.