fix: fix blowfish2 and add more tests

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
This commit is contained in:
2024-10-15 15:37:22 +05:30
parent 1f6e896785
commit ee4bd0d21d
2 changed files with 75 additions and 28 deletions

View File

@@ -733,7 +733,7 @@ void Blowfish2::initialize(std::string const &key) {
uint64_t j = 0, keylength = key.length();
for (uint64_t i = 0; i < N + 2; ++i) {
data = 0x00000000;
for (uint64_t k = 0; k < 4; ++k) {
for (uint64_t k = 0; k < 8; ++k) {
data = (data << 8) | key[j];
if (++j >= keylength) {
j = 0;
@@ -750,7 +750,7 @@ void Blowfish2::initialize(std::string const &key) {
PArray[i + 1] = datar;
}
for (uint64_t i = 0; i < 4; ++i) {
for (uint64_t i = 0; i < 8; ++i) {
for (uint64_t k = 0; k < 256; k += 2) {
encrypt(datal, datar);
Sboxes[i][k] = datal;