Cipher Fayadh
Block cipher Feistel 128-bit dengan fungsi putaran sigma-delta
Loading...
Searching...
No Matches
key_schedule.hpp File Reference

Key schedule: membangkitkan round key dari master key. More...

#include <cstdint>
#include "cipher.hpp"

Go to the source code of this file.

Functions

void key_schedule (uint64_t a, uint64_t b, uint64_t rk[ROUNDS])
 Bangkitkan round key K[0] ... K[15] dari master key.

Detailed Description

Key schedule: membangkitkan round key dari master key.

Function Documentation

◆ key_schedule()

void key_schedule ( uint64_t a,
uint64_t b,
uint64_t rk[ROUNDS] )

Bangkitkan round key K[0] ... K[15] dari master key.

Master key (128 bit) dipecah jadi dua 64 bit (a dan b). Tiap round i:

a = rotl(a, 13) + PHI * (i + 1) // mod 2^64
a = sbox64(a)
b ^= rotl(a, 29)
swap(a, b)
K_i = a xor b
uint64_t sbox64(uint64_t a)
Substitusi tiap byte pada nilai 64 bit.
Definition sbox.cpp:18

Konstanta PHI (0x9E3779B97F4A7C15, golden ratio) dikali nomor round, jadi tiap round key beda meskipun master key-nya berpola (misal semua nol).

Parameters
[in]aSeparuh kiri master key (8 byte pertama), 64 bit.
[in]bSeparuh kanan master key (8 byte terakhir), 64 bit.
[out]rkArray ROUNDS elemen, diisi K_0 ... K_15.
Note
Hanya dipanggil sekali per kunci (di constructor CustomCipher), bukan per blok.

Contoh penggunaan:

uint64_t rk[ROUNDS];
key_schedule(0x0123456789ABCDEFULL, 0xFEDCBA9876543210ULL, rk);
constexpr int ROUNDS
Jumlah round Feistel.
Definition cipher.hpp:17
void key_schedule(uint64_t a, uint64_t b, uint64_t rk[ROUNDS])
Bangkitkan round key K[0] ... K[15] dari master key.
Definition key_schedule.cpp:9