Add DES key schedule pre-draft implementation

This commit is contained in:
hashlag
2026-01-14 01:31:26 +03:00
parent 7f9430e0e6
commit 5e35462667
3 changed files with 201 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ set(ChaosTests_SOURCE Hash/Md4HasherTests.cpp
Mac/HmacTests.cpp
Cipher/Arc4GenTests.cpp
Cipher/Arc4CryptTests.cpp
Cipher/DesCryptTests.cpp
Service/SeArrayTests.cpp)
add_executable(ChaosTests ${ChaosTests_SOURCE})

View File

@@ -0,0 +1,38 @@
#include <gtest/gtest.h>
#include "Cipher/Des/DesCrypt.hpp"
using namespace Chaos::Cipher::Des;
TEST(DesCryptTests, KeyScheduleTest)
{
Inner_::RawKeyArray key;
key[0] = 0b00010011;
key[1] = 0b00110100;
key[2] = 0b01010111;
key[3] = 0b01111001;
key[4] = 0b10011011;
key[5] = 0b10111100;
key[6] = 0b11011111;
key[7] = 0b11110001;
Inner_::KeySchedule schedule(key);
ASSERT_EQ(0b000110110000001011101111111111000111000001110010ULL, schedule[0]);
ASSERT_EQ(0b011110011010111011011001110110111100100111100101ULL, schedule[1]);
ASSERT_EQ(0b010101011111110010001010010000101100111110011001ULL, schedule[2]);
ASSERT_EQ(0b011100101010110111010110110110110011010100011101ULL, schedule[3]);
ASSERT_EQ(0b011111001110110000000111111010110101001110101000ULL, schedule[4]);
ASSERT_EQ(0b011000111010010100111110010100000111101100101111ULL, schedule[5]);
ASSERT_EQ(0b111011001000010010110111111101100001100010111100ULL, schedule[6]);
ASSERT_EQ(0b111101111000101000111010110000010011101111111011ULL, schedule[7]);
ASSERT_EQ(0b111000001101101111101011111011011110011110000001ULL, schedule[8]);
ASSERT_EQ(0b101100011111001101000111101110100100011001001111ULL, schedule[9]);
ASSERT_EQ(0b001000010101111111010011110111101101001110000110ULL, schedule[10]);
ASSERT_EQ(0b011101010111000111110101100101000110011111101001ULL, schedule[11]);
ASSERT_EQ(0b100101111100010111010001111110101011101001000001ULL, schedule[12]);
ASSERT_EQ(0b010111110100001110110111111100101110011100111010ULL, schedule[13]);
ASSERT_EQ(0b101111111001000110001101001111010011111100001010ULL, schedule[14]);
ASSERT_EQ(0b110010110011110110001011000011100001011111110101ULL, schedule[15]);
}