Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hmac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace hmac {
digest_size = hmac_hash::SHA512::DIGEST_SIZE;
break;
default:
return {};
throw std::invalid_argument("Unsupported hash type");
}

// Step 1: Normalize key
Expand Down
7 changes: 7 additions & 0 deletions test_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ TEST(HMACTest, NullPointersThrow) {
EXPECT_THROW(hmac::get_hmac(key, 3, nullptr, 1, hmac::TypeHash::SHA256), std::invalid_argument);
}

TEST(HMACTest, InvalidTypeThrows) {
const char* key = "key";
const char* msg = "abc";
auto invalid = static_cast<hmac::TypeHash>(999);
EXPECT_THROW(hmac::get_hmac(key, 3, msg, 3, invalid), std::invalid_argument);
}

TEST(TOTPTest, AtTime) {
const std::string totp_key = "12345678901234567890";
uint64_t test_time = 1234567890;
Expand Down
Loading