libosmogsm 1.9.0.196-9975
Osmocom GSM library
aes-internal-enc.c File Reference

AES (Rijndael) cipher - encrypt. More...

#include "includes.h"
#include "common.h"
#include "crypto.h"
#include "aes_i.h"

Macros

#define ROUND(i, d, s)
 

Functions

static void rijndaelEncrypt (const u32 rk[], const u8 pt[16], u8 ct[16])
 
void * aes_encrypt_init (const u8 *key, size_t len)
 aes_encrypt_init - Initialize AES for encryption @key: Encryption key @len: Key length in bytes (usually 16, i.e., 128 bits) Returns: Pointer to context data or NULL on failure More...
 
void aes_encrypt (void *ctx, const u8 *plain, u8 *crypt)
 aes_encrypt - Encrypt one AES block @ctx: Context pointer from aes_encrypt_init() @plain: Plaintext data to be encrypted (16 bytes) @crypt: Buffer for the encrypted data (16 bytes) More...
 
void aes_encrypt_deinit (void *ctx)
 aes_encrypt_deinit - Deinitialize AES encryption @ctx: Context pointer from aes_encrypt_init() More...
 

Detailed Description

AES (Rijndael) cipher - encrypt.

Modifications to public domain implementation:

  • support only 128-bit keys
  • cleanup
  • use C pre-processor to make it easier to change S table access
  • added option (AES_SMALL_TABLES) for reducing code size by about 8 kB at cost of reduced throughput (quite small difference on Pentium 4, 10-25% when using -O1 or -O2 optimization)

Macro Definition Documentation

◆ ROUND

#define ROUND (   i,
  d,
 
)
Value:
d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \
d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \
d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \
d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]
#define TE2(i)
Definition: aes_i.h:81
#define TE0(i)
Definition: aes_i.h:79
#define TE1(i)
Definition: aes_i.h:80
#define TE3(i)
Definition: aes_i.h:82

Function Documentation

◆ aes_encrypt()

void aes_encrypt ( void *  ctx,
const u8 plain,
u8 crypt 
)

aes_encrypt - Encrypt one AES block @ctx: Context pointer from aes_encrypt_init() @plain: Plaintext data to be encrypted (16 bytes) @crypt: Buffer for the encrypted data (16 bytes)

References rijndaelEncrypt().

Referenced by aes_128_encrypt_block().

◆ aes_encrypt_deinit()

void aes_encrypt_deinit ( void *  ctx)

aes_encrypt_deinit - Deinitialize AES encryption @ctx: Context pointer from aes_encrypt_init()

References AES_PRIV_SIZE, os_free, and os_memset.

Referenced by aes_128_encrypt_block().

◆ aes_encrypt_init()

void * aes_encrypt_init ( const u8 key,
size_t  len 
)

aes_encrypt_init - Initialize AES for encryption @key: Encryption key @len: Key length in bytes (usually 16, i.e., 128 bits) Returns: Pointer to context data or NULL on failure

References AES_PRIV_SIZE, len, os_malloc, and rijndaelKeySetupEnc().

Referenced by aes_128_encrypt_block().

◆ rijndaelEncrypt()

static void rijndaelEncrypt ( const u32  rk[],
const u8  pt[16],
u8  ct[16] 
)
static

References GETU32, PUTU32, ROUND, TE41, TE42, TE43, and TE44.

Referenced by aes_encrypt().