#include "rijndael.h"Include dependency graph for my_aes.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | AES_KEY_LENGTH 128 |
Functions | |
| int | my_aes_encrypt (const char *source, int source_length, char *dest, const char *key, int key_length) |
| int | my_aes_decrypt (const char *source, int source_length, char *dest, const char *key, int key_length) |
| int | my_aes_get_size (int source_length) |
| #define AES_KEY_LENGTH 128 |
| int my_aes_decrypt | ( | const char * | source, | |
| int | source_length, | |||
| char * | dest, | |||
| const char * | key, | |||
| int | key_length | |||
| ) |
Definition at line 175 of file my_aes.c.
References AES_BAD_DATA, AES_BLOCK_SIZE, AES_DECRYPT, yaSSL::block, memcpy, my_aes_create_key(), KEYINSTANCE::nr, rijndaelDecrypt(), and KEYINSTANCE::rk.
Referenced by Item_func_aes_decrypt::val_str().
00177 { 00178 KEYINSTANCE aes_key; 00179 uint8 block[AES_BLOCK_SIZE]; /* 128 bit block used for padding */ 00180 int rc; /* Result codes */ 00181 int num_blocks; /* Number of complete blocks */ 00182 uint pad_len; /* Pad size for the last block */ 00183 int i; 00184 00185 if ((rc=my_aes_create_key(&aes_key,AES_DECRYPT,key,key_length))) 00186 return rc; 00187 00188 num_blocks = source_length/AES_BLOCK_SIZE; 00189 00190 if ((source_length != num_blocks*AES_BLOCK_SIZE) || num_blocks ==0 ) 00191 return AES_BAD_DATA; /* Input size has to be even and at least one block */ 00192 00193 for (i = num_blocks-1; i > 0; i--) /* Decode all but last blocks */ 00194 { 00195 rijndaelDecrypt(aes_key.rk, aes_key.nr, (const uint8*) source, 00196 (uint8*) dest); 00197 source+= AES_BLOCK_SIZE; 00198 dest+= AES_BLOCK_SIZE; 00199 } 00200 00201 rijndaelDecrypt(aes_key.rk, aes_key.nr, (const uint8*) source, block); 00202 /* Use last char in the block as size */ 00203 pad_len = (uint) (uchar) block[AES_BLOCK_SIZE-1]; 00204 00205 if (pad_len > AES_BLOCK_SIZE) 00206 return AES_BAD_DATA; 00207 /* We could also check whole padding but we do not really need this */ 00208 00209 memcpy(dest, block, AES_BLOCK_SIZE - pad_len); 00210 return AES_BLOCK_SIZE*num_blocks - pad_len; 00211 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_aes_encrypt | ( | const char * | source, | |
| int | source_length, | |||
| char * | dest, | |||
| const char * | key, | |||
| int | key_length | |||
| ) |
Definition at line 127 of file my_aes.c.
References AES_BLOCK_SIZE, AES_ENCRYPT, bfill, yaSSL::block, memcpy, my_aes_create_key(), KEYINSTANCE::nr, rijndaelEncrypt(), and KEYINSTANCE::rk.
Referenced by Item_func_aes_encrypt::val_str().
00129 { 00130 KEYINSTANCE aes_key; 00131 uint8 block[AES_BLOCK_SIZE]; /* 128 bit block used for padding */ 00132 int rc; /* result codes */ 00133 int num_blocks; /* number of complete blocks */ 00134 char pad_len; /* pad size for the last block */ 00135 int i; 00136 00137 if ((rc= my_aes_create_key(&aes_key,AES_ENCRYPT,key,key_length))) 00138 return rc; 00139 00140 num_blocks = source_length/AES_BLOCK_SIZE; 00141 00142 for (i = num_blocks; i > 0; i--) /* Encode complete blocks */ 00143 { 00144 rijndaelEncrypt(aes_key.rk, aes_key.nr, (const uint8*) source, 00145 (uint8*) dest); 00146 source+= AES_BLOCK_SIZE; 00147 dest+= AES_BLOCK_SIZE; 00148 } 00149 00150 /* Encode the rest. We always have incomplete block */ 00151 pad_len = AES_BLOCK_SIZE - (source_length - AES_BLOCK_SIZE*num_blocks); 00152 memcpy(block, source, 16 - pad_len); 00153 bfill(block + AES_BLOCK_SIZE - pad_len, pad_len, pad_len); 00154 rijndaelEncrypt(aes_key.rk, aes_key.nr, block, (uint8*) dest); 00155 return AES_BLOCK_SIZE*(num_blocks + 1); 00156 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int my_aes_get_size | ( | int | source_length | ) |
Definition at line 225 of file my_aes.c.
References AES_BLOCK_SIZE.
Referenced by Item_func_aes_encrypt::fix_length_and_dec(), and Item_func_aes_encrypt::val_str().
00226 { 00227 return AES_BLOCK_SIZE*(source_length/AES_BLOCK_SIZE)+AES_BLOCK_SIZE; 00228 }
Here is the caller graph for this function:

1.4.7

