summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/my_aes.h83
-rw-r--r--include/rijndael.h48
-rw-r--r--include/sha1.h85
3 files changed, 216 insertions, 0 deletions
diff --git a/include/my_aes.h b/include/my_aes.h
new file mode 100644
index 00000000000..9aa250d0d3a
--- /dev/null
+++ b/include/my_aes.h
@@ -0,0 +1,83 @@
+/* Copyright (C) 2002 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+
+/* Header file for my_aes.c */
+/* Wrapper to give simple interface for MySQL to AES standard encryption */
+
+#ifndef __MY_AES_H
+#define __MY_AES_H
+
+#include "my_global.h"
+#include <stdio.h>
+#include "rijndael.h"
+
+#define AES_KEY_LENGTH 128
+/* Must be 128 192 or 256 */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+my_aes_crypt - 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);
+
+/*
+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);
+
+
+/*
+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);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+
+#endif
diff --git a/include/rijndael.h b/include/rijndael.h
new file mode 100644
index 00000000000..60be0d725c8
--- /dev/null
+++ b/include/rijndael.h
@@ -0,0 +1,48 @@
+/* Copyright (C) 2002 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+
+/*
+ rijndael-alg-fst.h
+
+ @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.
+
+ Modified by Peter Zaitsev to fit MySQL coding style.
+
+ */
+#ifndef __RIJNDAEL_ALG_FST_H
+#define __RIJNDAEL_ALG_FST_H
+
+#define MAXKC (256/32)
+#define MAXKB (256/8)
+#define MAXNR 14
+
+int rijndaelKeySetupEnc(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[],
+ int keyBits);
+int rijndaelKeySetupDec(uint32 rk[/*4*(Nr + 1)*/], const uint8 cipherKey[],
+ int keyBits);
+void rijndaelEncrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr,
+ const uint8 pt[16], uint8 ct[16]);
+void rijndaelDecrypt(const uint32 rk[/*4*(Nr + 1)*/], int Nr,
+ const uint8 ct[16], uint8 pt[16]);
+
+#endif /* __RIJNDAEL_ALG_FST_H */
diff --git a/include/sha1.h b/include/sha1.h
new file mode 100644
index 00000000000..ed3fbaf0f2a
--- /dev/null
+++ b/include/sha1.h
@@ -0,0 +1,85 @@
+/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ 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
+
+ Description:
+ This is the header file for code which implements the Secure
+ Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
+ April 17, 1995.
+
+ Many of the variable names in this code, especially the
+ single character names, were used because those were the names
+ used in the publication.
+
+ Please read the file sha1.c for more information.
+
+*/
+
+/* Modified 2002 by Peter Zaitsev to better follow MySQL standards */
+
+
+#ifndef _SHA1_H_
+#define _SHA1_H_
+
+#include "my_global.h"
+
+/* Required for uint32, uint8, int16 ulonglong types */
+
+enum sha_result_codes
+{
+ SHA_SUCCESS = 0,
+ SHA_NULL, /* Null pointer parameter */
+ SHA_INPUT_TOO_LONG, /* input data too long */
+ SHA_STATE_ERROR /* called Input after Result */
+};
+
+#define SHA1_HASH_SIZE 20 /* Hash size in bytes */
+
+/*
+ This structure will hold context information for the SHA-1
+ hashing operation
+ */
+typedef struct SHA1_CONTEXT
+{
+ ulonglong Length; /* Message length in bits */
+ uint32 Intermediate_Hash[SHA1_HASH_SIZE/4]; /* Message Digest */
+ int Computed; /* Is the digest computed? */
+ int Corrupted; /* Is the message digest corrupted? */
+ int16 Message_Block_Index; /* Index into message block array */
+ uint8 Message_Block[64]; /* 512-bit message blocks */
+} SHA1_CONTEXT;
+
+/*
+ * Function Prototypes
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int sha1_reset( SHA1_CONTEXT* );
+int sha1_input( SHA1_CONTEXT*, const uint8 *, unsigned int );
+int sha1_result( SHA1_CONTEXT* , uint8 Message_Digest[SHA1_HASH_SIZE] );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif