Eneboo - Documentación para desarrolladores
|
00001 /* Copyright (C) 2002 MySQL AB & MySQL Finland AB & TCX DataKonsult AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 00018 /* Header file for my_aes.c */ 00019 /* Wrapper to give simple interface for MySQL to AES standard encryption */ 00020 00021 #include "rijndael.h" 00022 00023 C_MODE_START 00024 00025 #define AES_KEY_LENGTH 128 /* Must be 128 192 or 256 */ 00026 00027 /* 00028 my_aes_encrypt - Crypt buffer with AES encryption algorithm. 00029 source - Pointer to data for encryption 00030 source_length - size of encryption data 00031 dest - buffer to place encrypted data (must be large enough) 00032 key - Key to be used for encryption 00033 kel_length - Length of the key. Will handle keys of any length 00034 00035 returns - size of encrypted data, or negative in case of error. 00036 */ 00037 00038 int my_aes_encrypt(const char *source, int source_length, char *dest, 00039 const char *key, int key_length); 00040 00041 /* 00042 my_aes_decrypt - DeCrypt buffer with AES encryption algorithm. 00043 source - Pointer to data for decryption 00044 source_length - size of encrypted data 00045 dest - buffer to place decrypted data (must be large enough) 00046 key - Key to be used for decryption 00047 kel_length - Length of the key. Will handle keys of any length 00048 00049 returns - size of original data, or negative in case of error. 00050 */ 00051 00052 00053 int my_aes_decrypt(const char *source, int source_length, char *dest, 00054 const char *key, int key_length); 00055 00056 /* 00057 my_aes_get_size - get size of buffer which will be large enough for encrypted 00058 data 00059 source_length - length of data to be encrypted 00060 00061 returns - size of buffer required to store encrypted data 00062 */ 00063 00064 int my_aes_get_size(int source_length); 00065 00066 C_MODE_END