Cipher Fayadh
Block cipher Feistel 128-bit dengan fungsi putaran sigma-delta
Toggle main menu visibility
Loading...
Searching...
No Matches
cipher.hpp
Go to the documentation of this file.
1
#ifndef CIPHER_HPP
2
#define CIPHER_HPP
3
4
#include <cstddef>
5
#include <cstdint>
6
11
13
constexpr
size_t
BLOCK_SIZE
= 16;
15
constexpr
size_t
KEY_SIZE
= 16;
17
constexpr
int
ROUNDS
= 16;
18
28
class
BlockCipher
{
29
public
:
30
virtual
~BlockCipher
() =
default
;
31
37
virtual
void
encrypt_block
(
const
uint8_t *in, uint8_t *out)
const
= 0;
38
44
virtual
void
decrypt_block
(
const
uint8_t *in, uint8_t *out)
const
= 0;
45
};
46
74
class
CustomCipher
:
public
BlockCipher
{
75
public
:
80
explicit
CustomCipher
(
const
uint8_t master_key[
KEY_SIZE
]);
81
82
void
encrypt_block
(
const
uint8_t *in, uint8_t *out)
const override
;
83
void
decrypt_block
(
const
uint8_t *in, uint8_t *out)
const override
;
84
85
private
:
86
uint64_t rk_[
ROUNDS
];
87
};
88
89
#endif
KEY_SIZE
constexpr size_t KEY_SIZE
Ukuran master key dalam byte (128 bit, 16x8 bit).
Definition
cipher.hpp:15
ROUNDS
constexpr int ROUNDS
Jumlah round Feistel.
Definition
cipher.hpp:17
BLOCK_SIZE
constexpr size_t BLOCK_SIZE
Ukuran satu blok dalam byte (128 bit, 16x8 bit).
Definition
cipher.hpp:13
BlockCipher
Interface block cipher 128-bit.
Definition
cipher.hpp:28
BlockCipher::decrypt_block
virtual void decrypt_block(const uint8_t *in, uint8_t *out) const =0
Dekripsi satu blok.
BlockCipher::encrypt_block
virtual void encrypt_block(const uint8_t *in, uint8_t *out) const =0
Enkripsi satu blok.
CustomCipher::decrypt_block
void decrypt_block(const uint8_t *in, uint8_t *out) const override
Dekripsi satu blok.
Definition
cipher.cpp:31
CustomCipher::CustomCipher
CustomCipher(const uint8_t master_key[KEY_SIZE])
Buat cipher dan bangkitkan round key dari master key.
Definition
cipher.cpp:15
CustomCipher::encrypt_block
void encrypt_block(const uint8_t *in, uint8_t *out) const override
Enkripsi satu blok.
Definition
cipher.cpp:19
include
cipher.hpp
Generated by
1.18.0