mirror of
https://github.com/avinal/blowfish.git
synced 2026-01-11 07:18:32 +05:30
feat: add more robust tests
- add test to cover corner cases and known failure points Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
22
tests/test_vectors.cpp
Normal file
22
tests/test_vectors.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-FileCopyrightText: 2025 Avinal Kumar avinal.xlvii@gmail.com
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "test_framework.h"
|
||||
#include <blowfish/blowfish.h>
|
||||
|
||||
// Known Answer Tests (KAT): Validate Blowfish output against fixed reference
|
||||
// vectors to ensure algorithmic correctness.
|
||||
TEST("Blowfish Known Test Vectors") {
|
||||
Blowfish bf("abcdefghijklmnopqrstuvwxyz");
|
||||
|
||||
uint32_t L = 0x424C4F57; // "BLOW"
|
||||
uint32_t R = 0x46495348; // "FISH"
|
||||
|
||||
bf.encrypt(L, R);
|
||||
EXPECT_EQ(L, 0x324ED0FE);
|
||||
EXPECT_EQ(R, 0xF413A203);
|
||||
|
||||
bf.decrypt(L, R);
|
||||
EXPECT_EQ(L, 0x424C4F57);
|
||||
EXPECT_EQ(R, 0x46495348);
|
||||
}
|
||||
Reference in New Issue
Block a user