Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Macros | |
#define | ROTL28(rs, sh) ((((rs) << (sh)) | ((rs) >> (28 - (sh)))) & 0x0FFFFFFF) |
#define | ROTR28(rs, sh) ((((rs) >> (sh)) | ((rs) << (28 - (sh)))) & 0x0FFFFFFF) |
#define | ROTL(rs, sh) (((rs) << (sh)) | ((rs) >> (32 - (sh)))) |
#define | ROTR(rs, sh) (((rs) >> (sh)) | ((rs) << (32 - (sh)))) |
Functions | |
RZ_API void | rz_des_permute_key (ut32 *keylo, ut32 *keyhi) |
Apply PC-1. More... | |
RZ_API void | rz_des_permute_key_inv (ut32 *keylo, ut32 *keyhi) |
Inverse of rz_des_permute_key (PC-1) More... | |
RZ_API void | rz_des_permute_block0 (ut32 *blocklo, ut32 *blockhi) |
first permutation of the input block More... | |
RZ_API void | rz_des_permute_block1 (ut32 *blocklo, ut32 *blockhi) |
last permutation of the block More... | |
RZ_API void | rz_des_shift_key (int i, bool decrypt, RZ_INOUT ut32 *deskeylo, RZ_INOUT ut32 *deskeyhi) |
Apply the respective shift to the key for a given round. More... | |
RZ_API void | rz_des_pc2 (RZ_OUT ut32 *keylo, RZ_OUT ut32 *keyhi, RZ_IN ut32 deslo, RZ_IN ut32 deshi) |
PC-2 permutation of a key. More... | |
RZ_API void | rz_des_round_key (int i, RZ_OUT ut32 *keylo, RZ_OUT ut32 *keyhi, RZ_INOUT ut32 *deskeylo, RZ_INOUT ut32 *deskeyhi) |
Calculate the final key to be used in a given round. More... | |
RZ_API void | rz_des_round (RZ_OUT ut32 *buflo, RZ_OUT ut32 *bufhi, RZ_IN ut32 *roundkeylo, RZ_IN ut32 *roundkeyhi) |
Apply the cipher function (f) More... | |
Variables | |
static const ut32 | sbox1 [64] |
static const ut32 | sbox2 [64] |
static const ut32 | sbox3 [64] |
static const ut32 | sbox4 [64] |
static const ut32 | sbox5 [64] |
static const ut32 | sbox6 [64] |
static const ut32 | sbox7 [64] |
static const ut32 | sbox8 [64] |
static const st8 | pc1_inv [64] |
RZ_API void rz_des_pc2 | ( | RZ_OUT ut32 * | keylo, |
RZ_OUT ut32 * | keyhi, | ||
RZ_IN ut32 | deslo, | ||
RZ_IN ut32 | deshi | ||
) |
PC-2 permutation of a key.
Definition at line 247 of file des.c.
References rz_return_if_fail.
Referenced by avr_custom_des(), and rz_des_round_key().
first permutation of the input block
Definition at line 171 of file des.c.
References hi(), lo, ROTL, and rz_return_if_fail.
Referenced by avr_custom_des(), des_decrypt(), and des_encrypt().
last permutation of the block
Definition at line 195 of file des.c.
References hi(), lo, ROTR, and rz_return_if_fail.
Referenced by avr_custom_des(), des_decrypt(), and des_encrypt().
Apply PC-1.
Definition at line 115 of file des.c.
References rz_return_if_fail.
Referenced by avr_custom_des(), and des_set_key().
Inverse of rz_des_permute_key (PC-1)
This is usually not necessary when executing DES. Keep in mind that PC-1 is not injective on arbitrary values, as it drops the parity bits. This inverse function simply sets the positions of those to 0.
Definition at line 153 of file des.c.
References i, in, out, p, pc1_inv, rz_return_if_fail, st8, and ut64().
Referenced by avr_custom_des().
RZ_API void rz_des_round | ( | RZ_OUT ut32 * | buflo, |
RZ_OUT ut32 * | bufhi, | ||
RZ_IN ut32 * | roundkeylo, | ||
RZ_IN ut32 * | roundkeyhi | ||
) |
Apply the cipher function (f)
Definition at line 292 of file des.c.
References hi(), lo, ROTR, rz_return_if_fail, sbox1, sbox2, sbox3, sbox4, sbox5, sbox6, sbox7, and sbox8.
Referenced by avr_custom_des(), des_decrypt(), and des_encrypt().
RZ_API void rz_des_round_key | ( | int | i, |
RZ_OUT ut32 * | keylo, | ||
RZ_OUT ut32 * | keyhi, | ||
RZ_INOUT ut32 * | deskeylo, | ||
RZ_INOUT ut32 * | deskeyhi | ||
) |
Calculate the final key to be used in a given round.
i | number of the round |
keylo | derivated round key (output) |
keyhi | derivated round key (output) |
deskeylo | des derivated key (input+modified) |
deskeyhi | des derivated key (input+modified) |
This function should be applied successively with i from 0 to 15 as deskeylo/deskeyhi is left-shifted in each iteration.
Definition at line 285 of file des.c.
References i, rz_des_pc2(), rz_des_shift_key(), and rz_return_if_fail.
Referenced by des_set_key().
RZ_API void rz_des_shift_key | ( | int | i, |
bool | decrypt, | ||
RZ_INOUT ut32 * | deskeylo, | ||
RZ_INOUT ut32 * | deskeyhi | ||
) |
Apply the respective shift to the key for a given round.
i | number of the round |
decrypt | If false, the specified left-shift is executed. If true, the inverse is applied. |
Definition at line 225 of file des.c.
References i, ROTL28, ROTR28, and rz_return_if_fail.
Referenced by avr_custom_des(), and rz_des_round_key().
Definition at line 103 of file des.c.
Referenced by rz_des_permute_key_inv().
Definition at line 15 of file des.c.
Referenced by fn(), and rz_des_round().
Definition at line 26 of file des.c.
Referenced by fn(), and rz_des_round().
Definition at line 37 of file des.c.
Referenced by fn(), and rz_des_round().
Definition at line 48 of file des.c.
Referenced by fn(), and rz_des_round().
Definition at line 59 of file des.c.
Referenced by rz_des_round().
Definition at line 70 of file des.c.
Referenced by rz_des_round().
Definition at line 81 of file des.c.
Referenced by rz_des_round().
Definition at line 92 of file des.c.
Referenced by rz_des_round().