mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-02 01:48:16 +03:00
Compare commits
47 Commits
android-fi
...
windows
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edbe1baceb | ||
|
|
b296444d0c | ||
|
|
38ad2399ed | ||
|
|
f24e68c845 | ||
|
|
879adbfcc0 | ||
|
|
0b27896396 | ||
|
|
5e27785d40 | ||
|
|
94fb7d4c00 | ||
|
|
463e4eb584 | ||
|
|
61bd00c12b | ||
|
|
4a329b2e1d | ||
|
|
9d77bb17c5 | ||
|
|
1f3436945f | ||
|
|
1d8149a3b3 | ||
|
|
05ab85e853 | ||
|
|
ead7bfc155 | ||
|
|
d651c2b38d | ||
|
|
8703d8bbf4 | ||
|
|
24b2f5892c | ||
|
|
1aa234af4d | ||
|
|
e8dd3cece3 | ||
|
|
4508c9c863 | ||
|
|
76bfcf40ca | ||
|
|
d947e5e20e | ||
|
|
fb55975a75 | ||
|
|
d2f3cc44db | ||
|
|
1233e05fcb | ||
|
|
f7cdca7ad2 | ||
|
|
b1edca8c4c | ||
|
|
2d17c2b52f | ||
|
|
7a69af7b00 | ||
|
|
99e02e25c9 | ||
|
|
6e5ef80a0e | ||
|
|
18e088f8ff | ||
|
|
dc2be1dcb4 | ||
|
|
cb04a1e451 | ||
|
|
977bac3205 | ||
|
|
63e458ef84 | ||
|
|
81b976c384 | ||
|
|
0d2a493312 | ||
|
|
2f12021cce | ||
|
|
61302b61e7 | ||
|
|
2c6669f5e3 | ||
|
|
2a490d398c | ||
|
|
b62d2f4f1a | ||
|
|
7a91fbebd9 | ||
|
|
557c300975 |
22
.gitignore
vendored
22
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
*.mak
|
||||
*.mak.vpc_crc
|
||||
*.vpc_crc
|
||||
*.vpc.*
|
||||
*.project
|
||||
*obj_*
|
||||
build/
|
||||
@@ -8,3 +9,24 @@ build/
|
||||
.lock-waf*
|
||||
__pycache__
|
||||
*.pyc
|
||||
.vs/
|
||||
Debug/
|
||||
Debug_*/
|
||||
Release/
|
||||
Release_*/
|
||||
*.tlog/
|
||||
*.obj
|
||||
*.pch
|
||||
*.log
|
||||
*.idb
|
||||
*.pdb
|
||||
*.rc
|
||||
*.bin
|
||||
*.vcxproj*
|
||||
*.sln
|
||||
*.dll*
|
||||
*.exp
|
||||
*.ilk
|
||||
ValveETWProviderEvents.h
|
||||
game/client/*/client.lib
|
||||
game/server/*/server.lib
|
||||
25
README.md
25
README.md
@@ -1,20 +1,27 @@
|
||||
# source-engine
|
||||
The main purpose of this repository is to port the engine for other platforms.
|
||||
|
||||
# Goals
|
||||
* fixing bugs
|
||||
* NEON support
|
||||
* ~~NEON support~~
|
||||
* DXVK support
|
||||
* remove unnecessary dependencies
|
||||
* Elbrus port
|
||||
* Arm(android) port
|
||||
* ~~Arm(android) port~~
|
||||
* improve performance
|
||||
* replace current buildsystem with waf
|
||||
* ~~replace current buildsystem with waf~~
|
||||
* rewrite achivement system( to work without steam )
|
||||
# How to Build?
|
||||
1. Clone repo ( ```git clone https://github.com/nillerusr/source-engine```)
|
||||
2. Run ```git submodule init && git submodule update```
|
||||
* 64-bit support
|
||||
|
||||
# How to Build?
|
||||
Clone repo and change directory:
|
||||
```
|
||||
git clone https://github.com/nillerusr/source-engine --recursive --depth 1
|
||||
cd source-engine
|
||||
```
|
||||
On Linux:
|
||||
|
||||
dependencies:
|
||||
fontconfig, freetype2, OpenAL, SDL2, libbz2, libcurl, libjpeg, libpng, zlib
|
||||
```
|
||||
./waf configure -T debug
|
||||
./waf build
|
||||
@@ -25,5 +32,5 @@ export ANDROID_NDK=/path/to/ndk
|
||||
./waf configure -T debug --android=armeabi-v7a,4.9,21
|
||||
./waf build
|
||||
```
|
||||
On Windows:
|
||||
**TODO(WAF is not configured for Windows. Use VPC as temporary solution)**
|
||||
On Windows/MacOS:
|
||||
**TODO(WAF is not configured for Windows/MacOS. Use VPC as temporary solution)**
|
||||
|
||||
@@ -42,10 +42,11 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info )
|
||||
m_info.m_atiNewer = true;
|
||||
|
||||
m_info.m_hasGammaWrites = true;
|
||||
m_info.m_cantAttachSRGB = false;
|
||||
|
||||
// If you haven't created a GL context by now (and initialized gGL), you're about to crash.
|
||||
|
||||
m_info.m_hasMixedAttachmentSizes = gGL->m_bHave_GL_ARB_framebuffer_object;
|
||||
m_info.m_hasMixedAttachmentSizes = gGL->m_bHave_GL_EXT_framebuffer_object;
|
||||
m_info.m_hasBGRA = gGL->m_bHave_GL_EXT_vertex_array_bgra;
|
||||
|
||||
// !!! FIXME: what do these do on the Mac?
|
||||
@@ -64,8 +65,15 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info )
|
||||
m_info.m_hasNativeClipVertexMode = true;
|
||||
}
|
||||
|
||||
#ifdef TOGLES
|
||||
m_info.m_hasOcclusionQuery = true;
|
||||
m_info.m_hasFramebufferBlit = true;
|
||||
m_info.m_hasUniformBuffers = true;
|
||||
#else
|
||||
m_info.m_hasOcclusionQuery = gGL->m_bHave_GL_ARB_occlusion_query;
|
||||
m_info.m_hasFramebufferBlit = gGL->m_bHave_GL_EXT_framebuffer_blit || gGL->m_bHave_GL_ARB_framebuffer_object;
|
||||
m_info.m_hasUniformBuffers = gGL->m_bHave_GL_ARB_uniform_buffer;
|
||||
#endif
|
||||
|
||||
GLint nMaxAniso = 0;
|
||||
gGL->glGetIntegerv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &nMaxAniso );
|
||||
@@ -88,8 +96,7 @@ void GLMRendererInfo::Init( GLMRendererInfoFields *info )
|
||||
m_info.m_hasBindableUniforms = false;
|
||||
}
|
||||
}
|
||||
|
||||
m_info.m_hasUniformBuffers = gGL->m_bHave_GL_ARB_uniform_buffer;
|
||||
|
||||
m_info.m_hasPerfPackage1 = true; // this flag is Mac-specific. We do slower things if you don't have Mac OS X 10.x.y or later. Linux always does the fast path!
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "tier1/utllinkedlist.h"
|
||||
#include "tier1/convar.h"
|
||||
#include <EGL/egl.h>
|
||||
|
||||
// NOTE: This has to be the last file included! (turned off below, since this is included like a header)
|
||||
#include "tier0/memdbgon.h"
|
||||
@@ -56,9 +57,16 @@ COpenGLEntryPoints *gGL = NULL;
|
||||
|
||||
const int kBogusSwapInterval = INT_MAX;
|
||||
|
||||
#ifdef ANDROID
|
||||
static void *gl4es = NULL;
|
||||
void *(*_glGetProcAddress)( const char * );
|
||||
#if defined ANDROID || defined TOGLES
|
||||
static void *l_gl4es = NULL;
|
||||
static void *l_egl = NULL;
|
||||
static void *l_gles = NULL;
|
||||
|
||||
typedef void *(*t_glGetProcAddress)( const char * );
|
||||
t_glGetProcAddress _glGetProcAddress;
|
||||
|
||||
typedef EGLBoolean (*t_eglBindAPI)(EGLenum api);
|
||||
t_eglBindAPI _eglBindAPI;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -175,16 +183,26 @@ void CheckGLError( int line )
|
||||
void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, void *fallback)
|
||||
{
|
||||
void *retval = NULL;
|
||||
|
||||
#ifndef TOGLES // TODO(nillerusr): remove this hack
|
||||
if ((!okay) && (!bRequired)) // always look up if required (so we get a complete list of crucial missing symbols).
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
// The SDL path would work on all these platforms, if we were using SDL there, too...
|
||||
|
||||
|
||||
#ifdef ANDROID
|
||||
#if defined ANDROID || defined TOGLES
|
||||
// SDL does the right thing, so we never need to use tier0 in this case.
|
||||
if( _glGetProcAddress )
|
||||
{
|
||||
retval = _glGetProcAddress(fn);
|
||||
|
||||
Msg("_glGetProcAddress(%s) = %x\n", fn, retval);
|
||||
|
||||
if( !retval && l_gles )
|
||||
retval = dlsym( l_gles, fn );
|
||||
}
|
||||
//printf("CDynamicFunctionOpenGL: SDL_GL_GetProcAddress(\"%s\") returned %p\n", fn, retval);
|
||||
if ((retval == NULL) && (fallback != NULL))
|
||||
{
|
||||
@@ -207,7 +225,12 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
|
||||
// Note that a non-NULL response doesn't mean it's safe to call the function!
|
||||
// You always have to check that the extension is supported;
|
||||
// an implementation MAY return NULL in this case, but it doesn't have to (and doesn't, with the DRI drivers).
|
||||
|
||||
#ifdef TOGLES // TODO(nillerusr): remove this hack
|
||||
okay = retval != NULL;
|
||||
#else
|
||||
okay = (okay && (retval != NULL));
|
||||
#endif
|
||||
if (bRequired && !okay)
|
||||
{
|
||||
// We can't continue execution, because one or more GL function pointers will be NULL.
|
||||
@@ -238,7 +261,7 @@ public:
|
||||
|
||||
virtual void IncWindowRefCount();
|
||||
virtual void DecWindowRefCount();
|
||||
|
||||
|
||||
// Get the next N events. The function returns the number of events that were filled into your array.
|
||||
virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false );
|
||||
#ifdef LINUX
|
||||
@@ -374,7 +397,7 @@ private:
|
||||
Uint32 m_MouseButtonDownTimeStamp;
|
||||
int m_MouseButtonDownX;
|
||||
int m_MouseButtonDownY;
|
||||
|
||||
|
||||
double m_flPrevGLSwapWindowTime;
|
||||
};
|
||||
|
||||
@@ -492,7 +515,11 @@ InitReturnVal_t CSDLMgr::Init()
|
||||
SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
|
||||
}
|
||||
|
||||
#if defined( TOGLES )
|
||||
if (SDL_GL_LoadLibrary("libGLESv3.so") == -1)
|
||||
#else
|
||||
if (SDL_GL_LoadLibrary(NULL) == -1)
|
||||
#endif
|
||||
Error( "SDL_GL_LoadLibrary(NULL) failed: %s", SDL_GetError() );
|
||||
#endif
|
||||
}
|
||||
@@ -544,23 +571,62 @@ InitReturnVal_t CSDLMgr::Init()
|
||||
m_MouseButtonDownTimeStamp = 0;
|
||||
m_MouseButtonDownX = 0;
|
||||
m_MouseButtonDownY = 0;
|
||||
|
||||
|
||||
m_bExpectSyntheticMouseMotion = false;
|
||||
m_nMouseTargetX = 0;
|
||||
m_nMouseTargetY = 0;
|
||||
m_nWarpDelta = 0;
|
||||
m_bRawInput = false;
|
||||
|
||||
|
||||
m_flPrevGLSwapWindowTime = 0.0f;
|
||||
|
||||
|
||||
memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs));
|
||||
|
||||
int *attCursor = m_pixelFormatAttribs;
|
||||
|
||||
#define SET_GL_ATTR(key,value) \
|
||||
*(attCursor++) = (int) (key); \
|
||||
*(attCursor++) = (int) (value);
|
||||
#define SET_GL_ATTR(key,value) \
|
||||
*(attCursor++) = (int) (key); \
|
||||
*(attCursor++) = (int) (value);
|
||||
|
||||
|
||||
#ifdef TOGLES
|
||||
l_egl = dlopen("libEGL.so", RTLD_LAZY);
|
||||
l_gles = dlopen("libGLESv3.so", RTLD_LAZY);
|
||||
|
||||
if( l_egl )
|
||||
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_egl, "eglGetProcAddress");
|
||||
|
||||
SET_GL_ATTR(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
SET_GL_ATTR(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SET_GL_ATTR(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
#elif ANDROID
|
||||
bool m_bOGL = false;
|
||||
|
||||
l_egl = dlopen("libEGL.so", RTLD_LAZY);
|
||||
|
||||
if( l_egl )
|
||||
{
|
||||
_eglBindAPI = (t_eglBindAPI)dlsym(l_egl, "eglBindAPI");
|
||||
|
||||
if( _eglBindAPI && _eglBindAPI(EGL_OPENGL_API) )
|
||||
{
|
||||
Msg("OpenGL support found!\n");
|
||||
m_bOGL = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( m_bOGL )
|
||||
{
|
||||
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_egl, "eglGetProcAddress");
|
||||
SET_GL_ATTR(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
}
|
||||
else
|
||||
{
|
||||
l_gl4es = dlopen("libgl4es.so", RTLD_LAZY);
|
||||
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_gl4es, "gl4es_glGetProcAddress");
|
||||
}
|
||||
#endif
|
||||
SET_GL_ATTR(SDL_GL_RED_SIZE, 8);
|
||||
SET_GL_ATTR(SDL_GL_GREEN_SIZE, 8);
|
||||
SET_GL_ATTR(SDL_GL_BLUE_SIZE, 8);
|
||||
@@ -584,11 +650,11 @@ InitReturnVal_t CSDLMgr::Init()
|
||||
// GL entry points, but the game hasn't made a window yet. So it's time
|
||||
// to make a window! We make a 640x480 one here, and later, when asked
|
||||
// to really actually make a window, we just resize the one we built here.
|
||||
if ( !CreateHiddenGameWindow( "", 640, 480 ) )
|
||||
if ( !CreateHiddenGameWindow( "", 1280, 720 ) )
|
||||
Error( "CreateGameWindow failed" );
|
||||
|
||||
|
||||
SDL_HideWindow( m_Window );
|
||||
|
||||
|
||||
return INIT_OK;
|
||||
}
|
||||
|
||||
@@ -618,7 +684,11 @@ void CSDLMgr::Shutdown()
|
||||
SDLAPP_FUNC;
|
||||
|
||||
if (gGL && m_readFBO)
|
||||
#ifdef TOGLES
|
||||
gGL->glDeleteFramebuffers(1, &m_readFBO);
|
||||
#else
|
||||
gGL->glDeleteFramebuffersEXT(1, &m_readFBO);
|
||||
#endif
|
||||
m_readFBO = 0;
|
||||
|
||||
if ( m_Window )
|
||||
@@ -724,7 +794,7 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
||||
#if defined( DX_TO_GL_ABSTRACTION )
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
#endif
|
||||
m_Window = SDL_CreateWindow( pTitle, x, y, width, height, flags );
|
||||
m_Window = SDL_CreateWindow( pTitle, x, y, width, height, flags );
|
||||
|
||||
if (m_Window == NULL)
|
||||
Error( "Failed to create SDL window: %s", SDL_GetError() );
|
||||
@@ -759,14 +829,12 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
||||
|
||||
SDL_GL_MakeCurrent(m_Window, m_GLContext);
|
||||
|
||||
#ifdef ANDROID
|
||||
gl4es = dlopen("libgl4es.so", RTLD_LAZY);
|
||||
|
||||
if( gl4es )
|
||||
#if defined ANDROID && !defined TOGLES
|
||||
if( l_gl4es )
|
||||
{
|
||||
_glGetProcAddress = dlsym(gl4es, "gl4es_GetProcAddress" );
|
||||
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_gl4es, "gl4es_GetProcAddress" );
|
||||
void (*initialize_gl4es)( );
|
||||
initialize_gl4es = dlsym(gl4es, "initialize_gl4es" );
|
||||
initialize_gl4es = (void(*)())dlsym(l_gl4es, "initialize_gl4es" );
|
||||
initialize_gl4es();
|
||||
}
|
||||
#endif
|
||||
@@ -786,7 +854,9 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
||||
// If we specified -gl_debug, make sure the extension string is present now.
|
||||
if ( CommandLine()->FindParm( "-gl_debug" ) )
|
||||
{
|
||||
#ifndef TOGLES
|
||||
Assert( V_strstr(pszString, "GL_ARB_debug_output") );
|
||||
#endif
|
||||
}
|
||||
#endif // DBGFLAG_ASSERT
|
||||
|
||||
@@ -811,7 +881,11 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
|
||||
DebugPrintf("\n");
|
||||
}
|
||||
|
||||
#ifdef TOGLES
|
||||
gGL->glGenFramebuffers(1, &m_readFBO);
|
||||
#else
|
||||
gGL->glGenFramebuffersEXT(1, &m_readFBO);
|
||||
#endif
|
||||
|
||||
gGL->glViewport(0, 0, width, height); /* Reset The Current Viewport And Perspective Transformation */
|
||||
gGL->glScissor(0, 0, width, height); /* Reset The Current Viewport And Perspective Transformation */
|
||||
@@ -988,10 +1062,10 @@ void CSDLMgr::PostEvent( const CCocoaEvent &theEvent, bool debugEvent )
|
||||
SDLAPP_FUNC;
|
||||
|
||||
m_CocoaEventsMutex.Lock();
|
||||
|
||||
|
||||
CUtlLinkedList<CCocoaEvent,int> &queue = debugEvent ? m_CocoaEvents : m_DebugEvents;
|
||||
queue.AddToTail( theEvent );
|
||||
|
||||
|
||||
m_CocoaEventsMutex.Unlock();
|
||||
}
|
||||
|
||||
@@ -1158,6 +1232,17 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
|
||||
// bind a quickie FBO to enclose the source texture
|
||||
GLint myreadfb = 1000;
|
||||
|
||||
#ifdef TOGLES
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, myreadfb);
|
||||
CheckGLError( __LINE__ );
|
||||
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0); // to the default FB/backbuffer
|
||||
CheckGLError( __LINE__ );
|
||||
|
||||
// attach source tex to source FB
|
||||
glFramebufferTexture2D( GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, params->m_srcTexName, 0);
|
||||
CheckGLError( __LINE__ );
|
||||
#else
|
||||
glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, myreadfb);
|
||||
CheckGLError( __LINE__ );
|
||||
|
||||
@@ -1167,6 +1252,7 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
|
||||
// attach source tex to source FB
|
||||
glFramebufferTexture2DEXT( GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, params->m_srcTexName, 0);
|
||||
CheckGLError( __LINE__ );
|
||||
#endif
|
||||
|
||||
// blit
|
||||
|
||||
@@ -1201,6 +1287,23 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
|
||||
// go NEAREST if sizes match
|
||||
GLenum filter = ( ((srcxmax-srcxmin)==(dstxmax-dstxmin)) && ((srcymax-srcymin)==(dstymax-dstymin)) ) ? GL_NEAREST : GL_LINEAR;
|
||||
|
||||
#ifdef TOGLES
|
||||
glBlitFramebuffer(
|
||||
/* src min and maxes xy xy */ srcxmin, srcymin, srcxmax,srcymax,
|
||||
/* dst min and maxes xy xy */ dstxmin, dstymax, dstxmax,dstymin, // note yflip here
|
||||
GL_COLOR_BUFFER_BIT, filter );
|
||||
CheckGLError( __LINE__ );
|
||||
|
||||
// detach source tex
|
||||
glFramebufferTexture2D( GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||
CheckGLError( __LINE__ );
|
||||
|
||||
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0);
|
||||
CheckGLError( __LINE__ );
|
||||
|
||||
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0); // to the default FB/backbuffer
|
||||
CheckGLError( __LINE__ );
|
||||
#else
|
||||
glBlitFramebufferEXT(
|
||||
/* src min and maxes xy xy */ srcxmin, srcymin, srcxmax,srcymax,
|
||||
/* dst min and maxes xy xy */ dstxmin, dstymax, dstxmax,dstymin, // note yflip here
|
||||
@@ -1216,6 +1319,7 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
|
||||
|
||||
glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, 0); // to the default FB/backbuffer
|
||||
CheckGLError( __LINE__ );
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1309,6 +1413,7 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
|
||||
|
||||
m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF();
|
||||
|
||||
|
||||
CheckGLError( __LINE__ );
|
||||
}
|
||||
#endif // DX_TO_GL_ABSTRACTION
|
||||
@@ -1836,7 +1941,6 @@ void CSDLMgr::PumpWindowsMessageLoop()
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_QUIT:
|
||||
{
|
||||
CCocoaEvent theEvent;
|
||||
@@ -1844,7 +1948,6 @@ void CSDLMgr::PumpWindowsMessageLoop()
|
||||
PostEvent( theEvent );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1880,7 +1983,11 @@ void CSDLMgr::DecWindowRefCount()
|
||||
|
||||
if ( gGL && m_readFBO )
|
||||
{
|
||||
#ifdef TOGLES
|
||||
gGL->glDeleteFramebuffers( 1, &m_readFBO );
|
||||
#else
|
||||
gGL->glDeleteFramebuffersEXT( 1, &m_readFBO );
|
||||
#endif
|
||||
}
|
||||
m_readFBO = 0;
|
||||
|
||||
|
||||
@@ -18,13 +18,24 @@ def build(bld):
|
||||
source = [
|
||||
'AppSystemGroup.cpp',
|
||||
'../public/filesystem_init.cpp',
|
||||
# 'vguimatsysapp.cpp' [$WIN32]
|
||||
# 'winapp.cpp' [$WIN32]
|
||||
'posixapp.cpp',# [$POSIX]
|
||||
'sdlmgr.cpp'# [$SDL]
|
||||
# 'glmrendererinfo_osx.mm' [$OSXALL]
|
||||
]
|
||||
|
||||
if bld.env.SDL:
|
||||
source += [
|
||||
'sdlmgr.cpp'
|
||||
]
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
source += [
|
||||
'vguimatsysapp.cpp',
|
||||
'winapp.cpp'
|
||||
]
|
||||
else:
|
||||
source += [
|
||||
'posixapp.cpp',# [$POSIX]
|
||||
]
|
||||
|
||||
includes = [
|
||||
'.',
|
||||
'../public',
|
||||
|
||||
@@ -15,6 +15,8 @@ $Configuration
|
||||
$AdditionalIncludeDirectories "$BASE;$SRCDIR\dx9sdk\include" [$WINDOWS]
|
||||
$AdditionalIncludeDirectories "$BASE;$SRCDIR\x360xdk\include\win32\vs2005" [$WINDOWS]
|
||||
$AdditionalIncludeDirectories "$BASE;$SRCDIR\thirdparty\stb"
|
||||
|
||||
$PreprocessorDefinitions "$BASE;NO_X360_XDK;" [!$X360]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ def build(bld):
|
||||
'float_bm.cpp',
|
||||
'float_bm2.cpp',
|
||||
'float_bm3.cpp',
|
||||
#'float_bm4.cpp', [$WINDOWS]
|
||||
'float_bm_bilateral_filter.cpp',
|
||||
'float_cube.cpp',
|
||||
'imageformat.cpp',
|
||||
@@ -31,6 +30,11 @@ def build(bld):
|
||||
'tgawriter.cpp',
|
||||
'bitmap.cpp'
|
||||
]
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
source += [
|
||||
'float_bm4.cpp'
|
||||
]
|
||||
|
||||
includes = [
|
||||
'.',
|
||||
@@ -43,6 +47,9 @@ def build(bld):
|
||||
defines = []
|
||||
|
||||
libs = []
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
libs += ['NVTC', 'ATI_COMPRESS_MT_VC10']
|
||||
|
||||
bld.stlib(
|
||||
source = source,
|
||||
|
||||
@@ -53,20 +53,20 @@ CCvarSlider::CCvarSlider( Panel *parent, const char *panelName, char const *capt
|
||||
void CCvarSlider::SetupSlider( float minValue, float maxValue, const char *cvarname, bool bAllowOutOfRange )
|
||||
{
|
||||
// make sure min/max don't go outside cvar range if there's one
|
||||
ConVarRef var( cvarname, true );
|
||||
if ( var.IsValid() )
|
||||
{
|
||||
float flCVarMin;
|
||||
if ( var.GetMin( flCVarMin ) )
|
||||
{
|
||||
minValue = m_bUseConVarMinMax ? flCVarMin : MAX( minValue, flCVarMin );
|
||||
}
|
||||
float flCVarMax;
|
||||
if ( var.GetMax( flCVarMax ) )
|
||||
{
|
||||
maxValue = m_bUseConVarMinMax ? flCVarMax : MIN( maxValue, flCVarMax );
|
||||
}
|
||||
}
|
||||
//ConVarRef var( cvarname, true );
|
||||
//if ( var.IsValid() )
|
||||
//{
|
||||
// float flCVarMin;
|
||||
// if ( var.GetMin( flCVarMin ) )
|
||||
// {
|
||||
// minValue = m_bUseConVarMinMax ? flCVarMin : MAX( minValue, flCVarMin );
|
||||
// }
|
||||
// float flCVarMax;
|
||||
// if ( var.GetMax( flCVarMax ) )
|
||||
// {
|
||||
// maxValue = m_bUseConVarMinMax ? flCVarMax : MIN( maxValue, flCVarMax );
|
||||
// }
|
||||
//}
|
||||
|
||||
m_flMinValue = minValue;
|
||||
m_flMaxValue = maxValue;
|
||||
|
||||
87
common/iconv.h
Normal file
87
common/iconv.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "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
|
||||
* COPYRIGHT OWNER 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file iconv.h
|
||||
* @brief Character encoding conversion.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* If we just use void* in the typedef, the compiler exposes that in error messages. */
|
||||
struct __iconv_t;
|
||||
|
||||
/**
|
||||
* The `iconv_t` type that represents an instance of a converter.
|
||||
*/
|
||||
typedef struct __iconv_t* iconv_t;
|
||||
|
||||
/**
|
||||
* [iconv_open(3)](http://man7.org/linux/man-pages/man3/iconv_open.3.html) allocates a new converter
|
||||
* from `__src_encoding` to `__dst_encoding`.
|
||||
*
|
||||
* Returns a new `iconv_t` on success and returns `((iconv_t) -1)` and sets `errno` on failure.
|
||||
*
|
||||
* Available since API level 28.
|
||||
*/
|
||||
|
||||
#if __ANDROID_API__ >= 28
|
||||
iconv_t iconv_open(const char* __src_encoding, const char* __dst_encoding) __INTRODUCED_IN(28);
|
||||
|
||||
/**
|
||||
* [iconv(3)](http://man7.org/linux/man-pages/man3/iconv.3.html) converts characters from one
|
||||
* encoding to another.
|
||||
*
|
||||
* Android supports the `utf8`, `ascii`, `usascii`, `utf16be`, `utf16le`, `utf32be`, `utf32le`,
|
||||
* and `wchart` encodings. Android also supports the GNU `//IGNORE` and `//TRANSLIT` extensions.
|
||||
*
|
||||
* Returns the number of characters converted on success and returns `((size_t) -1)` and
|
||||
* sets `errno` on failure.
|
||||
*
|
||||
* Available since API level 28.
|
||||
*/
|
||||
size_t iconv(iconv_t __converter, char** __src_buf, size_t* __src_bytes_left, char** __dst_buf, size_t* __dst_bytes_left) __INTRODUCED_IN(28);
|
||||
|
||||
/**
|
||||
* [iconv_close(3)](http://man7.org/linux/man-pages/man3/iconv_close.3.html) deallocates a converter
|
||||
* returned by iconv_open().
|
||||
*
|
||||
* Returns 0 on success and returns -1 and sets `errno` on failure.
|
||||
*
|
||||
* Available since API level 28.
|
||||
*/
|
||||
int iconv_close(iconv_t __converter) __INTRODUCED_IN(28);
|
||||
#endif /* __ANDROID_API__ >= 28 */
|
||||
|
||||
|
||||
__END_DECLS
|
||||
1
creategameprojects.bat
Normal file
1
creategameprojects.bat
Normal file
@@ -0,0 +1 @@
|
||||
devtools\bin\vpc.exe /2019 +game /hl2 /mksln game.sln
|
||||
@@ -5,7 +5,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$macro SRCDIR ".."
|
||||
$Macro OUTBINDIR "$LIBPUBLIC"
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR ".."
|
||||
$Macro OUTBINDIR "$LIBPUBLIC"
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
$include "$SRCDIR\vpc_scripts\source_cryptlib_include.vpc"
|
||||
@@ -142,6 +142,7 @@ $Project "Dedicated"
|
||||
$Lib tier2
|
||||
$Lib tier3
|
||||
$Lib vgui_controls [$WIN32]
|
||||
$Lib vpklib
|
||||
$LibExternal "$SRCDIR/thirdparty/libedit-3.1/src/.libs/libedit" [$LINUXALL]
|
||||
$ImpLibExternal steam_api
|
||||
$ImpLib SDL2 [$SDL]
|
||||
|
||||
@@ -24,11 +24,8 @@ def build(bld):
|
||||
'../common/SteamAppStartup.cpp',
|
||||
'sys_common.cpp',
|
||||
'sys_ded.cpp',
|
||||
#'sys_windows.cpp', [$WINDOWS]
|
||||
'sys_linux.cpp', # [$POSIX]
|
||||
'console/conproc.cpp',
|
||||
'console/textconsole.cpp',
|
||||
'console/TextConsoleUnix.cpp', # [$POSIX]
|
||||
'../filesystem/filetracker.cpp',
|
||||
'../filesystem/basefilesystem.cpp',
|
||||
'../filesystem/packfile.cpp',
|
||||
@@ -36,9 +33,19 @@ def build(bld):
|
||||
'../filesystem/filesystem_stdio.cpp',
|
||||
'../filesystem/QueuedLoader.cpp',
|
||||
'../public/zip_utils.cpp',
|
||||
'../filesystem/linux_support.cpp' # [$POSIX]
|
||||
]
|
||||
|
||||
if bld.env.DEST_OS == 'win32'
|
||||
source += [
|
||||
'sys_windows.cpp'
|
||||
]
|
||||
else:
|
||||
source += [
|
||||
'sys_linux.cpp', # [$POSIX]
|
||||
'console/TextConsoleUnix.cpp', # [$POSIX]
|
||||
'../filesystem/linux_support.cpp' # [$POSIX]
|
||||
]
|
||||
|
||||
includes = [
|
||||
'.',
|
||||
'../public',
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,7 +11,7 @@
|
||||
// Fix for VS 2010 build errors copied from Dota
|
||||
#if !defined( NEW_DXSDK ) && ( _MSC_VER >= 1600 )
|
||||
#undef KSDATAFORMAT_SUBTYPE_WAVEFORMATEX
|
||||
#undef KSDATAFORMAT_SUBTYPE_PCM
|
||||
//#undef KSDATAFORMAT_SUBTYPE_PCM
|
||||
#undef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
|
||||
#endif
|
||||
#include <ksmedia.h>
|
||||
@@ -46,6 +46,8 @@ typedef enum {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;
|
||||
// hack - need to include latest dsound.h
|
||||
#undef DSSPEAKER_5POINT1
|
||||
#undef DSSPEAKER_7POINT1
|
||||
#undef DSSPEAKER_7POINT1_SURROUND
|
||||
#undef DSSPEAKER_5POINT1_SURROUND
|
||||
#define DSSPEAKER_5POINT1 6
|
||||
#define DSSPEAKER_7POINT1 7
|
||||
#define DSSPEAKER_7POINT1_SURROUND 8
|
||||
|
||||
@@ -539,64 +539,62 @@ struct leafnums_t
|
||||
CCollisionBSPData *pBSPData;
|
||||
};
|
||||
|
||||
|
||||
|
||||
int CM_BoxLeafnums( leafnums_t &context, const Vector ¢er, const Vector &extents, int nodenum )
|
||||
{
|
||||
int leafCount = 0;
|
||||
const int NODELIST_MAX = 1024;
|
||||
int nodeList[NODELIST_MAX];
|
||||
int nodeReadIndex = 0;
|
||||
int nodeWriteIndex = 0;
|
||||
cplane_t *plane;
|
||||
cnode_t *node;
|
||||
int prev_topnode = -1;
|
||||
int leafCount = 0;
|
||||
const int NODELIST_MAX = 1024;
|
||||
int nodeList[NODELIST_MAX];
|
||||
int nodeReadIndex = 0;
|
||||
int nodeWriteIndex = 0;
|
||||
cplane_t *plane;
|
||||
cnode_t *node;
|
||||
int prev_topnode = -1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (nodenum < 0)
|
||||
{
|
||||
// This handles the case when the box lies completely
|
||||
// within a single node. In that case, the top node should be
|
||||
// the parent of the leaf
|
||||
if (context.leafTopNode == -1)
|
||||
context.leafTopNode = prev_topnode;
|
||||
while (1)
|
||||
{
|
||||
if (nodenum < 0)
|
||||
{
|
||||
// This handles the case when the box lies completely
|
||||
// within a single node. In that case, the top node should be
|
||||
// the parent of the leaf
|
||||
if (context.leafTopNode == -1)
|
||||
context.leafTopNode = prev_topnode;
|
||||
|
||||
if (leafCount < context.leafMaxCount)
|
||||
{
|
||||
context.pLeafList[leafCount] = -1 - nodenum;
|
||||
leafCount++;
|
||||
}
|
||||
if ( nodeReadIndex == nodeWriteIndex )
|
||||
return leafCount;
|
||||
nodenum = nodeList[nodeReadIndex];
|
||||
nodeReadIndex = (nodeReadIndex+1) & (NODELIST_MAX-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = &context.pBSPData->map_rootnode[nodenum];
|
||||
plane = node->plane;
|
||||
// s = BoxOnPlaneSide (leaf_mins, leaf_maxs, plane);
|
||||
// s = BOX_ON_PLANE_SIDE(*leaf_mins, *leaf_maxs, plane);
|
||||
float d0 = DotProduct( plane->normal, center ) - plane->dist;
|
||||
float d1 = DotProductAbs( plane->normal, extents );
|
||||
prev_topnode = nodenum;
|
||||
if (d0 >= d1)
|
||||
nodenum = node->children[0];
|
||||
else if (d0 < -d1)
|
||||
nodenum = node->children[1];
|
||||
else
|
||||
{ // go down both
|
||||
if (context.leafTopNode == -1)
|
||||
context.leafTopNode = nodenum;
|
||||
nodeList[nodeWriteIndex] = node->children[0];
|
||||
nodeWriteIndex = (nodeWriteIndex+1) & (NODELIST_MAX-1);
|
||||
// check for overflow of the ring buffer
|
||||
Assert(nodeWriteIndex != nodeReadIndex);
|
||||
nodenum = node->children[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (leafCount < context.leafMaxCount)
|
||||
{
|
||||
context.pLeafList[leafCount] = -1 - nodenum;
|
||||
leafCount++;
|
||||
}
|
||||
if ( nodeReadIndex == nodeWriteIndex )
|
||||
return leafCount;
|
||||
nodenum = nodeList[nodeReadIndex];
|
||||
nodeReadIndex = (nodeReadIndex+1) & (NODELIST_MAX-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = &context.pBSPData->map_rootnode[nodenum];
|
||||
plane = node->plane;
|
||||
// s = BoxOnPlaneSide (leaf_mins, leaf_maxs, plane);
|
||||
// s = BOX_ON_PLANE_SIDE(*leaf_mins, *leaf_maxs, plane);
|
||||
float d0 = DotProduct( plane->normal, center ) - plane->dist;
|
||||
float d1 = DotProductAbs( plane->normal, extents );
|
||||
prev_topnode = nodenum;
|
||||
if (d0 >= d1)
|
||||
nodenum = node->children[0];
|
||||
else if (d0 < -d1)
|
||||
nodenum = node->children[1];
|
||||
else
|
||||
{ // go down both
|
||||
if (context.leafTopNode == -1)
|
||||
context.leafTopNode = nodenum;
|
||||
nodeList[nodeWriteIndex] = node->children[0];
|
||||
nodeWriteIndex = (nodeWriteIndex+1) & (NODELIST_MAX-1);
|
||||
// check for overflow of the ring buffer
|
||||
Assert(nodeWriteIndex != nodeReadIndex);
|
||||
nodenum = node->children[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CM_BoxLeafnums ( const Vector& mins, const Vector& maxs, int *list, int listsize, int *topnode)
|
||||
@@ -2666,38 +2664,32 @@ bool CM_HeadnodeVisible (int nodenum, const byte *visbits, int vissize )
|
||||
// *visbits - pvs or pas of some cluster
|
||||
// Output : true if visible, false if not
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MAX_BOX_LEAVES 256
|
||||
int CM_BoxVisible( const Vector& mins, const Vector& maxs, const byte *visbits, int vissize )
|
||||
#define MAX_BOX_LEAVES 256
|
||||
int CM_BoxVisible( const Vector& mins, const Vector& maxs, const byte *visbits, int vissize )
|
||||
{
|
||||
int leafList[MAX_BOX_LEAVES];
|
||||
int topnode;
|
||||
int leafList[MAX_BOX_LEAVES];
|
||||
int topnode;
|
||||
|
||||
// FIXME: Could save a loop here by traversing the tree in this routine like the code above
|
||||
int count = CM_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAVES, &topnode );
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
int cluster = CM_LeafCluster( leafList[i] );
|
||||
int offset = cluster>>3;
|
||||
// FIXME: Could save a loop here by traversing the tree in this routine like the code above
|
||||
int count = CM_BoxLeafnums( mins, maxs, leafList, MAX_BOX_LEAVES, &topnode );
|
||||
for ( int i = 0; i < count; i++ )
|
||||
{
|
||||
int cluster = CM_LeafCluster( leafList[i] );
|
||||
int offset = cluster>>3;
|
||||
|
||||
if ( offset == -1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ( offset > vissize )
|
||||
{
|
||||
Sys_Error( "CM_BoxVisible: cluster %i, offset %i out of bounds %i\n", cluster, offset, vissize );
|
||||
}
|
||||
|
||||
if ( offset > vissize || offset < 0 )
|
||||
{
|
||||
Sys_Error( "CM_BoxVisible: cluster %i, offset %i out of bounds %i\n", cluster, offset, vissize );
|
||||
}
|
||||
|
||||
if (visbits[cluster>>3] & (1<<(cluster&7)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (visbits[cluster>>3] & (1<<(cluster&7)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns the world-space center of an entity
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$macro SRCDIR ".."
|
||||
$Macro OUTBINDIR "$LIBPUBLIC"
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
$include "$SRCDIR\vpc_scripts\source_replay.vpc"
|
||||
@@ -1120,7 +1120,7 @@ $Project "engine"
|
||||
// http://code.google.com/p/gperftools/wiki/GooglePerformanceTools
|
||||
$File "$SRCDIR/thirdparty/gperftools-2.0/.libs/libprofiler.so" [$GPROFILER]
|
||||
|
||||
$Lib "$LIBCOMMON/binkw32" [$WIN32&&!$QUICKTIME_WIN32]
|
||||
//$Lib "$LIBCOMMON/binkw32" [$WIN32&&!$QUICKTIME_WIN32]
|
||||
$File "$LIBCOMMON\quicktime\QTMLClient" [$WIN32&&$QUICKTIME_WIN32]
|
||||
$ImpLib "SDL2" [$SDL]
|
||||
$File "$SRCDIR\DX9SDK\lib\dsound.lib" [$WIN32]
|
||||
|
||||
@@ -966,23 +966,20 @@ void SaveSurfAtCrossHair()
|
||||
}
|
||||
|
||||
|
||||
void DebugDrawLightmapAtCrossHair()
|
||||
void DebugDrawLightmapAtCrossHair() // Lol
|
||||
{
|
||||
return;
|
||||
#if 0
|
||||
IMaterial *pMaterial;
|
||||
int lightmapPageSize[2];
|
||||
|
||||
if( s_CrossHairSurfID <= 0 )
|
||||
{
|
||||
if( !s_CrossHairSurfID )
|
||||
return;
|
||||
}
|
||||
materials->GetLightmapPageSize( materialSortInfoArray[MSurf_MaterialSortID( s_CrossHairSurfID )].lightmapPageID,
|
||||
&lightmapPageSize[0], &lightmapPageSize[1] );
|
||||
pMaterial = MSurf_TexInfo( s_CrossHairSurfID )->material;
|
||||
// pMaterial->GetLowResColorSample( textureS, textureT, baseColor );
|
||||
DrawLightmapPage( materialSortInfoArray[MSurf_MaterialSortID( s_CrossHairSurfID )].lightmapPageID );
|
||||
|
||||
#if 0
|
||||
int i;
|
||||
for( i = 0; i < 2; i++ )
|
||||
{
|
||||
|
||||
@@ -3903,7 +3903,7 @@ void Host_PostInit()
|
||||
EngineVGui()->PostInit();
|
||||
}
|
||||
|
||||
#if defined( LINUX )
|
||||
#if defined( LINUX ) && !defined ANDROID
|
||||
const char en_US[] = "en_US.UTF-8";
|
||||
const char *CurrentLocale = setlocale( LC_ALL, NULL );
|
||||
if ( !CurrentLocale )
|
||||
|
||||
@@ -2128,8 +2128,8 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
|
||||
int nNumberOfFields;
|
||||
|
||||
char *pData;
|
||||
int nFieldSize;
|
||||
|
||||
short nFieldSize;
|
||||
|
||||
pData = pSaveData;
|
||||
|
||||
// Allocate a table for the strings, and parse the table
|
||||
@@ -2148,9 +2148,12 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
|
||||
pTokenList = NULL;
|
||||
|
||||
// short, short (size, index of field name)
|
||||
nFieldSize = *(short *)pData;
|
||||
|
||||
Q_memcpy( &nFieldSize, pData, sizeof(short) );
|
||||
pData += sizeof(short);
|
||||
pFieldName = pTokenList[ *(short *)pData ];
|
||||
short index = 0;
|
||||
Q_memcpy( &index, pData, sizeof(short) );
|
||||
pFieldName = pTokenList[index];
|
||||
|
||||
if ( !pFieldName || Q_stricmp( pFieldName, "GameHeader" ) )
|
||||
{
|
||||
@@ -2161,7 +2164,7 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
|
||||
|
||||
// int (fieldcount)
|
||||
pData += sizeof(short);
|
||||
nNumberOfFields = *(int*)pData;
|
||||
Q_memcpy( &nNumberOfFields, pData, sizeof(int) );
|
||||
pData += nFieldSize;
|
||||
|
||||
// Each field is a short (size), short (index of name), binary string of "size" bytes (data)
|
||||
@@ -2172,10 +2175,11 @@ int CSaveRestore::SaveReadNameAndComment( FileHandle_t f, OUT_Z_CAP(nameSize) ch
|
||||
// szName
|
||||
// Actual Data
|
||||
|
||||
nFieldSize = *(short *)pData;
|
||||
Q_memcpy( &nFieldSize, pData, sizeof(short) );
|
||||
pData += sizeof(short);
|
||||
|
||||
pFieldName = pTokenList[ *(short *)pData ];
|
||||
Q_memcpy( &index, pData, sizeof(short) );
|
||||
pFieldName = pTokenList[index];
|
||||
pData += sizeof(short);
|
||||
|
||||
if ( !Q_stricmp( pFieldName, "comment" ) )
|
||||
|
||||
@@ -1388,6 +1388,7 @@ bool CGameServer::FinishCertificateCheck( netadr_t &adr, int nAuthProtocol, cons
|
||||
if ( AllowDebugDedicatedServerOutsideSteam() )
|
||||
return true;
|
||||
|
||||
/*
|
||||
if ( !Host_IsSinglePlayerGame() || sv.IsDedicated()) // PROTOCOL_HASHEDCDKEY isn't allowed for multiplayer servers
|
||||
{
|
||||
RejectConnection( adr, clientChallenge, "#GameUI_ServerCDKeyAuthInvalid" );
|
||||
@@ -1398,7 +1399,7 @@ bool CGameServer::FinishCertificateCheck( netadr_t &adr, int nAuthProtocol, cons
|
||||
{
|
||||
RejectConnection( adr, clientChallenge, "#GameUI_ServerInvalidCDKey" );
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
int nHashCount = 0;
|
||||
|
||||
|
||||
@@ -358,27 +358,7 @@ void CEngine::Frame( void )
|
||||
// Calculate how long we need to wait.
|
||||
int nSleepMS = (int)( ( m_flMinFrameTime - m_flFrameTime ) * 1000 - fBusyWaitMS );
|
||||
if ( nSleepMS > 0 )
|
||||
{
|
||||
ThreadSleep( nSleepMS );
|
||||
}
|
||||
else
|
||||
{
|
||||
// On x86, busy-wait using PAUSE instruction which encourages
|
||||
// power savings by idling for ~10 cycles (also yielding to
|
||||
// the other logical hyperthread core if the CPU supports it)
|
||||
for (int i = 2000; i >= 0; --i)
|
||||
{
|
||||
#if defined(POSIX)
|
||||
#ifdef __arm__
|
||||
raise(SIGINT);
|
||||
#else
|
||||
__asm( "pause" ); __asm( "pause" ); __asm( "pause" ); __asm( "pause" );
|
||||
#endif
|
||||
#elif defined(IS_WINDOWS_PC)
|
||||
_asm { pause }; _asm { pause }; _asm { pause }; _asm { pause };
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Go back to the top of the loop and see if it is time yet.
|
||||
}
|
||||
|
||||
@@ -364,7 +364,11 @@ void CGame::DispatchInputEvent( const InputEvent_t &event )
|
||||
case IE_ButtonReleased:
|
||||
Key_Event( event );
|
||||
break;
|
||||
|
||||
case IE_FingerDown:
|
||||
case IE_FingerUp:
|
||||
case IE_FingerMotion:
|
||||
if( g_ClientDLL )
|
||||
g_ClientDLL->IN_TouchEvent( event.m_nType, event.m_nData, event.m_nData2, event.m_nData3 );
|
||||
default:
|
||||
// Let vgui have the first whack at events
|
||||
if ( g_pMatSystemSurface && g_pMatSystemSurface->HandleInputEvent( event ) )
|
||||
@@ -911,7 +915,11 @@ bool CGame::CreateGameWindow( void )
|
||||
|
||||
if ( IsOpenGL() )
|
||||
{
|
||||
#ifdef TOGLES
|
||||
V_strcat( windowName, " - OpenGLES", sizeof( windowName ) );
|
||||
#else
|
||||
V_strcat( windowName, " - OpenGL", sizeof( windowName ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PIX_ENABLE || defined( PIX_INSTRUMENTATION )
|
||||
|
||||
@@ -696,6 +696,11 @@ void CEngineVGui::Init()
|
||||
COM_TimestampedLog( "Building Panels (staticGameUIPanel)" );
|
||||
|
||||
staticGameUIPanel = new CEnginePanel( staticPanel, "GameUI Panel" );
|
||||
if (IsAndroid() || CommandLine()->CheckParm("-gameuiproportionality"))
|
||||
{
|
||||
staticGameUIPanel->SetProportional(true);
|
||||
}
|
||||
|
||||
staticGameUIPanel->SetBounds( 0, 0, videomode->GetModeUIWidth(), videomode->GetModeUIHeight() );
|
||||
staticGameUIPanel->SetPaintBorderEnabled(false);
|
||||
staticGameUIPanel->SetPaintBackgroundEnabled(false);
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
|
||||
|
||||
$Macro SRCDIR "..\..\.."
|
||||
$Macro OUTBINDIR "$LIBPUBLIC"
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE,$SRCDIR\thirdparty\minimp3\,..\..\..\public,..\..\..\public\tier1,..\..,..\..\..\common,..\..\audio\public"
|
||||
$PreprocessorDefinitions "$BASE;"
|
||||
}
|
||||
$Compiler
|
||||
{
|
||||
$AdditionalIncludeDirectories "$BASE,$SRCDIR\thirdparty\minimp3\,..\..\..\public,..\..\..\public\tier1,..\..,..\..\..\common,..\..\audio\public"
|
||||
$DisableSpecificWarnings "$BASE;4706"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "vaudio_minimp3"
|
||||
|
||||
@@ -171,7 +171,6 @@ def build(bld):
|
||||
'sys_dll.cpp',
|
||||
'sys_dll2.cpp',
|
||||
'sys_engine.cpp',
|
||||
'sys_linuxwind.cpp', #[$POSIX]
|
||||
'testscriptmgr.cpp',
|
||||
'traceinit.cpp',
|
||||
'../public/vallocator.cpp',
|
||||
@@ -193,21 +192,34 @@ def build(bld):
|
||||
'EngineSoundServer.cpp',
|
||||
'audio/private/voice_wavefile.cpp',
|
||||
'audio/private/vox.cpp',
|
||||
'audio/private/snd_posix.cpp', # [$POSIX]
|
||||
#'audio/private/snd_dev_direct.cpp', [$WINDOWS]/
|
||||
#'audio/private/snd_dev_wave.cpp', [$WINDOWS]/
|
||||
#'audio/private/voice_mixer_controls.cpp', [$WINDOWS] /
|
||||
#'audio/private/voice_record_dsound.cpp', [$WINDOWS] /
|
||||
|
||||
#'audio/private/snd_dev_xaudio.cpp',[$X360]
|
||||
#'audio/private/snd_wave_mixer_xma.cpp', [$X360]
|
||||
|
||||
'audio/private/snd_dev_sdl.cpp', #[$SDL && !$OSXALL]
|
||||
#'audio/private/snd_dev_openal.cpp', # [$OSXALL]
|
||||
#'audio/private/snd_dev_mac_audioqueue.cpp',# [$OSXALL]
|
||||
#'audio/private/voice_record_mac_audioqueue.cpp', #[$OSXALL]
|
||||
]
|
||||
|
||||
if bld.env.SDL:
|
||||
source += [
|
||||
'audio/private/snd_dev_sdl.cpp' #[$SDL && !$OSXALL]
|
||||
]
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
source += [
|
||||
'../public/tier0/memoverride.cpp',
|
||||
'audio/private/snd_dev_direct.cpp',
|
||||
'audio/private/snd_dev_wave.cpp',
|
||||
'audio/private/voice_mixer_controls.cpp',
|
||||
'audio/private/voice_record_dsound.cpp',
|
||||
]
|
||||
else:
|
||||
source += [
|
||||
'sys_linuxwind.cpp',
|
||||
'audio/private/snd_posix.cpp',
|
||||
]
|
||||
|
||||
if bld.env.DEDICATED:
|
||||
source += ['cl_null.cpp']
|
||||
else:
|
||||
@@ -295,8 +307,6 @@ def build(bld):
|
||||
'audio/private/VBRHeader.cpp', #[!$X360]
|
||||
'audio/private/voice.cpp', #[!$X360]
|
||||
'audio/private/voice_sound_engine_interface.cpp', #[!$X360]
|
||||
'audio/private/voice_mixer_controls_openal.cpp', #[$OSXALL||$LINUXALL]
|
||||
'audio/private/voice_record_openal.cpp', #[$OSXALL||$LINUXALL]
|
||||
'../public/vgui_controls/vgui_controls.cpp',
|
||||
'../common/vgui/vgui_basebudgetpanel.cpp',
|
||||
'../common/vgui/vgui_budgetbargraphpanel.cpp',
|
||||
@@ -314,6 +324,12 @@ def build(bld):
|
||||
'vgui_vprofpanel.cpp',
|
||||
'toolframework.cpp'
|
||||
]
|
||||
|
||||
if bld.env.DEST_OS != 'win32':
|
||||
source += [
|
||||
'audio/private/voice_mixer_controls_openal.cpp', #[$OSXALL||$LINUXALL]
|
||||
'audio/private/voice_record_openal.cpp' #[$OSXALL||$LINUXALL]
|
||||
]
|
||||
|
||||
includes = [
|
||||
'.',
|
||||
@@ -332,7 +348,9 @@ def build(bld):
|
||||
|
||||
if bld.env.DEST_OS == 'android':
|
||||
libs += ['SSL', 'CRYPTO'] # android curl was built with openssl
|
||||
|
||||
elif bld.env.DEST_OS == 'win32':
|
||||
libs += ['USER32', 'WINMM', 'WININET', 'DSOUND', 'DXGUID', 'GDI32', 'bzip2']
|
||||
|
||||
install_path = bld.env.LIBDIR
|
||||
|
||||
bld.shlib(
|
||||
|
||||
2
external/vpc/tier0/threadtools.cpp
vendored
2
external/vpc/tier0/threadtools.cpp
vendored
@@ -49,7 +49,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef _PS3
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#endif
|
||||
#include "tier0/threadtools.h"
|
||||
|
||||
|
||||
35
external/vpc/utils/vpc/main.cpp
vendored
35
external/vpc/utils/vpc/main.cpp
vendored
@@ -75,7 +75,7 @@ CVPC::CVPC()
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
m_eVSVersion = k_EVSVersion_2015;
|
||||
m_eVSVersion = k_EVSVersion_2019;
|
||||
m_bUseVS2010FileFormat = true;
|
||||
m_bUseUnity = false;
|
||||
#else
|
||||
@@ -175,11 +175,6 @@ void CVPC::Shutdown( bool bHasError )
|
||||
UnloadPerforceInterface();
|
||||
}
|
||||
|
||||
#if defined( STANDALONE_VPC )
|
||||
class CP4;
|
||||
extern CP4 s_p4;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CVPC::LoadPerforceInterface()
|
||||
@@ -190,11 +185,6 @@ bool CVPC::LoadPerforceInterface()
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined( STANDALONE_VPC )
|
||||
p4 = (IP4*)&s_p4;
|
||||
return (p4 != NULL);
|
||||
#else
|
||||
|
||||
//
|
||||
// Try to load p4lib.dll and the filesystem since the p4lib relies on it
|
||||
//
|
||||
@@ -234,7 +224,6 @@ bool CVPC::LoadPerforceInterface()
|
||||
p4->Connect( Sys_GetFactory( m_pFilesystemModule ) );
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -635,7 +624,8 @@ void CVPC::SpewUsage( void )
|
||||
Log_Msg( LOG_VPC, "[/srcctl]: Enable P4SCC source control integration - can also set environment variable VPC_SRCCTL to 1\n" );
|
||||
#endif
|
||||
Log_Msg( LOG_VPC, "[/mirror]: <path> - Mirror output files to specified path. Used for A:B testing.\n" );
|
||||
Log_Msg( LOG_VPC, "[/2015]: Generate projects and solutions for Visual Studio 2015 [default]\n" );
|
||||
Log_Msg( LOG_VPC, "[/2019]: Generate projects and solutions for Visual Studio 2019 [default]\n" );
|
||||
Log_Msg( LOG_VPC, "[/2015]: Generate projects and solutions for Visual Studio 2015\n" );
|
||||
Log_Msg( LOG_VPC, "[/2013]: Generate projects and solutions for Visual Studio 2013\n" );
|
||||
Log_Msg( LOG_VPC, "[/2012]: Generate projects and solutions for Visual Studio 2012\n" );
|
||||
Log_Msg( LOG_VPC, "[/2010]: Generate projects and solutions for Visual Studio 2010\n" );
|
||||
@@ -1004,6 +994,11 @@ void CVPC::HandleSingleCommandLineArg( const char *pArg )
|
||||
m_eVSVersion = k_EVSVersion_2015;
|
||||
m_ExtraOptionsCRCString += pArgName;
|
||||
}
|
||||
else if ( !V_stricmp( pArgName, "2019" ) )
|
||||
{
|
||||
m_eVSVersion = k_EVSVersion_2019;
|
||||
m_ExtraOptionsCRCString += pArgName;
|
||||
}
|
||||
else if ( !V_stricmp( pArgName, "nounity" ) )
|
||||
{
|
||||
m_bUseUnity = false;
|
||||
@@ -1825,6 +1820,16 @@ void CVPC::SetMacrosAndConditionals()
|
||||
// VS2010 is strictly win32/xbox360
|
||||
switch ( m_eVSVersion )
|
||||
{
|
||||
case k_EVSVersion_2019:
|
||||
m_ExtraOptionsCRCString += "VS2019";
|
||||
SetConditional( "VS2019", true );
|
||||
|
||||
// temporarily allow VS2013 conditionals also as there are many. Will fix.
|
||||
SetConditional( "VS2013", true );
|
||||
|
||||
m_bUseVS2010FileFormat = true;
|
||||
break;
|
||||
|
||||
case k_EVSVersion_2015:
|
||||
m_ExtraOptionsCRCString += "VS2015";
|
||||
SetConditional( "VS2015", true );
|
||||
@@ -2362,7 +2367,9 @@ void CVPC::SetupGenerators()
|
||||
{
|
||||
// spew what we are generating
|
||||
const char *pchLogLine = "Generating for Visual Studio 2005.\n";
|
||||
if ( m_eVSVersion == k_EVSVersion_2015 )
|
||||
if ( m_eVSVersion == k_EVSVersion_2019 )
|
||||
pchLogLine = "Generating for Visual Studio 2019.\n";
|
||||
else if ( m_eVSVersion == k_EVSVersion_2015 )
|
||||
pchLogLine = "Generating for Visual Studio 2015.\n";
|
||||
else if ( m_eVSVersion == k_EVSVersion_2013 )
|
||||
pchLogLine = "Generating for Visual Studio 2013.\n";
|
||||
|
||||
@@ -27,6 +27,12 @@ class CSolutionGenerator_Win32 : public IBaseSolutionGenerator
|
||||
public:
|
||||
void GetVCPROJSolutionGUID( char (&szSolutionGUID)[256] )
|
||||
{
|
||||
if ( g_pVPC->Is2019() )
|
||||
{
|
||||
V_strncpy( szSolutionGUID, "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}", ARRAYSIZE(szSolutionGUID) );
|
||||
return;
|
||||
}
|
||||
|
||||
HKEY hKey;
|
||||
int firstVer = 8;
|
||||
const int lastVer = 14; // Handle up to VS 14, AKA VS 2015
|
||||
@@ -114,7 +120,12 @@ public:
|
||||
g_pVPC->VPCError( "Can't open %s for writing.", pSolutionFilename );
|
||||
|
||||
|
||||
if ( g_pVPC->Is2015() )
|
||||
if ( g_pVPC->Is2019() )
|
||||
{
|
||||
fprintf( fp, "\xef\xbb\xbf\nMicrosoft Visual Studio Solution File, Format Version 12.00\n" );
|
||||
fprintf( fp, "# Visual Studio Version 16\n" );
|
||||
}
|
||||
else if ( g_pVPC->Is2015() )
|
||||
{
|
||||
fprintf( fp, "\xef\xbb\xbf\nMicrosoft Visual Studio Solution File, Format Version 12.00\n" ); // still on 12
|
||||
fprintf( fp, "# Visual Studio 2015\n" );
|
||||
|
||||
2
external/vpc/utils/vpc/vpc.h
vendored
2
external/vpc/utils/vpc/vpc.h
vendored
@@ -182,6 +182,7 @@ enum EVSVersion
|
||||
k_EVSVersion_2012,
|
||||
k_EVSVersion_2013,
|
||||
k_EVSVersion_2015,
|
||||
k_EVSVersion_2019,
|
||||
};
|
||||
|
||||
class CVPC
|
||||
@@ -218,6 +219,7 @@ public:
|
||||
bool Is2012() { return m_eVSVersion == k_EVSVersion_2012; } // When this returns true so does Is2010() because of the file format similarities
|
||||
bool Is2013() { return m_eVSVersion == k_EVSVersion_2013; } // When this returns true so does Is2010() because of the file format similarities
|
||||
bool Is2015() { return m_eVSVersion == k_EVSVersion_2015; } // When this returns true so does Is2010() because of the file format similarities
|
||||
bool Is2019() { return m_eVSVersion == k_EVSVersion_2019; } // When this returns true so does Is2010() because of the file format similarities
|
||||
bool BUse2008() { return m_eVSVersion == k_EVSVersion_2008; }
|
||||
bool IsDedicatedBuild() { return m_bDedicatedBuild; }
|
||||
bool IsUnity() { return m_bUseUnity; }
|
||||
|
||||
21
external/vpc/utils/vpc/vpc.vcxproj
vendored
21
external/vpc/utils/vpc/vpc.vcxproj
vendored
@@ -13,21 +13,21 @@
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{36C5F545-588F-4091-B480-89E03EDBDA93}</ProjectGuid>
|
||||
<RootNamespace>vpc</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
@@ -58,9 +58,8 @@
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>p4 edit ..\..\..\..\devtools\bin\vpc.exe && copy /y $(TargetPath) ..\..\..\..\devtools\bin\vpc.exe
|
||||
p4 edit ..\..\..\..\devtools\bin\vpc.pdb && copy /y $(TargetDir)\vpc.pdb ..\..\..\..\devtools\bin\vpc.pdb
|
||||
</Command>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -83,14 +82,12 @@ p4 edit ..\..\..\..\devtools\bin\vpc.pdb && copy /y $(TargetDir)\vpc.pdb
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>p4 edit ..\..\..\..\devtools\bin\vpc.exe && copy /y $(TargetPath) ..\..\..\..\devtools\bin\vpc.exe
|
||||
p4 edit ..\..\..\..\devtools\bin\vpc.pdb && copy /y $(TargetDir)\vpc.pdb ..\..\..\..\devtools\bin\vpc.pdb
|
||||
</Command>
|
||||
<Command>
|
||||
</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\interfaces\interfaces.cpp" />
|
||||
<ClCompile Include="..\..\p4lib\p4.cpp" />
|
||||
<ClCompile Include="..\..\tier0\assert_dialog.cpp" />
|
||||
<ClCompile Include="..\..\tier0\commandline.cpp" />
|
||||
<ClCompile Include="..\..\tier0\cpu.cpp" />
|
||||
|
||||
3
external/vpc/utils/vpc/vpc.vcxproj.filters
vendored
3
external/vpc/utils/vpc/vpc.vcxproj.filters
vendored
@@ -245,9 +245,6 @@
|
||||
<ClCompile Include="solutiongenerator_codelite.cpp">
|
||||
<Filter>VPC\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\p4lib\p4.cpp">
|
||||
<Filter>Dependencies\Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\tier0\mem_helpers.h">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$macro SRCDIR ".."
|
||||
$Macro OUTBINDIR "$LIBPUBLIC"
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
$include "$SRCDIR\vpc_scripts\source_cryptlib_include.vpc"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR ".."
|
||||
$Macro OUTBINDIR "$LIBPUBLIC"
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
|
||||
|
||||
@@ -28,10 +28,14 @@ def build(bld):
|
||||
'../public/kevvaluescompiler.cpp',
|
||||
'../public/zip_utils.cpp',
|
||||
'QueuedLoader.cpp',
|
||||
'linux_support.cpp', # [$POSIX]
|
||||
'../public/tier0/memoverride.cpp'
|
||||
]
|
||||
|
||||
if bld.env.DEST_OS != 'win32':
|
||||
source += [
|
||||
'linux_support.cpp'
|
||||
]
|
||||
|
||||
includes = [
|
||||
'.',
|
||||
'../public',
|
||||
@@ -43,6 +47,9 @@ def build(bld):
|
||||
defines = []
|
||||
|
||||
libs = ['tier0','tier1','tier2','vstdlib','vpklib']
|
||||
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
libs += ['SHELL32']
|
||||
|
||||
install_path = bld.env.LIBDIR
|
||||
|
||||
|
||||
@@ -101,11 +101,12 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
int iMax = event->GetInt( "max_val" );
|
||||
wchar_t szLocalizedName[256]=L"";
|
||||
|
||||
#if 0
|
||||
if ( IsPC() )
|
||||
{
|
||||
// shouldn't ever get achievement progress if steam not running and user logged in, but check just in case
|
||||
if ( !steamapicontext->SteamUserStats() )
|
||||
{
|
||||
{
|
||||
Msg( "Steam not running, achievement progress notification not displayed\n" );
|
||||
}
|
||||
else
|
||||
@@ -115,6 +116,7 @@ void CAchievementNotificationPanel::FireGameEvent( IGameEvent * event )
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// on X360 we need to show our own achievement progress UI
|
||||
|
||||
@@ -245,7 +247,7 @@ void CAchievementNotificationPanel::SetXAndWide( Panel *pPanel, int x, int wide
|
||||
pPanel->SetWide( wide );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( achievement_notification_test, "Test the hud notification UI", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY )
|
||||
CON_COMMAND_F( achievement_notification_test, "Test the hud notification UI", FCVAR_CHEAT )
|
||||
{
|
||||
static int iCount=0;
|
||||
|
||||
@@ -269,4 +271,4 @@ CON_COMMAND_F( achievement_notification_test, "Test the hud notification UI", FC
|
||||
#endif
|
||||
|
||||
iCount++;
|
||||
}
|
||||
}
|
||||
|
||||
673
game/client/arch.c
Normal file
673
game/client/arch.c
Normal file
File diff suppressed because one or more lines are too long
11523
game/client/base_texture.h
Normal file
11523
game/client/base_texture.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4761,7 +4761,7 @@ C_BaseEntity *C_BaseEntity::Instance( int iEnt )
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#include <typeinfo.h>
|
||||
#include <typeinfo>
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@
|
||||
#include "client_virtualreality.h"
|
||||
#include "mumble.h"
|
||||
#include "vgui_controls/BuildGroup.h"
|
||||
#include "touch.h"
|
||||
|
||||
// NVNT includes
|
||||
#include "hud_macros.h"
|
||||
@@ -729,11 +730,12 @@ public:
|
||||
|
||||
// Returns true if the disconnect command has been handled by the client
|
||||
virtual bool DisconnectAttempt( void );
|
||||
public:
|
||||
|
||||
void PrecacheMaterial( const char *pMaterialName );
|
||||
|
||||
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar );
|
||||
|
||||
virtual void IN_TouchEvent( int type, int fingerId, int x, int y );
|
||||
private:
|
||||
void UncacheAllMaterials( );
|
||||
void ResetStringTablePointers();
|
||||
@@ -1039,6 +1041,8 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
|
||||
|
||||
gHUD.Init();
|
||||
|
||||
gTouch.Init();
|
||||
|
||||
g_pClientMode->Init();
|
||||
|
||||
if ( !IGameSystem::InitAllSystems() )
|
||||
@@ -1202,7 +1206,8 @@ void CHLClient::Shutdown( void )
|
||||
|
||||
gHUD.Shutdown();
|
||||
VGui_Shutdown();
|
||||
|
||||
gTouch.Shutdown();
|
||||
|
||||
ParticleMgr()->Term();
|
||||
|
||||
vgui::BuildGroup::ClearResFileCache();
|
||||
@@ -1419,8 +1424,23 @@ int CHLClient::IN_KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszC
|
||||
return input->KeyEvent( eventcode, keynum, pszCurrentBinding );
|
||||
}
|
||||
|
||||
void CHLClient::ExtraMouseSample( float frametime, bool active )
|
||||
void CHLClient::IN_TouchEvent( int type, int fingerId, int x, int y )
|
||||
{
|
||||
if( enginevgui->IsGameUIVisible() )
|
||||
return;
|
||||
|
||||
touch_event_t ev;
|
||||
|
||||
ev.type = type;
|
||||
ev.fingerid = fingerId;
|
||||
ev.x = x;
|
||||
ev.y = y;
|
||||
|
||||
gTouch.ProcessEvent( &ev );
|
||||
}
|
||||
|
||||
void CHLClient::ExtraMouseSample( float frametime, bool active )
|
||||
{
|
||||
Assert( C_BaseEntity::IsAbsRecomputationsEnabled() );
|
||||
Assert( C_BaseEntity::IsAbsQueriesValid() );
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ $MacroRequired "GAMENAME"
|
||||
$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
|
||||
$include "$SRCDIR\vpc_scripts\protobuf_builder.vpc"
|
||||
$Include "$SRCDIR\vpc_scripts\source_replay.vpc" [$TF]
|
||||
$Include "$SRCDIR\game\protobuf_include.vpc"
|
||||
|
||||
$Configuration "Debug"
|
||||
{
|
||||
@@ -506,6 +505,8 @@ $Project
|
||||
$File "$SRCDIR\public\haptics\haptic_msgs.cpp" [!$X360]
|
||||
$File "$SRCDIR\public\haptics\haptic_utils.cpp" [$WIN32&&!$X360]
|
||||
|
||||
$File "$SRCDIR\game\client\touch.cpp"
|
||||
|
||||
$Folder "Sixense"
|
||||
{
|
||||
$File "sixense\in_sixense.cpp"
|
||||
|
||||
@@ -9,7 +9,6 @@ $Macro GAMENAME "hl2" [!$SOURCESDK]
|
||||
$Macro GAMENAME "mod_hl2" [$SOURCESDK]
|
||||
|
||||
$Include "$SRCDIR\game\client\client_base.vpc"
|
||||
$Include "$SRCDIR\game\protobuf_include.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ $include "$SRCDIR\game\shared\tf\tf_gcmessages_include.vpc"
|
||||
$Include "$SRCDIR\game\client\client_econ_base.vpc"
|
||||
$Include "$SRCDIR\vpc_scripts\source_saxxyawards.vpc"
|
||||
$Include "$SRCDIR\utils\itemtest_lib\itemtest_lib_support.vpc" [$WORKSHOP_IMPORT_ENABLE]
|
||||
$Include "$SRCDIR\game\protobuf_include.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
|
||||
@@ -1134,9 +1134,7 @@ void ClientModeShared::FireGameEvent( IGameEvent *event )
|
||||
bool bValidTeam = false;
|
||||
|
||||
if ( (GetLocalTeam() && GetLocalTeam()->GetTeamNumber() == team) )
|
||||
{
|
||||
bValidTeam = true;
|
||||
}
|
||||
|
||||
//If we're in the spectator team then we should be getting whatever messages the person I'm spectating gets.
|
||||
if ( bValidTeam == false )
|
||||
@@ -1152,15 +1150,11 @@ void ClientModeShared::FireGameEvent( IGameEvent *event )
|
||||
}
|
||||
}
|
||||
|
||||
if ( team == 0 && GetLocalTeam() > 0 )
|
||||
{
|
||||
if ( team == 0 && GetLocalTeam() )
|
||||
bValidTeam = false;
|
||||
}
|
||||
|
||||
if ( team == 255 )
|
||||
{
|
||||
bValidTeam = true;
|
||||
}
|
||||
|
||||
if ( bValidTeam == true )
|
||||
{
|
||||
|
||||
@@ -134,10 +134,9 @@ void LoadHudTextures( CUtlDict< CHudTexture *, int >& list, const char *szFilena
|
||||
pTemp = pTemp->GetNextKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Failed for some reason. Delete the Key data and abort.
|
||||
pKeyValuesData->deleteThis();
|
||||
pKeyValuesData->deleteThis();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -459,7 +458,9 @@ void CHud::Init( void )
|
||||
|
||||
// check to see if we have sprites for this res; if not, step down
|
||||
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
|
||||
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
|
||||
|
||||
// Нахуя, а главное зачем ?
|
||||
// LoadHudTextures( textureList, "scripts/mod_textures", NULL );
|
||||
|
||||
int c = textureList.Count();
|
||||
for ( int index = 0; index < c; index++ )
|
||||
|
||||
@@ -22,7 +22,7 @@ static CPDumpPanel *g_pPDumpPanel = NULL;
|
||||
// retaining our own warning setup...ywb
|
||||
#ifdef WIN32
|
||||
#pragma warning( push )
|
||||
#include <typeinfo.h>
|
||||
#include <typeinfo>
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,12 +19,16 @@
|
||||
#include "bitbuf.h"
|
||||
#include "checksum_md5.h"
|
||||
#include "hltvcamera.h"
|
||||
#include "touch.h"
|
||||
#include "ienginevgui.h"
|
||||
|
||||
#if defined( REPLAY_ENABLED )
|
||||
#include "replay/replaycamera.h"
|
||||
#endif
|
||||
#include <ctype.h> // isalnum()
|
||||
#include <voice_status.h>
|
||||
#include "cam_thirdperson.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
|
||||
#ifdef SIXENSE
|
||||
#include "sixense/in_sixense.h"
|
||||
@@ -289,11 +293,11 @@ Add a kbutton_t * to the list of pointers the engine can retrieve via KB_Find
|
||||
*/
|
||||
void CInput::AddKeyButton( const char *name, kbutton_t *pkb )
|
||||
{
|
||||
CKeyboardKey *p;
|
||||
CKeyboardKey *p;
|
||||
kbutton_t *kb;
|
||||
|
||||
kb = FindKey( name );
|
||||
|
||||
|
||||
if ( kb )
|
||||
return;
|
||||
|
||||
@@ -307,7 +311,7 @@ void CInput::AddKeyButton( const char *name, kbutton_t *pkb )
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CInput::CInput( void )
|
||||
{
|
||||
@@ -319,7 +323,7 @@ CInput::CInput( void )
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CInput::~CInput( void )
|
||||
{
|
||||
@@ -952,6 +956,7 @@ void CInput::ControllerMove( float frametime, CUserCmd *cmd )
|
||||
|
||||
SteamControllerMove( frametime, cmd );
|
||||
JoyStickMove( frametime, cmd );
|
||||
gTouch.Move( frametime, cmd );
|
||||
|
||||
// NVNT if we have a haptic device..
|
||||
if(haptics && haptics->HasDevice())
|
||||
@@ -1105,11 +1110,10 @@ void CInput::ExtraMouseSample( float frametime, bool active )
|
||||
prediction->SetLocalViewAngles( cmd->viewangles );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CInput::CreateMove ( int sequence_number, float input_sample_frametime, bool active )
|
||||
{
|
||||
{
|
||||
CUserCmd *cmd = &m_pCommands[ sequence_number % MULTIPLAYER_BACKUP ];
|
||||
CVerifiedUserCmd *pVerified = &m_pVerifiedCommands[ sequence_number % MULTIPLAYER_BACKUP ];
|
||||
|
||||
@@ -1196,11 +1200,11 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
|
||||
cmd->buttons = GetButtonBits( 1 );
|
||||
#endif
|
||||
|
||||
// Using joystick?
|
||||
// Using joystick or touch?
|
||||
#ifdef SIXENSE
|
||||
if ( in_joystick.GetInt() || g_pSixenseInput->IsEnabled() )
|
||||
if ( in_joystick.GetInt() || g_pSixenseInput->IsEnabled() || touch_enable.GetInt() )
|
||||
#else
|
||||
if ( in_joystick.GetInt() )
|
||||
if ( in_joystick.GetInt() || touch_enable.GetInt() )
|
||||
#endif
|
||||
{
|
||||
if ( cmd->forwardmove > 0 )
|
||||
|
||||
@@ -120,7 +120,7 @@ entities. Each one is useful under different conditions.
|
||||
#include "utllinkedlist.h"
|
||||
#include "utldict.h"
|
||||
#ifdef WIN32
|
||||
#include <typeinfo.h>
|
||||
#include <typeinfo>
|
||||
#else
|
||||
#include <typeinfo>
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "cbase.h"
|
||||
#include "c_baseentity.h"
|
||||
#ifdef WIN32
|
||||
#include <typeinfo.h>
|
||||
#include <typeinfo>
|
||||
#endif
|
||||
#include "tier0/vprof.h"
|
||||
|
||||
|
||||
364
game/client/third/minizip/CMakeLists.txt
Executable file
364
game/client/third/minizip/CMakeLists.txt
Executable file
@@ -0,0 +1,364 @@
|
||||
#***************************************************************************
|
||||
# Copyright: Matthias Schmieder,
|
||||
# E-Mail: schmieder.matthias@gmail.com
|
||||
# Year: 2016
|
||||
#***************************************************************************
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
option(USE_ZLIB "Enables ZLIB compression" ON)
|
||||
option(USE_BZIP2 "Enables BZIP2 compression" ON)
|
||||
option(USE_LZMA "Enables LZMA compression" ON)
|
||||
option(USE_PKCRYPT "Enables PKWARE traditional encryption" ON)
|
||||
option(USE_AES "Enables AES encryption" ON)
|
||||
option(BUILD_TEST "Builds minizip test executable" OFF)
|
||||
|
||||
# Set a consistent MACOSX_RPATH default across all CMake versions.
|
||||
# When CMake 2.8.12 is required, change this default to 1.
|
||||
# When CMake 3.0.0 is required, remove this block (see CMP0042).
|
||||
if(NOT DEFINED CMAKE_MACOSX_RPATH)
|
||||
set(CMAKE_MACOSX_RPATH 0)
|
||||
endif()
|
||||
|
||||
project("minizip")
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for executables")
|
||||
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
|
||||
set(INSTALL_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for headers")
|
||||
set(INSTALL_MAN_DIR ${CMAKE_INSTALL_MANDIR} CACHE PATH "Installation directory for manual pages")
|
||||
set(INSTALL_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE PATH "Installation directory for pkgconfig (.pc) files")
|
||||
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/minizip CACHE PATH "Installation directory for cmake files.")
|
||||
|
||||
set(VERSION "2.3.3")
|
||||
|
||||
# Set cmake debug postfix to d
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
# Ensure correct version of zlib is referenced
|
||||
if(USE_ZLIB)
|
||||
set(ZLIB_ROOT ${DEF_ZLIB_ROOT} CACHE PATH "Parent directory of zlib installation")
|
||||
find_package(ZLIB REQUIRED)
|
||||
if(ZLIB_FOUND)
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
endif()
|
||||
add_definitions(-DHAVE_ZLIB)
|
||||
endif()
|
||||
|
||||
set(MINIZIP_PC ${CMAKE_CURRENT_BINARY_DIR}/minizip.pc)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/minizip.pc.cmakein ${MINIZIP_PC} @ONLY)
|
||||
|
||||
set(PROJECT_NAME libminizip)
|
||||
|
||||
set(MINIZIP_SRC
|
||||
mz_os.c
|
||||
mz_compat.c
|
||||
mz_strm.c
|
||||
mz_strm_buf.c
|
||||
mz_strm_mem.c
|
||||
mz_strm_posix.c
|
||||
mz_strm_split.c
|
||||
mz_zip.c)
|
||||
|
||||
set(MINIZIP_PUBLIC_HEADERS
|
||||
mz.h
|
||||
mz_os.h
|
||||
mz_compat.h
|
||||
mz_strm.h
|
||||
mz_strm_buf.h
|
||||
mz_strm_mem.h
|
||||
mz_strm_posix.h
|
||||
mz_strm_split.h
|
||||
mz_zip.h)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND MINIZIP_SRC "mz_os_win32.c" "mz_strm_win32.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_os_win32.h" "mz_strm_win32.h")
|
||||
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
|
||||
add_definitions(-DMZ_USE_WINRT_API)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
add_compile_options(-O3)
|
||||
|
||||
list(APPEND MINIZIP_SRC "mz_os_posix.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_os_posix.h")
|
||||
|
||||
set(define_lfs_macros TRUE)
|
||||
|
||||
if(ANDROID)
|
||||
string(REGEX REPLACE "android-([0-9+])" "\\1"
|
||||
android_api "${ANDROID_PLATFORM}")
|
||||
if(${android_api} LESS 24)
|
||||
set(define_lfs_macros FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(define_lfs_macros)
|
||||
add_definitions(-D__USE_FILE_OFFSET64)
|
||||
add_definitions(-D__USE_LARGEFILE64)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE)
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(LIBBSD libbsd REQUIRED)
|
||||
|
||||
include_directories(${LIBBSD_INCLUDE_DIRS})
|
||||
link_directories(${LIBBSD_LIBRARY_DIRS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_PKCRYPT)
|
||||
add_definitions(-DHAVE_PKCRYPT)
|
||||
|
||||
list(APPEND MINIZIP_SRC "mz_strm_pkcrypt.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_pkcrypt.h")
|
||||
endif()
|
||||
|
||||
if(USE_AES)
|
||||
add_definitions(-DHAVE_AES)
|
||||
|
||||
list(APPEND MINIZIP_SRC "mz_strm_aes.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_aes.h")
|
||||
|
||||
set(AES_SRC
|
||||
lib/aes/aescrypt.c
|
||||
lib/aes/aeskey.c
|
||||
lib/aes/aestab.c
|
||||
lib/aes/hmac.c
|
||||
lib/aes/pwd2key.c
|
||||
lib/aes/sha1.c)
|
||||
|
||||
set(AES_PUBLIC_HEADERS
|
||||
lib/aes/aes.h
|
||||
lib/aes/aesopt.h
|
||||
lib/aes/aestab.h
|
||||
lib/aes/brg_endian.h
|
||||
lib/aes/brg_types.h
|
||||
lib/aes/hmac.h
|
||||
lib/aes/pwd2key.h
|
||||
lib/aes/sha1.h)
|
||||
|
||||
include_directories(lib/aes)
|
||||
|
||||
source_group("AES" FILES ${AES_SRC} ${AES_PUBLIC_HEADERS})
|
||||
endif()
|
||||
|
||||
if(USE_ZLIB)
|
||||
add_definitions(-DHAVE_ZLIB)
|
||||
|
||||
list(APPEND MINIZIP_SRC "mz_strm_zlib.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_zlib.h")
|
||||
|
||||
include(CheckFunctionExists)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
|
||||
CHECK_FUNCTION_EXISTS(z_get_crc_table
|
||||
NEEDS_Z_PREFIX)
|
||||
|
||||
if(NEEDS_Z_PREFIX)
|
||||
add_definitions(-DZ_PREFIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_BZIP2)
|
||||
add_definitions(-DHAVE_BZIP2)
|
||||
add_definitions(-DBZ_NO_STDIO)
|
||||
|
||||
list(APPEND MINIZIP_SRC "mz_strm_bzip.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_bzip.h")
|
||||
|
||||
set(BZIP2_SRC
|
||||
lib/bzip2/blocksort.c
|
||||
lib/bzip2/bzlib.c
|
||||
lib/bzip2/compress.c
|
||||
lib/bzip2/crctable.c
|
||||
lib/bzip2/decompress.c
|
||||
lib/bzip2/huffman.c
|
||||
lib/bzip2/randtable.c)
|
||||
|
||||
set(BZIP2_PUBLIC_HEADERS
|
||||
lib/bzip2/bzlib.h
|
||||
lib/bzip2/bzlib_private.h)
|
||||
|
||||
include_directories(lib/bzip2)
|
||||
|
||||
source_group("BZip2" FILES ${BZIP2_SRC} ${BZIP2_PUBLIC_HEADERS})
|
||||
endif()
|
||||
|
||||
if(USE_LZMA)
|
||||
add_definitions(-DHAVE_LZMA)
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
add_definitions(-DLZMA_API_STATIC)
|
||||
|
||||
list(APPEND MINIZIP_SRC "mz_strm_lzma.c")
|
||||
list(APPEND MINIZIP_PUBLIC_HEADERS "mz_strm_lzma.h")
|
||||
|
||||
set(LZMA_CHECK_SRC
|
||||
lib/liblzma/check/check.c
|
||||
lib/liblzma/check/crc32_fast.c
|
||||
lib/liblzma/check/crc32_table.c)
|
||||
set(LZMA_COMMON_SRC
|
||||
lib/liblzma/common/alone_decoder.c
|
||||
lib/liblzma/common/alone_encoder.c
|
||||
lib/liblzma/common/common.c
|
||||
lib/liblzma/common/filter_encoder.c)
|
||||
set(LZMA_LZ_SRC
|
||||
lib/liblzma/lz/lz_decoder.c
|
||||
lib/liblzma/lz/lz_encoder.c
|
||||
lib/liblzma/lz/lz_encoder_mf.c)
|
||||
set(LZMA_LZMA_SRC
|
||||
lib/liblzma/lzma/fastpos.h
|
||||
lib/liblzma/lzma/fastpos_table.c
|
||||
lib/liblzma/lzma/lzma_decoder.c
|
||||
lib/liblzma/lzma/lzma_encoder.c
|
||||
lib/liblzma/lzma/lzma_encoder_optimum_fast.c
|
||||
lib/liblzma/lzma/lzma_encoder_optimum_normal.c
|
||||
lib/liblzma/lzma/lzma_encoder_presets.c)
|
||||
set(LZMA_RANGECODER_SRC
|
||||
lib/liblzma/rangecoder/price_table.c)
|
||||
|
||||
set(LZMA_CONFIG_HEADERS
|
||||
lib/liblzma/config.h)
|
||||
set(LZMA_API_HEADERS
|
||||
lib/liblzma/api/lzma.h
|
||||
lib/liblzma/api/lzma/base.h
|
||||
lib/liblzma/api/lzma/check.h
|
||||
lib/liblzma/api/lzma/container.h
|
||||
lib/liblzma/api/lzma/filter.h
|
||||
lib/liblzma/api/lzma/lzma12.h
|
||||
lib/liblzma/api/lzma/version.h
|
||||
lib/liblzma/api/lzma/vli.h)
|
||||
set(LZMA_CHECK_HEADERS
|
||||
lib/liblzma/check/check.h
|
||||
lib/liblzma/check/crc32_table_be.h
|
||||
lib/liblzma/check/crc32_table_le.h
|
||||
lib/liblzma/check/crc_macros.h)
|
||||
set(LZMA_COMMON_HEADERS
|
||||
lib/liblzma/common/alone_decoder.h
|
||||
lib/liblzma/common/common.h
|
||||
lib/liblzma/common/filter_encoder.h
|
||||
lib/liblzma/common/index.h
|
||||
lib/liblzma/common/memcmplen.h
|
||||
lib/liblzma/common/sysdefs.h
|
||||
lib/liblzma/common/tuklib_common.h
|
||||
lib/liblzma/common/tuklib_config.h
|
||||
lib/liblzma/common/tuklib_integer.h)
|
||||
set(LZMA_LZ_HEADERS
|
||||
lib/liblzma/lz/lz_decoder.h
|
||||
lib/liblzma/lz/lz_encoder.h
|
||||
lib/liblzma/lz/lz_encoder_hash.h
|
||||
lib/liblzma/lz/lz_encoder_hash_table.h)
|
||||
set(LZMA_LZMA_HEADERS
|
||||
lib/liblzma/lzma/lzma2_encoder.h
|
||||
lib/liblzma/lzma/lzma_common.h
|
||||
lib/liblzma/lzma/lzma_decoder.h
|
||||
lib/liblzma/lzma/lzma_encoder.h
|
||||
lib/liblzma/lzma/lzma_encoder_private.h)
|
||||
set(LZMA_RANGECODER_HEADERS
|
||||
lib/liblzma/rangecoder/price.h
|
||||
lib/liblzma/rangecoder/range_common.h
|
||||
lib/liblzma/rangecoder/range_decoder.h
|
||||
lib/liblzma/rangecoder/range_encoder.h)
|
||||
|
||||
set(LZMA_PUBLIC_HEADERS
|
||||
${LZMA_CONFIG_HEADERS}
|
||||
${LZMA_API_HEADERS}
|
||||
${LZMA_CHECK_HEADERS}
|
||||
${LZMA_COMMON_HEADERS}
|
||||
${LZMA_LZ_HEADERS}
|
||||
${LZMA_LZMA_HEADERS}
|
||||
${LZMA_RANGECODER_HEADERS})
|
||||
|
||||
set(LZMA_SRC
|
||||
${LZMA_CHECK_SRC}
|
||||
${LZMA_COMMON_SRC}
|
||||
${LZMA_LZ_SRC}
|
||||
${LZMA_LZMA_SRC}
|
||||
${LZMA_RANGECODER_SRC})
|
||||
|
||||
include_directories(lib/liblzma
|
||||
lib/liblzma/api
|
||||
lib/liblzma/check
|
||||
lib/liblzma/common
|
||||
lib/liblzma/lz
|
||||
lib/liblzma/lzma
|
||||
lib/liblzma/rangecoder)
|
||||
|
||||
source_group("LZMA" FILES ${LZMA_CONFIG_HEADERS})
|
||||
source_group("LZMA\\API" FILES ${LZMA_API_HEADERS})
|
||||
source_group("LZMA\\Check" FILES ${LZMA_CHECK_SRC} ${LZMA_CHECK_HEADERS})
|
||||
source_group("LZMA\\Common" FILES ${LZMA_COMMON_SRC} ${LZMA_COMMON_HEADERS})
|
||||
source_group("LZMA\\LZ" FILES ${LZMA_LZ_SRC} ${LZMA_LZ_HEADERS})
|
||||
source_group("LZMA\\LZMA" FILES ${LZMA_LZMA_SRC} ${LZMA_LZMA_HEADERS})
|
||||
source_group("LZMA\\RangeCoder" FILES ${LZMA_RANGECODER_SRC} ${LZMA_RANGECODER_HEADERS})
|
||||
endif()
|
||||
|
||||
# Enable x86 optimizations if supported
|
||||
if(CMAKE_C_COMPILER MATCHES ".*clang")
|
||||
include(CheckCCompilerFlag)
|
||||
macro(enable_option_if_supported option variable)
|
||||
check_c_compiler_flag("-Werror=unused-command-line-argument ${option}" ${variable})
|
||||
if(${variable})
|
||||
add_compile_options(${option})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
enable_option_if_supported(-msse3 check_opt_sse3)
|
||||
enable_option_if_supported(-msse4.1 check_opt_sse41)
|
||||
enable_option_if_supported(-maes check_opt_aes)
|
||||
endif()
|
||||
|
||||
# Create minizip library
|
||||
source_group("Minizip" FILES ${MINIZIP_SRC} ${MINIZIP_PUBLIC_HEADERS})
|
||||
|
||||
add_library(${PROJECT_NAME}
|
||||
${MINIZIP_SRC} ${MINIZIP_PUBLIC_HEADERS}
|
||||
${AES_SRC} ${AES_PUBLIC_HEADERS}
|
||||
${BZIP2_SRC} ${BZIP2_PUBLIC_HEADERS}
|
||||
${LZMA_SRC} ${LZMA_PUBLIC_HEADERS})
|
||||
|
||||
if (MINGW AND BUILD_SHARED_LIBS)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_NAME "minizip")
|
||||
endif ()
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE C PREFIX ""
|
||||
POSITION_INDEPENDENT_CODE 1)
|
||||
if(USE_ZLIB)
|
||||
target_link_libraries(${PROJECT_NAME} ZLIB::ZLIB)
|
||||
endif()
|
||||
if(USE_LZMA)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES C_STANDARD 99)
|
||||
endif()
|
||||
if(UNIX)
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBBSD_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:${INSTALL_INC_DIR}>)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
|
||||
INCLUDES DESTINATION "${INSTALL_INC_DIR}"
|
||||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
|
||||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}")
|
||||
|
||||
install(EXPORT ${PROJECT_NAME}
|
||||
DESTINATION "${INSTALL_CMAKE_DIR}"
|
||||
NAMESPACE "MINIZIP::")
|
||||
|
||||
install(FILES ${MINIZIP_PUBLIC_HEADERS} DESTINATION "${INSTALL_INC_DIR}")
|
||||
install(FILES ${MINIZIP_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
|
||||
|
||||
if(BUILD_TEST)
|
||||
add_executable(minizip "minizip.c")
|
||||
target_link_libraries(minizip ${PROJECT_NAME})
|
||||
|
||||
install(TARGETS minizip
|
||||
RUNTIME DESTINATION "bin")
|
||||
endif()
|
||||
17
game/client/third/minizip/LICENSE
Executable file
17
game/client/third/minizip/LICENSE
Executable file
@@ -0,0 +1,17 @@
|
||||
Condition of use and distribution are the same as zlib:
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgement in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
37
game/client/third/minizip/Minizip.podspec
Executable file
37
game/client/third/minizip/Minizip.podspec
Executable file
@@ -0,0 +1,37 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'Minizip'
|
||||
s.version = '2.3.3'
|
||||
s.license = 'zlib'
|
||||
s.summary = 'Minizip contrib in zlib with the latest bug fixes and advanced features'
|
||||
s.description = <<-DESC
|
||||
Minizip zlib contribution that includes:
|
||||
* AES encryption
|
||||
* I/O buffering
|
||||
* PKWARE disk splitting
|
||||
It also has the latest bug fixes that having been found all over the internet.
|
||||
DESC
|
||||
s.homepage = 'https://github.com/nmoinvaz/minizip'
|
||||
s.authors = 'Nathan Moinvaziri', 'Gilles Vollant'
|
||||
|
||||
s.source = { :git => 'https://github.com/nmoinvaz/minizip.git' }
|
||||
s.libraries = 'z'
|
||||
|
||||
s.subspec 'Core' do |sp|
|
||||
sp.source_files = '{mz_os,mz_compat,mz_strm,mz_strm_mem,mz_strm_buf,mz_zip,mz_strm_crypt,mz_strm_posix,mz_strm_zlib}.{c,h}'
|
||||
end
|
||||
|
||||
s.subspec 'AES' do |sp|
|
||||
sp.dependency 'Minizip/Core'
|
||||
sp.source_files = 'lib/aes/*.{c,h}', 'mz_strm_aes.{c,h}'
|
||||
end
|
||||
|
||||
s.subspec 'BZIP2' do |sp|
|
||||
sp.dependency 'Minizip/Core'
|
||||
sp.source_files = 'lib/bzip2/*.{c,h}', 'mz_strm_bzip.{c,h}'
|
||||
end
|
||||
|
||||
s.subspec 'LZMA' do |sp|
|
||||
sp.dependency 'Minizip/Core'
|
||||
sp.source_files = 'lib/liblzma/*.{c,h}', 'mz_strm_lzma.{c,h}'
|
||||
end
|
||||
end
|
||||
177
game/client/third/minizip/README.md
Executable file
177
game/client/third/minizip/README.md
Executable file
@@ -0,0 +1,177 @@
|
||||
# Minizip 2.3.3
|
||||
|
||||
This library is a refactoring of the minizip contribution found in the zlib distribution and is supported on Windows, macOS, and Linux. The motivation for this work has been the inclusion of advanced features, improvements in code maintainability and readability, and the reduction of duplicate code. It is based on the original work of [Gilles Vollant](http://www.winimage.com/zLibDll/minizip.html) that has been contributed to by many people over the years.
|
||||
|
||||
Dev: 
|
||||
Master: 
|
||||
|
||||
For my older fork of this library checkout the [1.2](https://github.com/nmoinvaz/minizip/tree/1.2) branch.
|
||||
For the original work maintained by Mark Adler checkout the zlib minizip [contrib](https://github.com/madler/zlib/tree/master/contrib/minizip).
|
||||
|
||||
## Build
|
||||
|
||||
To generate the project files for your platform and IDE download and run cmake in the project directory.
|
||||
|
||||
```
|
||||
cmake .
|
||||
cmake . -DBUILD_TEST=ON
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
## Build Options
|
||||
|
||||
| Name | Description | Default Value |
|
||||
|:- |:-|:-:|
|
||||
| USE_ZLIB | Enables ZLIB compression | ON |
|
||||
| USE_BZIP2 | Enables BZIP2 compression | ON |
|
||||
| USE_LZMA | Enables LZMA compression | ON |
|
||||
| USE_PKCRYPT | Enables PKWARE traditional encryption | ON |
|
||||
| USE_AES | Enables AES encryption | ON |
|
||||
| BUILD_TEST | Builds minizip test executable | OFF |
|
||||
|
||||
## Contents
|
||||
|
||||
| File(s) | Description | Required |
|
||||
|:- |:-|:-:|
|
||||
| minizip.c | Sample application | No |
|
||||
| mz_compat.\* | Minizip 1.0 compatibility layer | No |
|
||||
| mz.h | Error codes and flags | Yes |
|
||||
| mz_os\* | OS specific helper functions | Encryption, Disk Splitting |
|
||||
| mz_strm.\* | Stream interface | Yes |
|
||||
| mz_strm_aes.\* | WinZIP AES stream | No |
|
||||
| mz_strm_buf.\* | Buffered stream | No |
|
||||
| mz_strm_bzip.\* | BZIP2 stream using libbzip2 | No |
|
||||
| mz_strm_lzma.\* | LZMA stream using liblzma | zlib or liblzma |
|
||||
| mz_strm_mem.\* | Memory stream | Yes |
|
||||
| mz_strm_split.\* | Disk splitting stream | No |
|
||||
| mz_strm_pkcrypt.\* | PKWARE traditional encryption stream | No |
|
||||
| mz_strm_posix.\* | File stream using Posix functions | Non-windows systems |
|
||||
| mz_strm_win32.\* | File stream using Win32 API functions | Windows systems |
|
||||
| mz_strm_zlib.\* | Deflate stream using zlib | zlib or liblzma |
|
||||
| mz_zip.\* | Zip functionality | Yes |
|
||||
|
||||
## Features
|
||||
|
||||
### Compression Methods
|
||||
|
||||
#### BZIP2
|
||||
|
||||
+ Requires ``cmake . -DUSE_BZIP2=ON`` or ``#define HAVE_BZIP2``
|
||||
+ Requires [BZIP2](http://www.bzip.org/) library
|
||||
|
||||
#### LZMA
|
||||
|
||||
+ Requires ``cmake . -DUSE_LZMA=ON`` or ``#define HAVE_LZMA``
|
||||
+ Requires [liblzma](https://tukaani.org/xz/) library
|
||||
|
||||
### Encryption
|
||||
|
||||
#### [WinZIP AES Encryption](https://www.winzip.com/aes_info.htm)
|
||||
|
||||
+ Requires ``cmake . -DUSE_AES=ON`` or ``#define HAVE_AES``
|
||||
+ Requires Brian Gladman's [AES](https://github.com/BrianGladman/aes) and [SHA](https://github.com/BrianGladman/sha) libraries
|
||||
|
||||
When zipping with a password it will always use AES 256-bit encryption.
|
||||
When unzipping it will use AES decryption only if necessary.
|
||||
|
||||
#### Disabling All Encryption
|
||||
|
||||
To disable encryption use the following cmake commands:
|
||||
|
||||
```
|
||||
cmake . -DUSE_AES=OFF
|
||||
cmake . -DUSE_PKCRYPT=OFF
|
||||
```
|
||||
|
||||
### NTFS Timestamps
|
||||
|
||||
Support has been added for UTC last modified, last accessed, and creation dates.
|
||||
|
||||
### Streams
|
||||
|
||||
This library has been refactored around streams.
|
||||
|
||||
#### Memory Streaming
|
||||
|
||||
To unzip from a zip file in memory pass the memory stream to the open function.
|
||||
```
|
||||
uint8_t *zip_buffer = NULL;
|
||||
int32_t zip_buffer_size = 0;
|
||||
void *mem_stream = NULL;
|
||||
|
||||
// fill zip_buffer with zip contents
|
||||
mz_stream_mem_create(&mem_stream);
|
||||
mz_stream_mem_set_buffer(mem_stream, zip_buffer, zip_buffer_size);
|
||||
mz_stream_open(mem_stream, NULL, MZ_OPEN_MODE_READ);
|
||||
|
||||
void *zip_handle = mz_zip_open(mem_stream, MZ_OPEN_MODE_READ);
|
||||
// do unzip operations
|
||||
|
||||
mz_stream_mem_delete(&mem_stream);
|
||||
```
|
||||
|
||||
To create a zip file in memory first create a growable memory stream and pass it to the open function.
|
||||
|
||||
```
|
||||
void *mem_stream = NULL;
|
||||
|
||||
mz_stream_mem_create(&mem_stream);
|
||||
mz_stream_mem_set_grow_size(mem_stream, (128 * 1024));
|
||||
mz_stream_open(mem_stream, NULL, MZ_OPEN_MODE_CREATE);
|
||||
|
||||
void *zip_handle = mz_zip_open(mem_stream, MZ_OPEN_MODE_WRITE);
|
||||
// do unzip operations
|
||||
|
||||
mz_stream_mem_delete(&mem_stream);
|
||||
```
|
||||
|
||||
For a complete example, see test_zip_mem() in [test.c](https://github.com/nmoinvaz/minizip/blob/master/test/test.c).
|
||||
|
||||
#### Buffered Streaming
|
||||
|
||||
By default the library will read bytes typically one at a time. The buffered stream allows for buffered read and write operations to improve I/O performance.
|
||||
|
||||
```
|
||||
void *stream = NULL;
|
||||
void *buf_stream = NULL;
|
||||
|
||||
mz_stream_os_create(&stream)
|
||||
// do open os stream
|
||||
|
||||
mz_stream_buffered_create(&buf_stream);
|
||||
mz_stream_buffered_open(buf_stream, NULL, MZ_OPEN_MODE_READ);
|
||||
mz_stream_buffered_set_base(buf_stream, stream);
|
||||
|
||||
void *zip_handle = mz_zip_open(buf_stream, MZ_OPEN_MODE_READ);
|
||||
```
|
||||
|
||||
#### Disk Splitting Stream
|
||||
|
||||
To create an archive with multiple disks use the disk splitting stream and supply a disk size value in bytes.
|
||||
|
||||
```
|
||||
void *stream = NULL;
|
||||
void *split_stream = NULL;
|
||||
|
||||
mz_stream_os_create(&stream);
|
||||
|
||||
mz_stream_split_create(&split_stream);
|
||||
mz_stream_split_set_prop_int64(split_stream, MZ_STREAM_PROP_DISK_SIZE, 64 * 1024);
|
||||
|
||||
mz_stream_set_base(split_stream, stream);
|
||||
|
||||
mz_stream_open(split_stream, path..
|
||||
|
||||
void *zip_handle = mz_zip_open(split_stream, MZ_OPEN_MODE_WRITE);
|
||||
```
|
||||
|
||||
### Windows RT
|
||||
|
||||
+ Requires ``#define MZ_USE_WINRT_API``
|
||||
|
||||
## Limitations
|
||||
|
||||
+ Archives are required to have a central directory.
|
||||
+ Central directory header values should be correct and it is necessary for the compressed size to be accurate for AES encryption.
|
||||
+ Central directory encryption is not supported due to licensing restrictions mentioned by PKWARE in their zip appnote.
|
||||
+ Central directory is the only data stored on the last disk of a split-disk archive and doesn't follow disk size restrictions.
|
||||
270
game/client/third/minizip/lib/aes/aes.h
Executable file
270
game/client/third/minizip/lib/aes/aes.h
Executable file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This file contains the definitions required to use AES in C. See aesopt.h
|
||||
for optimisation details.
|
||||
*/
|
||||
|
||||
#ifndef _AES_H
|
||||
#define _AES_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/* This include is used to find 8 & 32 bit unsigned integer types */
|
||||
#include "brg_types.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define AES_128 /* if a fast 128 bit key scheduler is needed */
|
||||
#define AES_192 /* if a fast 192 bit key scheduler is needed */
|
||||
#define AES_256 /* if a fast 256 bit key scheduler is needed */
|
||||
#define AES_VAR /* if variable key size scheduler is needed */
|
||||
#define AES_MODES /* if support is needed for modes */
|
||||
|
||||
/* The following must also be set in assembler files if being used */
|
||||
|
||||
#define AES_ENCRYPT /* if support for encryption is needed */
|
||||
#define AES_DECRYPT /* if support for decryption is needed */
|
||||
|
||||
#define AES_BLOCK_SIZE 16 /* the AES block size in bytes */
|
||||
#define N_COLS 4 /* the number of columns in the state */
|
||||
|
||||
/* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */
|
||||
/* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */
|
||||
/* or 44, 52 or 60 32-bit words. */
|
||||
|
||||
#if defined( AES_VAR ) || defined( AES_256 )
|
||||
#define KS_LENGTH 60
|
||||
#elif defined( AES_192 )
|
||||
#define KS_LENGTH 52
|
||||
#else
|
||||
#define KS_LENGTH 44
|
||||
#endif
|
||||
|
||||
#define AES_RETURN INT_RETURN
|
||||
|
||||
/* the character array 'inf' in the following structures is used */
|
||||
/* to hold AES context information. This AES code uses cx->inf.b[0] */
|
||||
/* to hold the number of rounds multiplied by 16. The other three */
|
||||
/* elements can be used by code that implements additional modes */
|
||||
|
||||
typedef union
|
||||
{ uint32_t l;
|
||||
uint8_t b[4];
|
||||
} aes_inf;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( disable : 4324 )
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_WIN64)
|
||||
#define ALIGNED_(x) __declspec(align(x))
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
#define ALIGNED_(x) __attribute__ ((aligned(x)))
|
||||
#else
|
||||
#define ALIGNED_(x)
|
||||
#endif
|
||||
|
||||
typedef struct ALIGNED_(16)
|
||||
{ uint32_t ks[KS_LENGTH];
|
||||
aes_inf inf;
|
||||
} aes_encrypt_ctx;
|
||||
|
||||
typedef struct ALIGNED_(16)
|
||||
{ uint32_t ks[KS_LENGTH];
|
||||
aes_inf inf;
|
||||
} aes_decrypt_ctx;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( default : 4324 )
|
||||
#endif
|
||||
|
||||
/* This routine must be called before first use if non-static */
|
||||
/* tables are being used */
|
||||
|
||||
AES_RETURN aes_init(void);
|
||||
|
||||
/* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */
|
||||
/* those in the range 128 <= key_len <= 256 are given in bits */
|
||||
|
||||
#if defined( AES_ENCRYPT )
|
||||
|
||||
#if defined( AES_128 ) || defined( AES_VAR)
|
||||
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
#if defined( AES_192 ) || defined( AES_VAR)
|
||||
AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
#if defined( AES_256 ) || defined( AES_VAR)
|
||||
AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
#if defined( AES_VAR )
|
||||
AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_DECRYPT )
|
||||
|
||||
#if defined( AES_128 ) || defined( AES_VAR)
|
||||
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
#if defined( AES_192 ) || defined( AES_VAR)
|
||||
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
#if defined( AES_256 ) || defined( AES_VAR)
|
||||
AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
#if defined( AES_VAR )
|
||||
AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]);
|
||||
#endif
|
||||
|
||||
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_MODES )
|
||||
|
||||
/* Multiple calls to the following subroutines for multiple block */
|
||||
/* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */
|
||||
/* long messages incrementally provided that the context AND the iv */
|
||||
/* are preserved between all such calls. For the ECB and CBC modes */
|
||||
/* each individual call within a series of incremental calls must */
|
||||
/* process only full blocks (i.e. len must be a multiple of 16) but */
|
||||
/* the CFB, OFB and CTR mode calls can handle multiple incremental */
|
||||
/* calls of any length. Each mode is reset when a new AES key is */
|
||||
/* set but ECB needs no reset and CBC can be reset without setting */
|
||||
/* a new key by setting a new IV value. To reset CFB, OFB and CTR */
|
||||
/* without setting the key, aes_mode_reset() must be called and the */
|
||||
/* IV must be set. NOTE: All these calls update the IV on exit so */
|
||||
/* this has to be reset if a new operation with the same IV as the */
|
||||
/* previous one is required (or decryption follows encryption with */
|
||||
/* the same IV array). */
|
||||
|
||||
AES_RETURN aes_test_alignment_detection(unsigned int n);
|
||||
|
||||
AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, const aes_encrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, const aes_decrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, unsigned char *iv, const aes_encrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_cbc_decrypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, unsigned char *iv, const aes_decrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_mode_reset(aes_encrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_cfb_encrypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_cfb_decrypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
|
||||
|
||||
#define aes_ofb_encrypt aes_ofb_crypt
|
||||
#define aes_ofb_decrypt aes_ofb_crypt
|
||||
|
||||
AES_RETURN aes_ofb_crypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, unsigned char *iv, aes_encrypt_ctx cx[1]);
|
||||
|
||||
typedef void cbuf_inc(unsigned char *cbuf);
|
||||
|
||||
#define aes_ctr_encrypt aes_ctr_crypt
|
||||
#define aes_ctr_decrypt aes_ctr_crypt
|
||||
|
||||
AES_RETURN aes_ctr_crypt(const unsigned char *ibuf, unsigned char *obuf,
|
||||
int len, unsigned char *cbuf, cbuf_inc ctr_inc, aes_encrypt_ctx cx[1]);
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
# define ADD_AESNI_MODE_CALLS
|
||||
#endif
|
||||
|
||||
#if 0 && defined( ADD_AESNI_MODE_CALLS )
|
||||
# define USE_AES_CONTEXT
|
||||
#endif
|
||||
|
||||
#ifdef ADD_AESNI_MODE_CALLS
|
||||
# ifdef USE_AES_CONTEXT
|
||||
|
||||
AES_RETURN aes_CBC_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
unsigned char ivec[16],
|
||||
unsigned long length,
|
||||
const aes_encrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_CBC_decrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
unsigned char ivec[16],
|
||||
unsigned long length,
|
||||
const aes_decrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN AES_CTR_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
const unsigned char ivec[8],
|
||||
const unsigned char nonce[4],
|
||||
unsigned long length,
|
||||
const aes_encrypt_ctx cx[1]);
|
||||
|
||||
# else
|
||||
|
||||
void aes_CBC_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
unsigned char ivec[16],
|
||||
unsigned long length,
|
||||
unsigned char *key,
|
||||
int number_of_rounds);
|
||||
|
||||
void aes_CBC_decrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
unsigned char ivec[16],
|
||||
unsigned long length,
|
||||
unsigned char *key,
|
||||
int number_of_rounds);
|
||||
|
||||
void AES_CTR_encrypt(const unsigned char *in,
|
||||
unsigned char *out,
|
||||
const unsigned char ivec[8],
|
||||
const unsigned char nonce[4],
|
||||
unsigned long length,
|
||||
const unsigned char *key,
|
||||
int number_of_rounds);
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
301
game/client/third/minizip/lib/aes/aescrypt.c
Executable file
301
game/client/third/minizip/lib/aes/aescrypt.c
Executable file
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#include "aesopt.h"
|
||||
#include "aestab.h"
|
||||
|
||||
#if defined( USE_INTEL_AES_IF_PRESENT )
|
||||
# include "aes_ni.h"
|
||||
#else
|
||||
/* map names here to provide the external API ('name' -> 'aes_name') */
|
||||
# define aes_xi(x) aes_ ## x
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define si(y,x,k,c) (s(y,c) = word_in(x, c) ^ (k)[c])
|
||||
#define so(y,x,c) word_out(y, c, s(x,c))
|
||||
|
||||
#if defined(ARRAYS)
|
||||
#define locals(y,x) x[4],y[4]
|
||||
#else
|
||||
#define locals(y,x) x##0,x##1,x##2,x##3,y##0,y##1,y##2,y##3
|
||||
#endif
|
||||
|
||||
#define l_copy(y, x) s(y,0) = s(x,0); s(y,1) = s(x,1); \
|
||||
s(y,2) = s(x,2); s(y,3) = s(x,3);
|
||||
#define state_in(y,x,k) si(y,x,k,0); si(y,x,k,1); si(y,x,k,2); si(y,x,k,3)
|
||||
#define state_out(y,x) so(y,x,0); so(y,x,1); so(y,x,2); so(y,x,3)
|
||||
#define round(rm,y,x,k) rm(y,x,k,0); rm(y,x,k,1); rm(y,x,k,2); rm(y,x,k,3)
|
||||
|
||||
#if ( FUNCS_IN_C & ENCRYPTION_IN_C )
|
||||
|
||||
/* Visual C++ .Net v7.1 provides the fastest encryption code when using
|
||||
Pentium optimiation with small code but this is poor for decryption
|
||||
so we need to control this with the following VC++ pragmas
|
||||
*/
|
||||
|
||||
#if defined( _MSC_VER ) && !defined( _WIN64 )
|
||||
#pragma optimize( "s", on )
|
||||
#endif
|
||||
|
||||
/* Given the column (c) of the output state variable, the following
|
||||
macros give the input state variables which are needed in its
|
||||
computation for each row (r) of the state. All the alternative
|
||||
macros give the same end values but expand into different ways
|
||||
of calculating these values. In particular the complex macro
|
||||
used for dynamically variable block sizes is designed to expand
|
||||
to a compile time constant whenever possible but will expand to
|
||||
conditional clauses on some branches (I am grateful to Frank
|
||||
Yellin for this construction)
|
||||
*/
|
||||
|
||||
#define fwd_var(x,r,c)\
|
||||
( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
|
||||
: r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\
|
||||
: r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
|
||||
: ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2)))
|
||||
|
||||
#if defined(FT4_SET)
|
||||
#undef dec_fmvars
|
||||
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c))
|
||||
#elif defined(FT1_SET)
|
||||
#undef dec_fmvars
|
||||
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c))
|
||||
#else
|
||||
#define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c)))
|
||||
#endif
|
||||
|
||||
#if defined(FL4_SET)
|
||||
#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c))
|
||||
#elif defined(FL1_SET)
|
||||
#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c))
|
||||
#else
|
||||
#define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c))
|
||||
#endif
|
||||
|
||||
AES_RETURN aes_xi(encrypt)(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1])
|
||||
{ uint32_t locals(b0, b1);
|
||||
const uint32_t *kp;
|
||||
#if defined( dec_fmvars )
|
||||
dec_fmvars; /* declare variables for fwd_mcol() if needed */
|
||||
#endif
|
||||
|
||||
if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
kp = cx->ks;
|
||||
state_in(b0, in, kp);
|
||||
|
||||
#if (ENC_UNROLL == FULL)
|
||||
|
||||
switch(cx->inf.b[0])
|
||||
{
|
||||
case 14 * 16:
|
||||
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
|
||||
kp += 2 * N_COLS;
|
||||
case 12 * 16:
|
||||
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
|
||||
kp += 2 * N_COLS;
|
||||
case 10 * 16:
|
||||
round(fwd_rnd, b1, b0, kp + 1 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 2 * N_COLS);
|
||||
round(fwd_rnd, b1, b0, kp + 3 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 4 * N_COLS);
|
||||
round(fwd_rnd, b1, b0, kp + 5 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 6 * N_COLS);
|
||||
round(fwd_rnd, b1, b0, kp + 7 * N_COLS);
|
||||
round(fwd_rnd, b0, b1, kp + 8 * N_COLS);
|
||||
round(fwd_rnd, b1, b0, kp + 9 * N_COLS);
|
||||
round(fwd_lrnd, b0, b1, kp +10 * N_COLS);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if (ENC_UNROLL == PARTIAL)
|
||||
{ uint32_t rnd;
|
||||
for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
|
||||
{
|
||||
kp += N_COLS;
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
kp += N_COLS;
|
||||
round(fwd_rnd, b0, b1, kp);
|
||||
}
|
||||
kp += N_COLS;
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
#else
|
||||
{ uint32_t rnd;
|
||||
for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
|
||||
{
|
||||
kp += N_COLS;
|
||||
round(fwd_rnd, b1, b0, kp);
|
||||
l_copy(b0, b1);
|
||||
}
|
||||
#endif
|
||||
kp += N_COLS;
|
||||
round(fwd_lrnd, b0, b1, kp);
|
||||
}
|
||||
#endif
|
||||
|
||||
state_out(out, b0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ( FUNCS_IN_C & DECRYPTION_IN_C)
|
||||
|
||||
/* Visual C++ .Net v7.1 provides the fastest encryption code when using
|
||||
Pentium optimiation with small code but this is poor for decryption
|
||||
so we need to control this with the following VC++ pragmas
|
||||
*/
|
||||
|
||||
#if defined( _MSC_VER ) && !defined( _WIN64 )
|
||||
#pragma optimize( "t", on )
|
||||
#endif
|
||||
|
||||
/* Given the column (c) of the output state variable, the following
|
||||
macros give the input state variables which are needed in its
|
||||
computation for each row (r) of the state. All the alternative
|
||||
macros give the same end values but expand into different ways
|
||||
of calculating these values. In particular the complex macro
|
||||
used for dynamically variable block sizes is designed to expand
|
||||
to a compile time constant whenever possible but will expand to
|
||||
conditional clauses on some branches (I am grateful to Frank
|
||||
Yellin for this construction)
|
||||
*/
|
||||
|
||||
#define inv_var(x,r,c)\
|
||||
( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\
|
||||
: r == 1 ? ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))\
|
||||
: r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\
|
||||
: ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0)))
|
||||
|
||||
#if defined(IT4_SET)
|
||||
#undef dec_imvars
|
||||
#define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,n),inv_var,rf1,c))
|
||||
#elif defined(IT1_SET)
|
||||
#undef dec_imvars
|
||||
#define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c))
|
||||
#else
|
||||
#define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)))
|
||||
#endif
|
||||
|
||||
#if defined(IL4_SET)
|
||||
#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c))
|
||||
#elif defined(IL1_SET)
|
||||
#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c))
|
||||
#else
|
||||
#define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))
|
||||
#endif
|
||||
|
||||
/* This code can work with the decryption key schedule in the */
|
||||
/* order that is used for encrytpion (where the 1st decryption */
|
||||
/* round key is at the high end ot the schedule) or with a key */
|
||||
/* schedule that has been reversed to put the 1st decryption */
|
||||
/* round key at the low end of the schedule in memory (when */
|
||||
/* AES_REV_DKS is defined) */
|
||||
|
||||
#ifdef AES_REV_DKS
|
||||
#define key_ofs 0
|
||||
#define rnd_key(n) (kp + n * N_COLS)
|
||||
#else
|
||||
#define key_ofs 1
|
||||
#define rnd_key(n) (kp - n * N_COLS)
|
||||
#endif
|
||||
|
||||
AES_RETURN aes_xi(decrypt)(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1])
|
||||
{ uint32_t locals(b0, b1);
|
||||
#if defined( dec_imvars )
|
||||
dec_imvars; /* declare variables for inv_mcol() if needed */
|
||||
#endif
|
||||
const uint32_t *kp;
|
||||
|
||||
if(cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0);
|
||||
state_in(b0, in, kp);
|
||||
|
||||
#if (DEC_UNROLL == FULL)
|
||||
|
||||
kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2));
|
||||
switch(cx->inf.b[0])
|
||||
{
|
||||
case 14 * 16:
|
||||
round(inv_rnd, b1, b0, rnd_key(-13));
|
||||
round(inv_rnd, b0, b1, rnd_key(-12));
|
||||
case 12 * 16:
|
||||
round(inv_rnd, b1, b0, rnd_key(-11));
|
||||
round(inv_rnd, b0, b1, rnd_key(-10));
|
||||
case 10 * 16:
|
||||
round(inv_rnd, b1, b0, rnd_key(-9));
|
||||
round(inv_rnd, b0, b1, rnd_key(-8));
|
||||
round(inv_rnd, b1, b0, rnd_key(-7));
|
||||
round(inv_rnd, b0, b1, rnd_key(-6));
|
||||
round(inv_rnd, b1, b0, rnd_key(-5));
|
||||
round(inv_rnd, b0, b1, rnd_key(-4));
|
||||
round(inv_rnd, b1, b0, rnd_key(-3));
|
||||
round(inv_rnd, b0, b1, rnd_key(-2));
|
||||
round(inv_rnd, b1, b0, rnd_key(-1));
|
||||
round(inv_lrnd, b0, b1, rnd_key( 0));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if (DEC_UNROLL == PARTIAL)
|
||||
{ uint32_t rnd;
|
||||
for(rnd = 0; rnd < (cx->inf.b[0] >> 5) - 1; ++rnd)
|
||||
{
|
||||
kp = rnd_key(1);
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
kp = rnd_key(1);
|
||||
round(inv_rnd, b0, b1, kp);
|
||||
}
|
||||
kp = rnd_key(1);
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
#else
|
||||
{ uint32_t rnd;
|
||||
for(rnd = 0; rnd < (cx->inf.b[0] >> 4) - 1; ++rnd)
|
||||
{
|
||||
kp = rnd_key(1);
|
||||
round(inv_rnd, b1, b0, kp);
|
||||
l_copy(b0, b1);
|
||||
}
|
||||
#endif
|
||||
kp = rnd_key(1);
|
||||
round(inv_lrnd, b0, b1, kp);
|
||||
}
|
||||
#endif
|
||||
|
||||
state_out(out, b0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
554
game/client/third/minizip/lib/aes/aeskey.c
Executable file
554
game/client/third/minizip/lib/aes/aeskey.c
Executable file
@@ -0,0 +1,554 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#include "aesopt.h"
|
||||
#include "aestab.h"
|
||||
|
||||
#if defined( USE_INTEL_AES_IF_PRESENT )
|
||||
# include "aes_ni.h"
|
||||
#else
|
||||
/* map names here to provide the external API ('name' -> 'aes_name') */
|
||||
# define aes_xi(x) aes_ ## x
|
||||
#endif
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
# include "aes_via_ace.h"
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Initialise the key schedule from the user supplied key. The key
|
||||
length can be specified in bytes, with legal values of 16, 24
|
||||
and 32, or in bits, with legal values of 128, 192 and 256. These
|
||||
values correspond with Nk values of 4, 6 and 8 respectively.
|
||||
|
||||
The following macros implement a single cycle in the key
|
||||
schedule generation process. The number of cycles needed
|
||||
for each cx->n_col and nk value is:
|
||||
|
||||
nk = 4 5 6 7 8
|
||||
------------------------------
|
||||
cx->n_col = 4 10 9 8 7 7
|
||||
cx->n_col = 5 14 11 10 9 9
|
||||
cx->n_col = 6 19 15 12 11 11
|
||||
cx->n_col = 7 21 19 16 13 14
|
||||
cx->n_col = 8 29 23 19 17 14
|
||||
*/
|
||||
|
||||
#if defined( REDUCE_CODE_SIZE )
|
||||
# define ls_box ls_sub
|
||||
uint32_t ls_sub(const uint32_t t, const uint32_t n);
|
||||
# define inv_mcol im_sub
|
||||
uint32_t im_sub(const uint32_t x);
|
||||
# ifdef ENC_KS_UNROLL
|
||||
# undef ENC_KS_UNROLL
|
||||
# endif
|
||||
# ifdef DEC_KS_UNROLL
|
||||
# undef DEC_KS_UNROLL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (FUNCS_IN_C & ENC_KEYING_IN_C)
|
||||
|
||||
#if defined(AES_128) || defined( AES_VAR )
|
||||
|
||||
#define ke4(k,i) \
|
||||
{ k[4*(i)+4] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \
|
||||
k[4*(i)+5] = ss[1] ^= ss[0]; \
|
||||
k[4*(i)+6] = ss[2] ^= ss[1]; \
|
||||
k[4*(i)+7] = ss[3] ^= ss[2]; \
|
||||
}
|
||||
|
||||
AES_RETURN aes_xi(encrypt_key128)(const unsigned char *key, aes_encrypt_ctx cx[1])
|
||||
{ uint32_t ss[4];
|
||||
|
||||
cx->ks[0] = ss[0] = word_in(key, 0);
|
||||
cx->ks[1] = ss[1] = word_in(key, 1);
|
||||
cx->ks[2] = ss[2] = word_in(key, 2);
|
||||
cx->ks[3] = ss[3] = word_in(key, 3);
|
||||
|
||||
#ifdef ENC_KS_UNROLL
|
||||
ke4(cx->ks, 0); ke4(cx->ks, 1);
|
||||
ke4(cx->ks, 2); ke4(cx->ks, 3);
|
||||
ke4(cx->ks, 4); ke4(cx->ks, 5);
|
||||
ke4(cx->ks, 6); ke4(cx->ks, 7);
|
||||
ke4(cx->ks, 8);
|
||||
#else
|
||||
{ uint32_t i;
|
||||
for(i = 0; i < 9; ++i)
|
||||
ke4(cx->ks, i);
|
||||
}
|
||||
#endif
|
||||
ke4(cx->ks, 9);
|
||||
cx->inf.l = 0;
|
||||
cx->inf.b[0] = 10 * 16;
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
if(VIA_ACE_AVAILABLE)
|
||||
cx->inf.b[1] = 0xff;
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(AES_192) || defined( AES_VAR )
|
||||
|
||||
#define kef6(k,i) \
|
||||
{ k[6*(i)+ 6] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \
|
||||
k[6*(i)+ 7] = ss[1] ^= ss[0]; \
|
||||
k[6*(i)+ 8] = ss[2] ^= ss[1]; \
|
||||
k[6*(i)+ 9] = ss[3] ^= ss[2]; \
|
||||
}
|
||||
|
||||
#define ke6(k,i) \
|
||||
{ kef6(k,i); \
|
||||
k[6*(i)+10] = ss[4] ^= ss[3]; \
|
||||
k[6*(i)+11] = ss[5] ^= ss[4]; \
|
||||
}
|
||||
|
||||
AES_RETURN aes_xi(encrypt_key192)(const unsigned char *key, aes_encrypt_ctx cx[1])
|
||||
{ uint32_t ss[6];
|
||||
|
||||
cx->ks[0] = ss[0] = word_in(key, 0);
|
||||
cx->ks[1] = ss[1] = word_in(key, 1);
|
||||
cx->ks[2] = ss[2] = word_in(key, 2);
|
||||
cx->ks[3] = ss[3] = word_in(key, 3);
|
||||
cx->ks[4] = ss[4] = word_in(key, 4);
|
||||
cx->ks[5] = ss[5] = word_in(key, 5);
|
||||
|
||||
#ifdef ENC_KS_UNROLL
|
||||
ke6(cx->ks, 0); ke6(cx->ks, 1);
|
||||
ke6(cx->ks, 2); ke6(cx->ks, 3);
|
||||
ke6(cx->ks, 4); ke6(cx->ks, 5);
|
||||
ke6(cx->ks, 6);
|
||||
#else
|
||||
{ uint32_t i;
|
||||
for(i = 0; i < 7; ++i)
|
||||
ke6(cx->ks, i);
|
||||
}
|
||||
#endif
|
||||
kef6(cx->ks, 7);
|
||||
cx->inf.l = 0;
|
||||
cx->inf.b[0] = 12 * 16;
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
if(VIA_ACE_AVAILABLE)
|
||||
cx->inf.b[1] = 0xff;
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(AES_256) || defined( AES_VAR )
|
||||
|
||||
#define kef8(k,i) \
|
||||
{ k[8*(i)+ 8] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \
|
||||
k[8*(i)+ 9] = ss[1] ^= ss[0]; \
|
||||
k[8*(i)+10] = ss[2] ^= ss[1]; \
|
||||
k[8*(i)+11] = ss[3] ^= ss[2]; \
|
||||
}
|
||||
|
||||
#define ke8(k,i) \
|
||||
{ kef8(k,i); \
|
||||
k[8*(i)+12] = ss[4] ^= ls_box(ss[3],0); \
|
||||
k[8*(i)+13] = ss[5] ^= ss[4]; \
|
||||
k[8*(i)+14] = ss[6] ^= ss[5]; \
|
||||
k[8*(i)+15] = ss[7] ^= ss[6]; \
|
||||
}
|
||||
|
||||
AES_RETURN aes_xi(encrypt_key256)(const unsigned char *key, aes_encrypt_ctx cx[1])
|
||||
{ uint32_t ss[8];
|
||||
|
||||
cx->ks[0] = ss[0] = word_in(key, 0);
|
||||
cx->ks[1] = ss[1] = word_in(key, 1);
|
||||
cx->ks[2] = ss[2] = word_in(key, 2);
|
||||
cx->ks[3] = ss[3] = word_in(key, 3);
|
||||
cx->ks[4] = ss[4] = word_in(key, 4);
|
||||
cx->ks[5] = ss[5] = word_in(key, 5);
|
||||
cx->ks[6] = ss[6] = word_in(key, 6);
|
||||
cx->ks[7] = ss[7] = word_in(key, 7);
|
||||
|
||||
#ifdef ENC_KS_UNROLL
|
||||
ke8(cx->ks, 0); ke8(cx->ks, 1);
|
||||
ke8(cx->ks, 2); ke8(cx->ks, 3);
|
||||
ke8(cx->ks, 4); ke8(cx->ks, 5);
|
||||
#else
|
||||
{ uint32_t i;
|
||||
for(i = 0; i < 6; ++i)
|
||||
ke8(cx->ks, i);
|
||||
}
|
||||
#endif
|
||||
kef8(cx->ks, 6);
|
||||
cx->inf.l = 0;
|
||||
cx->inf.b[0] = 14 * 16;
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
if(VIA_ACE_AVAILABLE)
|
||||
cx->inf.b[1] = 0xff;
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (FUNCS_IN_C & DEC_KEYING_IN_C)
|
||||
|
||||
/* this is used to store the decryption round keys */
|
||||
/* in forward or reverse order */
|
||||
|
||||
#ifdef AES_REV_DKS
|
||||
#define v(n,i) ((n) - (i) + 2 * ((i) & 3))
|
||||
#else
|
||||
#define v(n,i) (i)
|
||||
#endif
|
||||
|
||||
#if DEC_ROUND == NO_TABLES
|
||||
#define ff(x) (x)
|
||||
#else
|
||||
#define ff(x) inv_mcol(x)
|
||||
#if defined( dec_imvars )
|
||||
#define d_vars dec_imvars
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(AES_128) || defined( AES_VAR )
|
||||
|
||||
#define k4e(k,i) \
|
||||
{ k[v(40,(4*(i))+4)] = ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; \
|
||||
k[v(40,(4*(i))+5)] = ss[1] ^= ss[0]; \
|
||||
k[v(40,(4*(i))+6)] = ss[2] ^= ss[1]; \
|
||||
k[v(40,(4*(i))+7)] = ss[3] ^= ss[2]; \
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
||||
#define kdf4(k,i) \
|
||||
{ ss[0] = ss[0] ^ ss[2] ^ ss[1] ^ ss[3]; \
|
||||
ss[1] = ss[1] ^ ss[3]; \
|
||||
ss[2] = ss[2] ^ ss[3]; \
|
||||
ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \
|
||||
ss[i % 4] ^= ss[4]; \
|
||||
ss[4] ^= k[v(40,(4*(i)))]; k[v(40,(4*(i))+4)] = ff(ss[4]); \
|
||||
ss[4] ^= k[v(40,(4*(i))+1)]; k[v(40,(4*(i))+5)] = ff(ss[4]); \
|
||||
ss[4] ^= k[v(40,(4*(i))+2)]; k[v(40,(4*(i))+6)] = ff(ss[4]); \
|
||||
ss[4] ^= k[v(40,(4*(i))+3)]; k[v(40,(4*(i))+7)] = ff(ss[4]); \
|
||||
}
|
||||
|
||||
#define kd4(k,i) \
|
||||
{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; \
|
||||
ss[i % 4] ^= ss[4]; ss[4] = ff(ss[4]); \
|
||||
k[v(40,(4*(i))+4)] = ss[4] ^= k[v(40,(4*(i)))]; \
|
||||
k[v(40,(4*(i))+5)] = ss[4] ^= k[v(40,(4*(i))+1)]; \
|
||||
k[v(40,(4*(i))+6)] = ss[4] ^= k[v(40,(4*(i))+2)]; \
|
||||
k[v(40,(4*(i))+7)] = ss[4] ^= k[v(40,(4*(i))+3)]; \
|
||||
}
|
||||
|
||||
#define kdl4(k,i) \
|
||||
{ ss[4] = ls_box(ss[(i+3) % 4], 3) ^ t_use(r,c)[i]; ss[i % 4] ^= ss[4]; \
|
||||
k[v(40,(4*(i))+4)] = (ss[0] ^= ss[1]) ^ ss[2] ^ ss[3]; \
|
||||
k[v(40,(4*(i))+5)] = ss[1] ^ ss[3]; \
|
||||
k[v(40,(4*(i))+6)] = ss[0]; \
|
||||
k[v(40,(4*(i))+7)] = ss[1]; \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define kdf4(k,i) \
|
||||
{ ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ff(ss[0]); \
|
||||
ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ff(ss[1]); \
|
||||
ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ff(ss[2]); \
|
||||
ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ff(ss[3]); \
|
||||
}
|
||||
|
||||
#define kd4(k,i) \
|
||||
{ ss[4] = ls_box(ss[3],3) ^ t_use(r,c)[i]; \
|
||||
ss[0] ^= ss[4]; ss[4] = ff(ss[4]); k[v(40,(4*(i))+ 4)] = ss[4] ^= k[v(40,(4*(i)))]; \
|
||||
ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[4] ^= k[v(40,(4*(i))+ 1)]; \
|
||||
ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[4] ^= k[v(40,(4*(i))+ 2)]; \
|
||||
ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[4] ^= k[v(40,(4*(i))+ 3)]; \
|
||||
}
|
||||
|
||||
#define kdl4(k,i) \
|
||||
{ ss[0] ^= ls_box(ss[3],3) ^ t_use(r,c)[i]; k[v(40,(4*(i))+ 4)] = ss[0]; \
|
||||
ss[1] ^= ss[0]; k[v(40,(4*(i))+ 5)] = ss[1]; \
|
||||
ss[2] ^= ss[1]; k[v(40,(4*(i))+ 6)] = ss[2]; \
|
||||
ss[3] ^= ss[2]; k[v(40,(4*(i))+ 7)] = ss[3]; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
AES_RETURN aes_xi(decrypt_key128)(const unsigned char *key, aes_decrypt_ctx cx[1])
|
||||
{ uint32_t ss[5];
|
||||
#if defined( d_vars )
|
||||
d_vars;
|
||||
#endif
|
||||
|
||||
cx->ks[v(40,(0))] = ss[0] = word_in(key, 0);
|
||||
cx->ks[v(40,(1))] = ss[1] = word_in(key, 1);
|
||||
cx->ks[v(40,(2))] = ss[2] = word_in(key, 2);
|
||||
cx->ks[v(40,(3))] = ss[3] = word_in(key, 3);
|
||||
|
||||
#ifdef DEC_KS_UNROLL
|
||||
kdf4(cx->ks, 0); kd4(cx->ks, 1);
|
||||
kd4(cx->ks, 2); kd4(cx->ks, 3);
|
||||
kd4(cx->ks, 4); kd4(cx->ks, 5);
|
||||
kd4(cx->ks, 6); kd4(cx->ks, 7);
|
||||
kd4(cx->ks, 8); kdl4(cx->ks, 9);
|
||||
#else
|
||||
{ uint32_t i;
|
||||
for(i = 0; i < 10; ++i)
|
||||
k4e(cx->ks, i);
|
||||
#if !(DEC_ROUND == NO_TABLES)
|
||||
for(i = N_COLS; i < 10 * N_COLS; ++i)
|
||||
cx->ks[i] = inv_mcol(cx->ks[i]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
cx->inf.l = 0;
|
||||
cx->inf.b[0] = 10 * 16;
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
if(VIA_ACE_AVAILABLE)
|
||||
cx->inf.b[1] = 0xff;
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(AES_192) || defined( AES_VAR )
|
||||
|
||||
#define k6ef(k,i) \
|
||||
{ k[v(48,(6*(i))+ 6)] = ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; \
|
||||
k[v(48,(6*(i))+ 7)] = ss[1] ^= ss[0]; \
|
||||
k[v(48,(6*(i))+ 8)] = ss[2] ^= ss[1]; \
|
||||
k[v(48,(6*(i))+ 9)] = ss[3] ^= ss[2]; \
|
||||
}
|
||||
|
||||
#define k6e(k,i) \
|
||||
{ k6ef(k,i); \
|
||||
k[v(48,(6*(i))+10)] = ss[4] ^= ss[3]; \
|
||||
k[v(48,(6*(i))+11)] = ss[5] ^= ss[4]; \
|
||||
}
|
||||
|
||||
#define kdf6(k,i) \
|
||||
{ ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ff(ss[0]); \
|
||||
ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ff(ss[1]); \
|
||||
ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ff(ss[2]); \
|
||||
ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ff(ss[3]); \
|
||||
ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ff(ss[4]); \
|
||||
ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ff(ss[5]); \
|
||||
}
|
||||
|
||||
#define kd6(k,i) \
|
||||
{ ss[6] = ls_box(ss[5],3) ^ t_use(r,c)[i]; \
|
||||
ss[0] ^= ss[6]; ss[6] = ff(ss[6]); k[v(48,(6*(i))+ 6)] = ss[6] ^= k[v(48,(6*(i)))]; \
|
||||
ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[6] ^= k[v(48,(6*(i))+ 1)]; \
|
||||
ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[6] ^= k[v(48,(6*(i))+ 2)]; \
|
||||
ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[6] ^= k[v(48,(6*(i))+ 3)]; \
|
||||
ss[4] ^= ss[3]; k[v(48,(6*(i))+10)] = ss[6] ^= k[v(48,(6*(i))+ 4)]; \
|
||||
ss[5] ^= ss[4]; k[v(48,(6*(i))+11)] = ss[6] ^= k[v(48,(6*(i))+ 5)]; \
|
||||
}
|
||||
|
||||
#define kdl6(k,i) \
|
||||
{ ss[0] ^= ls_box(ss[5],3) ^ t_use(r,c)[i]; k[v(48,(6*(i))+ 6)] = ss[0]; \
|
||||
ss[1] ^= ss[0]; k[v(48,(6*(i))+ 7)] = ss[1]; \
|
||||
ss[2] ^= ss[1]; k[v(48,(6*(i))+ 8)] = ss[2]; \
|
||||
ss[3] ^= ss[2]; k[v(48,(6*(i))+ 9)] = ss[3]; \
|
||||
}
|
||||
|
||||
AES_RETURN aes_xi(decrypt_key192)(const unsigned char *key, aes_decrypt_ctx cx[1])
|
||||
{ uint32_t ss[7];
|
||||
#if defined( d_vars )
|
||||
d_vars;
|
||||
#endif
|
||||
|
||||
cx->ks[v(48,(0))] = ss[0] = word_in(key, 0);
|
||||
cx->ks[v(48,(1))] = ss[1] = word_in(key, 1);
|
||||
cx->ks[v(48,(2))] = ss[2] = word_in(key, 2);
|
||||
cx->ks[v(48,(3))] = ss[3] = word_in(key, 3);
|
||||
|
||||
#ifdef DEC_KS_UNROLL
|
||||
cx->ks[v(48,(4))] = ff(ss[4] = word_in(key, 4));
|
||||
cx->ks[v(48,(5))] = ff(ss[5] = word_in(key, 5));
|
||||
kdf6(cx->ks, 0); kd6(cx->ks, 1);
|
||||
kd6(cx->ks, 2); kd6(cx->ks, 3);
|
||||
kd6(cx->ks, 4); kd6(cx->ks, 5);
|
||||
kd6(cx->ks, 6); kdl6(cx->ks, 7);
|
||||
#else
|
||||
cx->ks[v(48,(4))] = ss[4] = word_in(key, 4);
|
||||
cx->ks[v(48,(5))] = ss[5] = word_in(key, 5);
|
||||
{ uint32_t i;
|
||||
|
||||
for(i = 0; i < 7; ++i)
|
||||
k6e(cx->ks, i);
|
||||
k6ef(cx->ks, 7);
|
||||
#if !(DEC_ROUND == NO_TABLES)
|
||||
for(i = N_COLS; i < 12 * N_COLS; ++i)
|
||||
cx->ks[i] = inv_mcol(cx->ks[i]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
cx->inf.l = 0;
|
||||
cx->inf.b[0] = 12 * 16;
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
if(VIA_ACE_AVAILABLE)
|
||||
cx->inf.b[1] = 0xff;
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(AES_256) || defined( AES_VAR )
|
||||
|
||||
#define k8ef(k,i) \
|
||||
{ k[v(56,(8*(i))+ 8)] = ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; \
|
||||
k[v(56,(8*(i))+ 9)] = ss[1] ^= ss[0]; \
|
||||
k[v(56,(8*(i))+10)] = ss[2] ^= ss[1]; \
|
||||
k[v(56,(8*(i))+11)] = ss[3] ^= ss[2]; \
|
||||
}
|
||||
|
||||
#define k8e(k,i) \
|
||||
{ k8ef(k,i); \
|
||||
k[v(56,(8*(i))+12)] = ss[4] ^= ls_box(ss[3],0); \
|
||||
k[v(56,(8*(i))+13)] = ss[5] ^= ss[4]; \
|
||||
k[v(56,(8*(i))+14)] = ss[6] ^= ss[5]; \
|
||||
k[v(56,(8*(i))+15)] = ss[7] ^= ss[6]; \
|
||||
}
|
||||
|
||||
#define kdf8(k,i) \
|
||||
{ ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ff(ss[0]); \
|
||||
ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ff(ss[1]); \
|
||||
ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ff(ss[2]); \
|
||||
ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ff(ss[3]); \
|
||||
ss[4] ^= ls_box(ss[3],0); k[v(56,(8*(i))+12)] = ff(ss[4]); \
|
||||
ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ff(ss[5]); \
|
||||
ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ff(ss[6]); \
|
||||
ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ff(ss[7]); \
|
||||
}
|
||||
|
||||
#define kd8(k,i) \
|
||||
{ ss[8] = ls_box(ss[7],3) ^ t_use(r,c)[i]; \
|
||||
ss[0] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+ 8)] = ss[8] ^= k[v(56,(8*(i)))]; \
|
||||
ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[8] ^= k[v(56,(8*(i))+ 1)]; \
|
||||
ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[8] ^= k[v(56,(8*(i))+ 2)]; \
|
||||
ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[8] ^= k[v(56,(8*(i))+ 3)]; \
|
||||
ss[8] = ls_box(ss[3],0); \
|
||||
ss[4] ^= ss[8]; ss[8] = ff(ss[8]); k[v(56,(8*(i))+12)] = ss[8] ^= k[v(56,(8*(i))+ 4)]; \
|
||||
ss[5] ^= ss[4]; k[v(56,(8*(i))+13)] = ss[8] ^= k[v(56,(8*(i))+ 5)]; \
|
||||
ss[6] ^= ss[5]; k[v(56,(8*(i))+14)] = ss[8] ^= k[v(56,(8*(i))+ 6)]; \
|
||||
ss[7] ^= ss[6]; k[v(56,(8*(i))+15)] = ss[8] ^= k[v(56,(8*(i))+ 7)]; \
|
||||
}
|
||||
|
||||
#define kdl8(k,i) \
|
||||
{ ss[0] ^= ls_box(ss[7],3) ^ t_use(r,c)[i]; k[v(56,(8*(i))+ 8)] = ss[0]; \
|
||||
ss[1] ^= ss[0]; k[v(56,(8*(i))+ 9)] = ss[1]; \
|
||||
ss[2] ^= ss[1]; k[v(56,(8*(i))+10)] = ss[2]; \
|
||||
ss[3] ^= ss[2]; k[v(56,(8*(i))+11)] = ss[3]; \
|
||||
}
|
||||
|
||||
AES_RETURN aes_xi(decrypt_key256)(const unsigned char *key, aes_decrypt_ctx cx[1])
|
||||
{ uint32_t ss[9];
|
||||
#if defined( d_vars )
|
||||
d_vars;
|
||||
#endif
|
||||
|
||||
cx->ks[v(56,(0))] = ss[0] = word_in(key, 0);
|
||||
cx->ks[v(56,(1))] = ss[1] = word_in(key, 1);
|
||||
cx->ks[v(56,(2))] = ss[2] = word_in(key, 2);
|
||||
cx->ks[v(56,(3))] = ss[3] = word_in(key, 3);
|
||||
|
||||
#ifdef DEC_KS_UNROLL
|
||||
cx->ks[v(56,(4))] = ff(ss[4] = word_in(key, 4));
|
||||
cx->ks[v(56,(5))] = ff(ss[5] = word_in(key, 5));
|
||||
cx->ks[v(56,(6))] = ff(ss[6] = word_in(key, 6));
|
||||
cx->ks[v(56,(7))] = ff(ss[7] = word_in(key, 7));
|
||||
kdf8(cx->ks, 0); kd8(cx->ks, 1);
|
||||
kd8(cx->ks, 2); kd8(cx->ks, 3);
|
||||
kd8(cx->ks, 4); kd8(cx->ks, 5);
|
||||
kdl8(cx->ks, 6);
|
||||
#else
|
||||
cx->ks[v(56,(4))] = ss[4] = word_in(key, 4);
|
||||
cx->ks[v(56,(5))] = ss[5] = word_in(key, 5);
|
||||
cx->ks[v(56,(6))] = ss[6] = word_in(key, 6);
|
||||
cx->ks[v(56,(7))] = ss[7] = word_in(key, 7);
|
||||
{ uint32_t i;
|
||||
|
||||
for(i = 0; i < 6; ++i)
|
||||
k8e(cx->ks, i);
|
||||
k8ef(cx->ks, 6);
|
||||
#if !(DEC_ROUND == NO_TABLES)
|
||||
for(i = N_COLS; i < 14 * N_COLS; ++i)
|
||||
cx->ks[i] = inv_mcol(cx->ks[i]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
cx->inf.l = 0;
|
||||
cx->inf.b[0] = 14 * 16;
|
||||
|
||||
#ifdef USE_VIA_ACE_IF_PRESENT
|
||||
if(VIA_ACE_AVAILABLE)
|
||||
cx->inf.b[1] = 0xff;
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( AES_VAR )
|
||||
|
||||
AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1])
|
||||
{
|
||||
switch(key_len)
|
||||
{
|
||||
case 16: case 128: return aes_encrypt_key128(key, cx);
|
||||
case 24: case 192: return aes_encrypt_key192(key, cx);
|
||||
case 32: case 256: return aes_encrypt_key256(key, cx);
|
||||
default: return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1])
|
||||
{
|
||||
switch(key_len)
|
||||
{
|
||||
case 16: case 128: return aes_decrypt_key128(key, cx);
|
||||
case 24: case 192: return aes_decrypt_key192(key, cx);
|
||||
case 32: case 256: return aes_decrypt_key256(key, cx);
|
||||
default: return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
776
game/client/third/minizip/lib/aes/aesopt.h
Executable file
776
game/client/third/minizip/lib/aes/aesopt.h
Executable file
@@ -0,0 +1,776 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This file contains the compilation options for AES (Rijndael) and code
|
||||
that is common across encryption, key scheduling and table generation.
|
||||
|
||||
OPERATION
|
||||
|
||||
These source code files implement the AES algorithm Rijndael designed by
|
||||
Joan Daemen and Vincent Rijmen. This version is designed for the standard
|
||||
block size of 16 bytes and for key sizes of 128, 192 and 256 bits (16, 24
|
||||
and 32 bytes).
|
||||
|
||||
This version is designed for flexibility and speed using operations on
|
||||
32-bit words rather than operations on bytes. It can be compiled with
|
||||
either big or little endian internal byte order but is faster when the
|
||||
native byte order for the processor is used.
|
||||
|
||||
THE CIPHER INTERFACE
|
||||
|
||||
The cipher interface is implemented as an array of bytes in which lower
|
||||
AES bit sequence indexes map to higher numeric significance within bytes.
|
||||
|
||||
uint8_t (an unsigned 8-bit type)
|
||||
uint32_t (an unsigned 32-bit type)
|
||||
struct aes_encrypt_ctx (structure for the cipher encryption context)
|
||||
struct aes_decrypt_ctx (structure for the cipher decryption context)
|
||||
AES_RETURN the function return type
|
||||
|
||||
C subroutine calls:
|
||||
|
||||
AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
||||
AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
||||
AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]);
|
||||
AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out,
|
||||
const aes_encrypt_ctx cx[1]);
|
||||
|
||||
AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
||||
AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
||||
AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]);
|
||||
AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out,
|
||||
const aes_decrypt_ctx cx[1]);
|
||||
|
||||
IMPORTANT NOTE: If you are using this C interface with dynamic tables make sure that
|
||||
you call aes_init() before AES is used so that the tables are initialised.
|
||||
|
||||
C++ aes class subroutines:
|
||||
|
||||
Class AESencrypt for encryption
|
||||
|
||||
Construtors:
|
||||
AESencrypt(void)
|
||||
AESencrypt(const unsigned char *key) - 128 bit key
|
||||
Members:
|
||||
AES_RETURN key128(const unsigned char *key)
|
||||
AES_RETURN key192(const unsigned char *key)
|
||||
AES_RETURN key256(const unsigned char *key)
|
||||
AES_RETURN encrypt(const unsigned char *in, unsigned char *out) const
|
||||
|
||||
Class AESdecrypt for encryption
|
||||
Construtors:
|
||||
AESdecrypt(void)
|
||||
AESdecrypt(const unsigned char *key) - 128 bit key
|
||||
Members:
|
||||
AES_RETURN key128(const unsigned char *key)
|
||||
AES_RETURN key192(const unsigned char *key)
|
||||
AES_RETURN key256(const unsigned char *key)
|
||||
AES_RETURN decrypt(const unsigned char *in, unsigned char *out) const
|
||||
*/
|
||||
|
||||
#if !defined( _AESOPT_H )
|
||||
#define _AESOPT_H
|
||||
|
||||
#if defined( __cplusplus )
|
||||
#include "aescpp.h"
|
||||
#else
|
||||
#include "aes.h"
|
||||
#endif
|
||||
|
||||
/* PLATFORM SPECIFIC INCLUDES */
|
||||
|
||||
#include "brg_endian.h"
|
||||
|
||||
/* CONFIGURATION - THE USE OF DEFINES
|
||||
|
||||
Later in this section there are a number of defines that control the
|
||||
operation of the code. In each section, the purpose of each define is
|
||||
explained so that the relevant form can be included or excluded by
|
||||
setting either 1's or 0's respectively on the branches of the related
|
||||
#if clauses. The following local defines should not be changed.
|
||||
*/
|
||||
|
||||
#define ENCRYPTION_IN_C 1
|
||||
#define DECRYPTION_IN_C 2
|
||||
#define ENC_KEYING_IN_C 4
|
||||
#define DEC_KEYING_IN_C 8
|
||||
|
||||
#define NO_TABLES 0
|
||||
#define ONE_TABLE 1
|
||||
#define FOUR_TABLES 4
|
||||
#define NONE 0
|
||||
#define PARTIAL 1
|
||||
#define FULL 2
|
||||
|
||||
/* --- START OF USER CONFIGURED OPTIONS --- */
|
||||
|
||||
/* 1. BYTE ORDER WITHIN 32 BIT WORDS
|
||||
|
||||
The fundamental data processing units in Rijndael are 8-bit bytes. The
|
||||
input, output and key input are all enumerated arrays of bytes in which
|
||||
bytes are numbered starting at zero and increasing to one less than the
|
||||
number of bytes in the array in question. This enumeration is only used
|
||||
for naming bytes and does not imply any adjacency or order relationship
|
||||
from one byte to another. When these inputs and outputs are considered
|
||||
as bit sequences, bits 8*n to 8*n+7 of the bit sequence are mapped to
|
||||
byte[n] with bit 8n+i in the sequence mapped to bit 7-i within the byte.
|
||||
In this implementation bits are numbered from 0 to 7 starting at the
|
||||
numerically least significant end of each byte (bit n represents 2^n).
|
||||
|
||||
However, Rijndael can be implemented more efficiently using 32-bit
|
||||
words by packing bytes into words so that bytes 4*n to 4*n+3 are placed
|
||||
into word[n]. While in principle these bytes can be assembled into words
|
||||
in any positions, this implementation only supports the two formats in
|
||||
which bytes in adjacent positions within words also have adjacent byte
|
||||
numbers. This order is called big-endian if the lowest numbered bytes
|
||||
in words have the highest numeric significance and little-endian if the
|
||||
opposite applies.
|
||||
|
||||
This code can work in either order irrespective of the order used by the
|
||||
machine on which it runs. Normally the internal byte order will be set
|
||||
to the order of the processor on which the code is to be run but this
|
||||
define can be used to reverse this in special situations
|
||||
|
||||
WARNING: Assembler code versions rely on PLATFORM_BYTE_ORDER being set.
|
||||
This define will hence be redefined later (in section 4) if necessary
|
||||
*/
|
||||
|
||||
#if 1
|
||||
# define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER
|
||||
#elif 0
|
||||
# define ALGORITHM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#elif 0
|
||||
# define ALGORITHM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#else
|
||||
# error The algorithm byte order is not defined
|
||||
#endif
|
||||
|
||||
/* 2. Intel AES AND VIA ACE SUPPORT */
|
||||
|
||||
#if defined( __GNUC__ ) && defined( __i386__ ) \
|
||||
|| defined( _WIN32 ) && defined( _M_IX86 ) && !(defined( _WIN64 ) \
|
||||
|| defined( _WIN32_WCE ) || defined( _MSC_VER ) && ( _MSC_VER <= 800 ))
|
||||
# define VIA_ACE_POSSIBLE
|
||||
#endif
|
||||
|
||||
#if (defined( _WIN64 ) && defined( _MSC_VER )) \
|
||||
|| (defined( __GNUC__ ) && defined( __x86_64__ )) && !(defined( __APPLE__ ))\
|
||||
&& !(defined( INTEL_AES_POSSIBLE ))
|
||||
# define INTEL_AES_POSSIBLE
|
||||
#endif
|
||||
|
||||
/* Define this option if support for the Intel AESNI is required
|
||||
If USE_INTEL_AES_IF_PRESENT is defined then AESNI will be used
|
||||
if it is detected (both present and enabled).
|
||||
|
||||
AESNI uses a decryption key schedule with the first decryption
|
||||
round key at the high end of the key scedule with the following
|
||||
round keys at lower positions in memory. So AES_REV_DKS must NOT
|
||||
be defined when AESNI will be used. ALthough it is unlikely that
|
||||
assembler code will be used with an AESNI build, if it is then
|
||||
AES_REV_DKS must NOT be defined when the assembler files are
|
||||
built
|
||||
*/
|
||||
|
||||
#if 0 && defined( INTEL_AES_POSSIBLE ) && !defined( USE_INTEL_AES_IF_PRESENT )
|
||||
# define USE_INTEL_AES_IF_PRESENT
|
||||
#endif
|
||||
|
||||
/* Define this option if support for the VIA ACE is required. This uses
|
||||
inline assembler instructions and is only implemented for the Microsoft,
|
||||
Intel and GCC compilers. If VIA ACE is known to be present, then defining
|
||||
ASSUME_VIA_ACE_PRESENT will remove the ordinary encryption/decryption
|
||||
code. If USE_VIA_ACE_IF_PRESENT is defined then VIA ACE will be used if
|
||||
it is detected (both present and enabled) but the normal AES code will
|
||||
also be present.
|
||||
|
||||
When VIA ACE is to be used, all AES encryption contexts MUST be 16 byte
|
||||
aligned; other input/output buffers do not need to be 16 byte aligned
|
||||
but there are very large performance gains if this can be arranged.
|
||||
VIA ACE also requires the decryption key schedule to be in reverse
|
||||
order (which later checks below ensure).
|
||||
|
||||
AES_REV_DKS must be set for assembler code used with a VIA ACE build
|
||||
*/
|
||||
|
||||
#if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( USE_VIA_ACE_IF_PRESENT )
|
||||
# define USE_VIA_ACE_IF_PRESENT
|
||||
#endif
|
||||
|
||||
#if 0 && defined( VIA_ACE_POSSIBLE ) && !defined( ASSUME_VIA_ACE_PRESENT )
|
||||
# define ASSUME_VIA_ACE_PRESENT
|
||||
# endif
|
||||
|
||||
/* 3. ASSEMBLER SUPPORT
|
||||
|
||||
This define (which can be on the command line) enables the use of the
|
||||
assembler code routines for encryption, decryption and key scheduling
|
||||
as follows:
|
||||
|
||||
ASM_X86_V1C uses the assembler (aes_x86_v1.asm) with large tables for
|
||||
encryption and decryption and but with key scheduling in C
|
||||
ASM_X86_V2 uses assembler (aes_x86_v2.asm) with compressed tables for
|
||||
encryption, decryption and key scheduling
|
||||
ASM_X86_V2C uses assembler (aes_x86_v2.asm) with compressed tables for
|
||||
encryption and decryption and but with key scheduling in C
|
||||
ASM_AMD64_C uses assembler (aes_amd64.asm) with compressed tables for
|
||||
encryption and decryption and but with key scheduling in C
|
||||
|
||||
Change one 'if 0' below to 'if 1' to select the version or define
|
||||
as a compilation option.
|
||||
*/
|
||||
|
||||
#if 0 && !defined( ASM_X86_V1C )
|
||||
# define ASM_X86_V1C
|
||||
#elif 0 && !defined( ASM_X86_V2 )
|
||||
# define ASM_X86_V2
|
||||
#elif 0 && !defined( ASM_X86_V2C )
|
||||
# define ASM_X86_V2C
|
||||
#elif 0 && !defined( ASM_AMD64_C )
|
||||
# define ASM_AMD64_C
|
||||
#endif
|
||||
|
||||
#if defined( __i386 ) || defined( _M_IX86 )
|
||||
# define A32_
|
||||
#elif defined( __x86_64__ ) || defined( _M_X64 )
|
||||
# define A64_
|
||||
#endif
|
||||
|
||||
#if (defined ( ASM_X86_V1C ) || defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )) \
|
||||
&& !defined( A32_ ) || defined( ASM_AMD64_C ) && !defined( A64_ )
|
||||
# error Assembler code is only available for x86 and AMD64 systems
|
||||
#endif
|
||||
|
||||
/* 4. FAST INPUT/OUTPUT OPERATIONS.
|
||||
|
||||
On some machines it is possible to improve speed by transferring the
|
||||
bytes in the input and output arrays to and from the internal 32-bit
|
||||
variables by addressing these arrays as if they are arrays of 32-bit
|
||||
words. On some machines this will always be possible but there may
|
||||
be a large performance penalty if the byte arrays are not aligned on
|
||||
the normal word boundaries. On other machines this technique will
|
||||
lead to memory access errors when such 32-bit word accesses are not
|
||||
properly aligned. The option SAFE_IO avoids such problems but will
|
||||
often be slower on those machines that support misaligned access
|
||||
(especially so if care is taken to align the input and output byte
|
||||
arrays on 32-bit word boundaries). If SAFE_IO is not defined it is
|
||||
assumed that access to byte arrays as if they are arrays of 32-bit
|
||||
words will not cause problems when such accesses are misaligned.
|
||||
*/
|
||||
#if 1 && !defined( _MSC_VER )
|
||||
# define SAFE_IO
|
||||
#endif
|
||||
|
||||
/* 5. LOOP UNROLLING
|
||||
|
||||
The code for encryption and decrytpion cycles through a number of rounds
|
||||
that can be implemented either in a loop or by expanding the code into a
|
||||
long sequence of instructions, the latter producing a larger program but
|
||||
one that will often be much faster. The latter is called loop unrolling.
|
||||
There are also potential speed advantages in expanding two iterations in
|
||||
a loop with half the number of iterations, which is called partial loop
|
||||
unrolling. The following options allow partial or full loop unrolling
|
||||
to be set independently for encryption and decryption
|
||||
*/
|
||||
#if 1
|
||||
# define ENC_UNROLL FULL
|
||||
#elif 0
|
||||
# define ENC_UNROLL PARTIAL
|
||||
#else
|
||||
# define ENC_UNROLL NONE
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
# define DEC_UNROLL FULL
|
||||
#elif 0
|
||||
# define DEC_UNROLL PARTIAL
|
||||
#else
|
||||
# define DEC_UNROLL NONE
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
# define ENC_KS_UNROLL
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
# define DEC_KS_UNROLL
|
||||
#endif
|
||||
|
||||
/* 6. FAST FINITE FIELD OPERATIONS
|
||||
|
||||
If this section is included, tables are used to provide faster finite
|
||||
field arithmetic (this has no effect if STATIC_TABLES is defined).
|
||||
*/
|
||||
#if 1
|
||||
# define FF_TABLES
|
||||
#endif
|
||||
|
||||
/* 7. INTERNAL STATE VARIABLE FORMAT
|
||||
|
||||
The internal state of Rijndael is stored in a number of local 32-bit
|
||||
word varaibles which can be defined either as an array or as individual
|
||||
names variables. Include this section if you want to store these local
|
||||
varaibles in arrays. Otherwise individual local variables will be used.
|
||||
*/
|
||||
#if 1
|
||||
# define ARRAYS
|
||||
#endif
|
||||
|
||||
/* 8. FIXED OR DYNAMIC TABLES
|
||||
|
||||
When this section is included the tables used by the code are compiled
|
||||
statically into the binary file. Otherwise the subroutine aes_init()
|
||||
must be called to compute them before the code is first used.
|
||||
*/
|
||||
#if 1 && !(defined( _MSC_VER ) && ( _MSC_VER <= 800 ))
|
||||
# define STATIC_TABLES
|
||||
#endif
|
||||
|
||||
/* 9. MASKING OR CASTING FROM LONGER VALUES TO BYTES
|
||||
|
||||
In some systems it is better to mask longer values to extract bytes
|
||||
rather than using a cast. This option allows this choice.
|
||||
*/
|
||||
#if 0
|
||||
# define to_byte(x) ((uint8_t)(x))
|
||||
#else
|
||||
# define to_byte(x) ((x) & 0xff)
|
||||
#endif
|
||||
|
||||
/* 10. TABLE ALIGNMENT
|
||||
|
||||
On some sytsems speed will be improved by aligning the AES large lookup
|
||||
tables on particular boundaries. This define should be set to a power of
|
||||
two giving the desired alignment. It can be left undefined if alignment
|
||||
is not needed. This option is specific to the Microsft VC++ compiler -
|
||||
it seems to sometimes cause trouble for the VC++ version 6 compiler.
|
||||
*/
|
||||
|
||||
#if 1 && defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
|
||||
# define TABLE_ALIGN 32
|
||||
#endif
|
||||
|
||||
/* 11. REDUCE CODE AND TABLE SIZE
|
||||
|
||||
This replaces some expanded macros with function calls if AES_ASM_V2 or
|
||||
AES_ASM_V2C are defined
|
||||
*/
|
||||
|
||||
#if 1 && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C ))
|
||||
# define REDUCE_CODE_SIZE
|
||||
#endif
|
||||
|
||||
/* 12. TABLE OPTIONS
|
||||
|
||||
This cipher proceeds by repeating in a number of cycles known as 'rounds'
|
||||
which are implemented by a round function which can optionally be speeded
|
||||
up using tables. The basic tables are each 256 32-bit words, with either
|
||||
one or four tables being required for each round function depending on
|
||||
how much speed is required. The encryption and decryption round functions
|
||||
are different and the last encryption and decrytpion round functions are
|
||||
different again making four different round functions in all.
|
||||
|
||||
This means that:
|
||||
1. Normal encryption and decryption rounds can each use either 0, 1
|
||||
or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
|
||||
2. The last encryption and decryption rounds can also use either 0, 1
|
||||
or 4 tables and table spaces of 0, 1024 or 4096 bytes each.
|
||||
|
||||
Include or exclude the appropriate definitions below to set the number
|
||||
of tables used by this implementation.
|
||||
*/
|
||||
|
||||
#if 1 /* set tables for the normal encryption round */
|
||||
# define ENC_ROUND FOUR_TABLES
|
||||
#elif 0
|
||||
# define ENC_ROUND ONE_TABLE
|
||||
#else
|
||||
# define ENC_ROUND NO_TABLES
|
||||
#endif
|
||||
|
||||
#if 1 /* set tables for the last encryption round */
|
||||
# define LAST_ENC_ROUND FOUR_TABLES
|
||||
#elif 0
|
||||
# define LAST_ENC_ROUND ONE_TABLE
|
||||
#else
|
||||
# define LAST_ENC_ROUND NO_TABLES
|
||||
#endif
|
||||
|
||||
#if 1 /* set tables for the normal decryption round */
|
||||
# define DEC_ROUND FOUR_TABLES
|
||||
#elif 0
|
||||
# define DEC_ROUND ONE_TABLE
|
||||
#else
|
||||
# define DEC_ROUND NO_TABLES
|
||||
#endif
|
||||
|
||||
#if 1 /* set tables for the last decryption round */
|
||||
# define LAST_DEC_ROUND FOUR_TABLES
|
||||
#elif 0
|
||||
# define LAST_DEC_ROUND ONE_TABLE
|
||||
#else
|
||||
# define LAST_DEC_ROUND NO_TABLES
|
||||
#endif
|
||||
|
||||
/* The decryption key schedule can be speeded up with tables in the same
|
||||
way that the round functions can. Include or exclude the following
|
||||
defines to set this requirement.
|
||||
*/
|
||||
#if 1
|
||||
# define KEY_SCHED FOUR_TABLES
|
||||
#elif 0
|
||||
# define KEY_SCHED ONE_TABLE
|
||||
#else
|
||||
# define KEY_SCHED NO_TABLES
|
||||
#endif
|
||||
|
||||
/* ---- END OF USER CONFIGURED OPTIONS ---- */
|
||||
|
||||
/* VIA ACE support is only available for VC++ and GCC */
|
||||
|
||||
#if !defined( _MSC_VER ) && !defined( __GNUC__ )
|
||||
# if defined( ASSUME_VIA_ACE_PRESENT )
|
||||
# undef ASSUME_VIA_ACE_PRESENT
|
||||
# endif
|
||||
# if defined( USE_VIA_ACE_IF_PRESENT )
|
||||
# undef USE_VIA_ACE_IF_PRESENT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( ASSUME_VIA_ACE_PRESENT ) && !defined( USE_VIA_ACE_IF_PRESENT )
|
||||
# define USE_VIA_ACE_IF_PRESENT
|
||||
#endif
|
||||
|
||||
/* define to reverse decryption key schedule */
|
||||
#if 1 || defined( USE_VIA_ACE_IF_PRESENT ) && !defined ( AES_REV_DKS )
|
||||
# define AES_REV_DKS
|
||||
#endif
|
||||
|
||||
/* Intel AESNI uses a decryption key schedule in the encryption order */
|
||||
#if defined( USE_INTEL_AES_IF_PRESENT ) && defined ( AES_REV_DKS )
|
||||
# undef AES_REV_DKS
|
||||
#endif
|
||||
|
||||
/* Assembler support requires the use of platform byte order */
|
||||
|
||||
#if ( defined( ASM_X86_V1C ) || defined( ASM_X86_V2C ) || defined( ASM_AMD64_C ) ) \
|
||||
&& (ALGORITHM_BYTE_ORDER != PLATFORM_BYTE_ORDER)
|
||||
# undef ALGORITHM_BYTE_ORDER
|
||||
# define ALGORITHM_BYTE_ORDER PLATFORM_BYTE_ORDER
|
||||
#endif
|
||||
|
||||
/* In this implementation the columns of the state array are each held in
|
||||
32-bit words. The state array can be held in various ways: in an array
|
||||
of words, in a number of individual word variables or in a number of
|
||||
processor registers. The following define maps a variable name x and
|
||||
a column number c to the way the state array variable is to be held.
|
||||
The first define below maps the state into an array x[c] whereas the
|
||||
second form maps the state into a number of individual variables x0,
|
||||
x1, etc. Another form could map individual state colums to machine
|
||||
register names.
|
||||
*/
|
||||
|
||||
#if defined( ARRAYS )
|
||||
# define s(x,c) x[c]
|
||||
#else
|
||||
# define s(x,c) x##c
|
||||
#endif
|
||||
|
||||
/* This implementation provides subroutines for encryption, decryption
|
||||
and for setting the three key lengths (separately) for encryption
|
||||
and decryption. Since not all functions are needed, masks are set
|
||||
up here to determine which will be implemented in C
|
||||
*/
|
||||
|
||||
#if !defined( AES_ENCRYPT )
|
||||
# define EFUNCS_IN_C 0
|
||||
#elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \
|
||||
|| defined( ASM_X86_V2C ) || defined( ASM_AMD64_C )
|
||||
# define EFUNCS_IN_C ENC_KEYING_IN_C
|
||||
#elif !defined( ASM_X86_V2 )
|
||||
# define EFUNCS_IN_C ( ENCRYPTION_IN_C | ENC_KEYING_IN_C )
|
||||
#else
|
||||
# define EFUNCS_IN_C 0
|
||||
#endif
|
||||
|
||||
#if !defined( AES_DECRYPT )
|
||||
# define DFUNCS_IN_C 0
|
||||
#elif defined( ASSUME_VIA_ACE_PRESENT ) || defined( ASM_X86_V1C ) \
|
||||
|| defined( ASM_X86_V2C ) || defined( ASM_AMD64_C )
|
||||
# define DFUNCS_IN_C DEC_KEYING_IN_C
|
||||
#elif !defined( ASM_X86_V2 )
|
||||
# define DFUNCS_IN_C ( DECRYPTION_IN_C | DEC_KEYING_IN_C )
|
||||
#else
|
||||
# define DFUNCS_IN_C 0
|
||||
#endif
|
||||
|
||||
#define FUNCS_IN_C ( EFUNCS_IN_C | DFUNCS_IN_C )
|
||||
|
||||
/* END OF CONFIGURATION OPTIONS */
|
||||
|
||||
#define RC_LENGTH (5 * (AES_BLOCK_SIZE / 4 - 2))
|
||||
|
||||
/* Disable or report errors on some combinations of options */
|
||||
|
||||
#if ENC_ROUND == NO_TABLES && LAST_ENC_ROUND != NO_TABLES
|
||||
# undef LAST_ENC_ROUND
|
||||
# define LAST_ENC_ROUND NO_TABLES
|
||||
#elif ENC_ROUND == ONE_TABLE && LAST_ENC_ROUND == FOUR_TABLES
|
||||
# undef LAST_ENC_ROUND
|
||||
# define LAST_ENC_ROUND ONE_TABLE
|
||||
#endif
|
||||
|
||||
#if ENC_ROUND == NO_TABLES && ENC_UNROLL != NONE
|
||||
# undef ENC_UNROLL
|
||||
# define ENC_UNROLL NONE
|
||||
#endif
|
||||
|
||||
#if DEC_ROUND == NO_TABLES && LAST_DEC_ROUND != NO_TABLES
|
||||
# undef LAST_DEC_ROUND
|
||||
# define LAST_DEC_ROUND NO_TABLES
|
||||
#elif DEC_ROUND == ONE_TABLE && LAST_DEC_ROUND == FOUR_TABLES
|
||||
# undef LAST_DEC_ROUND
|
||||
# define LAST_DEC_ROUND ONE_TABLE
|
||||
#endif
|
||||
|
||||
#if DEC_ROUND == NO_TABLES && DEC_UNROLL != NONE
|
||||
# undef DEC_UNROLL
|
||||
# define DEC_UNROLL NONE
|
||||
#endif
|
||||
|
||||
#if defined( bswap32 )
|
||||
# define aes_sw32 bswap32
|
||||
#elif defined( bswap_32 )
|
||||
# define aes_sw32 bswap_32
|
||||
#else
|
||||
# define brot(x,n) (((uint32_t)(x) << n) | ((uint32_t)(x) >> (32 - n)))
|
||||
# define aes_sw32(x) ((brot((x),8) & 0x00ff00ff) | (brot((x),24) & 0xff00ff00))
|
||||
#endif
|
||||
|
||||
/* upr(x,n): rotates bytes within words by n positions, moving bytes to
|
||||
higher index positions with wrap around into low positions
|
||||
ups(x,n): moves bytes by n positions to higher index positions in
|
||||
words but without wrap around
|
||||
bval(x,n): extracts a byte from a word
|
||||
|
||||
WARNING: The definitions given here are intended only for use with
|
||||
unsigned variables and with shift counts that are compile
|
||||
time constants
|
||||
*/
|
||||
|
||||
#if ( ALGORITHM_BYTE_ORDER == IS_LITTLE_ENDIAN )
|
||||
# define upr(x,n) (((uint32_t)(x) << (8 * (n))) | ((uint32_t)(x) >> (32 - 8 * (n))))
|
||||
# define ups(x,n) ((uint32_t) (x) << (8 * (n)))
|
||||
# define bval(x,n) to_byte((x) >> (8 * (n)))
|
||||
# define bytes2word(b0, b1, b2, b3) \
|
||||
(((uint32_t)(b3) << 24) | ((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0))
|
||||
#endif
|
||||
|
||||
#if ( ALGORITHM_BYTE_ORDER == IS_BIG_ENDIAN )
|
||||
# define upr(x,n) (((uint32_t)(x) >> (8 * (n))) | ((uint32_t)(x) << (32 - 8 * (n))))
|
||||
# define ups(x,n) ((uint32_t) (x) >> (8 * (n)))
|
||||
# define bval(x,n) to_byte((x) >> (24 - 8 * (n)))
|
||||
# define bytes2word(b0, b1, b2, b3) \
|
||||
(((uint32_t)(b0) << 24) | ((uint32_t)(b1) << 16) | ((uint32_t)(b2) << 8) | (b3))
|
||||
#endif
|
||||
|
||||
#if defined( SAFE_IO )
|
||||
# define word_in(x,c) bytes2word(((const uint8_t*)(x)+4*c)[0], ((const uint8_t*)(x)+4*c)[1], \
|
||||
((const uint8_t*)(x)+4*c)[2], ((const uint8_t*)(x)+4*c)[3])
|
||||
# define word_out(x,c,v) { ((uint8_t*)(x)+4*c)[0] = bval(v,0); ((uint8_t*)(x)+4*c)[1] = bval(v,1); \
|
||||
((uint8_t*)(x)+4*c)[2] = bval(v,2); ((uint8_t*)(x)+4*c)[3] = bval(v,3); }
|
||||
#elif ( ALGORITHM_BYTE_ORDER == PLATFORM_BYTE_ORDER )
|
||||
# define word_in(x,c) (*((uint32_t*)(x)+(c)))
|
||||
# define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = (v))
|
||||
#else
|
||||
# define word_in(x,c) aes_sw32(*((uint32_t*)(x)+(c)))
|
||||
# define word_out(x,c,v) (*((uint32_t*)(x)+(c)) = aes_sw32(v))
|
||||
#endif
|
||||
|
||||
/* the finite field modular polynomial and elements */
|
||||
|
||||
#define WPOLY 0x011b
|
||||
#define BPOLY 0x1b
|
||||
|
||||
/* multiply four bytes in GF(2^8) by 'x' {02} in parallel */
|
||||
|
||||
#define gf_c1 0x80808080
|
||||
#define gf_c2 0x7f7f7f7f
|
||||
#define gf_mulx(x) ((((x) & gf_c2) << 1) ^ ((((x) & gf_c1) >> 7) * BPOLY))
|
||||
|
||||
/* The following defines provide alternative definitions of gf_mulx that might
|
||||
give improved performance if a fast 32-bit multiply is not available. Note
|
||||
that a temporary variable u needs to be defined where gf_mulx is used.
|
||||
|
||||
#define gf_mulx(x) (u = (x) & gf_c1, u |= (u >> 1), ((x) & gf_c2) << 1) ^ ((u >> 3) | (u >> 6))
|
||||
#define gf_c4 (0x01010101 * BPOLY)
|
||||
#define gf_mulx(x) (u = (x) & gf_c1, ((x) & gf_c2) << 1) ^ ((u - (u >> 7)) & gf_c4)
|
||||
*/
|
||||
|
||||
/* Work out which tables are needed for the different options */
|
||||
|
||||
#if defined( ASM_X86_V1C )
|
||||
# if defined( ENC_ROUND )
|
||||
# undef ENC_ROUND
|
||||
# endif
|
||||
# define ENC_ROUND FOUR_TABLES
|
||||
# if defined( LAST_ENC_ROUND )
|
||||
# undef LAST_ENC_ROUND
|
||||
# endif
|
||||
# define LAST_ENC_ROUND FOUR_TABLES
|
||||
# if defined( DEC_ROUND )
|
||||
# undef DEC_ROUND
|
||||
# endif
|
||||
# define DEC_ROUND FOUR_TABLES
|
||||
# if defined( LAST_DEC_ROUND )
|
||||
# undef LAST_DEC_ROUND
|
||||
# endif
|
||||
# define LAST_DEC_ROUND FOUR_TABLES
|
||||
# if defined( KEY_SCHED )
|
||||
# undef KEY_SCHED
|
||||
# define KEY_SCHED FOUR_TABLES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ( FUNCS_IN_C & ENCRYPTION_IN_C ) || defined( ASM_X86_V1C )
|
||||
# if ENC_ROUND == ONE_TABLE
|
||||
# define FT1_SET
|
||||
# elif ENC_ROUND == FOUR_TABLES
|
||||
# define FT4_SET
|
||||
# else
|
||||
# define SBX_SET
|
||||
# endif
|
||||
# if LAST_ENC_ROUND == ONE_TABLE
|
||||
# define FL1_SET
|
||||
# elif LAST_ENC_ROUND == FOUR_TABLES
|
||||
# define FL4_SET
|
||||
# elif !defined( SBX_SET )
|
||||
# define SBX_SET
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ( FUNCS_IN_C & DECRYPTION_IN_C ) || defined( ASM_X86_V1C )
|
||||
# if DEC_ROUND == ONE_TABLE
|
||||
# define IT1_SET
|
||||
# elif DEC_ROUND == FOUR_TABLES
|
||||
# define IT4_SET
|
||||
# else
|
||||
# define ISB_SET
|
||||
# endif
|
||||
# if LAST_DEC_ROUND == ONE_TABLE
|
||||
# define IL1_SET
|
||||
# elif LAST_DEC_ROUND == FOUR_TABLES
|
||||
# define IL4_SET
|
||||
# elif !defined(ISB_SET)
|
||||
# define ISB_SET
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )))
|
||||
# if ((FUNCS_IN_C & ENC_KEYING_IN_C) || (FUNCS_IN_C & DEC_KEYING_IN_C))
|
||||
# if KEY_SCHED == ONE_TABLE
|
||||
# if !defined( FL1_SET ) && !defined( FL4_SET )
|
||||
# define LS1_SET
|
||||
# endif
|
||||
# elif KEY_SCHED == FOUR_TABLES
|
||||
# if !defined( FL4_SET )
|
||||
# define LS4_SET
|
||||
# endif
|
||||
# elif !defined( SBX_SET )
|
||||
# define SBX_SET
|
||||
# endif
|
||||
# endif
|
||||
# if (FUNCS_IN_C & DEC_KEYING_IN_C)
|
||||
# if KEY_SCHED == ONE_TABLE
|
||||
# define IM1_SET
|
||||
# elif KEY_SCHED == FOUR_TABLES
|
||||
# define IM4_SET
|
||||
# elif !defined( SBX_SET )
|
||||
# define SBX_SET
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* generic definitions of Rijndael macros that use tables */
|
||||
|
||||
#define no_table(x,box,vf,rf,c) bytes2word( \
|
||||
box[bval(vf(x,0,c),rf(0,c))], \
|
||||
box[bval(vf(x,1,c),rf(1,c))], \
|
||||
box[bval(vf(x,2,c),rf(2,c))], \
|
||||
box[bval(vf(x,3,c),rf(3,c))])
|
||||
|
||||
#define one_table(x,op,tab,vf,rf,c) \
|
||||
( tab[bval(vf(x,0,c),rf(0,c))] \
|
||||
^ op(tab[bval(vf(x,1,c),rf(1,c))],1) \
|
||||
^ op(tab[bval(vf(x,2,c),rf(2,c))],2) \
|
||||
^ op(tab[bval(vf(x,3,c),rf(3,c))],3))
|
||||
|
||||
#define four_tables(x,tab,vf,rf,c) \
|
||||
( tab[0][bval(vf(x,0,c),rf(0,c))] \
|
||||
^ tab[1][bval(vf(x,1,c),rf(1,c))] \
|
||||
^ tab[2][bval(vf(x,2,c),rf(2,c))] \
|
||||
^ tab[3][bval(vf(x,3,c),rf(3,c))])
|
||||
|
||||
#define vf1(x,r,c) (x)
|
||||
#define rf1(r,c) (r)
|
||||
#define rf2(r,c) ((8+r-c)&3)
|
||||
|
||||
/* perform forward and inverse column mix operation on four bytes in long word x in */
|
||||
/* parallel. NOTE: x must be a simple variable, NOT an expression in these macros. */
|
||||
|
||||
#if !(defined( REDUCE_CODE_SIZE ) && (defined( ASM_X86_V2 ) || defined( ASM_X86_V2C )))
|
||||
|
||||
#if defined( FM4_SET ) /* not currently used */
|
||||
# define fwd_mcol(x) four_tables(x,t_use(f,m),vf1,rf1,0)
|
||||
#elif defined( FM1_SET ) /* not currently used */
|
||||
# define fwd_mcol(x) one_table(x,upr,t_use(f,m),vf1,rf1,0)
|
||||
#else
|
||||
# define dec_fmvars uint32_t g2
|
||||
# define fwd_mcol(x) (g2 = gf_mulx(x), g2 ^ upr((x) ^ g2, 3) ^ upr((x), 2) ^ upr((x), 1))
|
||||
#endif
|
||||
|
||||
#if defined( IM4_SET )
|
||||
# define inv_mcol(x) four_tables(x,t_use(i,m),vf1,rf1,0)
|
||||
#elif defined( IM1_SET )
|
||||
# define inv_mcol(x) one_table(x,upr,t_use(i,m),vf1,rf1,0)
|
||||
#else
|
||||
# define dec_imvars uint32_t g2, g4, g9
|
||||
# define inv_mcol(x) (g2 = gf_mulx(x), g4 = gf_mulx(g2), g9 = (x) ^ gf_mulx(g4), g4 ^= g9, \
|
||||
(x) ^ g2 ^ g4 ^ upr(g2 ^ g9, 3) ^ upr(g4, 2) ^ upr(g9, 1))
|
||||
#endif
|
||||
|
||||
#if defined( FL4_SET )
|
||||
# define ls_box(x,c) four_tables(x,t_use(f,l),vf1,rf2,c)
|
||||
#elif defined( LS4_SET )
|
||||
# define ls_box(x,c) four_tables(x,t_use(l,s),vf1,rf2,c)
|
||||
#elif defined( FL1_SET )
|
||||
# define ls_box(x,c) one_table(x,upr,t_use(f,l),vf1,rf2,c)
|
||||
#elif defined( LS1_SET )
|
||||
# define ls_box(x,c) one_table(x,upr,t_use(l,s),vf1,rf2,c)
|
||||
#else
|
||||
# define ls_box(x,c) no_table(x,t_use(s,box),vf1,rf2,c)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( ASM_X86_V1C ) && defined( AES_DECRYPT ) && !defined( ISB_SET )
|
||||
# define ISB_SET
|
||||
#endif
|
||||
|
||||
#endif
|
||||
418
game/client/third/minizip/lib/aes/aestab.c
Executable file
418
game/client/third/minizip/lib/aes/aestab.c
Executable file
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#define DO_TABLES
|
||||
|
||||
#include "aes.h"
|
||||
#include "aesopt.h"
|
||||
|
||||
#if defined(STATIC_TABLES)
|
||||
|
||||
#define sb_data(w) {\
|
||||
w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\
|
||||
w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\
|
||||
w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\
|
||||
w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\
|
||||
w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\
|
||||
w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\
|
||||
w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\
|
||||
w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\
|
||||
w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\
|
||||
w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\
|
||||
w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\
|
||||
w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\
|
||||
w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\
|
||||
w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\
|
||||
w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\
|
||||
w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\
|
||||
w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\
|
||||
w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\
|
||||
w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\
|
||||
w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\
|
||||
w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\
|
||||
w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\
|
||||
w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\
|
||||
w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\
|
||||
w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\
|
||||
w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\
|
||||
w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\
|
||||
w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\
|
||||
w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\
|
||||
w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\
|
||||
w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\
|
||||
w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) }
|
||||
|
||||
#define isb_data(w) {\
|
||||
w(0x52), w(0x09), w(0x6a), w(0xd5), w(0x30), w(0x36), w(0xa5), w(0x38),\
|
||||
w(0xbf), w(0x40), w(0xa3), w(0x9e), w(0x81), w(0xf3), w(0xd7), w(0xfb),\
|
||||
w(0x7c), w(0xe3), w(0x39), w(0x82), w(0x9b), w(0x2f), w(0xff), w(0x87),\
|
||||
w(0x34), w(0x8e), w(0x43), w(0x44), w(0xc4), w(0xde), w(0xe9), w(0xcb),\
|
||||
w(0x54), w(0x7b), w(0x94), w(0x32), w(0xa6), w(0xc2), w(0x23), w(0x3d),\
|
||||
w(0xee), w(0x4c), w(0x95), w(0x0b), w(0x42), w(0xfa), w(0xc3), w(0x4e),\
|
||||
w(0x08), w(0x2e), w(0xa1), w(0x66), w(0x28), w(0xd9), w(0x24), w(0xb2),\
|
||||
w(0x76), w(0x5b), w(0xa2), w(0x49), w(0x6d), w(0x8b), w(0xd1), w(0x25),\
|
||||
w(0x72), w(0xf8), w(0xf6), w(0x64), w(0x86), w(0x68), w(0x98), w(0x16),\
|
||||
w(0xd4), w(0xa4), w(0x5c), w(0xcc), w(0x5d), w(0x65), w(0xb6), w(0x92),\
|
||||
w(0x6c), w(0x70), w(0x48), w(0x50), w(0xfd), w(0xed), w(0xb9), w(0xda),\
|
||||
w(0x5e), w(0x15), w(0x46), w(0x57), w(0xa7), w(0x8d), w(0x9d), w(0x84),\
|
||||
w(0x90), w(0xd8), w(0xab), w(0x00), w(0x8c), w(0xbc), w(0xd3), w(0x0a),\
|
||||
w(0xf7), w(0xe4), w(0x58), w(0x05), w(0xb8), w(0xb3), w(0x45), w(0x06),\
|
||||
w(0xd0), w(0x2c), w(0x1e), w(0x8f), w(0xca), w(0x3f), w(0x0f), w(0x02),\
|
||||
w(0xc1), w(0xaf), w(0xbd), w(0x03), w(0x01), w(0x13), w(0x8a), w(0x6b),\
|
||||
w(0x3a), w(0x91), w(0x11), w(0x41), w(0x4f), w(0x67), w(0xdc), w(0xea),\
|
||||
w(0x97), w(0xf2), w(0xcf), w(0xce), w(0xf0), w(0xb4), w(0xe6), w(0x73),\
|
||||
w(0x96), w(0xac), w(0x74), w(0x22), w(0xe7), w(0xad), w(0x35), w(0x85),\
|
||||
w(0xe2), w(0xf9), w(0x37), w(0xe8), w(0x1c), w(0x75), w(0xdf), w(0x6e),\
|
||||
w(0x47), w(0xf1), w(0x1a), w(0x71), w(0x1d), w(0x29), w(0xc5), w(0x89),\
|
||||
w(0x6f), w(0xb7), w(0x62), w(0x0e), w(0xaa), w(0x18), w(0xbe), w(0x1b),\
|
||||
w(0xfc), w(0x56), w(0x3e), w(0x4b), w(0xc6), w(0xd2), w(0x79), w(0x20),\
|
||||
w(0x9a), w(0xdb), w(0xc0), w(0xfe), w(0x78), w(0xcd), w(0x5a), w(0xf4),\
|
||||
w(0x1f), w(0xdd), w(0xa8), w(0x33), w(0x88), w(0x07), w(0xc7), w(0x31),\
|
||||
w(0xb1), w(0x12), w(0x10), w(0x59), w(0x27), w(0x80), w(0xec), w(0x5f),\
|
||||
w(0x60), w(0x51), w(0x7f), w(0xa9), w(0x19), w(0xb5), w(0x4a), w(0x0d),\
|
||||
w(0x2d), w(0xe5), w(0x7a), w(0x9f), w(0x93), w(0xc9), w(0x9c), w(0xef),\
|
||||
w(0xa0), w(0xe0), w(0x3b), w(0x4d), w(0xae), w(0x2a), w(0xf5), w(0xb0),\
|
||||
w(0xc8), w(0xeb), w(0xbb), w(0x3c), w(0x83), w(0x53), w(0x99), w(0x61),\
|
||||
w(0x17), w(0x2b), w(0x04), w(0x7e), w(0xba), w(0x77), w(0xd6), w(0x26),\
|
||||
w(0xe1), w(0x69), w(0x14), w(0x63), w(0x55), w(0x21), w(0x0c), w(0x7d) }
|
||||
|
||||
#define mm_data(w) {\
|
||||
w(0x00), w(0x01), w(0x02), w(0x03), w(0x04), w(0x05), w(0x06), w(0x07),\
|
||||
w(0x08), w(0x09), w(0x0a), w(0x0b), w(0x0c), w(0x0d), w(0x0e), w(0x0f),\
|
||||
w(0x10), w(0x11), w(0x12), w(0x13), w(0x14), w(0x15), w(0x16), w(0x17),\
|
||||
w(0x18), w(0x19), w(0x1a), w(0x1b), w(0x1c), w(0x1d), w(0x1e), w(0x1f),\
|
||||
w(0x20), w(0x21), w(0x22), w(0x23), w(0x24), w(0x25), w(0x26), w(0x27),\
|
||||
w(0x28), w(0x29), w(0x2a), w(0x2b), w(0x2c), w(0x2d), w(0x2e), w(0x2f),\
|
||||
w(0x30), w(0x31), w(0x32), w(0x33), w(0x34), w(0x35), w(0x36), w(0x37),\
|
||||
w(0x38), w(0x39), w(0x3a), w(0x3b), w(0x3c), w(0x3d), w(0x3e), w(0x3f),\
|
||||
w(0x40), w(0x41), w(0x42), w(0x43), w(0x44), w(0x45), w(0x46), w(0x47),\
|
||||
w(0x48), w(0x49), w(0x4a), w(0x4b), w(0x4c), w(0x4d), w(0x4e), w(0x4f),\
|
||||
w(0x50), w(0x51), w(0x52), w(0x53), w(0x54), w(0x55), w(0x56), w(0x57),\
|
||||
w(0x58), w(0x59), w(0x5a), w(0x5b), w(0x5c), w(0x5d), w(0x5e), w(0x5f),\
|
||||
w(0x60), w(0x61), w(0x62), w(0x63), w(0x64), w(0x65), w(0x66), w(0x67),\
|
||||
w(0x68), w(0x69), w(0x6a), w(0x6b), w(0x6c), w(0x6d), w(0x6e), w(0x6f),\
|
||||
w(0x70), w(0x71), w(0x72), w(0x73), w(0x74), w(0x75), w(0x76), w(0x77),\
|
||||
w(0x78), w(0x79), w(0x7a), w(0x7b), w(0x7c), w(0x7d), w(0x7e), w(0x7f),\
|
||||
w(0x80), w(0x81), w(0x82), w(0x83), w(0x84), w(0x85), w(0x86), w(0x87),\
|
||||
w(0x88), w(0x89), w(0x8a), w(0x8b), w(0x8c), w(0x8d), w(0x8e), w(0x8f),\
|
||||
w(0x90), w(0x91), w(0x92), w(0x93), w(0x94), w(0x95), w(0x96), w(0x97),\
|
||||
w(0x98), w(0x99), w(0x9a), w(0x9b), w(0x9c), w(0x9d), w(0x9e), w(0x9f),\
|
||||
w(0xa0), w(0xa1), w(0xa2), w(0xa3), w(0xa4), w(0xa5), w(0xa6), w(0xa7),\
|
||||
w(0xa8), w(0xa9), w(0xaa), w(0xab), w(0xac), w(0xad), w(0xae), w(0xaf),\
|
||||
w(0xb0), w(0xb1), w(0xb2), w(0xb3), w(0xb4), w(0xb5), w(0xb6), w(0xb7),\
|
||||
w(0xb8), w(0xb9), w(0xba), w(0xbb), w(0xbc), w(0xbd), w(0xbe), w(0xbf),\
|
||||
w(0xc0), w(0xc1), w(0xc2), w(0xc3), w(0xc4), w(0xc5), w(0xc6), w(0xc7),\
|
||||
w(0xc8), w(0xc9), w(0xca), w(0xcb), w(0xcc), w(0xcd), w(0xce), w(0xcf),\
|
||||
w(0xd0), w(0xd1), w(0xd2), w(0xd3), w(0xd4), w(0xd5), w(0xd6), w(0xd7),\
|
||||
w(0xd8), w(0xd9), w(0xda), w(0xdb), w(0xdc), w(0xdd), w(0xde), w(0xdf),\
|
||||
w(0xe0), w(0xe1), w(0xe2), w(0xe3), w(0xe4), w(0xe5), w(0xe6), w(0xe7),\
|
||||
w(0xe8), w(0xe9), w(0xea), w(0xeb), w(0xec), w(0xed), w(0xee), w(0xef),\
|
||||
w(0xf0), w(0xf1), w(0xf2), w(0xf3), w(0xf4), w(0xf5), w(0xf6), w(0xf7),\
|
||||
w(0xf8), w(0xf9), w(0xfa), w(0xfb), w(0xfc), w(0xfd), w(0xfe), w(0xff) }
|
||||
|
||||
#define rc_data(w) {\
|
||||
w(0x01), w(0x02), w(0x04), w(0x08), w(0x10),w(0x20), w(0x40), w(0x80),\
|
||||
w(0x1b), w(0x36) }
|
||||
|
||||
#define h0(x) (x)
|
||||
|
||||
#define w0(p) bytes2word(p, 0, 0, 0)
|
||||
#define w1(p) bytes2word(0, p, 0, 0)
|
||||
#define w2(p) bytes2word(0, 0, p, 0)
|
||||
#define w3(p) bytes2word(0, 0, 0, p)
|
||||
|
||||
#define u0(p) bytes2word(f2(p), p, p, f3(p))
|
||||
#define u1(p) bytes2word(f3(p), f2(p), p, p)
|
||||
#define u2(p) bytes2word(p, f3(p), f2(p), p)
|
||||
#define u3(p) bytes2word(p, p, f3(p), f2(p))
|
||||
|
||||
#define v0(p) bytes2word(fe(p), f9(p), fd(p), fb(p))
|
||||
#define v1(p) bytes2word(fb(p), fe(p), f9(p), fd(p))
|
||||
#define v2(p) bytes2word(fd(p), fb(p), fe(p), f9(p))
|
||||
#define v3(p) bytes2word(f9(p), fd(p), fb(p), fe(p))
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(STATIC_TABLES) || !defined(FF_TABLES)
|
||||
|
||||
#define f2(x) ((x<<1) ^ (((x>>7) & 1) * WPOLY))
|
||||
#define f4(x) ((x<<2) ^ (((x>>6) & 1) * WPOLY) ^ (((x>>6) & 2) * WPOLY))
|
||||
#define f8(x) ((x<<3) ^ (((x>>5) & 1) * WPOLY) ^ (((x>>5) & 2) * WPOLY) \
|
||||
^ (((x>>5) & 4) * WPOLY))
|
||||
#define f3(x) (f2(x) ^ x)
|
||||
#define f9(x) (f8(x) ^ x)
|
||||
#define fb(x) (f8(x) ^ f2(x) ^ x)
|
||||
#define fd(x) (f8(x) ^ f4(x) ^ x)
|
||||
#define fe(x) (f8(x) ^ f4(x) ^ f2(x))
|
||||
|
||||
#else
|
||||
|
||||
#define f2(x) ((x) ? pow[log[x] + 0x19] : 0)
|
||||
#define f3(x) ((x) ? pow[log[x] + 0x01] : 0)
|
||||
#define f9(x) ((x) ? pow[log[x] + 0xc7] : 0)
|
||||
#define fb(x) ((x) ? pow[log[x] + 0x68] : 0)
|
||||
#define fd(x) ((x) ? pow[log[x] + 0xee] : 0)
|
||||
#define fe(x) ((x) ? pow[log[x] + 0xdf] : 0)
|
||||
|
||||
#endif
|
||||
|
||||
#include "aestab.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined(STATIC_TABLES)
|
||||
|
||||
/* implemented in case of wrong call for fixed tables */
|
||||
|
||||
AES_RETURN aes_init(void)
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else /* Generate the tables for the dynamic table option */
|
||||
|
||||
#if defined(FF_TABLES)
|
||||
|
||||
#define gf_inv(x) ((x) ? pow[ 255 - log[x]] : 0)
|
||||
|
||||
#else
|
||||
|
||||
/* It will generally be sensible to use tables to compute finite
|
||||
field multiplies and inverses but where memory is scarse this
|
||||
code might sometimes be better. But it only has effect during
|
||||
initialisation so its pretty unimportant in overall terms.
|
||||
*/
|
||||
|
||||
/* return 2 ^ (n - 1) where n is the bit number of the highest bit
|
||||
set in x with x in the range 1 < x < 0x00000200. This form is
|
||||
used so that locals within fi can be bytes rather than words
|
||||
*/
|
||||
|
||||
static uint8_t hibit(const uint32_t x)
|
||||
{ uint8_t r = (uint8_t)((x >> 1) | (x >> 2));
|
||||
|
||||
r |= (r >> 2);
|
||||
r |= (r >> 4);
|
||||
return (r + 1) >> 1;
|
||||
}
|
||||
|
||||
/* return the inverse of the finite field element x */
|
||||
|
||||
static uint8_t gf_inv(const uint8_t x)
|
||||
{ uint8_t p1 = x, p2 = BPOLY, n1 = hibit(x), n2 = 0x80, v1 = 1, v2 = 0;
|
||||
|
||||
if(x < 2)
|
||||
return x;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
if(n1)
|
||||
while(n2 >= n1) /* divide polynomial p2 by p1 */
|
||||
{
|
||||
n2 /= n1; /* shift smaller polynomial left */
|
||||
p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */
|
||||
v2 ^= v1 * n2; /* shift accumulated value and */
|
||||
n2 = hibit(p2); /* add into result */
|
||||
}
|
||||
else
|
||||
return v1;
|
||||
|
||||
if(n2) /* repeat with values swapped */
|
||||
while(n1 >= n2)
|
||||
{
|
||||
n1 /= n2;
|
||||
p1 ^= p2 * n1;
|
||||
v1 ^= v2 * n1;
|
||||
n1 = hibit(p1);
|
||||
}
|
||||
else
|
||||
return v2;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* The forward and inverse affine transformations used in the S-box */
|
||||
uint8_t fwd_affine(const uint8_t x)
|
||||
{ uint32_t w = x;
|
||||
w ^= (w << 1) ^ (w << 2) ^ (w << 3) ^ (w << 4);
|
||||
return 0x63 ^ ((w ^ (w >> 8)) & 0xff);
|
||||
}
|
||||
|
||||
uint8_t inv_affine(const uint8_t x)
|
||||
{ uint32_t w = x;
|
||||
w = (w << 1) ^ (w << 3) ^ (w << 6);
|
||||
return 0x05 ^ ((w ^ (w >> 8)) & 0xff);
|
||||
}
|
||||
|
||||
static int init = 0;
|
||||
|
||||
AES_RETURN aes_init(void)
|
||||
{ uint32_t i, w;
|
||||
|
||||
#if defined(FF_TABLES)
|
||||
|
||||
uint8_t pow[512], log[256];
|
||||
|
||||
if(init)
|
||||
return EXIT_SUCCESS;
|
||||
/* log and power tables for GF(2^8) finite field with
|
||||
WPOLY as modular polynomial - the simplest primitive
|
||||
root is 0x03, used here to generate the tables
|
||||
*/
|
||||
|
||||
i = 0; w = 1;
|
||||
do
|
||||
{
|
||||
pow[i] = (uint8_t)w;
|
||||
pow[i + 255] = (uint8_t)w;
|
||||
log[w] = (uint8_t)i++;
|
||||
w ^= (w << 1) ^ (w & 0x80 ? WPOLY : 0);
|
||||
}
|
||||
while (w != 1);
|
||||
|
||||
#else
|
||||
if(init)
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
|
||||
for(i = 0, w = 1; i < RC_LENGTH; ++i)
|
||||
{
|
||||
t_set(r,c)[i] = bytes2word(w, 0, 0, 0);
|
||||
w = f2(w);
|
||||
}
|
||||
|
||||
for(i = 0; i < 256; ++i)
|
||||
{ uint8_t b;
|
||||
|
||||
b = fwd_affine(gf_inv((uint8_t)i));
|
||||
w = bytes2word(f2(b), b, b, f3(b));
|
||||
|
||||
#if defined( SBX_SET )
|
||||
t_set(s,box)[i] = b;
|
||||
#endif
|
||||
|
||||
#if defined( FT1_SET ) /* tables for a normal encryption round */
|
||||
t_set(f,n)[i] = w;
|
||||
#endif
|
||||
#if defined( FT4_SET )
|
||||
t_set(f,n)[0][i] = w;
|
||||
t_set(f,n)[1][i] = upr(w,1);
|
||||
t_set(f,n)[2][i] = upr(w,2);
|
||||
t_set(f,n)[3][i] = upr(w,3);
|
||||
#endif
|
||||
w = bytes2word(b, 0, 0, 0);
|
||||
|
||||
#if defined( FL1_SET ) /* tables for last encryption round (may also */
|
||||
t_set(f,l)[i] = w; /* be used in the key schedule) */
|
||||
#endif
|
||||
#if defined( FL4_SET )
|
||||
t_set(f,l)[0][i] = w;
|
||||
t_set(f,l)[1][i] = upr(w,1);
|
||||
t_set(f,l)[2][i] = upr(w,2);
|
||||
t_set(f,l)[3][i] = upr(w,3);
|
||||
#endif
|
||||
|
||||
#if defined( LS1_SET ) /* table for key schedule if t_set(f,l) above is*/
|
||||
t_set(l,s)[i] = w; /* not of the required form */
|
||||
#endif
|
||||
#if defined( LS4_SET )
|
||||
t_set(l,s)[0][i] = w;
|
||||
t_set(l,s)[1][i] = upr(w,1);
|
||||
t_set(l,s)[2][i] = upr(w,2);
|
||||
t_set(l,s)[3][i] = upr(w,3);
|
||||
#endif
|
||||
|
||||
b = gf_inv(inv_affine((uint8_t)i));
|
||||
w = bytes2word(fe(b), f9(b), fd(b), fb(b));
|
||||
|
||||
#if defined( IM1_SET ) /* tables for the inverse mix column operation */
|
||||
t_set(i,m)[b] = w;
|
||||
#endif
|
||||
#if defined( IM4_SET )
|
||||
t_set(i,m)[0][b] = w;
|
||||
t_set(i,m)[1][b] = upr(w,1);
|
||||
t_set(i,m)[2][b] = upr(w,2);
|
||||
t_set(i,m)[3][b] = upr(w,3);
|
||||
#endif
|
||||
|
||||
#if defined( ISB_SET )
|
||||
t_set(i,box)[i] = b;
|
||||
#endif
|
||||
#if defined( IT1_SET ) /* tables for a normal decryption round */
|
||||
t_set(i,n)[i] = w;
|
||||
#endif
|
||||
#if defined( IT4_SET )
|
||||
t_set(i,n)[0][i] = w;
|
||||
t_set(i,n)[1][i] = upr(w,1);
|
||||
t_set(i,n)[2][i] = upr(w,2);
|
||||
t_set(i,n)[3][i] = upr(w,3);
|
||||
#endif
|
||||
w = bytes2word(b, 0, 0, 0);
|
||||
#if defined( IL1_SET ) /* tables for last decryption round */
|
||||
t_set(i,l)[i] = w;
|
||||
#endif
|
||||
#if defined( IL4_SET )
|
||||
t_set(i,l)[0][i] = w;
|
||||
t_set(i,l)[1][i] = upr(w,1);
|
||||
t_set(i,l)[2][i] = upr(w,2);
|
||||
t_set(i,l)[3][i] = upr(w,3);
|
||||
#endif
|
||||
}
|
||||
init = 1;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Automatic code initialisation (suggested by by Henrik S. Gaßmann)
|
||||
based on code provided by Joe Lowe and placed in the public domain at:
|
||||
http://stackoverflow.com/questions/1113409/attribute-constructor-equivalent-in-vc
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#pragma section(".CRT$XCU", read)
|
||||
|
||||
__declspec(allocate(".CRT$XCU")) void (__cdecl *aes_startup)(void) = aes_init;
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
static void aes_startup(void) __attribute__((constructor));
|
||||
|
||||
static void aes_startup(void)
|
||||
{
|
||||
aes_init();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#pragma message( "dynamic tables must be initialised manually on your system" )
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
173
game/client/third/minizip/lib/aes/aestab.h
Executable file
173
game/client/third/minizip/lib/aes/aestab.h
Executable file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This file contains the code for declaring the tables needed to implement
|
||||
AES. The file aesopt.h is assumed to be included before this header file.
|
||||
If there are no global variables, the definitions here can be used to put
|
||||
the AES tables in a structure so that a pointer can then be added to the
|
||||
AES context to pass them to the AES routines that need them. If this
|
||||
facility is used, the calling program has to ensure that this pointer is
|
||||
managed appropriately. In particular, the value of the t_dec(in,it) item
|
||||
in the table structure must be set to zero in order to ensure that the
|
||||
tables are initialised. In practice the three code sequences in aeskey.c
|
||||
that control the calls to aes_init() and the aes_init() routine itself will
|
||||
have to be changed for a specific implementation. If global variables are
|
||||
available it will generally be preferable to use them with the precomputed
|
||||
STATIC_TABLES option that uses static global tables.
|
||||
|
||||
The following defines can be used to control the way the tables
|
||||
are defined, initialised and used in embedded environments that
|
||||
require special features for these purposes
|
||||
|
||||
the 't_dec' construction is used to declare fixed table arrays
|
||||
the 't_set' construction is used to set fixed table values
|
||||
the 't_use' construction is used to access fixed table values
|
||||
|
||||
256 byte tables:
|
||||
|
||||
t_xxx(s,box) => forward S box
|
||||
t_xxx(i,box) => inverse S box
|
||||
|
||||
256 32-bit word OR 4 x 256 32-bit word tables:
|
||||
|
||||
t_xxx(f,n) => forward normal round
|
||||
t_xxx(f,l) => forward last round
|
||||
t_xxx(i,n) => inverse normal round
|
||||
t_xxx(i,l) => inverse last round
|
||||
t_xxx(l,s) => key schedule table
|
||||
t_xxx(i,m) => key schedule table
|
||||
|
||||
Other variables and tables:
|
||||
|
||||
t_xxx(r,c) => the rcon table
|
||||
*/
|
||||
|
||||
#if !defined( _AESTAB_H )
|
||||
#define _AESTAB_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define t_dec(m,n) t_##m##n
|
||||
#define t_set(m,n) t_##m##n
|
||||
#define t_use(m,n) t_##m##n
|
||||
|
||||
#if defined(STATIC_TABLES)
|
||||
# if !defined( __GNUC__ ) && (defined( __MSDOS__ ) || defined( __WIN16__ ))
|
||||
/* make tables far data to avoid using too much DGROUP space (PG) */
|
||||
# define CONST const far
|
||||
# else
|
||||
# define CONST const
|
||||
# endif
|
||||
#else
|
||||
# define CONST
|
||||
#endif
|
||||
|
||||
#if defined(DO_TABLES)
|
||||
# define EXTERN
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(TABLE_ALIGN)
|
||||
#define ALIGN __declspec(align(TABLE_ALIGN))
|
||||
#else
|
||||
#define ALIGN
|
||||
#endif
|
||||
|
||||
#if defined( __WATCOMC__ ) && ( __WATCOMC__ >= 1100 )
|
||||
# define XP_DIR __cdecl
|
||||
#else
|
||||
# define XP_DIR
|
||||
#endif
|
||||
|
||||
#if defined(DO_TABLES) && defined(STATIC_TABLES)
|
||||
#define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256] = b(e)
|
||||
#define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256] = { b(e), b(f), b(g), b(h) }
|
||||
EXTERN ALIGN CONST uint32_t t_dec(r,c)[RC_LENGTH] = rc_data(w0);
|
||||
#else
|
||||
#define d_1(t,n,b,e) EXTERN ALIGN CONST XP_DIR t n[256]
|
||||
#define d_4(t,n,b,e,f,g,h) EXTERN ALIGN CONST XP_DIR t n[4][256]
|
||||
EXTERN ALIGN CONST uint32_t t_dec(r,c)[RC_LENGTH];
|
||||
#endif
|
||||
|
||||
#if defined( SBX_SET )
|
||||
d_1(uint8_t, t_dec(s,box), sb_data, h0);
|
||||
#endif
|
||||
#if defined( ISB_SET )
|
||||
d_1(uint8_t, t_dec(i,box), isb_data, h0);
|
||||
#endif
|
||||
|
||||
#if defined( FT1_SET )
|
||||
d_1(uint32_t, t_dec(f,n), sb_data, u0);
|
||||
#endif
|
||||
#if defined( FT4_SET )
|
||||
d_4(uint32_t, t_dec(f,n), sb_data, u0, u1, u2, u3);
|
||||
#endif
|
||||
|
||||
#if defined( FL1_SET )
|
||||
d_1(uint32_t, t_dec(f,l), sb_data, w0);
|
||||
#endif
|
||||
#if defined( FL4_SET )
|
||||
d_4(uint32_t, t_dec(f,l), sb_data, w0, w1, w2, w3);
|
||||
#endif
|
||||
|
||||
#if defined( IT1_SET )
|
||||
d_1(uint32_t, t_dec(i,n), isb_data, v0);
|
||||
#endif
|
||||
#if defined( IT4_SET )
|
||||
d_4(uint32_t, t_dec(i,n), isb_data, v0, v1, v2, v3);
|
||||
#endif
|
||||
|
||||
#if defined( IL1_SET )
|
||||
d_1(uint32_t, t_dec(i,l), isb_data, w0);
|
||||
#endif
|
||||
#if defined( IL4_SET )
|
||||
d_4(uint32_t, t_dec(i,l), isb_data, w0, w1, w2, w3);
|
||||
#endif
|
||||
|
||||
#if defined( LS1_SET )
|
||||
#if defined( FL1_SET )
|
||||
#undef LS1_SET
|
||||
#else
|
||||
d_1(uint32_t, t_dec(l,s), sb_data, w0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined( LS4_SET )
|
||||
#if defined( FL4_SET )
|
||||
#undef LS4_SET
|
||||
#else
|
||||
d_4(uint32_t, t_dec(l,s), sb_data, w0, w1, w2, w3);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined( IM1_SET )
|
||||
d_1(uint32_t, t_dec(i,m), mm_data, v0);
|
||||
#endif
|
||||
#if defined( IM4_SET )
|
||||
d_4(uint32_t, t_dec(i,m), mm_data, v0, v1, v2, v3);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
127
game/client/third/minizip/lib/aes/brg_endian.h
Executable file
127
game/client/third/minizip/lib/aes/brg_endian.h
Executable file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#ifndef _BRG_ENDIAN_H
|
||||
#define _BRG_ENDIAN_H
|
||||
|
||||
#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
|
||||
#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
|
||||
|
||||
/* Include files where endian defines and byteswap functions may reside */
|
||||
#if defined( __sun )
|
||||
# include <sys/isa_defs.h>
|
||||
#elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
|
||||
# include <sys/endian.h>
|
||||
#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
|
||||
defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ ) || \
|
||||
defined(__pnacl__)
|
||||
# include <machine/endian.h>
|
||||
#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
|
||||
# if !defined( __MINGW32__ ) && !defined( _AIX )
|
||||
# include <endian.h>
|
||||
# if !defined( __BEOS__ )
|
||||
# include <byteswap.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Now attempt to set the define for platform byte order using any */
|
||||
/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */
|
||||
/* seem to encompass most endian symbol definitions */
|
||||
|
||||
#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN )
|
||||
# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( BIG_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( LITTLE_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN )
|
||||
# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( _BIG_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( _LITTLE_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN )
|
||||
# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( __BIG_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( __LITTLE_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ )
|
||||
# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( __BIG_ENDIAN__ )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( __LITTLE_ENDIAN__ )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/* if the platform byte order could not be determined, then try to */
|
||||
/* set this define using common machine defines */
|
||||
#if !defined(PLATFORM_BYTE_ORDER)
|
||||
|
||||
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \
|
||||
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
|
||||
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
|
||||
defined( vax ) || defined( vms ) || defined( VMS ) || \
|
||||
defined( __VMS ) || defined( _M_X64 )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
|
||||
#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
|
||||
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
|
||||
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
|
||||
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
|
||||
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
|
||||
defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \
|
||||
defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
|
||||
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#else
|
||||
# error Please edit lines 126 or 128 in brg_endian.h to set the platform byte order
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
191
game/client/third/minizip/lib/aes/brg_types.h
Executable file
191
game/client/third/minizip/lib/aes/brg_types.h
Executable file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
The unsigned integer types defined here are of the form uint_<nn>t where
|
||||
<nn> is the length of the type; for example, the unsigned 32-bit type is
|
||||
'uint32_t'. These are NOT the same as the 'C99 integer types' that are
|
||||
defined in the inttypes.h and stdint.h headers since attempts to use these
|
||||
types have shown that support for them is still highly variable. However,
|
||||
since the latter are of the form uint<nn>_t, a regular expression search
|
||||
and replace (in VC++ search on 'uint_{:z}t' and replace with 'uint\1_t')
|
||||
can be used to convert the types used here to the C99 standard types.
|
||||
*/
|
||||
|
||||
#ifndef _BRG_TYPES_H
|
||||
#define _BRG_TYPES_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined( _MSC_VER ) && ( _MSC_VER >= 1300 )
|
||||
# include <stddef.h>
|
||||
# define ptrint_t intptr_t
|
||||
#elif defined( __ECOS__ )
|
||||
# define intptr_t unsigned int
|
||||
# define ptrint_t intptr_t
|
||||
#elif defined( __GNUC__ ) && ( __GNUC__ >= 3 )
|
||||
# define ptrint_t intptr_t
|
||||
#else
|
||||
# define ptrint_t int
|
||||
#endif
|
||||
|
||||
#ifndef BRG_UI32
|
||||
# define BRG_UI32
|
||||
# if UINT_MAX == 4294967295u
|
||||
# define li_32(h) 0x##h##u
|
||||
# elif ULONG_MAX == 4294967295u
|
||||
# define li_32(h) 0x##h##ul
|
||||
# elif defined( _CRAY )
|
||||
# error This code needs 32-bit data types, which Cray machines do not provide
|
||||
# else
|
||||
# error Please define uint32_t as a 32-bit unsigned integer type in brg_types.h
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef BRG_UI64
|
||||
# if defined( __BORLANDC__ ) && !defined( __MSDOS__ )
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ui64
|
||||
# elif defined( _MSC_VER ) && ( _MSC_VER < 1300 ) /* 1300 == VC++ 7.0 */
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ui64
|
||||
# elif defined( __sun ) && defined( ULONG_MAX ) && ULONG_MAX == 0xfffffffful
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ull
|
||||
# elif defined( __MVS__ )
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ull
|
||||
# elif defined( UINT_MAX ) && UINT_MAX > 4294967295u
|
||||
# if UINT_MAX == 18446744073709551615u
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##u
|
||||
# endif
|
||||
# elif defined( ULONG_MAX ) && ULONG_MAX > 4294967295u
|
||||
# if ULONG_MAX == 18446744073709551615ul
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ul
|
||||
# endif
|
||||
# elif defined( ULLONG_MAX ) && ULLONG_MAX > 4294967295u
|
||||
# if ULLONG_MAX == 18446744073709551615ull
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ull
|
||||
# endif
|
||||
# elif defined( ULONG_LONG_MAX ) && ULONG_LONG_MAX > 4294967295u
|
||||
# if ULONG_LONG_MAX == 18446744073709551615ull
|
||||
# define BRG_UI64
|
||||
# define li_64(h) 0x##h##ull
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined( BRG_UI64 )
|
||||
# if defined( NEED_UINT_64T )
|
||||
# error Please define uint64_t as an unsigned 64 bit type in brg_types.h
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef RETURN_VALUES
|
||||
# define RETURN_VALUES
|
||||
# if defined( DLL_EXPORT )
|
||||
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
|
||||
# define VOID_RETURN __declspec( dllexport ) void __stdcall
|
||||
# define INT_RETURN __declspec( dllexport ) int __stdcall
|
||||
# elif defined( __GNUC__ )
|
||||
# define VOID_RETURN __declspec( __dllexport__ ) void
|
||||
# define INT_RETURN __declspec( __dllexport__ ) int
|
||||
# else
|
||||
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
|
||||
# endif
|
||||
# elif defined( DLL_IMPORT )
|
||||
# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER )
|
||||
# define VOID_RETURN __declspec( dllimport ) void __stdcall
|
||||
# define INT_RETURN __declspec( dllimport ) int __stdcall
|
||||
# elif defined( __GNUC__ )
|
||||
# define VOID_RETURN __declspec( __dllimport__ ) void
|
||||
# define INT_RETURN __declspec( __dllimport__ ) int
|
||||
# else
|
||||
# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers
|
||||
# endif
|
||||
# elif defined( __WATCOMC__ )
|
||||
# define VOID_RETURN void __cdecl
|
||||
# define INT_RETURN int __cdecl
|
||||
# else
|
||||
# define VOID_RETURN void
|
||||
# define INT_RETURN int
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* These defines are used to detect and set the memory alignment of pointers.
|
||||
Note that offsets are in bytes.
|
||||
|
||||
ALIGN_OFFSET(x,n) return the positive or zero offset of
|
||||
the memory addressed by the pointer 'x'
|
||||
from an address that is aligned on an
|
||||
'n' byte boundary ('n' is a power of 2)
|
||||
|
||||
ALIGN_FLOOR(x,n) return a pointer that points to memory
|
||||
that is aligned on an 'n' byte boundary
|
||||
and is not higher than the memory address
|
||||
pointed to by 'x' ('n' is a power of 2)
|
||||
|
||||
ALIGN_CEIL(x,n) return a pointer that points to memory
|
||||
that is aligned on an 'n' byte boundary
|
||||
and is not lower than the memory address
|
||||
pointed to by 'x' ('n' is a power of 2)
|
||||
*/
|
||||
|
||||
#define ALIGN_OFFSET(x,n) (((ptrint_t)(x)) & ((n) - 1))
|
||||
#define ALIGN_FLOOR(x,n) ((uint8_t*)(x) - ( ((ptrint_t)(x)) & ((n) - 1)))
|
||||
#define ALIGN_CEIL(x,n) ((uint8_t*)(x) + (-((ptrint_t)(x)) & ((n) - 1)))
|
||||
|
||||
/* These defines are used to declare buffers in a way that allows
|
||||
faster operations on longer variables to be used. In all these
|
||||
defines 'size' must be a power of 2 and >= 8. NOTE that the
|
||||
buffer size is in bytes but the type length is in bits
|
||||
|
||||
UNIT_TYPEDEF(x,size) declares a variable 'x' of length
|
||||
'size' bits
|
||||
|
||||
BUFR_TYPEDEF(x,size,bsize) declares a buffer 'x' of length 'bsize'
|
||||
bytes defined as an array of variables
|
||||
each of 'size' bits (bsize must be a
|
||||
multiple of size / 8)
|
||||
|
||||
UNIT_CAST(x,size) casts a variable to a type of
|
||||
length 'size' bits
|
||||
|
||||
UPTR_CAST(x,size) casts a pointer to a pointer to a
|
||||
varaiable of length 'size' bits
|
||||
*/
|
||||
|
||||
#define UI_TYPE(size) uint##size##_t
|
||||
#define UNIT_TYPEDEF(x,size) typedef UI_TYPE(size) x
|
||||
#define BUFR_TYPEDEF(x,size,bsize) typedef UI_TYPE(size) x[bsize / (size >> 3)]
|
||||
#define UNIT_CAST(x,size) ((UI_TYPE(size) )(x))
|
||||
#define UPTR_CAST(x,size) ((UI_TYPE(size)*)(x))
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
209
game/client/third/minizip/lib/aes/hmac.c
Executable file
209
game/client/third/minizip/lib/aes/hmac.c
Executable file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This is an implementation of HMAC, the FIPS standard keyed hash function
|
||||
*/
|
||||
|
||||
#include "hmac.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* initialise the HMAC context to zero */
|
||||
int hmac_sha_begin(enum hmac_hash hash, hmac_ctx cx[1])
|
||||
{
|
||||
memset(cx, 0, sizeof(hmac_ctx));
|
||||
switch(hash)
|
||||
{
|
||||
#ifdef SHA_1
|
||||
case HMAC_SHA1:
|
||||
cx->f_begin = (hf_begin *)sha1_begin;
|
||||
cx->f_hash = (hf_hash *)sha1_hash;
|
||||
cx->f_end = (hf_end *)sha1_end;
|
||||
cx->input_len = SHA1_BLOCK_SIZE;
|
||||
cx->output_len = SHA1_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SHA_224
|
||||
case HMAC_SHA224:
|
||||
cx->f_begin = (hf_begin *)sha224_begin;
|
||||
cx->f_hash = (hf_hash *)sha224_hash;
|
||||
cx->f_end = (hf_end *)sha224_end;
|
||||
cx->input_len = SHA224_BLOCK_SIZE;
|
||||
cx->output_len = SHA224_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SHA_256
|
||||
case HMAC_SHA256:
|
||||
cx->f_begin = (hf_begin *)sha256_begin;
|
||||
cx->f_hash = (hf_hash *)sha256_hash;
|
||||
cx->f_end = (hf_end *)sha256_end;
|
||||
cx->input_len = SHA256_BLOCK_SIZE;
|
||||
cx->output_len = SHA256_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SHA_384
|
||||
case HMAC_SHA384:
|
||||
cx->f_begin = (hf_begin *)sha384_begin;
|
||||
cx->f_hash = (hf_hash *)sha384_hash;
|
||||
cx->f_end = (hf_end *)sha384_end;
|
||||
cx->input_len = SHA384_BLOCK_SIZE;
|
||||
cx->output_len = SHA384_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SHA_512
|
||||
case HMAC_SHA512:
|
||||
cx->f_begin = (hf_begin *)sha512_begin;
|
||||
cx->f_hash = (hf_hash *)sha512_hash;
|
||||
cx->f_end = (hf_end *)sha512_end;
|
||||
cx->input_len = SHA512_BLOCK_SIZE;
|
||||
cx->output_len = SHA512_DIGEST_SIZE;
|
||||
break;
|
||||
case HMAC_SHA512_256:
|
||||
cx->f_begin = (hf_begin *)sha512_256_begin;
|
||||
cx->f_hash = (hf_hash *)sha512_256_hash;
|
||||
cx->f_end = (hf_end *)sha512_256_end;
|
||||
cx->input_len = SHA512_256_BLOCK_SIZE;
|
||||
cx->output_len = SHA512_256_DIGEST_SIZE;
|
||||
break;
|
||||
case HMAC_SHA512_224:
|
||||
cx->f_begin = (hf_begin *)sha512_224_begin;
|
||||
cx->f_hash = (hf_hash *)sha512_224_hash;
|
||||
cx->f_end = (hf_end *)sha512_224_end;
|
||||
cx->input_len = SHA512_224_BLOCK_SIZE;
|
||||
cx->output_len = SHA512_224_DIGEST_SIZE;
|
||||
break;
|
||||
case HMAC_SHA512_192:
|
||||
cx->f_begin = (hf_begin *)sha512_192_begin;
|
||||
cx->f_hash = (hf_hash *)sha512_192_hash;
|
||||
cx->f_end = (hf_end *)sha512_192_end;
|
||||
cx->input_len = SHA512_192_BLOCK_SIZE;
|
||||
cx->output_len = SHA512_192_DIGEST_SIZE;
|
||||
break;
|
||||
case HMAC_SHA512_128:
|
||||
cx->f_begin = (hf_begin *)sha512_128_begin;
|
||||
cx->f_hash = (hf_hash *)sha512_128_hash;
|
||||
cx->f_end = (hf_begin *)sha512_128_end;
|
||||
cx->input_len = SHA512_128_BLOCK_SIZE;
|
||||
cx->output_len = SHA512_128_DIGEST_SIZE;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
return (int)cx->output_len;
|
||||
}
|
||||
|
||||
/* input the HMAC key (can be called multiple times) */
|
||||
int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1])
|
||||
{
|
||||
if(cx->klen == HMAC_IN_DATA) /* error if further key input */
|
||||
return EXIT_FAILURE; /* is attempted in data mode */
|
||||
|
||||
if(cx->klen + key_len > cx->input_len) /* if the key has to be hashed */
|
||||
{
|
||||
if(cx->klen <= cx->input_len) /* if the hash has not yet been */
|
||||
{ /* started, initialise it and */
|
||||
cx->f_begin(cx->sha_ctx); /* hash stored key characters */
|
||||
cx->f_hash(cx->key, cx->klen, cx->sha_ctx);
|
||||
}
|
||||
|
||||
cx->f_hash(key, key_len, cx->sha_ctx); /* hash long key data into hash */
|
||||
}
|
||||
else /* otherwise store key data */
|
||||
memcpy(cx->key + cx->klen, key, key_len);
|
||||
|
||||
cx->klen += key_len; /* update the key length count */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* input the HMAC data (can be called multiple times) - */
|
||||
/* note that this call terminates the key input phase */
|
||||
void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1])
|
||||
{ unsigned int i;
|
||||
|
||||
if(cx->klen != HMAC_IN_DATA) /* if not yet in data phase */
|
||||
{
|
||||
if(cx->klen > cx->input_len) /* if key is being hashed */
|
||||
{ /* complete the hash and */
|
||||
cx->f_end(cx->key, cx->sha_ctx); /* store the result as the */
|
||||
cx->klen = cx->output_len; /* key and set new length */
|
||||
}
|
||||
|
||||
/* pad the key if necessary */
|
||||
memset(cx->key + cx->klen, 0, cx->input_len - cx->klen);
|
||||
|
||||
/* xor ipad into key value */
|
||||
for(i = 0; i < (cx->input_len >> 2); ++i)
|
||||
((uint32_t*)cx->key)[i] ^= 0x36363636;
|
||||
|
||||
/* and start hash operation */
|
||||
cx->f_begin(cx->sha_ctx);
|
||||
cx->f_hash(cx->key, cx->input_len, cx->sha_ctx);
|
||||
|
||||
/* mark as now in data mode */
|
||||
cx->klen = HMAC_IN_DATA;
|
||||
}
|
||||
|
||||
/* hash the data (if any) */
|
||||
if(data_len)
|
||||
cx->f_hash(data, data_len, cx->sha_ctx);
|
||||
}
|
||||
|
||||
/* compute and output the MAC value */
|
||||
void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
|
||||
{ unsigned char dig[HMAC_MAX_OUTPUT_SIZE];
|
||||
unsigned int i;
|
||||
|
||||
/* if no data has been entered perform a null data phase */
|
||||
if(cx->klen != HMAC_IN_DATA)
|
||||
hmac_sha_data((const unsigned char*)0, 0, cx);
|
||||
|
||||
cx->f_end(dig, cx->sha_ctx); /* complete the inner hash */
|
||||
|
||||
/* set outer key value using opad and removing ipad */
|
||||
for(i = 0; i < (cx->input_len >> 2); ++i)
|
||||
((uint32_t*)cx->key)[i] ^= 0x36363636 ^ 0x5c5c5c5c;
|
||||
|
||||
/* perform the outer hash operation */
|
||||
cx->f_begin(cx->sha_ctx);
|
||||
cx->f_hash(cx->key, cx->input_len, cx->sha_ctx);
|
||||
cx->f_hash(dig, cx->output_len, cx->sha_ctx);
|
||||
cx->f_end(dig, cx->sha_ctx);
|
||||
|
||||
/* output the hash value */
|
||||
for(i = 0; i < mac_len; ++i)
|
||||
mac[i] = dig[i];
|
||||
}
|
||||
|
||||
/* 'do it all in one go' subroutine */
|
||||
void hmac_sha(enum hmac_hash hash, const unsigned char key[], unsigned long key_len,
|
||||
const unsigned char data[], unsigned long data_len,
|
||||
unsigned char mac[], unsigned long mac_len)
|
||||
{ hmac_ctx cx[1];
|
||||
|
||||
hmac_sha_begin(hash, cx);
|
||||
hmac_sha_key(key, key_len, cx);
|
||||
hmac_sha_data(data, data_len, cx);
|
||||
hmac_sha_end(mac, mac_len, cx);
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
119
game/client/third/minizip/lib/aes/hmac.h
Executable file
119
game/client/third/minizip/lib/aes/hmac.h
Executable file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This is an implementation of HMAC, the FIPS standard keyed hash function
|
||||
*/
|
||||
|
||||
#ifndef _HMAC2_H
|
||||
#define _HMAC2_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "sha1.h"
|
||||
|
||||
#if defined(SHA_224) || defined(SHA_256) || defined(SHA_384) || defined(SHA_512)
|
||||
#define HMAC_MAX_OUTPUT_SIZE SHA2_MAX_DIGEST_SIZE
|
||||
#define HMAC_MAX_BLOCK_SIZE SHA2_MAX_BLOCK_SIZE
|
||||
#else
|
||||
#define HMAC_MAX_OUTPUT_SIZE SHA1_DIGEST_SIZE
|
||||
#define HMAC_MAX_BLOCK_SIZE SHA1_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
#define HMAC_IN_DATA 0xffffffff
|
||||
|
||||
enum hmac_hash
|
||||
{
|
||||
#ifdef SHA_1
|
||||
HMAC_SHA1,
|
||||
#endif
|
||||
#ifdef SHA_224
|
||||
HMAC_SHA224,
|
||||
#endif
|
||||
#ifdef SHA_256
|
||||
HMAC_SHA256,
|
||||
#endif
|
||||
#ifdef SHA_384
|
||||
HMAC_SHA384,
|
||||
#endif
|
||||
#ifdef SHA_512
|
||||
HMAC_SHA512,
|
||||
HMAC_SHA512_256,
|
||||
HMAC_SHA512_224,
|
||||
HMAC_SHA512_192,
|
||||
HMAC_SHA512_128
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef VOID_RETURN hf_begin(void*);
|
||||
typedef VOID_RETURN hf_hash(const void*, unsigned long len, void*);
|
||||
typedef VOID_RETURN hf_end(void*, void*);
|
||||
|
||||
typedef struct
|
||||
{ hf_begin *f_begin;
|
||||
hf_hash *f_hash;
|
||||
hf_end *f_end;
|
||||
unsigned char key[HMAC_MAX_BLOCK_SIZE];
|
||||
union
|
||||
{
|
||||
#ifdef SHA_1
|
||||
sha1_ctx u_sha1;
|
||||
#endif
|
||||
#ifdef SHA_224
|
||||
sha224_ctx u_sha224;
|
||||
#endif
|
||||
#ifdef SHA_256
|
||||
sha256_ctx u_sha256;
|
||||
#endif
|
||||
#ifdef SHA_384
|
||||
sha384_ctx u_sha384;
|
||||
#endif
|
||||
#ifdef SHA_512
|
||||
sha512_ctx u_sha512;
|
||||
#endif
|
||||
} sha_ctx[1];
|
||||
unsigned long input_len;
|
||||
unsigned long output_len;
|
||||
unsigned long klen;
|
||||
} hmac_ctx;
|
||||
|
||||
/* returns the length of hash digest for the hash used */
|
||||
/* mac_len must not be greater than this */
|
||||
int hmac_sha_begin(enum hmac_hash hash, hmac_ctx cx[1]);
|
||||
|
||||
int hmac_sha_key(const unsigned char key[], unsigned long key_len, hmac_ctx cx[1]);
|
||||
|
||||
void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx cx[1]);
|
||||
|
||||
void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1]);
|
||||
|
||||
void hmac_sha(enum hmac_hash hash, const unsigned char key[], unsigned long key_len,
|
||||
const unsigned char data[], unsigned long data_len,
|
||||
unsigned char mac[], unsigned long mac_len);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
182
game/client/third/minizip/lib/aes/pwd2key.c
Executable file
182
game/client/third/minizip/lib/aes/pwd2key.c
Executable file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This is an implementation of RFC2898, which specifies key derivation from
|
||||
a password and a salt value.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "hmac.h"
|
||||
#include "pwd2key.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void derive_key(const unsigned char pwd[], /* the PASSWORD */
|
||||
unsigned int pwd_len, /* and its length */
|
||||
const unsigned char salt[], /* the SALT and its */
|
||||
unsigned int salt_len, /* length */
|
||||
unsigned int iter, /* the number of iterations */
|
||||
unsigned char key[], /* space for the output key */
|
||||
unsigned int key_len)/* and its required length */
|
||||
{
|
||||
unsigned int i, j, k, n_blk, h_size;
|
||||
unsigned char uu[HMAC_MAX_OUTPUT_SIZE], ux[HMAC_MAX_OUTPUT_SIZE];
|
||||
hmac_ctx c1[1], c2[1], c3[1];
|
||||
|
||||
/* set HMAC context (c1) for password */
|
||||
h_size = hmac_sha_begin(HMAC_SHA1, c1);
|
||||
hmac_sha_key(pwd, pwd_len, c1);
|
||||
|
||||
/* set HMAC context (c2) for password and salt */
|
||||
memcpy(c2, c1, sizeof(hmac_ctx));
|
||||
hmac_sha_data(salt, salt_len, c2);
|
||||
|
||||
/* find the number of SHA blocks in the key */
|
||||
n_blk = 1 + (key_len - 1) / h_size;
|
||||
|
||||
for(i = 0; i < n_blk; ++i) /* for each block in key */
|
||||
{
|
||||
/* ux[] holds the running xor value */
|
||||
memset(ux, 0, h_size);
|
||||
|
||||
/* set HMAC context (c3) for password and salt */
|
||||
memcpy(c3, c2, sizeof(hmac_ctx));
|
||||
|
||||
/* enter additional data for 1st block into uu */
|
||||
uu[0] = (unsigned char)((i + 1) >> 24);
|
||||
uu[1] = (unsigned char)((i + 1) >> 16);
|
||||
uu[2] = (unsigned char)((i + 1) >> 8);
|
||||
uu[3] = (unsigned char)(i + 1);
|
||||
|
||||
/* this is the key mixing iteration */
|
||||
for(j = 0, k = 4; j < iter; ++j)
|
||||
{
|
||||
/* add previous round data to HMAC */
|
||||
hmac_sha_data(uu, k, c3);
|
||||
|
||||
/* obtain HMAC for uu[] */
|
||||
hmac_sha_end(uu, h_size, c3);
|
||||
|
||||
/* xor into the running xor block */
|
||||
for(k = 0; k < h_size; ++k)
|
||||
ux[k] ^= uu[k];
|
||||
|
||||
/* set HMAC context (c3) for password */
|
||||
memcpy(c3, c1, sizeof(hmac_ctx));
|
||||
}
|
||||
|
||||
/* compile key blocks into the key output */
|
||||
j = 0; k = i * h_size;
|
||||
while(j < h_size && k < key_len)
|
||||
key[k++] = ux[j++];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct
|
||||
{ unsigned int pwd_len;
|
||||
unsigned int salt_len;
|
||||
unsigned int it_count;
|
||||
unsigned char *pwd;
|
||||
unsigned char salt[32];
|
||||
unsigned char key[32];
|
||||
} tests[] =
|
||||
{
|
||||
{ 8, 4, 5, (unsigned char*)"password",
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78
|
||||
},
|
||||
{
|
||||
0x5c, 0x75, 0xce, 0xf0, 0x1a, 0x96, 0x0d, 0xf7,
|
||||
0x4c, 0xb6, 0xb4, 0x9b, 0x9e, 0x38, 0xe6, 0xb5
|
||||
}
|
||||
},
|
||||
{ 8, 8, 5, (unsigned char*)"password",
|
||||
{
|
||||
0x12, 0x34, 0x56, 0x78, 0x78, 0x56, 0x34, 0x12
|
||||
},
|
||||
{
|
||||
0xd1, 0xda, 0xa7, 0x86, 0x15, 0xf2, 0x87, 0xe6,
|
||||
0xa1, 0xc8, 0xb1, 0x20, 0xd7, 0x06, 0x2a, 0x49
|
||||
}
|
||||
},
|
||||
{ 8, 21, 1, (unsigned char*)"password",
|
||||
{
|
||||
"ATHENA.MIT.EDUraeburn"
|
||||
},
|
||||
{
|
||||
0xcd, 0xed, 0xb5, 0x28, 0x1b, 0xb2, 0xf8, 0x01,
|
||||
0x56, 0x5a, 0x11, 0x22, 0xb2, 0x56, 0x35, 0x15
|
||||
}
|
||||
},
|
||||
{ 8, 21, 2, (unsigned char*)"password",
|
||||
{
|
||||
"ATHENA.MIT.EDUraeburn"
|
||||
},
|
||||
{
|
||||
0x01, 0xdb, 0xee, 0x7f, 0x4a, 0x9e, 0x24, 0x3e,
|
||||
0x98, 0x8b, 0x62, 0xc7, 0x3c, 0xda, 0x93, 0x5d
|
||||
}
|
||||
},
|
||||
{ 8, 21, 1200, (unsigned char*)"password",
|
||||
{
|
||||
"ATHENA.MIT.EDUraeburn"
|
||||
},
|
||||
{
|
||||
0x5c, 0x08, 0xeb, 0x61, 0xfd, 0xf7, 0x1e, 0x4e,
|
||||
0x4e, 0xc3, 0xcf, 0x6b, 0xa1, 0xf5, 0x51, 0x2b
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{ unsigned int i, j, key_len = 256;
|
||||
unsigned char key[256];
|
||||
|
||||
printf("\nTest of RFC2898 Password Based Key Derivation");
|
||||
for(i = 0; i < 5; ++i)
|
||||
{
|
||||
derive_key(tests[i].pwd, tests[i].pwd_len, tests[i].salt,
|
||||
tests[i].salt_len, tests[i].it_count, key, key_len);
|
||||
|
||||
printf("\ntest %i: ", i + 1);
|
||||
printf("key %s", memcmp(tests[i].key, key, 16) ? "is bad" : "is good");
|
||||
for(j = 0; j < key_len && j < 64; j += 4)
|
||||
{
|
||||
if(j % 16 == 0)
|
||||
printf("\n");
|
||||
printf("0x%02x%02x%02x%02x ", key[j], key[j + 1], key[j + 2], key[j + 3]);
|
||||
}
|
||||
printf(j < key_len ? " ... \n" : "\n");
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
45
game/client/third/minizip/lib/aes/pwd2key.h
Executable file
45
game/client/third/minizip/lib/aes/pwd2key.h
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
|
||||
This is an implementation of RFC2898, which specifies key derivation from
|
||||
a password and a salt value.
|
||||
*/
|
||||
|
||||
#ifndef PWD2KEY_H
|
||||
#define PWD2KEY_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void derive_key(
|
||||
const unsigned char pwd[], /* the PASSWORD, and */
|
||||
unsigned int pwd_len, /* its length */
|
||||
const unsigned char salt[], /* the SALT and its */
|
||||
unsigned int salt_len, /* length */
|
||||
unsigned int iter, /* the number of iterations */
|
||||
unsigned char key[], /* space for the output key */
|
||||
unsigned int key_len); /* and its required length */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
283
game/client/third/minizip/lib/aes/sha1.c
Executable file
283
game/client/third/minizip/lib/aes/sha1.c
Executable file
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#include <string.h> /* for memcpy() etc. */
|
||||
|
||||
#include "sha1.h"
|
||||
#include "brg_endian.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#if defined( _MSC_VER ) && ( _MSC_VER > 800 )
|
||||
#pragma intrinsic(memcpy)
|
||||
#pragma intrinsic(memset)
|
||||
#endif
|
||||
|
||||
#if 0 && defined(_MSC_VER)
|
||||
#define rotl32 _lrotl
|
||||
#define rotr32 _lrotr
|
||||
#else
|
||||
#define rotl32(x,n) (((x) << n) | ((x) >> (32 - n)))
|
||||
#define rotr32(x,n) (((x) >> n) | ((x) << (32 - n)))
|
||||
#endif
|
||||
|
||||
#if !defined(bswap_32)
|
||||
#define bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00))
|
||||
#endif
|
||||
|
||||
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
||||
#define SWAP_BYTES
|
||||
#else
|
||||
#undef SWAP_BYTES
|
||||
#endif
|
||||
|
||||
#if defined(SWAP_BYTES)
|
||||
#define bsw_32(p,n) \
|
||||
{ int _i = (n); while(_i--) ((uint32_t*)p)[_i] = bswap_32(((uint32_t*)p)[_i]); }
|
||||
#else
|
||||
#define bsw_32(p,n)
|
||||
#endif
|
||||
|
||||
#define SHA1_MASK (SHA1_BLOCK_SIZE - 1)
|
||||
|
||||
#if 0
|
||||
|
||||
#define ch(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
|
||||
#define parity(x,y,z) ((x) ^ (y) ^ (z))
|
||||
#define maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||
|
||||
#else /* Discovered by Rich Schroeppel and Colin Plumb */
|
||||
|
||||
#define ch(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
|
||||
#define parity(x,y,z) ((x) ^ (y) ^ (z))
|
||||
#define maj(x,y,z) (((x) & (y)) | ((z) & ((x) ^ (y))))
|
||||
|
||||
#endif
|
||||
|
||||
/* Compile 64 bytes of hash data into SHA1 context. Note */
|
||||
/* that this routine assumes that the byte order in the */
|
||||
/* ctx->wbuf[] at this point is in such an order that low */
|
||||
/* address bytes in the ORIGINAL byte stream will go in */
|
||||
/* this buffer to the high end of 32-bit words on BOTH big */
|
||||
/* and little endian systems */
|
||||
|
||||
#ifdef ARRAY
|
||||
#define q(v,n) v[n]
|
||||
#else
|
||||
#define q(v,n) v##n
|
||||
#endif
|
||||
|
||||
#ifdef SHA_1
|
||||
|
||||
#define one_cycle(v,a,b,c,d,e,f,k,h) \
|
||||
q(v,e) += rotr32(q(v,a),27) + \
|
||||
f(q(v,b),q(v,c),q(v,d)) + k + h; \
|
||||
q(v,b) = rotr32(q(v,b), 2)
|
||||
|
||||
#define five_cycle(v,f,k,i) \
|
||||
one_cycle(v, 0,1,2,3,4, f,k,hf(i )); \
|
||||
one_cycle(v, 4,0,1,2,3, f,k,hf(i+1)); \
|
||||
one_cycle(v, 3,4,0,1,2, f,k,hf(i+2)); \
|
||||
one_cycle(v, 2,3,4,0,1, f,k,hf(i+3)); \
|
||||
one_cycle(v, 1,2,3,4,0, f,k,hf(i+4))
|
||||
|
||||
VOID_RETURN sha1_compile(sha1_ctx ctx[1])
|
||||
{ uint32_t *w = ctx->wbuf;
|
||||
|
||||
#ifdef ARRAY
|
||||
uint32_t v[5];
|
||||
memcpy(v, ctx->hash, sizeof(ctx->hash));
|
||||
#else
|
||||
uint32_t v0, v1, v2, v3, v4;
|
||||
v0 = ctx->hash[0]; v1 = ctx->hash[1];
|
||||
v2 = ctx->hash[2]; v3 = ctx->hash[3];
|
||||
v4 = ctx->hash[4];
|
||||
#endif
|
||||
|
||||
#define hf(i) w[i]
|
||||
|
||||
five_cycle(v, ch, 0x5a827999, 0);
|
||||
five_cycle(v, ch, 0x5a827999, 5);
|
||||
five_cycle(v, ch, 0x5a827999, 10);
|
||||
one_cycle(v,0,1,2,3,4, ch, 0x5a827999, hf(15)); \
|
||||
|
||||
#undef hf
|
||||
#define hf(i) (w[(i) & 15] = rotl32( \
|
||||
w[((i) + 13) & 15] ^ w[((i) + 8) & 15] \
|
||||
^ w[((i) + 2) & 15] ^ w[(i) & 15], 1))
|
||||
|
||||
one_cycle(v,4,0,1,2,3, ch, 0x5a827999, hf(16));
|
||||
one_cycle(v,3,4,0,1,2, ch, 0x5a827999, hf(17));
|
||||
one_cycle(v,2,3,4,0,1, ch, 0x5a827999, hf(18));
|
||||
one_cycle(v,1,2,3,4,0, ch, 0x5a827999, hf(19));
|
||||
|
||||
five_cycle(v, parity, 0x6ed9eba1, 20);
|
||||
five_cycle(v, parity, 0x6ed9eba1, 25);
|
||||
five_cycle(v, parity, 0x6ed9eba1, 30);
|
||||
five_cycle(v, parity, 0x6ed9eba1, 35);
|
||||
|
||||
five_cycle(v, maj, 0x8f1bbcdc, 40);
|
||||
five_cycle(v, maj, 0x8f1bbcdc, 45);
|
||||
five_cycle(v, maj, 0x8f1bbcdc, 50);
|
||||
five_cycle(v, maj, 0x8f1bbcdc, 55);
|
||||
|
||||
five_cycle(v, parity, 0xca62c1d6, 60);
|
||||
five_cycle(v, parity, 0xca62c1d6, 65);
|
||||
five_cycle(v, parity, 0xca62c1d6, 70);
|
||||
five_cycle(v, parity, 0xca62c1d6, 75);
|
||||
|
||||
#ifdef ARRAY
|
||||
ctx->hash[0] += v[0]; ctx->hash[1] += v[1];
|
||||
ctx->hash[2] += v[2]; ctx->hash[3] += v[3];
|
||||
ctx->hash[4] += v[4];
|
||||
#else
|
||||
ctx->hash[0] += v0; ctx->hash[1] += v1;
|
||||
ctx->hash[2] += v2; ctx->hash[3] += v3;
|
||||
ctx->hash[4] += v4;
|
||||
#endif
|
||||
}
|
||||
|
||||
VOID_RETURN sha1_begin(sha1_ctx ctx[1])
|
||||
{
|
||||
memset(ctx, 0, sizeof(sha1_ctx));
|
||||
ctx->hash[0] = 0x67452301;
|
||||
ctx->hash[1] = 0xefcdab89;
|
||||
ctx->hash[2] = 0x98badcfe;
|
||||
ctx->hash[3] = 0x10325476;
|
||||
ctx->hash[4] = 0xc3d2e1f0;
|
||||
}
|
||||
|
||||
/* SHA1 hash data in an array of bytes into hash buffer and */
|
||||
/* call the hash_compile function as required. For both the */
|
||||
/* bit and byte orientated versions, the block length 'len' */
|
||||
/* must not be greater than 2^32 - 1 bits (2^29 - 1 bytes) */
|
||||
|
||||
VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1])
|
||||
{ uint32_t pos = (uint32_t)((ctx->count[0] >> 3) & SHA1_MASK);
|
||||
const unsigned char *sp = data;
|
||||
unsigned char *w = (unsigned char*)ctx->wbuf;
|
||||
#if SHA1_BITS == 1
|
||||
uint32_t ofs = (ctx->count[0] & 7);
|
||||
#else
|
||||
len <<= 3;
|
||||
#endif
|
||||
if((ctx->count[0] += len) < len)
|
||||
++(ctx->count[1]);
|
||||
#if SHA1_BITS == 1
|
||||
if(ofs) /* if not on a byte boundary */
|
||||
{
|
||||
if(ofs + len < 8) /* if no added bytes are needed */
|
||||
{
|
||||
w[pos] |= (*sp >> ofs);
|
||||
}
|
||||
else /* otherwise and add bytes */
|
||||
{ unsigned char part = w[pos];
|
||||
|
||||
while((int)(ofs + (len -= 8)) >= 0)
|
||||
{
|
||||
w[pos++] = part | (*sp >> ofs);
|
||||
part = *sp++ << (8 - ofs);
|
||||
if(pos == SHA1_BLOCK_SIZE)
|
||||
{
|
||||
bsw_32(w, SHA1_BLOCK_SIZE >> 2);
|
||||
sha1_compile(ctx); pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
w[pos] = part;
|
||||
}
|
||||
}
|
||||
else /* data is byte aligned */
|
||||
#endif
|
||||
{ uint32_t space = SHA1_BLOCK_SIZE - pos;
|
||||
|
||||
while(len >= (space << 3))
|
||||
{
|
||||
memcpy(w + pos, sp, space);
|
||||
bsw_32(w, SHA1_BLOCK_SIZE >> 2);
|
||||
sha1_compile(ctx);
|
||||
sp += space; len -= (space << 3);
|
||||
space = SHA1_BLOCK_SIZE; pos = 0;
|
||||
}
|
||||
memcpy(w + pos, sp, (len + 7 * SHA1_BITS) >> 3);
|
||||
}
|
||||
}
|
||||
|
||||
/* SHA1 final padding and digest calculation */
|
||||
|
||||
VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1])
|
||||
{ uint32_t i = (uint32_t)((ctx->count[0] >> 3) & SHA1_MASK), m1;
|
||||
|
||||
/* put bytes in the buffer in an order in which references to */
|
||||
/* 32-bit words will put bytes with lower addresses into the */
|
||||
/* top of 32 bit words on BOTH big and little endian machines */
|
||||
bsw_32(ctx->wbuf, (i + 3 + SHA1_BITS) >> 2);
|
||||
|
||||
/* we now need to mask valid bytes and add the padding which is */
|
||||
/* a single 1 bit and as many zero bits as necessary. Note that */
|
||||
/* we can always add the first padding byte here because the */
|
||||
/* buffer always has at least one empty slot */
|
||||
m1 = (unsigned char)0x80 >> (ctx->count[0] & 7);
|
||||
ctx->wbuf[i >> 2] &= ((0xffffff00 | (~m1 + 1)) << 8 * (~i & 3));
|
||||
ctx->wbuf[i >> 2] |= (m1 << 8 * (~i & 3));
|
||||
|
||||
/* we need 9 or more empty positions, one for the padding byte */
|
||||
/* (above) and eight for the length count. If there is not */
|
||||
/* enough space, pad and empty the buffer */
|
||||
if(i > SHA1_BLOCK_SIZE - 9)
|
||||
{
|
||||
if(i < 60) ctx->wbuf[15] = 0;
|
||||
sha1_compile(ctx);
|
||||
i = 0;
|
||||
}
|
||||
else /* compute a word index for the empty buffer positions */
|
||||
i = (i >> 2) + 1;
|
||||
|
||||
while(i < 14) /* and zero pad all but last two positions */
|
||||
ctx->wbuf[i++] = 0;
|
||||
|
||||
/* the following 32-bit length fields are assembled in the */
|
||||
/* wrong byte order on little endian machines but this is */
|
||||
/* corrected later since they are only ever used as 32-bit */
|
||||
/* word values. */
|
||||
ctx->wbuf[14] = ctx->count[1];
|
||||
ctx->wbuf[15] = ctx->count[0];
|
||||
sha1_compile(ctx);
|
||||
|
||||
/* extract the hash value as bytes in case the hash buffer is */
|
||||
/* misaligned for 32-bit words */
|
||||
for(i = 0; i < SHA1_DIGEST_SIZE; ++i)
|
||||
hval[i] = ((ctx->hash[i >> 2] >> (8 * (~i & 3))) & 0xff);
|
||||
}
|
||||
|
||||
VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len)
|
||||
{ sha1_ctx cx[1];
|
||||
|
||||
sha1_begin(cx); sha1_hash(data, len, cx); sha1_end(hval, cx);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
72
game/client/third/minizip/lib/aes/sha1.h
Executable file
72
game/client/third/minizip/lib/aes/sha1.h
Executable file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2010, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation.
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its operation, including, but not limited to, correctness
|
||||
and fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
*/
|
||||
|
||||
#ifndef _SHA1_H
|
||||
#define _SHA1_H
|
||||
|
||||
#define SHA_1
|
||||
|
||||
/* define for bit or byte oriented SHA */
|
||||
#if 1
|
||||
# define SHA1_BITS 0 /* byte oriented */
|
||||
#else
|
||||
# define SHA1_BITS 1 /* bit oriented */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "brg_types.h"
|
||||
|
||||
#define SHA1_BLOCK_SIZE 64
|
||||
#define SHA1_DIGEST_SIZE 20
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* type to hold the SHA256 context */
|
||||
|
||||
typedef struct
|
||||
{ uint32_t count[2];
|
||||
uint32_t hash[SHA1_DIGEST_SIZE >> 2];
|
||||
uint32_t wbuf[SHA1_BLOCK_SIZE >> 2];
|
||||
} sha1_ctx;
|
||||
|
||||
/* Note that these prototypes are the same for both bit and */
|
||||
/* byte oriented implementations. However the length fields */
|
||||
/* are in bytes or bits as appropriate for the version used */
|
||||
/* and bit sequences are input as arrays of bytes in which */
|
||||
/* bit sequences run from the most to the least significant */
|
||||
/* end of each byte. The value 'len' in sha1_hash for the */
|
||||
/* byte oriented version of SHA1 is limited to 2^29 bytes, */
|
||||
/* but multiple calls will handle longer data blocks. */
|
||||
|
||||
VOID_RETURN sha1_compile(sha1_ctx ctx[1]);
|
||||
|
||||
VOID_RETURN sha1_begin(sha1_ctx ctx[1]);
|
||||
VOID_RETURN sha1_hash(const unsigned char data[], unsigned long len, sha1_ctx ctx[1]);
|
||||
VOID_RETURN sha1_end(unsigned char hval[], sha1_ctx ctx[1]);
|
||||
VOID_RETURN sha1(unsigned char hval[], const unsigned char data[], unsigned long len);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
42
game/client/third/minizip/lib/bzip2/LICENSE
Executable file
42
game/client/third/minizip/lib/bzip2/LICENSE
Executable file
@@ -0,0 +1,42 @@
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
This program, "bzip2", the associated library "libbzip2", and all
|
||||
documentation, are copyright (C) 1996-2010 Julian R Seward. 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. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
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.
|
||||
|
||||
Julian Seward, jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0.6 of 6 September 2010
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
1094
game/client/third/minizip/lib/bzip2/blocksort.c
Executable file
1094
game/client/third/minizip/lib/bzip2/blocksort.c
Executable file
File diff suppressed because it is too large
Load Diff
1572
game/client/third/minizip/lib/bzip2/bzlib.c
Executable file
1572
game/client/third/minizip/lib/bzip2/bzlib.c
Executable file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user