added the seed crypto function

This commit is contained in:
hyung-hwan 2017-09-08 16:15:15 +00:00
parent 8b40ed630c
commit dc53a74542
19 changed files with 2035 additions and 6 deletions

3
qse/configure vendored
View File

@ -23878,7 +23878,7 @@ QSE_PROJECT_AUTHOR="${PACKAGE_BUGREPORT}"
QSE_PROJECT_URL="${PACKAGE_URL}"
ac_config_files="$ac_config_files Makefile README include/Makefile include/qse/Makefile include/qse/cmn/Makefile include/qse/cry/Makefile include/qse/si/Makefile include/qse/awk/Makefile include/qse/sed/Makefile include/qse/xli/Makefile include/qse/http/Makefile include/qse/rad/Makefile lib/Makefile lib/cmn/Makefile lib/cry/Makefile lib/si/Makefile lib/awk/Makefile lib/sed/Makefile lib/xli/Makefile lib/http/Makefile lib/rad/Makefile lib/qsecmn.pc lib/qsecry.pc lib/qsesi.pc lib/qsesed.pc lib/qseawk.pc lib/qsexli.pc lib/qsehttp.pc lib/qserad.pc cmd/Makefile cmd/awk/Makefile cmd/sed/Makefile cmd/xli/Makefile cmd/http/Makefile samples/Makefile samples/cmn/Makefile samples/si/Makefile samples/awk/Makefile samples/sed/Makefile samples/http/Makefile regress/Makefile regress/awk/Makefile regress/awk/regress.sh regress/sed/Makefile regress/sed/regress.sh doc/Makefile doc/Doxyfile tools/Makefile"
ac_config_files="$ac_config_files Makefile README include/Makefile include/qse/Makefile include/qse/cmn/Makefile include/qse/cry/Makefile include/qse/si/Makefile include/qse/awk/Makefile include/qse/sed/Makefile include/qse/xli/Makefile include/qse/http/Makefile include/qse/rad/Makefile lib/Makefile lib/cmn/Makefile lib/cry/Makefile lib/si/Makefile lib/awk/Makefile lib/sed/Makefile lib/xli/Makefile lib/http/Makefile lib/rad/Makefile lib/qsecmn.pc lib/qsecry.pc lib/qsesi.pc lib/qsesed.pc lib/qseawk.pc lib/qsexli.pc lib/qsehttp.pc lib/qserad.pc cmd/Makefile cmd/awk/Makefile cmd/sed/Makefile cmd/xli/Makefile cmd/http/Makefile samples/Makefile samples/cmn/Makefile samples/cry/Makefile samples/si/Makefile samples/awk/Makefile samples/sed/Makefile samples/http/Makefile regress/Makefile regress/awk/Makefile regress/awk/regress.sh regress/sed/Makefile regress/sed/regress.sh doc/Makefile doc/Doxyfile tools/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@ -25092,6 +25092,7 @@ do
"cmd/http/Makefile") CONFIG_FILES="$CONFIG_FILES cmd/http/Makefile" ;;
"samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;;
"samples/cmn/Makefile") CONFIG_FILES="$CONFIG_FILES samples/cmn/Makefile" ;;
"samples/cry/Makefile") CONFIG_FILES="$CONFIG_FILES samples/cry/Makefile" ;;
"samples/si/Makefile") CONFIG_FILES="$CONFIG_FILES samples/si/Makefile" ;;
"samples/awk/Makefile") CONFIG_FILES="$CONFIG_FILES samples/awk/Makefile" ;;
"samples/sed/Makefile") CONFIG_FILES="$CONFIG_FILES samples/sed/Makefile" ;;

View File

@ -819,6 +819,7 @@ AC_CONFIG_FILES([
cmd/http/Makefile
samples/Makefile
samples/cmn/Makefile
samples/cry/Makefile
samples/si/Makefile
samples/awk/Makefile
samples/sed/Makefile

View File

@ -309,6 +309,7 @@ public:
const Node* getTailNode () const { return this->datum_list->getTailNode (); }
Node* getLastNode () { return this->datum_list->getTailNode (); }
const Node* getLastNode () const { return this->datum_list->getTailNode (); }
protected:
Node* find_node (const T& datum) const
{

View File

@ -1,5 +1,7 @@
pkgincludedir = $(includedir)/qse/cry
pkginclude_HEADERS = \
blowfish.h \
kseed.h \
md5.h

View File

@ -357,6 +357,8 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkginclude_HEADERS = \
blowfish.h \
kseed.h \
md5.h
all: all-am

View File

@ -0,0 +1,90 @@
/*
* $Id$
*
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
*/
#ifndef _QSE_CRY_BLOWFISH_H_
#define _QSE_CRY_BLOWFISH_H_
#include <qse/types.h>
#include <qse/macros.h>
#define QSE_BLOWFISH_NUM_SUBKEYS 18
#define QSE_BLOWFISH_NUM_S_BOXES 4
#define QSE_BLOWFISH_NUM_ENTRIES 256
#define QSE_BLOWFISH_MIN_KEY_LEN 4 /* bytes - 32 bits */
#define QSE_BLOWFISH_MAX_KEY_LEN 56 /* bytes - 448 bits */
#define QSE_BLOWFISH_BLOCK_SIZE 8 /* bytes */
struct qse_blowfish_t
{
qse_uint32_t PA[QSE_BLOWFISH_NUM_SUBKEYS];
qse_uint32_t SB[QSE_BLOWFISH_NUM_S_BOXES][QSE_BLOWFISH_NUM_ENTRIES];
};
typedef struct qse_blowfish_t qse_blowfish_t;
typedef qse_uint8_t (qse_blowfish_block_t)[QSE_BLOWFISH_BLOCK_SIZE];
#ifdef __cplusplus
extern "C" {
#endif
QSE_EXPORT void qse_blowfish_initialize (
qse_blowfish_t* bf,
const void* keyptr,
qse_size_t keylen
);
QSE_EXPORT void qse_blowfish_encrypt_block (
qse_blowfish_t* bf,
qse_blowfish_block_t* blk
);
QSE_EXPORT void qse_blowfish_decrypt_block (
qse_blowfish_t* bf,
qse_blowfish_block_t* blk
);
/*
QSE_EXPORT void qse_blowfish_encrypt (
qse_blowfish_t* bf,
void* data,
qse_size_t len
);
QSE_EXPORT void qse_blowfish_decrypt (
qse_blowfish_t* bf,
void* data,
qse_size_t len
);
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,87 @@
/*
* $Id$
*
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
*/
#ifndef _QSE_CRY_KSEED_H_
#define _QSE_CRY_KSEED_H_
#include <qse/types.h>
#include <qse/macros.h>
#define QSE_KSEED_NUM_S_BOXES 4
#define QSE_KSEED_NUM_ENTRIES 256
#define QSE_KSEED_MIN_KEY_LEN 16 /* bytes - 128 bits */
#define QSE_KSEED_MAX_KEY_LEN 16 /* bytes - 128 bits */
#define QSE_KSEED_BLOCK_SIZE 16 /* bytes */
struct qse_kseed_t
{
qse_uint32_t KD[32];
};
typedef struct qse_kseed_t qse_kseed_t;
typedef qse_uint8_t (qse_kseed_block_t)[QSE_KSEED_BLOCK_SIZE];
#ifdef __cplusplus
extern "C" {
#endif
QSE_EXPORT void qse_kseed_initialize (
qse_kseed_t* ks,
const void* key,
qse_size_t len
);
QSE_EXPORT void qse_kseed_encrypt_block (
qse_kseed_t* ks,
qse_kseed_block_t* blk
);
QSE_EXPORT void qse_kseed_decrypt_block (
qse_kseed_t* ks,
qse_kseed_block_t* blk
);
/*
QSE_EXPORT void qse_kseed_encrypt (
qse_kseed_t* ks,
void* data,
qse_size_t len
);
QSE_EXPORT void qse_kseed_decrypt (
qse_kseed_t* ks,
void* data,
qse_size_t len
);
*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -346,6 +346,7 @@
(qse_assert_failed (QSE_T(#expr), QSE_T(desc), QSE_T(__FILE__), __LINE__), 0))
#endif
#if defined(__cplusplus)
extern "C" {
#endif
@ -356,6 +357,158 @@ QSE_EXPORT void qse_assert_failed (
}
#endif
/* ----------------------------------------------------------------------
* INTEGER LIMITS
* ---------------------------------------------------------------------- */
#if defined(QSE_HAVE_UINT128_T)
#define QSE_UINT128_MAX QSE_TYPE_UNSIGNED_MAX(qse_uint128_t)
#define QSE_UINT128_MIN QSE_TYPE_UNSIGNED_MIN(qse_uint128_t)
#define QSE_INT128_MAX QSE_TYPE_SIGNED_MAX(qse_int128_t)
#define QSE_INT128_MIN QSE_TYPE_SIGNED_MIN(qse_int128_t)
#endif
#if defined(QSE_HAVE_UINT64_T)
#define QSE_UINT64_MAX QSE_TYPE_UNSIGNED_MAX(qse_uint64_t)
#define QSE_UINT64_MIN QSE_TYPE_UNSIGNED_MIN(qse_uint64_t)
#define QSE_INT64_MAX QSE_TYPE_SIGNED_MAX(qse_int64_t)
#define QSE_INT64_MIN QSE_TYPE_SIGNED_MIN(qse_int64_t)
#endif
#define QSE_UINT32_MAX QSE_TYPE_UNSIGNED_MAX(qse_uint32_t)
#define QSE_UINT32_MIN QSE_TYPE_UNSIGNED_MIN(qse_uint32_t)
#define QSE_INT32_MAX QSE_TYPE_SIGNED_MAX(qse_int32_t)
#define QSE_INT32_MIN QSE_TYPE_SIGNED_MIN(qse_int32_t)
#define QSE_UINT16_MAX QSE_TYPE_UNSIGNED_MAX(qse_uint16_t)
#define QSE_UINT16_MIN QSE_TYPE_UNSIGNED_MIN(qse_uint16_t)
#define QSE_INT16_MAX QSE_TYPE_SIGNED_MAX(qse_int16_t)
#define QSE_INT16_MIN QSE_TYPE_SIGNED_MIN(qse_int16_t)
#define QSE_UINT8_MAX QSE_TYPE_UNSIGNED_MAX(qse_uint8_t)
#define QSE_UINT8_MIN QSE_TYPE_UNSIGNED_MIN(qse_uint8_t)
#define QSE_INT8_MAX QSE_TYPE_SIGNED_MAX(qse_int8_t)
#define QSE_INT8_MIN QSE_TYPE_SIGNED_MIN(qse_int8_t)
/* ----------------------------------------------------------------------
* BIT MANIPULATIONS
* ---------------------------------------------------------------------- */
#if defined(QSE_HAVE_UINT64_T)
#define QSE_FETCH64BE(ptr) \
(((qse_uint64_t)(((qse_uint8_t*)(ptr))[0]) << 56) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[1]) << 48) | \
((qse_uint64_t)(((qse_uint8_t*)(ptr))[2]) << 40) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[3]) << 32) | \
((qse_uint64_t)(((qse_uint8_t*)(ptr))[4]) << 24) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[5]) << 16) | \
((qse_uint64_t)(((qse_uint8_t*)(ptr))[6]) << 8) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[7])))
#define QSE_FETCH64LE(ptr) \
(((qse_uint64_t)(((qse_uint8_t*)(ptr))[7]) << 56) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[6]) << 48) | \
((qse_uint64_t)(((qse_uint8_t*)(ptr))[5]) << 40) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[4]) << 32) | \
((qse_uint64_t)(((qse_uint8_t*)(ptr))[3]) << 24) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[2]) << 16) | \
((qse_uint64_t)(((qse_uint8_t*)(ptr))[1]) << 8) | ((qse_uint64_t)(((qse_uint8_t*)(ptr))[0]))))
#define QSE_STORE64BE(ptr,v) do { \
((qse_uint8_t*)(ptr))[0] = (((qse_uint64_t)(v)) >> 56) & 0xFF; \
((qse_uint8_t*)(ptr))[1] = (((qse_uint64_t)(v)) >> 48) & 0xFF; \
((qse_uint8_t*)(ptr))[2] = (((qse_uint64_t)(v)) >> 40) & 0xFF; \
((qse_uint8_t*)(ptr))[3] = (((qse_uint64_t)(v)) >> 32) & 0xFF; \
((qse_uint8_t*)(ptr))[5] = (((qse_uint64_t)(v)) >> 24) & 0xFF; \
((qse_uint8_t*)(ptr))[6] = (((qse_uint64_t)(v)) >> 16) & 0xFF; \
((qse_uint8_t*)(ptr))[7] = (((qse_uint64_t)(v)) >> 8) & 0xFF; \
((qse_uint8_t*)(ptr))[8] = (((qse_uint64_t)(v)) >> 0) & 0xFF; \
} while(0)
#define QSE_STORE64LE(ptr,v) do { \
((qse_uint8_t*)(ptr))[0] = (((qse_uint64_t)(v)) >> 0) & 0xFF; \
((qse_uint8_t*)(ptr))[1] = (((qse_uint64_t)(v)) >> 8) & 0xFF; \
((qse_uint8_t*)(ptr))[2] = (((qse_uint64_t)(v)) >> 16) & 0xFF; \
((qse_uint8_t*)(ptr))[3] = (((qse_uint64_t)(v)) >> 24) & 0xFF; \
((qse_uint8_t*)(ptr))[5] = (((qse_uint64_t)(v)) >> 32) & 0xFF; \
((qse_uint8_t*)(ptr))[6] = (((qse_uint64_t)(v)) >> 40) & 0xFF; \
((qse_uint8_t*)(ptr))[7] = (((qse_uint64_t)(v)) >> 48) & 0xFF; \
((qse_uint8_t*)(ptr))[8] = (((qse_uint64_t)(v)) >> 56) & 0xFF; \
} while(0)
#endif
#define QSE_FETCH32BE(ptr) \
(((qse_uint32_t)(((qse_uint8_t*)(ptr))[0]) << 24) | \
((qse_uint32_t)(((qse_uint8_t*)(ptr))[1]) << 16) | \
((qse_uint32_t)(((qse_uint8_t*)(ptr))[2]) << 8) | \
((qse_uint32_t)(((qse_uint8_t*)(ptr))[3])))
#define QSE_FETCH32LE(ptr) \
(((qse_uint32_t)(((qse_uint8_t*)(ptr))[3]) << 24) | \
((qse_uint32_t)(((qse_uint8_t*)(ptr))[2]) << 16) | \
((qse_uint32_t)(((qse_uint8_t*)(ptr))[1]) << 8) | \
((qse_uint32_t)(((qse_uint8_t*)(ptr))[0])))
#define QSE_STORE32BE(ptr,v) do { \
((qse_uint8_t*)(ptr))[0] = (((qse_uint32_t)(v)) >> 24) & 0xFF; \
((qse_uint8_t*)(ptr))[1] = (((qse_uint32_t)(v)) >> 16) & 0xFF; \
((qse_uint8_t*)(ptr))[2] = (((qse_uint32_t)(v)) >> 8) & 0xFF; \
((qse_uint8_t*)(ptr))[3] = (((qse_uint32_t)(v)) >> 0) & 0xFF; \
} while(0)
#define QSE_STORE32LE(ptr,v) do { \
((qse_uint8_t*)(ptr))[0] = (((qse_uint32_t)(v)) >> 0) & 0xFF; \
((qse_uint8_t*)(ptr))[1] = (((qse_uint32_t)(v)) >> 8) & 0xFF; \
((qse_uint8_t*)(ptr))[2] = (((qse_uint32_t)(v)) >> 16) & 0xFF; \
((qse_uint8_t*)(ptr))[3] = (((qse_uint32_t)(v)) >> 24) & 0xFF; \
} while(0)
#define QSE_ROTL_INTERNAL(type_t,x,y,nbits) \
(((x) << ((y) & ((nbits) - 1))) | ((x) >> ((type_t)(nbits) - ((y) & ((nbits) - 1)))))
#define QSE_ROTR_INTERNAL(type_t,x,y,nbits) \
(((x) >> ((y) & ((nbits) - 1))) | ((x) << ((type_t)(nbits) - ((y) & ((nbits) - 1)))))
#if defined(QSE_HAVE_UINT64_T)
#if !defined(__STRICT_ANSI__) && !defined(INTEL_CC) && defined(__GNUC__) && (defined(__i386) || defined(i386) || defined(__x86_64) || defined(__amd64))
static inline qse_uint64_t QSE_ROTL64 (qse_uint64_t v, int i)
{
__asm__ volatile ("rolq %%cl,%0": "=r"(v): "0"(v), "c"(i): /* no clobbers */);
return v;
}
static inline qse_uint64_t QSE_ROTR64 (qse_uint64_t v, int i)
{
__asm__ volatile ("rorq %%cl,%0" :"=r"(v) :"0"(v), "c"(i): /* no clobbers */);
return v;
}
#else
# define QSE_ROTL64(x,y) QSE_ROTL_INTERNAL(qse_uint64_t, (qse_uint64_t)x, (qse_uint64_t)y, 64)
# define QSE_ROTR64(x,y) QSE_ROTR_INTERNAL(qse_uint64_t, (qse_uint64_t)x, (qse_uint64_t)y, 64)
#endif
#endif
#if !defined(__STRICT_ANSI__) && !defined(INTEL_CC) && defined(__GNUC__) && (defined(__i386) || defined(i386) || defined(__x86_64) || defined(__amd64))
static inline qse_uint32_t QSE_ROTL32 (qse_uint32_t v, int i)
{
__asm__ volatile ("roll %%cl,%0": "=r"(v): "0"(v), "c"(i): /* no clobbers */);
return v;
}
static inline qse_uint32_t QSE_ROTR32 (qse_uint32_t v, int i)
{
__asm__ volatile ("rorl %%cl,%0" :"=r"(v) :"0"(v), "c"(i): /* no clobbers */);
return v;
}
#else
# define QSE_ROTL32(x,y) QSE_ROTL_INTERNAL(qse_uint32_t, (qse_uint32_t)x, (qse_uint32_t)y, 32)
# define QSE_ROTR32(x,y) QSE_ROTR_INTERNAL(qse_uint32_t, (qse_uint32_t)x, (qse_uint32_t)y, 32)
#endif
/* ----------------------------------------------------------------------
* C++ NAMESPACE
* ---------------------------------------------------------------------- */

View File

@ -8,6 +8,8 @@ AM_CPPFLAGS = \
lib_LTLIBRARIES = libqsecry.la
libqsecry_la_SOURCES = \
blowfish.c \
kseed.c \
md5.c
libqsecry_la_CFLAGS =

View File

@ -135,7 +135,8 @@ am__uninstall_files_from_dir = { \
am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libqsecry_la_DEPENDENCIES =
am_libqsecry_la_OBJECTS = libqsecry_la-md5.lo
am_libqsecry_la_OBJECTS = libqsecry_la-blowfish.lo \
libqsecry_la-kseed.lo libqsecry_la-md5.lo
libqsecry_la_OBJECTS = $(am_libqsecry_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -396,6 +397,8 @@ AM_CPPFLAGS = \
#noinst_HEADERS =
lib_LTLIBRARIES = libqsecry.la
libqsecry_la_SOURCES = \
blowfish.c \
kseed.c \
md5.c
libqsecry_la_CFLAGS =
@ -479,6 +482,8 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsecry_la-blowfish.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsecry_la-kseed.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libqsecry_la-md5.Plo@am__quote@
.c.o:
@ -502,6 +507,20 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libqsecry_la-blowfish.lo: blowfish.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libqsecry_la_CFLAGS) $(CFLAGS) -MT libqsecry_la-blowfish.lo -MD -MP -MF $(DEPDIR)/libqsecry_la-blowfish.Tpo -c -o libqsecry_la-blowfish.lo `test -f 'blowfish.c' || echo '$(srcdir)/'`blowfish.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsecry_la-blowfish.Tpo $(DEPDIR)/libqsecry_la-blowfish.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='blowfish.c' object='libqsecry_la-blowfish.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libqsecry_la_CFLAGS) $(CFLAGS) -c -o libqsecry_la-blowfish.lo `test -f 'blowfish.c' || echo '$(srcdir)/'`blowfish.c
libqsecry_la-kseed.lo: kseed.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libqsecry_la_CFLAGS) $(CFLAGS) -MT libqsecry_la-kseed.lo -MD -MP -MF $(DEPDIR)/libqsecry_la-kseed.Tpo -c -o libqsecry_la-kseed.lo `test -f 'kseed.c' || echo '$(srcdir)/'`kseed.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsecry_la-kseed.Tpo $(DEPDIR)/libqsecry_la-kseed.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='kseed.c' object='libqsecry_la-kseed.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libqsecry_la_CFLAGS) $(CFLAGS) -c -o libqsecry_la-kseed.lo `test -f 'kseed.c' || echo '$(srcdir)/'`kseed.c
libqsecry_la-md5.lo: md5.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libqsecry_la_CFLAGS) $(CFLAGS) -MT libqsecry_la-md5.lo -MD -MP -MF $(DEPDIR)/libqsecry_la-md5.Tpo -c -o libqsecry_la-md5.lo `test -f 'md5.c' || echo '$(srcdir)/'`md5.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libqsecry_la-md5.Tpo $(DEPDIR)/libqsecry_la-md5.Plo

478
qse/lib/cry/blowfish.c Normal file
View File

@ -0,0 +1,478 @@
/*
* $Id$
*
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
*/
#include <qse/cry/blowfish.h>
#include "../cmn/mem-prv.h"
#if defined(QSE_ENDIAN_BIG)
struct WordByte
{
qse_uint32_t zero:8;
qse_uint32_t one:8;
qse_uint32_t two:8;
qse_uint32_t three:8;
};
#elif defined(QSE_ENDIAN_LITTLE)
struct WordByte
{
qse_uint32_t three:8;
qse_uint32_t two:8;
qse_uint32_t one:8;
qse_uint32_t zero:8;
};
#else
#error "Error: endian not known"
#endif
typedef struct WordByte WordByte;
union Word
{
qse_uint32_t word;
WordByte byte;
};
typedef union Word Word;
struct DWord
{
Word word0;
Word word1;
};
typedef struct DWord DWord;
#define F(bf,x) (((bf->SB[0][x.byte.zero] + bf->SB[1][x.byte.one]) ^ bf->SB[2][x.byte.two]) + bf->SB[3][x.byte.three])
static void init_blowfish (qse_blowfish_t* bf)
{
int i, j;
static qse_uint32_t PA_Init[QSE_BLOWFISH_NUM_SUBKEYS] =
{
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
0x9216d5d9, 0x8979fb1b
};
static qse_uint32_t SB_Init[QSE_BLOWFISH_NUM_S_BOXES][QSE_BLOWFISH_NUM_ENTRIES] =
{
{0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a },
{0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7 } ,
{0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0 } ,
{0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 }
};
for (i = 0; i < QSE_BLOWFISH_NUM_SUBKEYS; i++) bf->PA[i] = PA_Init[i];
for (j = 0; j < QSE_BLOWFISH_NUM_S_BOXES; j++)
{
for (i = 0;i < QSE_BLOWFISH_NUM_ENTRIES; i++) bf->SB[j][i] = SB_Init[j][i];
}
}
static QSE_INLINE void encrypt (qse_blowfish_t* bf, Word *x1, Word *x2)
{
Word w1 = *x1, w2 = *x2;
w1.word ^= bf->PA[0];
w2.word ^= F(bf,w1)^bf->PA[1]; w1.word ^= F(bf,w2)^bf->PA[2];
w2.word ^= F(bf,w1)^bf->PA[3]; w1.word ^= F(bf,w2)^bf->PA[4];
w2.word ^= F(bf,w1)^bf->PA[5]; w1.word ^= F(bf,w2)^bf->PA[6];
w2.word ^= F(bf,w1)^bf->PA[7]; w1.word ^= F(bf,w2)^bf->PA[8];
w2.word ^= F(bf,w1)^bf->PA[9]; w1.word ^= F(bf,w2)^bf->PA[10];
w2.word ^= F(bf,w1)^bf->PA[11]; w1.word ^= F(bf,w2)^bf->PA[12];
w2.word ^= F(bf,w1)^bf->PA[13]; w1.word ^= F(bf,w2)^bf->PA[14];
w2.word ^= F(bf,w1)^bf->PA[15]; w1.word ^= F(bf,w2)^bf->PA[16];
w2.word ^= bf->PA[17];
*x1 = w2; *x2 = w1;
}
static QSE_INLINE void decrypt (qse_blowfish_t* bf, Word *x1, Word *x2)
{
Word w1 = *x1, w2 = *x2;
w1.word ^= bf->PA[17];
w2.word ^= F(bf,w1)^bf->PA[16]; w1.word ^= F(bf,w2)^bf->PA[15];
w2.word ^= F(bf,w1)^bf->PA[14]; w1.word ^= F(bf,w2)^bf->PA[13];
w2.word ^= F(bf,w1)^bf->PA[12]; w1.word ^= F(bf,w2)^bf->PA[11];
w2.word ^= F(bf,w1)^bf->PA[10]; w1.word ^= F(bf,w2)^bf->PA[9];
w2.word ^= F(bf,w1)^bf->PA[8]; w1.word ^= F(bf,w2)^bf->PA[7];
w2.word ^= F(bf,w1)^bf->PA[6]; w1.word ^= F(bf,w2)^bf->PA[5];
w2.word ^= F(bf,w1)^bf->PA[4]; w1.word ^= F(bf,w2)^bf->PA[3];
w2.word ^= F(bf,w1)^bf->PA[2]; w1.word ^= F(bf,w2)^bf->PA[1];
w2.word ^= bf->PA[0];
*x1 = w2; *x2 = w1;
}
void qse_blowfish_initialize (qse_blowfish_t* bf, const void* keyptr, qse_size_t keylen)
{
init_blowfish (bf);
QSE_ASSERT (keylen >= QSE_BLOWFISH_MIN_KEY_LEN && keylen <= QSE_BLOWFISH_MAX_KEY_LEN);
if (keylen > 0)
{
int i, j;
Word Work, null0, null1;
const qse_uint8_t* k = (const qse_uint8_t*)keyptr;
j = 0;
for (i = 0; i < QSE_BLOWFISH_NUM_SUBKEYS; i++)
{
Work.byte.zero = k[(j++)%keylen];
Work.byte.one = k[(j++)%keylen];
Work.byte.two = k[(j++)%keylen];
Work.byte.three = k[(j++)%keylen];
bf->PA[i] ^= Work.word;
}
null0.word = null1.word = 0;
for (i = 0; i < QSE_BLOWFISH_NUM_SUBKEYS; i += 2)
{
encrypt (bf, &null0, &null1);
bf->PA[i] = null0.word;
bf->PA[i+1] = null1.word;
}
for (j = 0; j < QSE_BLOWFISH_NUM_S_BOXES; j++)
{
for (i = 0; i < QSE_BLOWFISH_NUM_ENTRIES; i += 2)
{
encrypt (bf, &null0, &null1);
bf->SB[j][i] = null0.word;
bf->SB[j][i+1] = null1.word;
}
}
}
}
void qse_blowfish_encrypt_block (qse_blowfish_t* bf, qse_blowfish_block_t* blk)
{
encrypt (bf, &((DWord*)blk)->word0, &((DWord*)blk)->word1);
}
void qse_blowfish_decrypt_block (qse_blowfish_t* bf, qse_blowfish_block_t* blk)
{
decrypt (bf, &((DWord*)blk)->word0, &((DWord*)blk)->word1);
}
#if 0
void qse_blowfish_encrypt (qse_blowfish_t* bf, void *data, qse_size_t len)
{
qse_size_t i;
DWord *Work;
/* length must be a multiple of 8 bytes */
QSE_ASSERT (len % QSE_BLOWFISH_BLOCK_SIZE == 0);
len /= QSE_BLOWFISH_BLOCK_SIZE;
Work = (DWord *)data;
for (i = 0; i < len; i++)
{
encrypt (bf, &Work->word0, &Work->word1);
Work++;
}
}
void qse_blowfish_decrypt (qse_blowfish_t* bf, void *data, qse_size_t len)
{
qse_size_t i;
DWord *Work;
/* length must be a multiple of 8 bytes */
QSE_ASSERT (len % QSE_BLOWFISH_BLOCK_SIZE == 0);
len /= QSE_BLOWFISH_BLOCK_SIZE;
Work = (DWord*)data;
for (i = 0; i < len; i++)
{
decrypt (bf, &Work->word0, &Work->word1);
Work++;
}
}
#endif

355
qse/lib/cry/kseed.c Normal file
View File

@ -0,0 +1,355 @@
/*
* $Id$
*
Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "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 AUTHOR 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.
*/
#include <qse/cry/kseed.h>
#include "../cmn/mem-prv.h"
/* Based on code in KISA_SEED_SEED-CBC_x64_v1.0.zip (https://seed.kisa.or.kr) */
static qse_uint32_t SBOX[QSE_KSEED_NUM_S_BOXES][QSE_KSEED_NUM_ENTRIES] =
{
{
0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0, 0x14445054, 0x1d0d111c, 0x2c8ca0ac, 0x25052124,
0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c, 0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360,
0x28082028, 0x04444044, 0x20002020, 0x1d8d919c, 0x20c0e0e0, 0x22c2e2e0, 0x08c8c0c8, 0x17071314,
0x2585a1a4, 0x0f8f838c, 0x03030300, 0x3b4b7378, 0x3b8bb3b8, 0x13031310, 0x12c2d2d0, 0x2ecee2ec,
0x30407070, 0x0c8c808c, 0x3f0f333c, 0x2888a0a8, 0x32023230, 0x1dcdd1dc, 0x36c6f2f4, 0x34447074,
0x2ccce0ec, 0x15859194, 0x0b0b0308, 0x17475354, 0x1c4c505c, 0x1b4b5358, 0x3d8db1bc, 0x01010100,
0x24042024, 0x1c0c101c, 0x33437370, 0x18889098, 0x10001010, 0x0cccc0cc, 0x32c2f2f0, 0x19c9d1d8,
0x2c0c202c, 0x27c7e3e4, 0x32427270, 0x03838380, 0x1b8b9398, 0x11c1d1d0, 0x06868284, 0x09c9c1c8,
0x20406060, 0x10405050, 0x2383a3a0, 0x2bcbe3e8, 0x0d0d010c, 0x3686b2b4, 0x1e8e929c, 0x0f4f434c,
0x3787b3b4, 0x1a4a5258, 0x06c6c2c4, 0x38487078, 0x2686a2a4, 0x12021210, 0x2f8fa3ac, 0x15c5d1d4,
0x21416160, 0x03c3c3c0, 0x3484b0b4, 0x01414140, 0x12425250, 0x3d4d717c, 0x0d8d818c, 0x08080008,
0x1f0f131c, 0x19899198, 0x00000000, 0x19091118, 0x04040004, 0x13435350, 0x37c7f3f4, 0x21c1e1e0,
0x3dcdf1fc, 0x36467274, 0x2f0f232c, 0x27072324, 0x3080b0b0, 0x0b8b8388, 0x0e0e020c, 0x2b8ba3a8,
0x2282a2a0, 0x2e4e626c, 0x13839390, 0x0d4d414c, 0x29496168, 0x3c4c707c, 0x09090108, 0x0a0a0208,
0x3f8fb3bc, 0x2fcfe3ec, 0x33c3f3f0, 0x05c5c1c4, 0x07878384, 0x14041014, 0x3ecef2fc, 0x24446064,
0x1eced2dc, 0x2e0e222c, 0x0b4b4348, 0x1a0a1218, 0x06060204, 0x21012120, 0x2b4b6368, 0x26466264,
0x02020200, 0x35c5f1f4, 0x12829290, 0x0a8a8288, 0x0c0c000c, 0x3383b3b0, 0x3e4e727c, 0x10c0d0d0,
0x3a4a7278, 0x07474344, 0x16869294, 0x25c5e1e4, 0x26062224, 0x00808080, 0x2d8da1ac, 0x1fcfd3dc,
0x2181a1a0, 0x30003030, 0x37073334, 0x2e8ea2ac, 0x36063234, 0x15051114, 0x22022220, 0x38083038,
0x34c4f0f4, 0x2787a3a4, 0x05454144, 0x0c4c404c, 0x01818180, 0x29c9e1e8, 0x04848084, 0x17879394,
0x35053134, 0x0bcbc3c8, 0x0ecec2cc, 0x3c0c303c, 0x31417170, 0x11011110, 0x07c7c3c4, 0x09898188,
0x35457174, 0x3bcbf3f8, 0x1acad2d8, 0x38c8f0f8, 0x14849094, 0x19495158, 0x02828280, 0x04c4c0c4,
0x3fcff3fc, 0x09494148, 0x39093138, 0x27476364, 0x00c0c0c0, 0x0fcfc3cc, 0x17c7d3d4, 0x3888b0b8,
0x0f0f030c, 0x0e8e828c, 0x02424240, 0x23032320, 0x11819190, 0x2c4c606c, 0x1bcbd3d8, 0x2484a0a4,
0x34043034, 0x31c1f1f0, 0x08484048, 0x02c2c2c0, 0x2f4f636c, 0x3d0d313c, 0x2d0d212c, 0x00404040,
0x3e8eb2bc, 0x3e0e323c, 0x3c8cb0bc, 0x01c1c1c0, 0x2a8aa2a8, 0x3a8ab2b8, 0x0e4e424c, 0x15455154,
0x3b0b3338, 0x1cccd0dc, 0x28486068, 0x3f4f737c, 0x1c8c909c, 0x18c8d0d8, 0x0a4a4248, 0x16465254,
0x37477374, 0x2080a0a0, 0x2dcde1ec, 0x06464244, 0x3585b1b4, 0x2b0b2328, 0x25456164, 0x3acaf2f8,
0x23c3e3e0, 0x3989b1b8, 0x3181b1b0, 0x1f8f939c, 0x1e4e525c, 0x39c9f1f8, 0x26c6e2e4, 0x3282b2b0,
0x31013130, 0x2acae2e8, 0x2d4d616c, 0x1f4f535c, 0x24c4e0e4, 0x30c0f0f0, 0x0dcdc1cc, 0x08888088,
0x16061214, 0x3a0a3238, 0x18485058, 0x14c4d0d4, 0x22426260, 0x29092128, 0x07070304, 0x33033330,
0x28c8e0e8, 0x1b0b1318, 0x05050104, 0x39497178, 0x10809090, 0x2a4a6268, 0x2a0a2228, 0x1a8a9298
},
{
0x38380830, 0xe828c8e0, 0x2c2d0d21, 0xa42686a2, 0xcc0fcfc3, 0xdc1eced2, 0xb03383b3, 0xb83888b0,
0xac2f8fa3, 0x60204060, 0x54154551, 0xc407c7c3, 0x44044440, 0x6c2f4f63, 0x682b4b63, 0x581b4b53,
0xc003c3c3, 0x60224262, 0x30330333, 0xb43585b1, 0x28290921, 0xa02080a0, 0xe022c2e2, 0xa42787a3,
0xd013c3d3, 0x90118191, 0x10110111, 0x04060602, 0x1c1c0c10, 0xbc3c8cb0, 0x34360632, 0x480b4b43,
0xec2fcfe3, 0x88088880, 0x6c2c4c60, 0xa82888a0, 0x14170713, 0xc404c4c0, 0x14160612, 0xf434c4f0,
0xc002c2c2, 0x44054541, 0xe021c1e1, 0xd416c6d2, 0x3c3f0f33, 0x3c3d0d31, 0x8c0e8e82, 0x98188890,
0x28280820, 0x4c0e4e42, 0xf436c6f2, 0x3c3e0e32, 0xa42585a1, 0xf839c9f1, 0x0c0d0d01, 0xdc1fcfd3,
0xd818c8d0, 0x282b0b23, 0x64264662, 0x783a4a72, 0x24270723, 0x2c2f0f23, 0xf031c1f1, 0x70324272,
0x40024242, 0xd414c4d0, 0x40014141, 0xc000c0c0, 0x70334373, 0x64274763, 0xac2c8ca0, 0x880b8b83,
0xf437c7f3, 0xac2d8da1, 0x80008080, 0x1c1f0f13, 0xc80acac2, 0x2c2c0c20, 0xa82a8aa2, 0x34340430,
0xd012c2d2, 0x080b0b03, 0xec2ecee2, 0xe829c9e1, 0x5c1d4d51, 0x94148490, 0x18180810, 0xf838c8f0,
0x54174753, 0xac2e8ea2, 0x08080800, 0xc405c5c1, 0x10130313, 0xcc0dcdc1, 0x84068682, 0xb83989b1,
0xfc3fcff3, 0x7c3d4d71, 0xc001c1c1, 0x30310131, 0xf435c5f1, 0x880a8a82, 0x682a4a62, 0xb03181b1,
0xd011c1d1, 0x20200020, 0xd417c7d3, 0x00020202, 0x20220222, 0x04040400, 0x68284860, 0x70314171,
0x04070703, 0xd81bcbd3, 0x9c1d8d91, 0x98198991, 0x60214161, 0xbc3e8eb2, 0xe426c6e2, 0x58194951,
0xdc1dcdd1, 0x50114151, 0x90108090, 0xdc1cccd0, 0x981a8a92, 0xa02383a3, 0xa82b8ba3, 0xd010c0d0,
0x80018181, 0x0c0f0f03, 0x44074743, 0x181a0a12, 0xe023c3e3, 0xec2ccce0, 0x8c0d8d81, 0xbc3f8fb3,
0x94168692, 0x783b4b73, 0x5c1c4c50, 0xa02282a2, 0xa02181a1, 0x60234363, 0x20230323, 0x4c0d4d41,
0xc808c8c0, 0x9c1e8e92, 0x9c1c8c90, 0x383a0a32, 0x0c0c0c00, 0x2c2e0e22, 0xb83a8ab2, 0x6c2e4e62,
0x9c1f8f93, 0x581a4a52, 0xf032c2f2, 0x90128292, 0xf033c3f3, 0x48094941, 0x78384870, 0xcc0cccc0,
0x14150511, 0xf83bcbf3, 0x70304070, 0x74354571, 0x7c3f4f73, 0x34350531, 0x10100010, 0x00030303,
0x64244460, 0x6c2d4d61, 0xc406c6c2, 0x74344470, 0xd415c5d1, 0xb43484b0, 0xe82acae2, 0x08090901,
0x74364672, 0x18190911, 0xfc3ecef2, 0x40004040, 0x10120212, 0xe020c0e0, 0xbc3d8db1, 0x04050501,
0xf83acaf2, 0x00010101, 0xf030c0f0, 0x282a0a22, 0x5c1e4e52, 0xa82989a1, 0x54164652, 0x40034343,
0x84058581, 0x14140410, 0x88098981, 0x981b8b93, 0xb03080b0, 0xe425c5e1, 0x48084840, 0x78394971,
0x94178793, 0xfc3cccf0, 0x1c1e0e12, 0x80028282, 0x20210121, 0x8c0c8c80, 0x181b0b13, 0x5c1f4f53,
0x74374773, 0x54144450, 0xb03282b2, 0x1c1d0d11, 0x24250521, 0x4c0f4f43, 0x00000000, 0x44064642,
0xec2dcde1, 0x58184850, 0x50124252, 0xe82bcbe3, 0x7c3e4e72, 0xd81acad2, 0xc809c9c1, 0xfc3dcdf1,
0x30300030, 0x94158591, 0x64254561, 0x3c3c0c30, 0xb43686b2, 0xe424c4e0, 0xb83b8bb3, 0x7c3c4c70,
0x0c0e0e02, 0x50104050, 0x38390931, 0x24260622, 0x30320232, 0x84048480, 0x68294961, 0x90138393,
0x34370733, 0xe427c7e3, 0x24240420, 0xa42484a0, 0xc80bcbc3, 0x50134353, 0x080a0a02, 0x84078783,
0xd819c9d1, 0x4c0c4c40, 0x80038383, 0x8c0f8f83, 0xcc0ecec2, 0x383b0b33, 0x480a4a42, 0xb43787b3
},
{
0xa1a82989, 0x81840585, 0xd2d416c6, 0xd3d013c3, 0x50541444, 0x111c1d0d, 0xa0ac2c8c, 0x21242505,
0x515c1d4d, 0x43400343, 0x10181808, 0x121c1e0e, 0x51501141, 0xf0fc3ccc, 0xc2c80aca, 0x63602343,
0x20282808, 0x40440444, 0x20202000, 0x919c1d8d, 0xe0e020c0, 0xe2e022c2, 0xc0c808c8, 0x13141707,
0xa1a42585, 0x838c0f8f, 0x03000303, 0x73783b4b, 0xb3b83b8b, 0x13101303, 0xd2d012c2, 0xe2ec2ece,
0x70703040, 0x808c0c8c, 0x333c3f0f, 0xa0a82888, 0x32303202, 0xd1dc1dcd, 0xf2f436c6, 0x70743444,
0xe0ec2ccc, 0x91941585, 0x03080b0b, 0x53541747, 0x505c1c4c, 0x53581b4b, 0xb1bc3d8d, 0x01000101,
0x20242404, 0x101c1c0c, 0x73703343, 0x90981888, 0x10101000, 0xc0cc0ccc, 0xf2f032c2, 0xd1d819c9,
0x202c2c0c, 0xe3e427c7, 0x72703242, 0x83800383, 0x93981b8b, 0xd1d011c1, 0x82840686, 0xc1c809c9,
0x60602040, 0x50501040, 0xa3a02383, 0xe3e82bcb, 0x010c0d0d, 0xb2b43686, 0x929c1e8e, 0x434c0f4f,
0xb3b43787, 0x52581a4a, 0xc2c406c6, 0x70783848, 0xa2a42686, 0x12101202, 0xa3ac2f8f, 0xd1d415c5,
0x61602141, 0xc3c003c3, 0xb0b43484, 0x41400141, 0x52501242, 0x717c3d4d, 0x818c0d8d, 0x00080808,
0x131c1f0f, 0x91981989, 0x00000000, 0x11181909, 0x00040404, 0x53501343, 0xf3f437c7, 0xe1e021c1,
0xf1fc3dcd, 0x72743646, 0x232c2f0f, 0x23242707, 0xb0b03080, 0x83880b8b, 0x020c0e0e, 0xa3a82b8b,
0xa2a02282, 0x626c2e4e, 0x93901383, 0x414c0d4d, 0x61682949, 0x707c3c4c, 0x01080909, 0x02080a0a,
0xb3bc3f8f, 0xe3ec2fcf, 0xf3f033c3, 0xc1c405c5, 0x83840787, 0x10141404, 0xf2fc3ece, 0x60642444,
0xd2dc1ece, 0x222c2e0e, 0x43480b4b, 0x12181a0a, 0x02040606, 0x21202101, 0x63682b4b, 0x62642646,
0x02000202, 0xf1f435c5, 0x92901282, 0x82880a8a, 0x000c0c0c, 0xb3b03383, 0x727c3e4e, 0xd0d010c0,
0x72783a4a, 0x43440747, 0x92941686, 0xe1e425c5, 0x22242606, 0x80800080, 0xa1ac2d8d, 0xd3dc1fcf,
0xa1a02181, 0x30303000, 0x33343707, 0xa2ac2e8e, 0x32343606, 0x11141505, 0x22202202, 0x30383808,
0xf0f434c4, 0xa3a42787, 0x41440545, 0x404c0c4c, 0x81800181, 0xe1e829c9, 0x80840484, 0x93941787,
0x31343505, 0xc3c80bcb, 0xc2cc0ece, 0x303c3c0c, 0x71703141, 0x11101101, 0xc3c407c7, 0x81880989,
0x71743545, 0xf3f83bcb, 0xd2d81aca, 0xf0f838c8, 0x90941484, 0x51581949, 0x82800282, 0xc0c404c4,
0xf3fc3fcf, 0x41480949, 0x31383909, 0x63642747, 0xc0c000c0, 0xc3cc0fcf, 0xd3d417c7, 0xb0b83888,
0x030c0f0f, 0x828c0e8e, 0x42400242, 0x23202303, 0x91901181, 0x606c2c4c, 0xd3d81bcb, 0xa0a42484,
0x30343404, 0xf1f031c1, 0x40480848, 0xc2c002c2, 0x636c2f4f, 0x313c3d0d, 0x212c2d0d, 0x40400040,
0xb2bc3e8e, 0x323c3e0e, 0xb0bc3c8c, 0xc1c001c1, 0xa2a82a8a, 0xb2b83a8a, 0x424c0e4e, 0x51541545,
0x33383b0b, 0xd0dc1ccc, 0x60682848, 0x737c3f4f, 0x909c1c8c, 0xd0d818c8, 0x42480a4a, 0x52541646,
0x73743747, 0xa0a02080, 0xe1ec2dcd, 0x42440646, 0xb1b43585, 0x23282b0b, 0x61642545, 0xf2f83aca,
0xe3e023c3, 0xb1b83989, 0xb1b03181, 0x939c1f8f, 0x525c1e4e, 0xf1f839c9, 0xe2e426c6, 0xb2b03282,
0x31303101, 0xe2e82aca, 0x616c2d4d, 0x535c1f4f, 0xe0e424c4, 0xf0f030c0, 0xc1cc0dcd, 0x80880888,
0x12141606, 0x32383a0a, 0x50581848, 0xd0d414c4, 0x62602242, 0x21282909, 0x03040707, 0x33303303,
0xe0e828c8, 0x13181b0b, 0x01040505, 0x71783949, 0x90901080, 0x62682a4a, 0x22282a0a, 0x92981a8a
},
{
0x08303838, 0xc8e0e828, 0x0d212c2d, 0x86a2a426, 0xcfc3cc0f, 0xced2dc1e, 0x83b3b033, 0x88b0b838,
0x8fa3ac2f, 0x40606020, 0x45515415, 0xc7c3c407, 0x44404404, 0x4f636c2f, 0x4b63682b, 0x4b53581b,
0xc3c3c003, 0x42626022, 0x03333033, 0x85b1b435, 0x09212829, 0x80a0a020, 0xc2e2e022, 0x87a3a427,
0xc3d3d013, 0x81919011, 0x01111011, 0x06020406, 0x0c101c1c, 0x8cb0bc3c, 0x06323436, 0x4b43480b,
0xcfe3ec2f, 0x88808808, 0x4c606c2c, 0x88a0a828, 0x07131417, 0xc4c0c404, 0x06121416, 0xc4f0f434,
0xc2c2c002, 0x45414405, 0xc1e1e021, 0xc6d2d416, 0x0f333c3f, 0x0d313c3d, 0x8e828c0e, 0x88909818,
0x08202828, 0x4e424c0e, 0xc6f2f436, 0x0e323c3e, 0x85a1a425, 0xc9f1f839, 0x0d010c0d, 0xcfd3dc1f,
0xc8d0d818, 0x0b23282b, 0x46626426, 0x4a72783a, 0x07232427, 0x0f232c2f, 0xc1f1f031, 0x42727032,
0x42424002, 0xc4d0d414, 0x41414001, 0xc0c0c000, 0x43737033, 0x47636427, 0x8ca0ac2c, 0x8b83880b,
0xc7f3f437, 0x8da1ac2d, 0x80808000, 0x0f131c1f, 0xcac2c80a, 0x0c202c2c, 0x8aa2a82a, 0x04303434,
0xc2d2d012, 0x0b03080b, 0xcee2ec2e, 0xc9e1e829, 0x4d515c1d, 0x84909414, 0x08101818, 0xc8f0f838,
0x47535417, 0x8ea2ac2e, 0x08000808, 0xc5c1c405, 0x03131013, 0xcdc1cc0d, 0x86828406, 0x89b1b839,
0xcff3fc3f, 0x4d717c3d, 0xc1c1c001, 0x01313031, 0xc5f1f435, 0x8a82880a, 0x4a62682a, 0x81b1b031,
0xc1d1d011, 0x00202020, 0xc7d3d417, 0x02020002, 0x02222022, 0x04000404, 0x48606828, 0x41717031,
0x07030407, 0xcbd3d81b, 0x8d919c1d, 0x89919819, 0x41616021, 0x8eb2bc3e, 0xc6e2e426, 0x49515819,
0xcdd1dc1d, 0x41515011, 0x80909010, 0xccd0dc1c, 0x8a92981a, 0x83a3a023, 0x8ba3a82b, 0xc0d0d010,
0x81818001, 0x0f030c0f, 0x47434407, 0x0a12181a, 0xc3e3e023, 0xcce0ec2c, 0x8d818c0d, 0x8fb3bc3f,
0x86929416, 0x4b73783b, 0x4c505c1c, 0x82a2a022, 0x81a1a021, 0x43636023, 0x03232023, 0x4d414c0d,
0xc8c0c808, 0x8e929c1e, 0x8c909c1c, 0x0a32383a, 0x0c000c0c, 0x0e222c2e, 0x8ab2b83a, 0x4e626c2e,
0x8f939c1f, 0x4a52581a, 0xc2f2f032, 0x82929012, 0xc3f3f033, 0x49414809, 0x48707838, 0xccc0cc0c,
0x05111415, 0xcbf3f83b, 0x40707030, 0x45717435, 0x4f737c3f, 0x05313435, 0x00101010, 0x03030003,
0x44606424, 0x4d616c2d, 0xc6c2c406, 0x44707434, 0xc5d1d415, 0x84b0b434, 0xcae2e82a, 0x09010809,
0x46727436, 0x09111819, 0xcef2fc3e, 0x40404000, 0x02121012, 0xc0e0e020, 0x8db1bc3d, 0x05010405,
0xcaf2f83a, 0x01010001, 0xc0f0f030, 0x0a22282a, 0x4e525c1e, 0x89a1a829, 0x46525416, 0x43434003,
0x85818405, 0x04101414, 0x89818809, 0x8b93981b, 0x80b0b030, 0xc5e1e425, 0x48404808, 0x49717839,
0x87939417, 0xccf0fc3c, 0x0e121c1e, 0x82828002, 0x01212021, 0x8c808c0c, 0x0b13181b, 0x4f535c1f,
0x47737437, 0x44505414, 0x82b2b032, 0x0d111c1d, 0x05212425, 0x4f434c0f, 0x00000000, 0x46424406,
0xcde1ec2d, 0x48505818, 0x42525012, 0xcbe3e82b, 0x4e727c3e, 0xcad2d81a, 0xc9c1c809, 0xcdf1fc3d,
0x00303030, 0x85919415, 0x45616425, 0x0c303c3c, 0x86b2b436, 0xc4e0e424, 0x8bb3b83b, 0x4c707c3c,
0x0e020c0e, 0x40505010, 0x09313839, 0x06222426, 0x02323032, 0x84808404, 0x49616829, 0x83939013,
0x07333437, 0xc7e3e427, 0x04202424, 0x84a0a424, 0xcbc3c80b, 0x43535013, 0x0a02080a, 0x87838407,
0xc9d1d819, 0x4c404c0c, 0x83838003, 0x8f838c0f, 0xcec2cc0e, 0x0b33383b, 0x4a42480a, 0x87b3b437
}
};
#define SUBSTITUTION(v) (SBOX[0][(v) & 0xFF] ^ SBOX[1][((v)>>8) & 0xFF] ^ SBOX[2][((v)>>16) & 0xFF] ^ SBOX[3][((v)>>24) & 0xFF])
#define UPDATE_KEY_SCHEDULE_R(X1, X2, X3, X4, T, KS) do { \
(T[0]) = (X3); \
(X3) = (((X3)<<8) ^ ((X4)>>24)) & 0xffffffffUL; \
(X4) = (((X4)<<8) ^ ((T[0])>>24)) & 0xffffffffUL; \
(T[0]) = ((X1) + (X3) - (KS)) & 0xffffffffUL; \
(T[1]) = ((X2) + (KS) - (X4)) & 0xffffffffUL; \
} while (0)
#define UPDATE_KEY_SCHEDULE_L(X1, X2, X3, X4, T, KS) do { \
(T[0]) = (X1); \
(X1) = (((X1)>>8) ^ ((X2)<<24)) & 0xffffffffUL; \
(X2) = (((X2)>>8) ^ ((T[0])<<24)) & 0xffffffffUL; \
(T[0]) = ((X1) + (X3) - (KS)) & 0xffffffffUL; \
(T[1]) = ((X2) + (KS) - (X4)) & 0xffffffffUL; \
} while(0)
#define UPDATE_KEY_SWAP(T, K) do { \
(K)[0] = SUBSTITUTION((T[0])); \
(K)[1] = SUBSTITUTION((T[1])); \
} while(0)
#define SEED_DOUBLE_ROUND(X1, X2, X3, X4, R1, R2, R3, R4) do { \
(T0) = (X3) ^ (R1); \
(T1) = (X4) ^ (R2); \
(T1) ^= (T0); \
(T1) = SUBSTITUTION((T1)); \
(T0) += (T1); \
(T0) = SUBSTITUTION((T0)); \
(T1) += (T0); \
(T1) = SUBSTITUTION((T1)); \
(T0) += (T1); \
(X1) ^= (T0); \
(X2) ^= (T1); \
(T0) = (X1) ^ (R3); \
(T1) = (X2) ^ (R4); \
(T1) ^= (T0); \
(T1) = SUBSTITUTION((T1)); \
(T0) += (T1); \
(T0) = SUBSTITUTION((T0)); \
(T1) += (T0); \
(T1) = SUBSTITUTION((T1)); \
(T0) += (T1); \
(X3) ^= (T0); \
(X4) ^= (T1); \
} while (0)
# define SEED_DOUBLE_ROUND_ENC(X1, X2, X3, X4, r) SEED_DOUBLE_ROUND(X1, X2,X3, X4, (r)[0], (r)[1], (r)[2], (r)[3]);
# define SEED_DOUBLE_ROUND_DEC(X1, X2, X3, X4, r) SEED_DOUBLE_ROUND(X1, X2,X3, X4, (r)[2], (r)[3], (r)[0], (r)[1]);
void qse_kseed_initialize (qse_kseed_t* ks, const void* keyptr, qse_size_t keylen)
{
qse_uint32_t k1, k2, k3, k4, T[2];
const qse_uint8_t* u8kptr;
QSE_ASSERT (keylen >= QSE_KSEED_MIN_KEY_LEN && keylen <= QSE_KSEED_MAX_KEY_LEN);
u8kptr = (const qse_uint8_t*)keyptr;
k1 = QSE_FETCH32BE(&u8kptr[0]);
k2 = QSE_FETCH32BE(&u8kptr[4]);
k3 = QSE_FETCH32BE(&u8kptr[8]);
k4 = QSE_FETCH32BE(&u8kptr[12]);
T[0] = (k1 + k3 - 0x9E3779B9) & 0xffffffff;
T[1] = (k2 - k4 + 0x9E3779B9) & 0xffffffff;
UPDATE_KEY_SWAP(T, &ks->KD[0]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0x3c6ef373); UPDATE_KEY_SWAP(T, &ks->KD[2]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0x78dde6e6); UPDATE_KEY_SWAP(T, &ks->KD[4]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0xf1bbcdcc); UPDATE_KEY_SWAP(T, &ks->KD[6]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0xe3779b99); UPDATE_KEY_SWAP(T, &ks->KD[8]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0xc6ef3733); UPDATE_KEY_SWAP(T, &ks->KD[10]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0x8dde6e67); UPDATE_KEY_SWAP(T, &ks->KD[12]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0x1bbcdccf); UPDATE_KEY_SWAP(T, &ks->KD[14]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0x3779b99e); UPDATE_KEY_SWAP(T, &ks->KD[16]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0x6ef3733c); UPDATE_KEY_SWAP(T, &ks->KD[18]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0xdde6e678); UPDATE_KEY_SWAP(T, &ks->KD[20]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0xbbcdccf1); UPDATE_KEY_SWAP(T, &ks->KD[22]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0x779b99e3); UPDATE_KEY_SWAP(T, &ks->KD[24]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0xef3733c6); UPDATE_KEY_SWAP(T, &ks->KD[26]);
UPDATE_KEY_SCHEDULE_R(k1, k2, k3, k4, T, 0xde6e678d); UPDATE_KEY_SWAP(T, &ks->KD[28]);
UPDATE_KEY_SCHEDULE_L(k1, k2, k3, k4, T, 0xbcdccf1b); UPDATE_KEY_SWAP(T, &ks->KD[30]);
}
#define EndianChange(dwS) ((QSE_ROTL32((dwS), 8) & (qse_uint32_t)0x00ff00ff) | (QSE_ROTR32((dwS), 8) & (qse_uint32_t)0xff00ff00))
void qse_kseed_encrypt_block (qse_kseed_t* ks, qse_kseed_block_t* blk)
{
qse_uint32_t L0, L1, R0, R1, T0, T1;
qse_uint32_t* k;
k = ks->KD;
L0 = QSE_FETCH32BE(&(*blk)[0]);
L1 = QSE_FETCH32BE(&(*blk)[4]);
R0 = QSE_FETCH32BE(&(*blk)[8]);
R1 = QSE_FETCH32BE(&(*blk)[12]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[0]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[4]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[8]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[12]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[16]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[20]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[24]);
SEED_DOUBLE_ROUND_ENC (L0, L1, R0, R1, &k[28]);
QSE_STORE32BE(&(*blk)[0], R0);
QSE_STORE32BE(&(*blk)[4], R1);
QSE_STORE32BE(&(*blk)[8], L0);
QSE_STORE32BE(&(*blk)[12], L1);
}
void qse_kseed_decrypt_block (qse_kseed_t* ks, qse_kseed_block_t* blk)
{
qse_uint32_t L0, L1, R0, R1, T0, T1;
qse_uint32_t *k;
k = ks->KD;
L0 = QSE_FETCH32BE(&(*blk)[0]);
L1 = QSE_FETCH32BE(&(*blk)[4]);
R0 = QSE_FETCH32BE(&(*blk)[8]);
R1 = QSE_FETCH32BE(&(*blk)[12]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[28]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[24]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[20]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[16]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[12]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[8]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[4]);
SEED_DOUBLE_ROUND_DEC(L0, L1, R0, R1, &k[0]);
QSE_STORE32BE(&(*blk)[0], R0);
QSE_STORE32BE(&(*blk)[4], R1);
QSE_STORE32BE(&(*blk)[8], L0);
QSE_STORE32BE(&(*blk)[12], L1);
}
#if 0
void qse_kseed_encrypt (qse_kseed_t* bf, void *data, qse_size_t len)
{
qse_size_t i;
qse_uint8_t* ptr, * end;
/* length must be a multiple of 16 bytes */
QSE_ASSERT (len % QSE_KSEED_BLOCK_SIZE == 0);
ptr = (qse_uint8_t*)data;
end = data + len;
while (ptr < end)
{
qse_kseek_encrypt_block (bf, ptr);
ptr += QSE_KSEED_BLOCK_SIZE;
}
}
void qse_kseed_decrypt (qse_kseed_t* bf, void *data, qse_size_t len)
{
qse_size_t i;
qse_uint8_t* ptr, * end;
/* length must be a multiple of 16 bytes */
QSE_ASSERT (len % QSE_KSEED_BLOCK_SIZE == 0);
ptr = (qse_uint8_t*)data;
end = data + len;
while (ptr < end)
{
qse_kseed_decrypt_block (bf, (const qse_uint32_t*)ptr, (qse_uint32_t*)ptr);
ptr += QSE_KSEED_BLOCK_SIZE;
}
}
#endif

View File

@ -148,7 +148,7 @@ static int str2argv (qse_mchar_t *str, qse_mchar_t* argv[], int max_argc)
int nflds, i;
qse_mchar_t* ptr;
nflds = qse_mbsspl (str, QSE_T(""), QSE_MT('\0'), QSE_MT('\0'), QSE_MT('\0'));
nflds = qse_mbsspl (str, QSE_MT(""), QSE_MT('\0'), QSE_MT('\0'), QSE_MT('\0'));
if (nflds <= 0)
{
return -1;

View File

@ -534,7 +534,7 @@ void qse_rad_copy_authenticator (qse_rad_hdr_t* dst, const qse_rad_hdr_t* src)
QSE_MEMCPY (dst->authenticator, src->authenticator, QSE_SIZEOF(dst->authenticator));
}
int qse_rad_set_authenticator (qse_rad_hdr_t* req, const qse_char_t* secret)
int qse_rad_set_authenticator (qse_rad_hdr_t* req, const qse_mchar_t* secret)
{
qse_md5_t md5;

View File

@ -1 +1 @@
SUBDIRS = cmn si awk sed http
SUBDIRS = cmn cry si awk sed http

View File

@ -367,7 +367,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = cmn si awk sed http
SUBDIRS = cmn cry si awk sed http
all: all-recursive
.SUFFIXES:

View File

@ -0,0 +1,21 @@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(includedir)
bin_PROGRAMS = \
bf01
AM_LDFLAGS = -L../../lib/cry -L../../lib/si -L../../lib/cmn
LDADD = -lqsecry -lqsesi -lqsecmn
if WIN32
if WCHAR
LDADD += $(UNICOWS_LIBS)
endif
endif
bf01_SOURCES = bf01.c

706
qse/samples/cry/Makefile.in Normal file
View File

@ -0,0 +1,706 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = bf01$(EXEEXT)
@WCHAR_TRUE@@WIN32_TRUE@am__append_1 = $(UNICOWS_LIBS)
subdir = samples/cry
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltargz.m4 $(top_srcdir)/m4/ltdl.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/lx_find_mpi.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_bf01_OBJECTS = bf01.$(OBJEXT)
bf01_OBJECTS = $(am_bf01_OBJECTS)
bf01_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
@WCHAR_TRUE@@WIN32_TRUE@am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
bf01_DEPENDENCIES = $(am__DEPENDENCIES_2)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(bf01_SOURCES)
DIST_SOURCES = $(bf01_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_MODE = @BUILD_MODE@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CHAR_MODE = @CHAR_MODE@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAVE_CXX = @HAVE_CXX@
INCLTDL = @INCLTDL@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBADD_DL = @LIBADD_DL@
LIBADD_DLD_LINK = @LIBADD_DLD_LINK@
LIBADD_DLOPEN = @LIBADD_DLOPEN@
LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@
LIBLTDL = @LIBLTDL@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTDLDEPS = @LTDLDEPS@
LTDLINCL = @LTDLINCL@
LTDLOPEN = @LTDLOPEN@
LTLIBOBJS = @LTLIBOBJS@
LT_ARGZ_H = @LT_ARGZ_H@
LT_CONFIG_H = @LT_CONFIG_H@
LT_DLLOADERS = @LT_DLLOADERS@
LT_DLPREOPEN = @LT_DLPREOPEN@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MPICC = @MPICC@
MPI_CFLAGS = @MPI_CFLAGS@
MPI_CLDFLAGS = @MPI_CLDFLAGS@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
PATH_SEPARATOR = @PATH_SEPARATOR@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@
QSE_PROJECT_URL = @QSE_PROJECT_URL@
QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@
QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@
QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@
QSE_SIZEOF_INT = @QSE_SIZEOF_INT@
QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@
QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@
QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@
QSE_SIZEOF_OFF64_T = @QSE_SIZEOF_OFF64_T@
QSE_SIZEOF_OFF_T = @QSE_SIZEOF_OFF_T@
QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@
QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@
QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@
QUADMATH_LIBS = @QUADMATH_LIBS@
RANLIB = @RANLIB@
RM = @RM@
RMDIR = @RMDIR@
SED = @SED@
SENDFILE_LIBS = @SENDFILE_LIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
SSL_LIBS = @SSL_LIBS@
STRIP = @STRIP@
TRUE = @TRUE@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
ltdl_LIBOBJS = @ltdl_LIBOBJS@
ltdl_LTLIBOBJS = @ltdl_LTLIBOBJS@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
subdirs = @subdirs@
sys_symbol_underscore = @sys_symbol_underscore@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
AM_CPPFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(includedir)
AM_LDFLAGS = -L../../lib/cry -L../../lib/si -L../../lib/cmn
LDADD = -lqsecry -lqsesi -lqsecmn $(am__append_1)
bf01_SOURCES = bf01.c
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign samples/cry/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign samples/cry/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
bf01$(EXEEXT): $(bf01_OBJECTS) $(bf01_DEPENDENCIES) $(EXTRA_bf01_DEPENDENCIES)
@rm -f bf01$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(bf01_OBJECTS) $(bf01_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bf01.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

111
qse/samples/cry/bf01.c Normal file
View File

@ -0,0 +1,111 @@
#include <qse/si/sio.h>
#include <qse/cry/blowfish.h>
#include <qse/cry/kseed.h>
#include <string.h>
#define R(f) \
do { \
qse_printf (QSE_T("== %s ==\n"), QSE_T(#f)); \
if (f() == -1) return -1; \
} while (0)
static int test1 ()
{
static qse_uint8_t test_data[][QSE_BLOWFISH_BLOCK_SIZE] =
{
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07},
{ 0xFF,0xFF,0xFF,0xAA,0xBB,0xCC,0xDD,0xEE},
{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' }
};
qse_blowfish_t bf;
qse_size_t i;
qse_blowfish_initialize (&bf, "ABCD",4);
for (i = 0; i < QSE_COUNTOF(test_data); i++)
{
qse_uint8_t tmp[16];
memcpy (tmp, test_data[i], QSE_BLOWFISH_BLOCK_SIZE);
qse_blowfish_encrypt_block (&bf, tmp);
qse_printf (QSE_T("%05d ENC => "), i);
if (memcmp (tmp, test_data[i], QSE_BLOWFISH_BLOCK_SIZE) == 0)
{
qse_printf (QSE_T("FAILURE\n"));
}
else
{
qse_printf (QSE_T("OK\n"));
}
qse_blowfish_decrypt_block (&bf, tmp);
qse_printf (QSE_T("%05d DEC => "), i);
if (memcmp (tmp, test_data[i], QSE_BLOWFISH_BLOCK_SIZE) != 0)
{
qse_printf (QSE_T("FAILURE\n"));
}
else
{
qse_printf (QSE_T("OK\n"));
}
}
return 0;
}
static int test2 ()
{
static qse_uint8_t test_data[][QSE_KSEED_BLOCK_SIZE] =
{
{ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F },
{ 0xFF,0xFF,0xFF,0xAA,0xBB,0xCC,0xDD,0xEE,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 },
{ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P' }
};
qse_kseed_t bf;
qse_size_t i;
//qse_kseed_initialize (&bf, "\xFF\xFF\xFF\x00",4); // <<-----
qse_kseed_initialize (&bf, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",16); // <<-----
for (i = 0; i < QSE_COUNTOF(test_data); i++)
{
qse_uint8_t tmp[16];
memcpy (tmp, test_data[i], QSE_KSEED_BLOCK_SIZE);
qse_kseed_encrypt_block (&bf, tmp);
qse_printf (QSE_T("%05d ENC => "), i);
if (memcmp (tmp, test_data[i], QSE_KSEED_BLOCK_SIZE) == 0)
{
qse_printf (QSE_T("FAILURE\n"));
}
else
{
qse_printf (QSE_T("OK\n"));
}
qse_kseed_decrypt_block (&bf, tmp);
qse_printf (QSE_T("%05d DEC => "), i);
if (memcmp (tmp, test_data[i], QSE_KSEED_BLOCK_SIZE) != 0)
{
qse_printf (QSE_T("FAILURE\n"));
}
else
{
qse_printf (QSE_T("OK\n"));
}
}
return 0;
}
int main ()
{
qse_openstdsios ();
R (test1);
R (test2);
qse_closestdsios ();
return 0;
}