193 aes_column (
const struct aes_table *table,
size_t stride,
201 byte =
in->byte[ ( stride *
offset ) & 0xf ];
211 return aes_entry_column (
entry, (
offset & 0x3 ) );
225 aes_output (
const struct aes_table *table,
size_t stride,
234 return ( aes_column ( table, stride,
in, (
offset + 0 ) ) ^
235 aes_column ( table, stride,
in, (
offset + 1 ) ) ^
236 aes_column ( table, stride,
in, (
offset + 2 ) ) ^
237 aes_column ( table, stride,
in, (
offset + 3 ) ) ^
251 aes_round (
const struct aes_table *table,
size_t stride,
259 out->column[0] = aes_output ( table, stride,
in,
key, 0 );
260 out->column[1] = aes_output ( table, stride,
in,
key, 1 );
261 out->column[2] = aes_output ( table, stride,
in,
key, 2 );
262 out->column[3] = aes_output ( table, stride,
in,
key, 3 );
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];
387 aes_addroundkey (
out,
key );
403 unsigned int rounds = aes->
rounds;
439 unsigned int rounds = aes->
rounds;
468 static __attribute__ ((
const )) unsigned
int aes_double (
unsigned int poly ) {
473 poly = rol8 ( poly, 1 );
494 unsigned int scalar_x_1;
495 unsigned int scalar_x;
506 scalar_x = aes_double (
scalar );
510 scalar_x_1 = ( scalar_x ^
scalar );
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;
537 scalar_x = aes_double (
scalar );
540 scalar_x2 = aes_double ( scalar_x );
543 scalar_x3 = aes_double ( scalar_x2 );
546 scalar_x3_1 = ( scalar_x3 ^
scalar );
551 scalar_x3_x_1 = ( scalar_x3_1 ^ scalar_x );
556 scalar_x3_x2 = ( scalar_x3 ^ scalar_x2 );
559 scalar_x3_x2_1 = ( scalar_x3_x2 ^
scalar );
564 scalar_x3_x2_x = ( scalar_x3_x2 ^ scalar_x );
575 unsigned int poly = 0x01;
576 unsigned int invpoly = 0x01;
577 unsigned int transformed;
584 poly ^= aes_double ( poly );
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++ ) {
687 unsigned int rcon = 0x01;
711 DBGC ( aes,
"AES %p unsupported key length (%zd bits)\n",
739 tmp = aes_key_rotate (
tmp );
740 tmp = aes_key_rcon (
tmp, rcon );
741 rcon = aes_double ( rcon );
751 offset +=
sizeof ( *next );
757 DBGC2 ( aes,
"AES %p expanded %zd-bit key:\n", aes, (
keylen * 8 ) );
763 memcpy ( dec--, enc++,
sizeof ( *dec ) );
772 enc++, &temp, &
zero );
773 aes_decrypt_rounds ( &temp, dec--, &
zero, 1 );
775 memcpy ( dec--, enc++,
sizeof ( *dec ) );
776 DBGC2 ( aes,
"AES %p inverted %zd-bit key:\n", aes, (
keylen * 8 ) );
unsigned int rounds
Number of rounds.
#define EINVAL
Invalid argument.
A single AES lookup table entry.
union aes_table_entry __attribute__((packed))
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 void const void void * dst
static const void const void * scalar
static void const void * src
void cipher_null_setiv(void *ctx __unused, const void *iv __unused, size_t ivlen __unused)
uint8_t byte[8]
Viewed as an array of bytes.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
uint32_t zero
Must be zero.
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.
Electronic codebook (ECB)
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.
static void const void size_t keylen
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.
static userptr_t size_t offset
Offset of the first segment within the content.
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)
union aes_table_entry entry[256]
Table entries, indexed by S(N)
static void aes_generate(void)
Generate AES lookup tables.
struct golan_eq_context ctx
uint32_t column[4]
Viewed as an array of four-byte columns.
union aes_matrix key[AES_MAX_ROUNDS]
Round keys.
CBC_CIPHER(aes_cbc, aes_cbc_algorithm, aes_algorithm, struct aes_context, AES_BLOCKSIZE)
struct cipher_algorithm aes_cbc_algorithm
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.
uint32_t end
Ending offset.
uint8_t product
Product string.
Input stride for ShiftRows.
#define AES_BLOCKSIZE
AES blocksize.
typeof(acpi_finder=acpi_find)
ACPI table finder.
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