From 9f4fff341b1ca691c4b1de135dcae392e1ff5602 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Sun, 20 Mar 2016 17:50:27 +0100 Subject: adding hextobyte implementation --- unittest/test_HOTP.cc | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/unittest/test_HOTP.cc b/unittest/test_HOTP.cc index dec299c..c1147d3 100644 --- a/unittest/test_HOTP.cc +++ b/unittest/test_HOTP.cc @@ -2,10 +2,11 @@ #include "catch.hpp" #include -#include +//#include #include "device_proto.h" #include "log.h" #include "stick10_commands.h" +#include using namespace std; using namespace nitrokey::device; @@ -20,7 +21,25 @@ std::string getSlotName(Stick10 &stick, int slotNo) { return sName; } -void setSecret (uint8_t slot_secret[]){}; +void setSecret (uint8_t slot_secret[], const char* secretHex){ + assert(strlen(secretHex)%2==0); + char buf[2]; + for(int i=0; i(slot_secret) ) == 0 ); +} TEST_CASE("Slot names are correct", "[slotNames]") { Stick10 stick; @@ -40,11 +59,13 @@ TEST_CASE("Slot names are correct", "[slotNames]") { { WriteToHOTPSlot::CommandTransaction::CommandPayload hwrite; hwrite.slot_number = 0; - strcpy(hwrite.slot_name, "rfc_test"); - strcpy(hwrite.slot_secret, ""); - hwrite.slot_config; - strcpy(hwrite.slot_token_id, ""); - strcpy(hwrite.slot_counter, ""); + strcpy(reinterpret_cast(hwrite.slot_name), "rfc_test"); + //strcpy(reinterpret_cast(hwrite.slot_secret), ""); + const char* secretHex = "3132333435363738393031323334353637383930"; + setSecret(hwrite.slot_secret, secretHex); + //hwrite.slot_config; + strcpy(reinterpret_cast(hwrite.slot_token_id), ""); + strcpy(reinterpret_cast(hwrite.slot_counter), ""); } -- cgit v1.2.3