Commit d5058037 authored by peter@linux.local's avatar peter@linux.local
Browse files

This is just code style/minor optimizations cleanup changeset

parent 7e80b058
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -1384,9 +1384,9 @@ int main(int argc, char **argv)
      return(first_error);
    }
  }
  /* There is no sense to start transaction if all tables are locked */
  else if (opt_single_transaction)
  {
    /* There is no sense to start transaction if all tables are locked */ 
    if (mysql_query(sock, "BEGIN"))
    {
      my_printf_error(0, "Error: Couldn't execute 'BEGIN': %s",
@@ -1394,7 +1394,6 @@ int main(int argc, char **argv)
      my_end(0);
      return(first_error);
    }    
    
  }
  if (opt_alldbs)
    dump_all_databases();
@@ -1440,12 +1439,13 @@ int main(int argc, char **argv)
		      MYF(0), mysql_error(sock));
   }
  }
  else if (opt_single_transaction) /* Just to make it beautiful enough */
  {
    /*
    In case we were locking all tables, we did not start transaction
    so there is no need to commit it.
    */
  else if (opt_single_transaction) /* Just to make it beautiful enough */
  {

    /* This should just free locks as we did not change anything */
    if (mysql_query(sock, "COMMIT"))
    {
+18 −17
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ extern "C" {
#endif

/*
my_aes_crypt  - Crypt buffer with AES encryption algorithm.
my_aes_encrypt  - Crypt buffer with AES encryption algorithm.
source        - Pinter to data for encryption
source_length - size of encruption data
dest          - buffer to place encrypted data (must be large enough)
@@ -65,7 +65,8 @@ int my_aes_decrypt(const char* source, int source_length, const char* dest,


/*
my_aes_get_size - get size of buffer which will be large enough for encrypted data
my_aes_get_size - get size of buffer which will be large enough for encrypted
                  data
source_length -  length of data to be encrypted

returns  - size of buffer required to store encrypted data
+16 −17
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
				 
/*
 sha1.h
 
+54 −20
Original line number Diff line number Diff line
@@ -15,17 +15,18 @@
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */


/* MY_AES.C  Implementation of AES Encryption for MySQL */ 
/* 
   Implementation of AES Encryption for MySQL 
   Initial version by Peter Zaitsev  June 2002    
*/ 


#include "my_global.h"				                                                                                      
#include "m_string.h"
#include <stdio.h>
#include "my_aes.h"


#define AES_ENCRYPT 1
#define AES_DECRYPT 2
enum encrypt_dir { AES_ENCRYPT, AES_DECRYPT };

#define AES_BLOCK_SIZE 16 
           /* Block size in bytes */
@@ -75,6 +76,18 @@ static int my_aes_create_key(KEYINSTANCE* aes_key,char direction, char* key,
}


/*
my_aes_encrypt  - Crypt buffer with AES encryption algorithm.
source        - Pinter to data for encryption
source_length - size of encruption data
dest          - buffer to place encrypted data (must be large enough)
key           - Key to be used for encryption
kel_length    - Lenght of the key. Will handle keys of any length

returns  - size of encrypted data, or negative in case of error.

*/

int my_aes_encrypt(const char* source, int source_length, const char* dest,
                   const char* key, int key_length)
{
@@ -105,6 +118,19 @@ int my_aes_encrypt(const char* source, int source_length, const char* dest,
  return AES_BLOCK_SIZE*(num_blocks + 1);    
}


/*
my_aes_decrypt  - DeCrypt buffer with AES encryption algorithm.
source        - Pinter to data for decryption
source_length - size of encrypted data
dest          - buffer to place decrypted data (must be large enough)
key           - Key to be used for decryption
kel_length    - Lenght of the key. Will handle keys of any length

returns  - size of original data, or negative in case of error.

*/ 

int my_aes_decrypt(const char* source, int source_length, const char* dest,
                   const char* key, int key_length)
{
@@ -144,6 +170,14 @@ int my_aes_decrypt(const char* source, int source_length, const char* dest,
  return AES_BLOCK_SIZE*num_blocks - pad_len;	  
}


/*
my_aes_get_size - get size of buffer which will be large enough for encrypted
                  data
source_length -  length of data to be encrypted
returns  - size of buffer required to store encrypted data		  
*/
 
int my_aes_get_size(int source_length)
{  
  return AES_BLOCK_SIZE*(source_length/AES_BLOCK_SIZE)+AES_BLOCK_SIZE;
+40 −49
Original line number Diff line number Diff line
@@ -15,30 +15,19 @@
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

				                                                                                      
/**
 * rijndael-alg-fst.c
 *
 * @version 3.0 (December 2000)
 *
 * Optimised ANSI C code for the Rijndael cipher (now AES)
 *
 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
 * @author Paulo Barreto <paulo.barreto@terra.com.br>
 *
 * This code is hereby placed in the public domain.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*
 rijndael-alg-fst.c
 
  @version 3.0 (December 2000)
 
  Optimised ANSI C code for the Rijndael cipher (now AES)
 
  @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
  @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
  @author Paulo Barreto <paulo.barreto@terra.com.br>
 
  This code is hereby placed in the public domain.
 
 */
 
#include <my_global.h> 
@@ -47,11 +36,13 @@
#include "rijndael.h"

/* 
 May be defined to use fastest and much larger code (~10K extra code)
 #define FULL_UNROLL 
 May be defined to use fastest and much larger code.
*/


#ifdef NOT_USED

/*
Te0[x] = S [x].[02, 01, 01, 03];
Te1[x] = S [x].[03, 02, 01, 01];
@@ -66,6 +57,8 @@ Td3[x] = Si[x].[09, 0d, 0b, 0e];
Td4[x] = Si[x].[01, 01, 01, 01];
*/

#endif

static const uint32 Te0[256]=
{
  0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,
@@ -801,9 +794,7 @@ int rijndaelKeySetupEnc(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[],
      rk[6] = rk[2] ^ rk[5];
      rk[7] = rk[3] ^ rk[6];
      if (++i == 10) 
      {
        return 10;
      }
      rk += 4;
    }
  }
@@ -814,12 +805,12 @@ int rijndaelKeySetupEnc(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[],
    for (;;) 
    {
      temp = rk[ 5];
      rk[ 6] = rk[ 0] ^
      rk[ 6] = (rk[ 0] ^
      (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
      (Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
      (Te4[(temp      ) & 0xff] & 0x0000ff00) ^
      (Te4[(temp >> 24)       ] & 0x000000ff) ^
      rcon[i];
      rcon[i]);
      rk[ 7] = rk[ 1] ^ rk[ 6];
      rk[ 8] = rk[ 2] ^ rk[ 7];
      rk[ 9] = rk[ 3] ^ rk[ 8];
@@ -839,12 +830,12 @@ int rijndaelKeySetupEnc(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[],
    for (;;) 
    {
      temp = rk[ 7];
      rk[ 8] = rk[ 0] ^
      rk[ 8] = (rk[ 0] ^
      (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
      (Te4[(temp >>  8) & 0xff] & 0x00ff0000) ^
      (Te4[(temp      ) & 0xff] & 0x0000ff00) ^
      (Te4[(temp >> 24)       ] & 0x000000ff) ^
      rcon[i];
      rcon[i]);
      rk[ 9] = rk[ 1] ^ rk[ 8];
      rk[10] = rk[ 2] ^ rk[ 9];
      rk[11] = rk[ 3] ^ rk[10];
@@ -853,11 +844,11 @@ int rijndaelKeySetupEnc(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[],
        return 14;
      }
      temp = rk[11];
      rk[12] = rk[ 4] ^
      rk[12] = (rk[ 4] ^
      (Te4[(temp >> 24)       ] & 0xff000000) ^
      (Te4[(temp >> 16) & 0xff] & 0x00ff0000) ^
      (Te4[(temp >>  8) & 0xff] & 0x0000ff00) ^
      (Te4[(temp      ) & 0xff] & 0x000000ff);
      (Te4[(temp      ) & 0xff] & 0x000000ff));
      rk[13] = rk[ 5] ^ rk[12];
      rk[14] = rk[ 6] ^ rk[13];
      rk[15] = rk[ 7] ^ rk[14];
Loading