mirror of
https://github.com/avinal/blowfish.git
synced 2026-01-09 22:38:33 +05:30
- add test to cover corner cases and known failure points Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
23 lines
599 B
C++
23 lines
599 B
C++
// 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);
|
|
}
|