201 byte =
in->byte[ ( stride *
offset ) & 0xf ];
227 unsigned int column ) {
228 size_t offset = ( column * 4 );
238 key->column[column] );
294 }
while ( --rounds );
335 }
while ( --rounds );
371 for ( out_offset = 0, in_offset = 0 ; out_offset < 16 ;
372 out_offset++, in_offset = ( ( in_offset + stride ) & 0xf ) ) {
375 byte =
in->byte[in_offset];
383 out->byte[out_offset] = entry->
byte[0];
403 unsigned int rounds = aes->
rounds;
439 unsigned int rounds = aes->
rounds;
473 poly = rol8 ( poly, 1 );
494 unsigned int scalar_x_1;
495 unsigned int scalar_x;
499 scalar = entry->
byte[0];
500 entry->
byte[1] = scalar;
501 entry->
byte[2] = scalar;
502 entry->
byte[5] = scalar;
503 entry->
byte[6] = scalar;
507 entry->
byte[4] = scalar_x;
510 scalar_x_1 = ( scalar_x ^ scalar );
511 entry->
byte[3] = scalar_x_1;
512 entry->
byte[7] = scalar_x_1;
523 unsigned int scalar_x3_x2_x;
524 unsigned int scalar_x3_x2_1;
525 unsigned int scalar_x3_x2;
526 unsigned int scalar_x3_x_1;
527 unsigned int scalar_x3_1;
528 unsigned int scalar_x3;
529 unsigned int scalar_x2;
530 unsigned int scalar_x;
534 scalar = entry->
byte[0];
546 scalar_x3_1 = ( scalar_x3 ^ scalar );
547 entry->
byte[1] = scalar_x3_1;
548 entry->
byte[5] = scalar_x3_1;
551 scalar_x3_x_1 = ( scalar_x3_1 ^ scalar_x );
552 entry->
byte[3] = scalar_x3_x_1;
553 entry->
byte[7] = scalar_x3_x_1;
556 scalar_x3_x2 = ( scalar_x3 ^ scalar_x2 );
559 scalar_x3_x2_1 = ( scalar_x3_x2 ^ scalar );
560 entry->
byte[2] = scalar_x3_x2_1;
561 entry->
byte[6] = scalar_x3_x2_1;
564 scalar_x3_x2_x = ( scalar_x3_x2 ^ scalar_x );
565 entry->
byte[4] = scalar_x3_x2_x;
575 unsigned int poly = 0x01;
576 unsigned int invpoly = 0x01;
577 unsigned int transformed;
591 invpoly ^= ( invpoly << 1 );
592 invpoly ^= ( invpoly << 2 );
593 invpoly ^= ( invpoly << 4 );
594 if ( invpoly & 0x80 )
599 transformed = ( 0x63 ^ invpoly ^ rol8 ( invpoly, 1 ) ^
600 rol8 ( invpoly, 2 ) ^ rol8 ( invpoly, 3 ) ^
601 rol8 ( invpoly, 4 ) );
606 }
while ( poly != 0x01 );
612 for ( i = 0 ; i < 256 ; i++ ) {
620 inventry->
byte[0] = i;
650 for ( i = 0 ; i < 4 ; i++ ) {
651 byte = ( column & 0xff );
653 column = ( ( column & ~0xff ) |
byte );
654 column =
rol32 ( column, 8 );
670 ( column ^ rcon ) : ( column ^ ( rcon << 24 ) ) );
687 unsigned int rcon = 0x01;
711 DBGC ( aes,
"AES %p unsupported key length (%zd bits)\n",
712 aes, ( keylen * 8 ) );
722 next = ( ( (
void * ) prev ) + keylen );
751 offset +=
sizeof ( *next );
757 DBGC2 ( aes,
"AES %p expanded %zd-bit key:\n", aes, ( keylen * 8 ) );
761 memset ( &zero, 0,
sizeof ( zero ) );
763 memcpy ( dec--, enc++,
sizeof ( *dec ) );
772 enc++, &temp, &zero );
775 memcpy ( dec--, enc++,
sizeof ( *dec ) );
776 DBGC2 ( aes,
"AES %p inverted %zd-bit key:\n", aes, ( keylen * 8 ) );
static uint32_t aes_output(const struct aes_table *table, size_t stride, const union aes_matrix *in, const union aes_matrix *key, unsigned int column)
Calculate intermediate round output column.
unsigned int rounds
Number of rounds.
#define EINVAL
Invalid argument.
A single AES lookup table entry.
struct cipher_algorithm aes_gcm_algorithm
static u32 rol32(u32 v, int bits)
Rotate 32-bit value left.
uint32_t next
Next descriptor address.
#define __LITTLE_ENDIAN
Constant representing little-endian byte order.
static uint32_t aes_column(const struct aes_table *table, size_t stride, const union aes_matrix *in, size_t offset)
Multiply [Inv]MixColumns matrix column by S-boxed input byte.
void cipher_null_setiv(void *ctx __unused, const void *iv __unused, size_t ivlen __unused)
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
struct golan_eq_context ctx
struct cipher_algorithm aes_algorithm
Basic AES algorithm.
struct aes_round_keys encrypt
Encryption keys.
static u32 ror32(u32 v, int bits)
Rotate 32-bit value right.
static uint32_t aes_entry_column(const union aes_table_entry *entry, unsigned int column)
Multiply [Inv]MixColumns matrix column by scalar multiplicand.
static unsigned int aes_double(unsigned int poly)
Multiply a polynomial by (x) modulo (x^8 + x^4 + x^3 + x^2 + 1) in GF(2^8)
Electronic codebook (ECB)
static uint32_t aes_key_rcon(uint32_t column, unsigned int rcon)
Apply schedule round constant to key column.
static struct aes_table aes_invmixcolumns
AES InvMixColumns lookup table.
struct aes_round_keys decrypt
Decryption keys.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static uint32_t aes_key_sbox(uint32_t column)
Apply S-box to key column.
GCM_CIPHER(aes_gcm, aes_gcm_algorithm, aes_algorithm, struct aes_context, AES_BLOCKSIZE)
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static void aes_invmixcolumns_entry(union aes_table_entry *entry)
Fill in InvMixColumns lookup table entry.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
static void aes_final(const struct aes_table *table, size_t stride, const union aes_matrix *in, union aes_matrix *out, const union aes_matrix *key)
Perform final round.
uint8_t byte[8]
Viewed as an array of bytes.
static struct aes_table aes_mixcolumns
AES MixColumns lookup table.
union aes_table_entry entry[256]
Table entries, indexed by S(N)
static void aes_generate(void)
Generate AES lookup tables.
union aes_matrix key[AES_MAX_ROUNDS]
Round keys.
CBC_CIPHER(aes_cbc, aes_cbc_algorithm, aes_algorithm, struct aes_context, AES_BLOCKSIZE)
static void aes_addroundkey(union aes_matrix *state, const union aes_matrix *key)
Perform standalone AddRoundKey.
struct cipher_algorithm aes_cbc_algorithm
static uint32_t aes_key_rotate(uint32_t column)
Rotate key column.
static void aes_encrypt_rounds(union aes_matrix *in, union aes_matrix *out, const union aes_matrix *key, unsigned int rounds)
Perform encryption intermediate rounds.
uint32_t column[4]
Viewed as an array of four-byte columns.
static void aes_decrypt(void *ctx, const void *src, void *dst, size_t len)
Decrypt data.
Galois/Counter Mode (GCM)
static void aes_encrypt(void *ctx, const void *src, void *dst, size_t len)
Encrypt data.
static void aes_round(const struct aes_table *table, size_t stride, const union aes_matrix *in, union aes_matrix *out, const union aes_matrix *key)
Perform a single intermediate round.
uint32_t end
Ending offset.
uint8_t product
Product string.
Input stride for ShiftRows.
uint16_t offset
Offset to command line.
#define AES_BLOCKSIZE
AES blocksize.
typeof(acpi_finder=acpi_find)
ACPI table finder.
static void aes_decrypt_rounds(union aes_matrix *in, union aes_matrix *out, const union aes_matrix *key, unsigned int rounds)
Perform decryption intermediate rounds.
struct cipher_algorithm aes_ecb_algorithm
ECB_CIPHER(aes_ecb, aes_ecb_algorithm, aes_algorithm, struct aes_context, AES_BLOCKSIZE)
const char * name
Algorithm name.
void cipher_null_auth(void *ctx __unused, void *auth __unused)
static void aes_mixcolumns_entry(union aes_table_entry *entry)
Fill in MixColumns lookup table entry.
Input stride for InvShiftRows.
static int aes_setkey(void *ctx, const void *key, size_t keylen)
Set key.
void * memset(void *dest, int character, size_t len) __nonnull