libbtc
bitcoinclibrary
|
Go to the source code of this file.
Macros | |
#define | HAVE_MEMCPY |
#define | HAVE_UINT_32T |
#define | USE_TABLES |
#define | VERSION_1 |
#define | WPOLY 0x011b |
#define | BPOLY 0x1b |
#define | DPOLY 0x008d |
#define | f1(x) (x) |
#define | f2(x) ((x << 1) ^ (((x >> 7) & 1) * WPOLY)) |
#define | f4(x) ((x << 2) ^ (((x >> 6) & 1) * WPOLY) ^ (((x >> 6) & 2) * WPOLY)) |
#define | f8(x) ((x << 3) ^ (((x >> 5) & 1) * WPOLY) ^ (((x >> 5) & 2) * WPOLY) ^ (((x >> 5) & 4) * WPOLY)) |
#define | d2(x) (((x) >> 1) ^ ((x)&1 ? DPOLY : 0)) |
#define | f3(x) (f2(x) ^ x) |
#define | f9(x) (f8(x) ^ x) |
#define | fb(x) (f8(x) ^ f2(x) ^ x) |
#define | fd(x) (f8(x) ^ f4(x) ^ x) |
#define | fe(x) (f8(x) ^ f4(x) ^ f2(x)) |
#define | sb_data(w) |
#define | isb_data(w) |
#define | mm_data(w) |
#define | s_box(x) sbox[(x)] |
#define | is_box(x) isbox[(x)] |
#define | gfm2_sb(x) gfm2_sbox[(x)] |
#define | gfm3_sb(x) gfm3_sbox[(x)] |
#define | gfm_9(x) gfmul_9[(x)] |
#define | gfm_b(x) gfmul_b[(x)] |
#define | gfm_d(x) gfmul_d[(x)] |
#define | gfm_e(x) gfmul_e[(x)] |
#define | block_copy_nn(d, s, l) memcpy(d, s, l) |
#define | block_copy(d, s) memcpy(d, s, N_BLOCK) |
Typedefs | |
typedef uint32_t | uint_32t |
Functions | |
static void | xor_block (void *d, const void *s) |
static void | copy_and_key (void *d, const void *s, const void *k) |
static void | add_round_key (uint_8t d[N_BLOCK], const uint_8t k[N_BLOCK]) |
static void | shift_sub_rows (uint_8t st[N_BLOCK]) |
static void | inv_shift_sub_rows (uint_8t st[N_BLOCK]) |
static void | mix_sub_columns (uint_8t dt[N_BLOCK]) |
static void | inv_mix_sub_columns (uint_8t dt[N_BLOCK]) |
return_type | aes_set_key (const unsigned char key[], length_type keylen, aes_context ctx[1]) |
return_type | aes_encrypt (const unsigned char in[N_BLOCK], unsigned char out[N_BLOCK], const aes_context ctx[1]) |
return_type | aes_cbc_encrypt (const unsigned char *in, unsigned char *out, int n_block, unsigned char iv[N_BLOCK], const aes_context ctx[1]) |
return_type | aes_decrypt (const unsigned char in[N_BLOCK], unsigned char out[N_BLOCK], const aes_context ctx[1]) |
return_type | aes_cbc_decrypt (const unsigned char *in, unsigned char *out, int n_block, unsigned char iv[N_BLOCK], const aes_context ctx[1]) |
Variables | |
static const uint_8t | sbox [256] = sb_data(f1) |
static const uint_8t | isbox [256] = isb_data(f1) |
static const uint_8t | gfm2_sbox [256] = sb_data(f2) |
static const uint_8t | gfm3_sbox [256] = sb_data(f3) |
static const uint_8t | gfmul_9 [256] = mm_data(f9) |
static const uint_8t | gfmul_b [256] = mm_data(fb) |
static const uint_8t | gfmul_d [256] = mm_data(fd) |
static const uint_8t | gfmul_e [256] = mm_data(fe) |
#define block_copy | ( | d, | |
s | |||
) | memcpy(d, s, N_BLOCK) |
Definition at line 220 of file aes.c.
Referenced by copy_and_key(), inv_mix_sub_columns(), and mix_sub_columns().
#define block_copy_nn | ( | d, | |
s, | |||
l | |||
) | memcpy(d, s, l) |
Definition at line 219 of file aes.c.
Referenced by aes_set_key().
#define f2 | ( | x | ) | ((x << 1) ^ (((x >> 7) & 1) * WPOLY)) |
Definition at line 85 of file aes.c.
Referenced by aes_set_key().
#define gfm2_sb | ( | x | ) | gfm2_sbox[(x)] |
Definition at line 126 of file aes.c.
Referenced by mix_sub_columns().
#define gfm3_sb | ( | x | ) | gfm3_sbox[(x)] |
Definition at line 127 of file aes.c.
Referenced by mix_sub_columns().
#define gfm_9 | ( | x | ) | gfmul_9[(x)] |
Definition at line 128 of file aes.c.
Referenced by inv_mix_sub_columns().
#define gfm_b | ( | x | ) | gfmul_b[(x)] |
Definition at line 129 of file aes.c.
Referenced by inv_mix_sub_columns().
#define gfm_d | ( | x | ) | gfmul_d[(x)] |
Definition at line 130 of file aes.c.
Referenced by inv_mix_sub_columns().
#define gfm_e | ( | x | ) | gfmul_e[(x)] |
Definition at line 131 of file aes.c.
Referenced by inv_mix_sub_columns().
#define is_box | ( | x | ) | isbox[(x)] |
Definition at line 125 of file aes.c.
Referenced by inv_mix_sub_columns(), and inv_shift_sub_rows().
#define isb_data | ( | w | ) |
#define mm_data | ( | w | ) |
#define s_box | ( | x | ) | sbox[(x)] |
Definition at line 124 of file aes.c.
Referenced by aes_set_key(), mix_sub_columns(), and shift_sub_rows().
#define sb_data | ( | w | ) |
#define VERSION_1 |
Definition at line 68 of file aes.c.
Referenced by aes_encrypt().
Definition at line 322 of file aes.c.
References xor_block().
Referenced by aes_decrypt(), and aes_encrypt().
return_type aes_cbc_decrypt | ( | const unsigned char * | in, |
unsigned char * | out, | ||
int | n_block, | ||
unsigned char | iv[N_BLOCK], | ||
const aes_context | ctx[1] | ||
) |
Definition at line 586 of file aes.c.
References aes_decrypt(), N_BLOCK, and xor_block().
return_type aes_cbc_encrypt | ( | const unsigned char * | in, |
unsigned char * | out, | ||
int | n_block, | ||
unsigned char | iv[N_BLOCK], | ||
const aes_context | ctx[1] | ||
) |
Definition at line 537 of file aes.c.
References aes_encrypt(), N_BLOCK, and xor_block().
return_type aes_decrypt | ( | const unsigned char | in[N_BLOCK], |
unsigned char | out[N_BLOCK], | ||
const aes_context | ctx[1] | ||
) |
Definition at line 557 of file aes.c.
References add_round_key(), copy_and_key(), inv_mix_sub_columns(), inv_shift_sub_rows(), aes_context::ksch, N_BLOCK, and aes_context::rnd.
Referenced by aes_cbc_decrypt().
return_type aes_encrypt | ( | const unsigned char | in[N_BLOCK], |
unsigned char | out[N_BLOCK], | ||
const aes_context | ctx[1] | ||
) |
Definition at line 508 of file aes.c.
References add_round_key(), copy_and_key(), aes_context::ksch, mix_sub_columns(), N_BLOCK, aes_context::rnd, shift_sub_rows(), and VERSION_1.
Referenced by aes_cbc_encrypt().
return_type aes_set_key | ( | const unsigned char | key[], |
length_type | keylen, | ||
aes_context | ctx[1] | ||
) |
Definition at line 449 of file aes.c.
References block_copy_nn, f2, aes_context::ksch, aes_context::rnd, and s_box.
|
static |
Definition at line 292 of file aes.c.
References block_copy, and xor_block().
Referenced by aes_decrypt(), and aes_encrypt().
|
static |
Definition at line 416 of file aes.c.
References block_copy, gfm_9, gfm_b, gfm_d, gfm_e, is_box, and N_BLOCK.
Referenced by aes_decrypt().
|
static |
|
static |
Definition at line 386 of file aes.c.
References block_copy, gfm2_sb, gfm3_sb, N_BLOCK, and s_box.
Referenced by aes_encrypt().
|
static |
|
static |
Definition at line 265 of file aes.c.
Referenced by add_round_key(), aes_cbc_decrypt(), aes_cbc_encrypt(), and copy_and_key().