Cipher Fayadh
Block cipher Feistel 128-bit dengan fungsi putaran sigma-delta
Loading...
Searching...
No Matches
CustomCipher Class Reference

Block cipher Feistel 16 round dengan fungsi F berbasis sigma-delta. More...

#include <cipher.hpp>

Inheritance diagram for CustomCipher:
BlockCipher

Public Member Functions

 CustomCipher (const uint8_t master_key[KEY_SIZE])
 Buat cipher dan bangkitkan round key dari master key.
void encrypt_block (const uint8_t *in, uint8_t *out) const override
 Enkripsi satu blok.
void decrypt_block (const uint8_t *in, uint8_t *out) const override
 Dekripsi satu blok.

Detailed Description

Block cipher Feistel 16 round dengan fungsi F berbasis sigma-delta.

Blok 128 bit dibelah menjadi L dan R (masing-masing 64 bit). Tiap round:

L' = R
R' = L xor F(R, K[i])

Dekripsi memakai alur yang sama dengan urutan round key dibalik, sehingga F tidak perlu punya invers.

Round key dibangkitkan sekali di constructor.

Note
Objek bersifat immutable setelah dibuat, jadi aman dipakai bersamaan dari beberapa thread untuk read (encrypt/decrypt).

Contoh penggunaan:

uint8_t key[KEY_SIZE] = { ... };
uint8_t pt[BLOCK_SIZE] = { ... };
uint8_t ct[BLOCK_SIZE], back[BLOCK_SIZE];
CustomCipher cipher(key);
cipher.encrypt_block(pt, ct);
cipher.decrypt_block(ct, back); // back == pt
constexpr size_t KEY_SIZE
Ukuran master key dalam byte (128 bit, 16x8 bit).
Definition cipher.hpp:15
constexpr size_t BLOCK_SIZE
Ukuran satu blok dalam byte (128 bit, 16x8 bit).
Definition cipher.hpp:13
CustomCipher(const uint8_t master_key[KEY_SIZE])
Buat cipher dan bangkitkan round key dari master key.
Definition cipher.cpp:15

Constructor & Destructor Documentation

◆ CustomCipher()

CustomCipher::CustomCipher ( const uint8_t master_key[KEY_SIZE])
explicit

Buat cipher dan bangkitkan round key dari master key.

Parameters
[in]master_keyMaster key, KEY_SIZE byte. Pointer tidak disimpan.

Member Function Documentation

◆ decrypt_block()

void CustomCipher::decrypt_block ( const uint8_t * in,
uint8_t * out ) const
overridevirtual

Dekripsi satu blok.

Parameters
[in]inCiphertext, BLOCK_SIZE byte.
[out]outPlaintext, BLOCK_SIZE byte.

Implements BlockCipher.

◆ encrypt_block()

void CustomCipher::encrypt_block ( const uint8_t * in,
uint8_t * out ) const
overridevirtual

Enkripsi satu blok.

Parameters
[in]inPlaintext, BLOCK_SIZE byte.
[out]outCiphertext, BLOCK_SIZE byte.

Implements BlockCipher.


The documentation for this class was generated from the following files: