Коммит 4006c3ea создал по автору Andrey A. Moiseenko's avatar Andrey A. Moiseenko
Просмотр файлов

Initial commit to mos.ru

владельцы
//==============================================================================
// PROJECT: ToolsLib
//==============================================================================
// FILE: AntiRobotCaptcha.cpp
//
// AUTHOR: Andrey A. Moiseenko
//
//==============================================================================
#include "stdafx.h"
#include "temp.h"
//#include "perm.h"
//#include "temp.h"
#define MAX_TRY_N 20 // number of guess and number of reg tryes for last 15 minutes
#define MAX_TRY_PATTERN 0x11111111
CAntiRobot::CAntiRobot(CMaaString fn, bool bThrow, int MaxCaptcheRequests, int RequestsPeriod, int MaxTriesNumber, int MaxCaptcheValidStore, int MaxRecords, int MaxCaptcheSuccessfulAccepts, int MaxCaptcheSuccessfulAcceptsPeriod)
: m_f(fn, "RWCD|SrSw", bThrow),
m_MaxTriesNumber(MaxTriesNumber <= -100 ? MAX_TRY_N : MaxTriesNumber),
m_Recs(m_MaxRecords = (MaxRecords >= 100 ? MaxRecords : 100), bThrow ? 1 : 0),
m_IsModified(0),
m_MaxCaptcheRequests(MaxCaptcheRequests),
m_RequestsPeriod(RequestsPeriod),
m_MaxCaptcheValidStore(MaxCaptcheValidStore),
m_MaxCaptcheSuccessfulAccepts(MaxCaptcheSuccessfulAccepts),
m_MaxCaptcheSuccessfulAcceptsPeriod(MaxCaptcheSuccessfulAcceptsPeriod)
{
m_MaxTriesNumber = m_MaxTriesNumber < MAX_TRY_PATTERN ? m_MaxTriesNumber : MAX_TRY_PATTERN;
if (m_Recs.IsValid())
{
m_Recs.Zero();
}
else
{
m_MaxRecords = 0;
}
if (m_f.IsOpen())
{
m_f.Read(m_Recs, (_dword)m_Recs.Size());
m_f.Seek(0);
}
}
CAntiRobot::~CAntiRobot()
{
if (m_f.IsOpen() && m_IsModified)
{
m_f.Seek(0);
m_f.Write(m_Recs, (_dword)m_Recs.Size());
m_f.Close();
}
}
int CAntiRobot::Set(ANTIROBOT_IP Ip, CMaaString &OutHash /*8+1 bytes*/, CMaaString &Question, int QuestionType)
{
OutHash = "unknown_hash_error";
_dword x = 0;
if (m_f.IsOpen())
{
CMaaString Ops = "+-*/";
if ((QuestionType & 0xff) != QuestionType || Ops.Find((char)QuestionType) < 0)
{
GetRnd(&QuestionType, (int)sizeof(QuestionType));
QuestionType = Ops[(int)((unsigned)QuestionType % 4)];
}
int rnd1 = 0, rnd2 = 0;
GetRnd(&rnd1, sizeof(rnd1));
GetRnd(&rnd2, sizeof(rnd2));
switch(QuestionType)
{
case '+':
case '-':
rnd1 = 10 + (unsigned)rnd1 % 90U;
rnd2 = 10 + (unsigned)rnd2 % 90U;
break;
case '*':
rnd1 = 1 + (unsigned)rnd1 % 9U;
rnd2 = 10 + (unsigned)rnd2 % 90U;
break;
case '/':
rnd2 = 1 + (unsigned)rnd2 % 9U;
rnd1 = (10 + (unsigned)rnd1 % 90U) / rnd2;
rnd1 *= rnd2;
break;
}
CMaaString Text = "This is a text";
Text.Format("%d %c %d = ", rnd1, (char)QuestionType, rnd2);
GetRnd(&x, (int)sizeof(x));
_dword t = (_dword)time(nullptr);
_dword t0 = 0;
int i;
int n = 0;
int j = 0;
int nAcceptsCompleted = 0;
for (i = 0; i < m_MaxRecords; i++)
{
if ((_sdword)(m_Recs[i].m_Time - t) > m_MaxCaptcheSuccessfulAcceptsPeriod || (_sdword)(m_Recs[i].m_Time - t) < -m_MaxCaptcheSuccessfulAcceptsPeriod)
{
m_Recs[i].m_Time = 0;
}
if (m_Recs[i].m_Ip == Ip && (_sdword)(m_Recs[i].m_Time - t) > -m_RequestsPeriod && (_sdword)(m_Recs[i].m_Time - t) < m_RequestsPeriod)
{
n++;
t0 = (_sdword)(t0 - m_Recs[i].m_Time) > 0 || t0 == 0 ? m_Recs[i].m_Time : t0;
}
if (m_Recs[i].m_Ip == Ip && m_Recs[i].m_Tries == MAX_TRY_PATTERN && (_sdword)(m_Recs[i].m_Time - t) > -m_MaxCaptcheSuccessfulAcceptsPeriod && (_sdword)(m_Recs[i].m_Time - t) < m_MaxCaptcheSuccessfulAcceptsPeriod)
{
nAcceptsCompleted++;
}
if ((_sdword)(m_Recs[i].m_Time - m_Recs[j].m_Time) < 0 || !m_Recs[i].m_Time)
{
j = i;
}
}
if (nAcceptsCompleted >= m_MaxCaptcheSuccessfulAccepts)
{
Text.Format("Maximum (%d) accepts was received from your IP address within %d day(s), contact site administrator to resolve this problem if it is need to be solved (for cellular, wireless or home networks, for example)", nAcceptsCompleted, (m_MaxCaptcheSuccessfulAcceptsPeriod + 24 * 3600 - 1) / (24 * 3600));
Question = Text;
}
else if (n < m_MaxCaptcheRequests)
{
m_IsModified = 1;
Question = Text;
OutHash.Format("%08X", x);
memcpy(m_Recs[j].m_Hash, OutHash, 8);
m_Recs[j].m_Ip = Ip;
m_Recs[j].m_Op = QuestionType;
m_Recs[j].m_Arg1 = rnd1;
m_Recs[j].m_Arg2 = rnd2;
m_Recs[j].m_Time = t;
m_Recs[j].m_Tries = 0;
return 1;
}
else if (n >= m_MaxCaptcheRequests && t0)
{
int s = (int)(m_RequestsPeriod - (int)(t - t0));
if (s > 0)
{
Text.Format("try %d minutes later", (s + 59) / 60);
Question = Text;
}
}
return -1;
}
return 0;
}
int CAntiRobot::GenerateHash(ANTIROBOT_IP Ip, CMaaString &OutHash, CMaaString *pQuestion, int QuestionType)
{
CMaaString Question;
return Set(Ip, OutHash, pQuestion ? *pQuestion : Question, QuestionType);
}
int CAntiRobot::GetQuestion(ANTIROBOT_IP Ip, CMaaString Hash, CMaaString &Question)
{
_dword t = (_dword)time(nullptr);
_dword t0 = 0;
int n = 0;
int nAcceptsCompleted = 0;
for (int i = 0; i < m_MaxRecords; i++)
{
if (m_Recs[i].m_Ip == Ip && (_sdword)(m_Recs[i].m_Time - t) > -m_RequestsPeriod && (_sdword)(m_Recs[i].m_Time - t) < m_RequestsPeriod)
{
n++;
t0 = (_sdword)(t0 - m_Recs[i].m_Time) > 0 || t0 == 0 ? m_Recs[i].m_Time : t0;
}
if (m_Recs[i].m_Ip == Ip && m_Recs[i].m_Tries == MAX_TRY_PATTERN && (_sdword)(m_Recs[i].m_Time - t) > -m_MaxCaptcheSuccessfulAcceptsPeriod && (_sdword)(m_Recs[i].m_Time - t) < m_MaxCaptcheSuccessfulAcceptsPeriod)
{
nAcceptsCompleted++;
}
if (m_Recs[i].m_Ip == Ip && Hash == CMaaString(m_Recs[i].m_Hash, 8))
{
if ((_sdword)(m_Recs[i].m_Time - t) > -m_MaxCaptcheValidStore && (_sdword)(m_Recs[i].m_Time - t) < m_MaxCaptcheValidStore && m_Recs[i].m_Tries < (_dword)m_MaxTriesNumber)
{
CMaaString Ops = "+-*/";
int QuestionType = m_Recs[i].m_Op;
if ((QuestionType & 0xff) == QuestionType && Ops.Find((char)QuestionType) >= 0)
{
CMaaString Text = "This is a text";
Text.Format2("%d%c%d", "%1 %2 %3 = ", m_Recs[i].m_Arg1, (char)QuestionType, m_Recs[i].m_Arg2);
Question = Text;
return 1;
}
}
else
{
CMaaString Text;
if (m_Recs[i].m_Tries < (_dword)m_MaxTriesNumber)
{
Text.Format2("%d%d%d", "Time expired (%2 min of %3), reload the captcha", (int)(t - m_Recs[i].m_Time), (int)(t - m_Recs[i].m_Time) / 60, 60);
}
else if (m_Recs[i].m_Tries == MAX_TRY_PATTERN)
{
Text.Format2("", "Already answered and accepted, renew the captcha");
}
else// if (m_Recs[i].m_Tries == MAX_TRY_PATTERN)
{
Text.Format2("%d%d", "Tries limit exceeded (%1 of %2), reload the captcha", (int)m_Recs[i].m_Tries, (int)m_MaxTriesNumber);
}
Question = Text;
return -1;
}
}
}
/*
if (n < m_MaxCaptcheRequests)
{
m_IsModified = 1;
Question = Text;
return 1;
}
*/
if (nAcceptsCompleted >= m_MaxCaptcheSuccessfulAccepts)
{
CMaaString Text;
Text.Format("Maximum (%d) accepts was received from your IP address within %d day(s), contact site administrator to resolve this problem if it is need to be solved (for cellular, wireless or home networks, for example)", nAcceptsCompleted, (m_MaxCaptcheSuccessfulAcceptsPeriod + 24 * 3600 - 1) / (24 * 3600));
Question = Text;
return -1;
}
if (n >= m_MaxCaptcheRequests && t0)
{
int s = (int)(m_RequestsPeriod - (int)(t - t0));
if (s > 0)
{
CMaaString Text;
Text.Format("%d requests was processed within %d minutes, try %d minutes later", n, (int)m_RequestsPeriod / 60, (s + 59) / 60);
Question = Text;
return -1;
}
}
return 0;
}
/*
int CAntiRobot::GetAnswer(ANTIROBOT_IP Ip, CMaaString Hash) // -1 on error
{
long t = (long)time(nullptr);
for (int i = 0; i < m_MaxRecords; i++)
{
if (m_Recs[i].m_Ip == Ip &&
Hash == CMaaString(m_Recs[i].m_Hash, 8) &&
m_Recs[i].m_Time > t - m_MaxCaptcheValidStore &&
m_Recs[i].m_Time < t + m_MaxCaptcheValidStore &&
m_Recs[i].m_Tries < (_dword)m_MaxTriesNumber
)
{
m_IsModified = 1;
m_Recs[i].m_Tries++;
return m_Recs[i].m_Arg1 + m_Recs[i].m_Arg2;
}
}
return -1;
}
*/
_dword g_Temp_dword______________________________________ = 1234567890;
_dword CAntiRobot::MaskInt(_dword x, _dword Mask)
{
_dword r = x & Mask;
m_Temp = r + 12345678;
g_Temp_dword______________________________________ += m_Temp + 987654321;
return r;
}
bool CAntiRobot::Check(ANTIROBOT_IP Ip, int Num, CMaaString Hash, CMaaString *pexterr)
{
if (Num < 1)
{
pexterr && pexterr->Format("Num = %d (< 1)", Num);
return false;
}
_dword t = (_dword)time(nullptr);
for (int i = 0; i < m_MaxRecords; i++)
{
if (m_Recs[i].m_Ip == Ip)
{
CMaaString temp(m_Recs[i].m_Hash, 8);
pexterr && pexterr->Format("%S\ni=%d, Hash[i]=%S, m_Recs[i].m_Hash=%S, t-m_Recs[i].m_Time=%d, m_Recs[i].m_Tries=%d", pexterr, i, &Hash, &temp, (int)(t-m_Recs[i].m_Time), m_Recs[i].m_Tries);
}
if (m_Recs[i].m_Ip == Ip && (Hash == "" || Hash == CMaaString(m_Recs[i].m_Hash, 8)) && (_sdword)(m_Recs[i].m_Time - t) > -m_MaxCaptcheValidStore && (_sdword)(m_Recs[i].m_Time - t) < m_MaxCaptcheValidStore && m_Recs[i].m_Tries < (_dword)m_MaxTriesNumber)
{
if (m_Recs[i].m_Tries < MAX_TRY_PATTERN)
{
m_IsModified = 1;
int Answer = -1;
if (m_Recs[i].m_Tries++ < (_dword)m_MaxTriesNumber)
{
if (m_Recs[i].m_Op == '+' || m_Recs[i].m_Op == '-')
{
_dword Mask = 0;
while(1)
{
_dword NewMask = (Mask << 1) | 1;
if (NewMask == Mask)
{
Answer = m_Recs[i].m_Op == '+' ?
m_Recs[i].m_Arg1 + m_Recs[i].m_Arg2 :
m_Recs[i].m_Arg1 - m_Recs[i].m_Arg2;
break;
}
Mask = NewMask;
int x1 = MaskInt(m_Recs[i].m_Arg1, Mask);
int x2 = MaskInt(m_Recs[i].m_Arg2, Mask);
int x = MaskInt(m_Recs[i].m_Op == '+' ? x1 + x2 : x1 - x2, Mask);
int n = MaskInt(Num, Mask);
if (n != x)
{
break;
}
}
}
switch(m_Recs[i].m_Op)
{
case '+':
//Answer = m_Recs[i].m_Arg1 + m_Recs[i].m_Arg2;
break;
case '-':
//Answer = m_Recs[i].m_Arg1 - m_Recs[i].m_Arg2;
break;
case '*':
Answer = m_Recs[i].m_Arg1 * m_Recs[i].m_Arg2;
break;
case '/':
Answer = m_Recs[i].m_Arg2 != 0 ? m_Recs[i].m_Arg1 / m_Recs[i].m_Arg2 : Answer;
break;
}
if (Num == Answer && Answer != -1)
{
m_Recs[i].m_Tries = MAX_TRY_PATTERN;
return true;
}
else
{
pexterr && pexterr->Format("Num=%d != ... arg1=%d, arg2=%d, op=%c", Num, m_Recs[i].m_Arg1, m_Recs[i].m_Arg2, (char)m_Recs[i].m_Op);
}
}
else
{
pexterr && pexterr->Format("m_Recs[i].m_Tries >= MAX_TRY_PATTERN (%d >= %d)", m_Recs[i].m_Tries, MAX_TRY_PATTERN);
}
}
}
}
return false;
}
bool CAntiRobot::Check(ANTIROBOT_IP Ip, CMaaString Reply, CMaaString Hash, CMaaString *pexterr)
{
int Num = -1;
CMaaString r = Reply.Mid(0, Reply.Length());
CMaaString h = Hash.Mid(0, Hash.Length());
sscanf(r, "%d", &Num);
return Check(Ip, Num, h, pexterr);
//int Num = -1;
//sscanf(Reply, "%d", &Num);
//return Check(Ip, Num, Hash, pexterr);
}
#define ANTIROBOT_IPV6_SUPPORT
#ifdef ANTIROBOT_IPV6_SUPPORT
#define ANTIROBOT_IP _IP6
#else
#define ANTIROBOT_IP _IP
#endif
class CAntiRobot
{
CMaaFile m_f;
struct sNumRec
{
ANTIROBOT_IP m_Ip;
char m_Hash[8];
_dword m_Op;
_dword m_Arg1, m_Arg2;
_dword m_Time;
_dword m_Tries;
};
int m_MaxTriesNumber;
int m_MaxRecords;
CMaaPtr<sNumRec> m_Recs;
int m_IsModified;
int m_MaxCaptcheRequests;
int m_RequestsPeriod;
int m_MaxCaptcheValidStore;
int m_MaxCaptcheSuccessfulAccepts;
int m_MaxCaptcheSuccessfulAcceptsPeriod;
public:
CAntiRobot(CMaaString fn, bool bThrow = false, int MaxCaptcheRequests = 20, int RequestsPeriod = 15 * 60, int MaxTriesNumber = 20, int MaxCaptcheValidStore = 60 * 60, int MaxRecords = 1000, int MaxCaptcheSuccessfulAccepts = 10/2*7, int MaxCaptcheSuccessfulAcceptsPeriod = 24 * 3600);
~CAntiRobot();
int Set(ANTIROBOT_IP Ip, CMaaString &OutHash /*8 bytes text*/, CMaaString &Question, int QuestionType = '+');
// int GetAnswer(ANTIROBOT_IP Ip, CMaaString Hash); // -1 on error
bool Check(ANTIROBOT_IP Ip, int Num, CMaaString Hash, CMaaString *pexterr = nullptr);
bool Check(ANTIROBOT_IP Ip, CMaaString Reply, CMaaString Hash, CMaaString *pexterr = nullptr);
int GenerateHash(ANTIROBOT_IP Ip, CMaaString &OutHash, CMaaString *pQuestion = nullptr, int QuestionType = '+');
int GetQuestion(ANTIROBOT_IP Ip, CMaaString Hash, CMaaString &Question);
private:
protected:
_dword m_Temp;
_dword MaskInt(_dword x, _dword Mask);
};
// CryptLib Project
/* CryptLib library for RusRoute firewall and other projects of
* Andrey A. Moiseenko and MaaSoftware (JSK, Russia)
* e-mail: support@maasoftware.ru, maa2002@mail.ru
* web: http://maasoftware.ru, http://maasoftware.com
* Author's full name: Andrey Alekseevitch Moiseenko
* (russian name: Моисеенко Андрей Алексеевич)
*/
// CryptLib/CryptLib.h
/* Copyright (C) 2002-2013 Andrey A. Moiseenko (support@maasoftware.ru)
* All rights reserved.
*
* This library contains the basic cryptography function,
* prime numbers checks and generator, random number generator,
* Mantgomery exponent, symmetric GOST and asymmetric RSA-like.
* The library implementation written
* by Andrey A. Moiseenko (support@maasoftware.ru).
* This library and applications are
* FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
* as long as the following conditions are aheared to.
*
* Copyright remains Andrey A. Moiseenko's, and as such any Copyright notices in
* the code are not to be removed. If this code is used in a product,
* Andrey A. Moiseenko should be given attribution as the author of the parts used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Andrey A. Moiseenko (support@maasoftware.ru)
*
* THIS SOFTWARE IS PROVIDED BY ANDREY A. MOISEENKO ``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 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include "stdafx.h"
#include "temp.h"
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="CryptLib"
ProjectGUID="{EB31E75D-5EF4-413A-B1E7-C58B433E8777}"
RootNamespace="CryptLib"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".."
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".."
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".."
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
RuntimeTypeInfo="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".."
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
RuntimeTypeInfo="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\des\des_ecb.cpp"
>
</File>
<File
RelativePath=".\des\des_enc.cpp"
>
</File>
<File
RelativePath=".\des\des_setkey.cpp"
>
</File>
<File
RelativePath=".\exp3.cpp"
>
</File>
<File
RelativePath=".\exp4.cpp"
>
</File>
<File
RelativePath=".\exp5.cpp"
>
</File>
<File
RelativePath=".\Gost_BS_MAA.cpp"
>
</File>
<File
RelativePath=".\Longint2.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\ntlm_proxy_auth.cpp"
>
</File>
<File
RelativePath=".\RSA.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\CryptLib.h"
>
</File>
<File
RelativePath=".\des\des.h"
>
</File>
<File
RelativePath=".\des\des_locl.h"
>
</File>
<File
RelativePath=".\exp3.h"
>
</File>
<File
RelativePath=".\exp4.h"
>
</File>
<File
RelativePath=".\exp5.h"
>
</File>
<File
RelativePath=".\Gost_BS_MAA.h"
>
</File>
<File
RelativePath=".\Longint2.h"
>
</File>
<File
RelativePath=".\ntlm_proxy_auth.h"
>
</File>
<File
RelativePath=".\des\podd.h"
>
</File>
<File
RelativePath=".\RSA.h"
>
</File>
<File
RelativePath=".\des\sk.h"
>
</File>
<File
RelativePath=".\des\spr.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\Temp.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="CryptLib"
ProjectGUID="{EB31E75D-5EF4-413A-B1E7-C58B433E8777}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\.."
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\.."
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\E1.cpp">
</File>
<File
RelativePath=".\exp3.cpp">
</File>
<File
RelativePath=".\exp4.cpp">
</File>
<File
RelativePath=".\exp5.cpp">
</File>
<File
RelativePath=".\Gost_BS_MAA.cpp">
</File>
<File
RelativePath=".\Longint2.cpp">
</File>
<File
RelativePath=".\main.cpp">
</File>
<File
RelativePath=".\RSA.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\CryptLib.h">
</File>
<File
RelativePath=".\E1.h">
</File>
<File
RelativePath=".\exp3.h">
</File>
<File
RelativePath=".\exp4.h">
</File>
<File
RelativePath=".\exp5.h">
</File>
<File
RelativePath=".\Gost_BS_MAA.h">
</File>
<File
RelativePath=".\Longint2.h">
</File>
<File
RelativePath=".\RSA.h">
</File>
<File
RelativePath=".\stdafx.h">
</File>
<File
RelativePath=".\Temp.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
Это отличие свёрнуто
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="des\des_ecb.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="des\des_enc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="des\des_setkey.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="exp5.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Gost_BS_MAA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Longint2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ntlm_proxy_auth.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="RSA.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sha256\hmac.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sha256\sha.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sha256\sha224-256.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sha256\sha384-512.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sha256\sha_iface.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sha256\usha.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AntiRobotCaptcha.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CryptLib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="des\des.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="des\des_locl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="exp5.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Gost_BS_MAA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Longint2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ntlm_proxy_auth.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="des\podd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="RSA.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="des\sk.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="des\spr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Temp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sha256\sha-private.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sha256\sha.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sha256\sha_iface.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AntiRobotCaptcha.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="li_32.nasm" />
<CustomBuild Include="li_32_64.nasm" />
<CustomBuild Include="li_64.nasm" />
</ItemGroup>
</Project>
\ Нет новой строки в конце файла
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
\ Нет новой строки в конце файла
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="CryptLib"
ProjectGUID="{EB31E75D-5EF4-413A-B1E7-C58B433E8777}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\.."
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\.."
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
RuntimeLibrary="0"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/CryptLib.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\E1.cpp">
</File>
<File
RelativePath=".\exp3.cpp">
</File>
<File
RelativePath=".\exp4.cpp">
</File>
<File
RelativePath=".\exp5.cpp">
</File>
<File
RelativePath=".\Gost_BS_MAA.cpp">
</File>
<File
RelativePath=".\Longint2.cpp">
</File>
<File
RelativePath=".\main.cpp">
</File>
<File
RelativePath=".\RSA.cpp">
</File>
<File
RelativePath=".\stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\CryptLib.h">
</File>
<File
RelativePath=".\E1.h">
</File>
<File
RelativePath=".\exp3.h">
</File>
<File
RelativePath=".\exp4.h">
</File>
<File
RelativePath=".\exp5.h">
</File>
<File
RelativePath=".\Gost_BS_MAA.h">
</File>
<File
RelativePath=".\Longint2.h">
</File>
<File
RelativePath=".\RSA.h">
</File>
<File
RelativePath=".\stdafx.h">
</File>
<File
RelativePath=".\Temp.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include "stdafx.h"
//#include <conio.h>
#include "temp.h"
void GostMain();
// GOST
// Брюс Шнайдер
// /*unsigned*/ char k87[256],k65[256],k43[256],k21[256];
typedef unsigned long u4;
typedef unsigned char byte;
struct gost_ctx
{
//u4 k[8];
/* Constant s-boxes -- set up in gost_init(). */
unsigned char k87[256],k65[256],k43[256],k21[256];
};
/* Note: encrypt and decrypt expect full blockspadding blocks is
caller's responsibility. All bulk encryption is done in
ECB node by these calls. Other modes may be added easily
enough.
*/
void gost_enc(gost_ctx *, u4 * key, u4 *, int);
void gost_dec(gost_ctx *, u4 * key, u4 *, int);
//void gost_key(gost_ctx *, u4 *);
void gost_init(gost_ctx *);
void gost_destroy(gost_ctx *);
#ifdef alpha /* Any other 64-bit machines? */
typedef unsigned int word32;
#else
typedef unsigned long word32;
#endif
void kboxinit(gost_ctx *c)
{
int i;
byte k8[16] = {14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6,
12, 5, 9, 0, 7 };
byte k7[16] = {15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2,
13, 12, 0, 5, 10 };
byte k6[16] = {10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12,
7, 11, 4, 2, 8 };
byte k5[16] = { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8,
5, 11, 12, 4, 15 };
byte k4[16] = { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3,
15, 13, 0, 14, 9 };
byte k3[16] = {12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3,
4, 14, 7, 5, 11 };
byte k2[16] = { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9,
7, 5, 10, 6, 1};
byte kl[16] = {13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3,
14, 5, 0, 12, 7};
for (i = 0; i < 256; i++)
{
c->k87[i] = k8[i >> 4] << 4 | k7[i & 15];
c->k65[i] = k6[i >> 4] << 4 | k5[i & 15];
c->k43[i] = k4[i >> 4] << 4 | k3[i & 15];
c->k21[i] = k2[i >> 4] << 4 | kl[i & 15];
}
}
static word32
f(gost_ctx *c,word32 x)
{
x = c->k87[x>>24 & 255] << 24 | c->k65[x>>16 & 255] << 16 |
c->k43[x>> 8 & 255] << 8 | c->k21[x & 255];
/* Rotate left 11 bits */
return x<<11 | x>>(32-11);
}
void gostcrypt(gost_ctx *c, u4 * key, word32 *d)
{
register word32 n1, n2; /* As naned in the GOST */
n1 = d[0];
n2 = d[1];
/* Instead of swapping halves, swap names each round */
n2 ^= f(c,n1+key[0]); n1 ^= f(c,n2+key[1]);
n2 ^= f(c,n1+key[2]); n1 ^= f(c,n2+key[3]);
n2 ^= f(c,n1+key[4]); n1 ^= f(c,n2+key[5]);
n2 ^= f(c,n1+key[6]); n1 ^= f(c,n2+key[7]);
n2 ^= f(c,n1+key[0]); n1 ^= f(c,n2+key[1]);
n2 ^= f(c,n1+key[2]); n1 ^= f(c,n2+key[3]);
n2 ^= f(c,n1+key[4]); n1 ^= f(c,n2+key[5]);
n2 ^= f(c,n1+key[6]); n1 ^= f(c,n2+key[7]);
n2 ^= f(c,n1+key[0]); n1 ^= f(c,n2+key[1]);
n2 ^= f(c,n1+key[2]); n1 ^= f(c,n2+key[3]);
n2 ^= f(c,n1+key[4]); n1 ^= f(c,n2+key[5]);
n2 ^= f(c,n1+key[6]); n1 ^= f(c,n2+key[7]);
n2 ^= f(c,n1+key[7]); n1 ^= f(c,n2+key[6]);
n2 ^= f(c,n1+key[5]); n1 ^= f(c,n2+key[4]);
n2 ^= f(c,n1+key[3]); n1 ^= f(c,n2+key[2]);
n2 ^= f(c,n1+key[1]); n1 ^= f(c,n2+key[0]);
d[0] = n2; d[1] = n1;
}
void
gostdecrypt(gost_ctx *c, u4 * key, u4 *d)
{
register word32 n1, n2; /* As naned in the GOST */
n1 = d[0]; n2 = d[1];
n2 ^= f(c,n1+key[0]); n1 ^= f(c,n2+key[1]);
n2 ^= f(c,n1+key[2]); n1 ^= f(c,n2+key[3]);
n2 ^= f(c,n1+key[4]); n1 ^= f(c,n2+key[5]);
n2 ^= f(c,n1+key[6]); n1 ^= f(c,n2+key[7]);
n2 ^= f(c,n1+key[7]); n1 ^= f(c,n2+key[6]);
n2 ^= f(c,n1+key[5]); n1 ^= f(c,n2+key[4]);
n2 ^= f(c,n1+key[3]); n1 ^= f(c,n2+key[2]);
n2 ^= f(c,n1+key[1]); n1 ^= f(c,n2+key[0]);
n2 ^= f(c,n1+key[7]); n1 ^= f(c,n2+key[6]);
n2 ^= f(c,n1+key[5]); n1 ^= f(c,n2+key[4]);
n2 ^= f(c,n1+key[3]); n1 ^= f(c,n2+key[2]);
n2 ^= f(c,n1+key[1]); n1 ^= f(c,n2+key[0]);
n2 ^= f(c,n1+key[7]); n1 ^= f(c,n2+key[6]);
n2 ^= f(c,n1+key[5]); n1 ^= f(c,n2+key[4]);
n2 ^= f(c,n1+key[3]); n1 ^= f(c,n2+key[2]);
n2 ^= f(c,n1+key[1]); n1 ^= f(c,n2+key[0]);
d[0] = n2; d[1] = n1;
}
void gost_enc(gost_ctx *c, u4 * key, u4 *d, int blocks)
{
int i;
for (i=0; i < blocks; i++)
{
gostcrypt(c, key, d);
d+=2;
}
}
void gost_dec(gost_ctx *c, u4 * key, u4 *d, int blocks)
{
int i;
for (i=0; i < blocks; i++)
{
gostdecrypt(c, key, d);
d+=2;
}
}
/*
void gost_key(gost_ctx *c, u4 *k)
{
int i;
for(i=0;i<8;i++) c->k[i]=k[i];
}
*/
void gost_init(gost_ctx *c)
{
kboxinit(c);
}
void gost_destroy(gost_ctx *c)
{
// int i;
// for(i=0;i<8;i++) c->k[i]=0;
}
CGostBS::CGostBS()
{
m_gc = new gost_ctx;
if (!m_gc)
{
throw 1;
}
gost_init(m_gc);
}
CGostBS::~CGostBS()
{
gost_destroy(m_gc);
delete m_gc;
}
// Key - 32 bytes, Salt - 8 bytes, OutSalt - 8 bytes
void CGostBS::Encrypt(const void * Key, const void * InData, size_t Size, const void * Salt, void * OutData, void *OutSalt)
{
unsigned long n12[2] = { *(const unsigned long *)Salt, *((const unsigned long *)Salt + 1) };
size_t i;
for (i = 0; i < (Size >> 3); i++)
{
gostcrypt(m_gc, (u4 *)Key, (word32 *)n12);
n12[0] ^= ((const unsigned long *) InData)[i * 2];
n12[1] ^= ((const unsigned long *) InData)[i * 2 + 1];
((unsigned long *) OutData)[i * 2] = n12[0];
((unsigned long *) OutData)[i * 2 + 1] = n12[1];
}
if (Size & 7)
{
unsigned long t[2] = {0,0};
memcpy(t, ((const unsigned long * )InData) + i * 2, Size & 7);
gostcrypt(m_gc, (u4 *)Key, (word32 *)n12);
t[0] ^= n12[0];
t[1] ^= n12[1];
memcpy(((unsigned long *) OutData) + i * 2, &t, Size & 7);
}
if (OutSalt)
{
*(unsigned long *)OutSalt = n12[0];
*((unsigned long *)OutSalt + 1) = n12[1];
}
}
// Key - 32 bytes, Salt - 8 bytes, OutSalt - 8 bytes
void CGostBS::Decrypt(const void * Key, const void * InData, size_t Size, const void * Salt, void * OutData, void *OutSalt)
{
unsigned long n12[2] = { *(const unsigned long *)Salt, *((const unsigned long *)Salt + 1) };
unsigned long N12[2];
size_t i;
for (i = 0; i < (Size >> 3); i++)
{
gostcrypt(m_gc, (u4 *)Key, (word32 *)n12);
N12[0] = ((const unsigned long *)InData)[i * 2];
N12[1] = ((const unsigned long *)InData)[i * 2 + 1];
((unsigned long *) OutData)[i * 2] = n12[0] ^ N12[0];
((unsigned long *) OutData)[i * 2 + 1] = n12[1] ^ N12[1];
n12[0] = N12[0];
n12[1] = N12[1];
}
if (Size & 7)
{
unsigned long t[2] = {0,0};
memcpy(t, ((const unsigned long * )InData) + i * 2, Size & 7);
gostcrypt(m_gc, (u4 *)Key, (word32 *)n12);
t[0] ^= n12[0];
t[1] ^= n12[1];
memcpy(((unsigned long *) OutData) + i * 2, &t, Size & 7);
}
if (OutSalt)
{
*(unsigned long *)OutSalt = n12[0];
*((unsigned long *)OutSalt + 1) = n12[1];
}
}
extern "C" int CryptSection1(int x);
extern "C" int gExtData;
int gExtData = 11;
int CryptSection1(int x)
{
return x + gExtData;
}
void GostTest()
{
{
HANDLE hp = GetCurrentProcess();
//DWORD Id = GetCurrentProcessId();
//GetCurrentProcessHandle(&hp);
unsigned char Buffer[128];
SIZE_T s = 0;
unsigned char * p = (unsigned char *)&CryptSection1;
if (*p == 0xe9)
{
printf("jump\n");
p += 5 + *(long *)(p + 1);
}
ReadProcessMemory(hp, p, Buffer, 128, &s);
printf("s = %d\n", s);
int i;
for (i = 0; i < s; i++)
{
printf("%02x ", Buffer[i]);
}
printf("\n %d\n", Buffer[35]);
int index = 8;
#ifdef _DEBUG
index = 35;
#endif
if (Buffer[index] == 1)
{
printf("fixing ...");
Buffer[index] = Buffer[index] + 100;
}
else
{
printf("pattern not matched\n");
}
s = 0;
WriteProcessMemory(hp, p, Buffer, index + 1, &s);
printf("%d bytes written.\n", s);
printf("CryptSection1(11) = %d\n", CryptSection1(11));
static int aa = 0;
aa++;
}
//GostMain(); return;
return;
CGostBS g;
#define N 10000
u4 k[8], data[N], data2[N], Salt[2];
for (int i = 0; i < 1000; i++)
{
GetRnd(k, sizeof(k));
//for (int j = 0; j < 100; j++)
{
GetRnd(data, sizeof(data));
GetRnd(Salt, sizeof(Salt));
g.Encrypt(k, data, sizeof(data), Salt, data2);
g.Decrypt(k, data2, sizeof(data2), Salt, data2);
if (!memcmp(data, data2, sizeof(data)))
{
printf("\r%d --> OK", i);
}
else
{
printf("\r%d - FAIL enc->dec\n", i);
}
g.Decrypt(k, data, sizeof(data), Salt, data2);
g.Encrypt(k, data2, sizeof(data2), Salt, data2);
if (!memcmp(data, data2, sizeof(data)))
{
printf("\r%d <-- OK", i);
}
else
{
printf("\r%d - FAIL dec->enc\n", i);
}
}
}
printf("\nDone\n");
}
#if 0
void GostMain()
{
gost_ctx gc;
u4 k[8], k2[8], data[10], data2[10];
int i ;
/* Initialize GOST context. */
gost_init (&gc);
/* Prepare keya simple key should be 0K, with this many rounds! */
for (i=0;i<8;i++)
{
k[i] = i;
k2[i] = htonl(k[i]);
}
k[1]=0;
k2[1] = htonl(k[1]);
gost_key(&gc,k);
/* Try some test vectors. */
data[0] = 0; data[1] = 0;
gostcrypt(&gc,data);
printf("Enc of zero vector: %08lx %08lx\n",data[0],data[1]);
gostcrypt(&gc,data);
printf("Enc of above: %08lx %08lx\n",data[0],data[1]);
data[0] = 0xffffffff; data[1] = 0xffffffff;
gostcrypt (&gc,data) ;
printf("Enc of ones vector: %08lx %08lx\n",data[0],data[1]);
gostcrypt(&gc,data);
printf("Enc of above: %08lx %08lx\n",data[0],data[1]);
/* Does gost dec () properly reverse gost enc [) '-
we deal OK with single-block lengths passed in gost dec()? Do we deal OK with different lengths passed in? */
/* Init data */
for (i=0;i<10;i++) data[i]=data2[i]=i;
data[1]=data2[1] = 0;
/* Encrypt data as 5 blocks. */
gost_enc (&gc,data,5);
__SimpleSubstEncrypt(gc.k, data2, 5, data2);
/* Display encrypted data. */
for (i=0;i<10;i+=2) printf("Block %02d = %08lx %08lx (%08lx %08lx)\n", i/2, data[i],data[i+1], data2[i],data2[i+1]);
/* Decrypt in different sized chunks. */
gost_dec(&gc,data,1);
gost_dec(&gc,data+2,4);
__SimpleSubstDecrypt(gc.k, data2, 5, data2);
printf("\n");
/* Display decrypted data. */
for (i=0;i<10;i+=2) printf("Block %02d = %08lx %08lx (%08lx %08lx)\n", i/2, data[i],data[i+1], data2[i],data2[i+1]);
gost_destroy(&gc);
}
#endif
void GostMain()
{
CGostBS g;
long k[8];
int i;
for (i = 0; i < 8; i++) k[i] = i;
long Data[21], Data2[21], Data3[21];
for (i = 0; i < 21; i++) Data[i] = i;
long Salt[2] = {1, 2};
long Salt2[2];
size_t NN = 20 * sizeof(_dword);
g.Encrypt(k, Data, NN / 2, Salt, Data2, Salt2);
g.Encrypt(k, Data + 10, NN / 2 + 4, Salt2, Data2 + 10, NULL);
g.Decrypt(k, Data2, NN + 4, Salt, Data3, NULL);
for (i = 0; i < 21; i++)
{
printf("%02d. %08lx %08lx %08lx\n", i, Data[i], Data2[i], Data3[i]);
}
}
struct gost_ctx;
class CGostBS
{
gost_ctx * m_gc;
public:
CGostBS();
~CGostBS();
// Key - 32 bytes, Salt - 8 bytes, OutSalt - 8 bytes
void Encrypt(const void * Key, const void * InData, size_t Size, const void * Salt, void * OutData, void *OutSalt = NULL);
void Decrypt(const void * Key, const void * InData, size_t Size, const void * Salt, void * OutData, void *OutSalt = NULL);
};
#if 0
// GOST
// Брюс Шнайдер
// /*unsigned*/ char k87[256],k65[256],k43[256],k21[256];
//typedef unsigned long u4;
typedef _dword u4;
typedef unsigned char byte;
typedef struct
{
u4 k[8];
/* Constant s-boxes -- set up in gost_init(). */
unsigned char k87[256],k65[256],k43[256],k21[256];
} gost_ctx;
/* Note: encrypt and decrypt expect full blockspadding blocks is
caller's responsibility. All bulk encryption is done in
ECB node by these calls. Other modes may be added easily
enough.
*/
void gost_enc(gost_ctx *, u4 *, int);
void gost_dec(gost_ctx *, u4 *, int);
void gost_key(gost_ctx *, u4 *);
void gost_init(gost_ctx *);
void gost_destroy(gost_ctx *);
#endif
Это отличие свёрнуто
// CryptLib Project
/* CryptLib library for RusRoute firewall and other projects of
* Andrey A. Moiseenko and MaaSoftware (JSK, Russia)
* e-mail: support@maasoftware.ru, maa2002@mail.ru
* web: http://maasoftware.ru, http://maasoftware.com
* Author's full name: Andrey Alekseevitch Moiseenko
* (russian name: Моисеенко Андрей Алексеевич)
*/
// CryptLib/Gost_BS_MAA.h
/* Copyright (C) 2002-2013 Andrey A. Moiseenko (support@maasoftware.ru)
* All rights reserved.
*
* This library contains the basic cryptography function,
* prime numbers checks and generator, random number generator,
* Mantgomery exponent, symmetric GOST and asymmetric RSA-like.
* This file is GOST chiper implementation given from
* the book Bruce Schneier "Applied Cryptography" with changes of
* Andrey A. Moiseenko (support@maasoftware.ru).
* This library and applications are
* FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
* as long as the following conditions are aheared to.
*
* Copyright remains Andrey A. Moiseenko's, and as such any Copyright notices in
* the code are not to be removed. If this code is used in a product,
* Andrey A. Moiseenko should be given attribution as the author of the parts used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Andrey A. Moiseenko (support@maasoftware.ru)
*
* THIS SOFTWARE IS PROVIDED BY ANDREY A. MOISEENKO ``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 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
//struct gost_ctx;
struct gost_ctx
{
//u4 k[8];
// Constant s-boxes -- set up in gost_init().
//
// Брюс Шнайдер:
// char k87[256],k65[256],k43[256],k21[256];
//
// Моисеенко Андрей:
// unsigned char k87[256],k65[256],k43[256],k21[256];
//
_dword k87[256], k65[256], k43[256], k21[256];
unsigned char StaticKey[32];
gost_ctx() noexcept;
~gost_ctx();
_dword
#ifdef _WIN32
//_fastcall
#endif
//f(_dword x) const noexcept { return k87[x >> 24 & 255] | k65[x >> 16 & 255] | k43[x >> 8 & 255] | k21[x & 255]; }
f(_dword x) const noexcept { return k21[x & 255] | k43[x >> 8 & 255] | k65[x >> 16 & 255] | k87[x >> 24 & 255]; }
void gostcrypt(const _dword* key, _dword* d) const noexcept;
void gostcrypt16(const _dword* key, _dword* d) const noexcept;
void gostdecrypt(const _dword* key, _dword* d) const noexcept;
void gost_enc(const _dword* key, _dword*, int) const noexcept;
void gost_dec(const _dword* key, _dword*, int) const noexcept;
//void gost_key(gost_ctx *, u4 *);
// High level functions
void Encrypt(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt) const noexcept;
void Decrypt(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt) const noexcept;
void Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword* ImitoValue, const _dword* Salt, const void* End) const noexcept;
};
class CGostBsMaa
{
gost_ctx m_gc;
public:
CGostBsMaa() noexcept;
~CGostBsMaa();
// Key - 32 bytes, Salt - 8 bytes, OutSalt - 8 bytes
void Encrypt(const void * Key, const void * InData, size_t Size, const void * Salt, void * OutData = nullptr, void *OutSalt = nullptr) const noexcept;
void Decrypt(const void * Key, const void * InData, size_t Size, const void * Salt, void * OutData = nullptr, void *OutSalt = nullptr) const noexcept;
void Imito(const void * Key, const void * InData, size_t Size, void * ImitoValue, const void * Salt = nullptr, const void * End = nullptr) const noexcept;
void Hash(const void * Key, const void * InData, size_t Size, const void * Salt, void * Hash, int HashSize = 32) const noexcept;
void JoinHash(const void * Key, const void * Hash1, const void * Hash2, int HashSize, const void * Salt, void * OutHash, void * OutSalt = nullptr/*not recommended for >= 2 calls*/) const noexcept;
void GenSalt(void *OutSalt) const;
void GenKey(void *OutKey) const;
void GenKeyByPassword(CMaaString strPassword, void *OutKey, void * Salt = nullptr, int VariableSalt = 1) const; // -1 for using existed Salt (passed as a argument)
CMaaString GeneratePassword(int len = 16) const;
CMaaString EncryptByPassword(CMaaString strPassword, CMaaString Data) const;
CMaaString DecryptByPassword(CMaaString strPassword, CMaaString Data, bool &bResult) const;
};
//extern CGostBsMaa gGostBsMaa;
extern CGostBsMaa & GetGlobal___gGostBsMaa() noexcept;
#define gGostBsMaa GetGlobal___gGostBsMaa()
/*
CGostBsMaa::Encrypt(): x1 = 91746719 B/s = 89596.40 KB/s = 87.496 MB/s = 733.974 mbits/s
CGostBsMaa_tst::Encrypt(): x2 = 71841679 B/s = 70157.89 KB/s = 68.514 MB/s = 574.733 mbits/s
x2/x1 = 0.783044, x1/x2 = 1.277068
*/
struct gost_ctx_tst;
class CGostBsMaa_tst
{
gost_ctx_tst* m_gc;
public:
CGostBsMaa_tst();
~CGostBsMaa_tst();
// Key - 32 bytes, Salt - 8 bytes, OutSalt - 8 bytes
void Encrypt(const void* Key, const void* InData, size_t Size, const void* Salt, void* OutData = nullptr, void* OutSalt = nullptr);
void Decrypt(const void* Key, const void* InData, size_t Size, const void* Salt, void* OutData = nullptr, void* OutSalt = nullptr);
void Imito(const void* Key, const void* InData, size_t Size, void* ImitoValue, const void* Salt = nullptr, const void* End = nullptr);
/*
void Hash(const void* Key, const void* InData, size_t Size, const void* Salt, void* Hash, int HashSize = 32);
void JoinHash(const void* Key, const void* Hash1, const void* Hash2, int HashSize, const void* Salt, void* OutHash, void* OutSalt = nullptr);
void GenSalt(void* OutSalt);
void GenKey(void* OutKey);
void GenKeyByPassword(CMaaString strPassword, void* OutKey, void* Salt = nullptr, int VariableSalt = 1); // -1 for using existed Salt (passed as a argument)
CMaaString GeneratePassword(int len = 16);
CMaaString EncryptByPassword(CMaaString strPassword, CMaaString Data);
CMaaString DecryptByPassword(CMaaString strPassword, CMaaString Data, bool& bResult);
*/
};
Это отличие свёрнуто
// CryptLib Project
/* CryptLib library for RusRoute firewall and other projects of
* Andrey A. Moiseenko and MaaSoftware (JSK, Russia)
* e-mail: support@maasoftware.ru, maa2002@mail.ru
* web: http://maasoftware.ru, http://maasoftware.com
* Author's full name: Andrey Alekseevitch Moiseenko
* (russian name: Моисеенко Андрей Алексеевич)
*/
// CryptLib/CryptLib.h
/* Copyright (C) 2002-2013 Andrey A. Moiseenko (support@maasoftware.ru)
* All rights reserved.
*
* This library contains the basic cryptography function,
* prime numbers checks and generator, random number generator,
* Mantgomery exponent, symmetric GOST and asymmetric RSA-like.
* The library implementation written
* by Andrey A. Moiseenko (support@maasoftware.ru).
* This library and applications are
* FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
* as long as the following conditions are aheared to.
*
* Copyright remains Andrey A. Moiseenko's, and as such any Copyright notices in
* the code are not to be removed. If this code is used in a product,
* Andrey A. Moiseenko should be given attribution as the author of the parts used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Andrey A. Moiseenko (support@maasoftware.ru)
*
* THIS SOFTWARE IS PROVIDED BY ANDREY A. MOISEENKO ``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 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
include ../Makefile.inc
OBJECTS_DIR = ./
HEADERS =
SOURCES = stdafx.cpp \
exp5.cpp \
Gost_BS_MAA.cpp \
main.cpp \
longint2.cpp \
RSA.cpp \
AntiRobotCaptcha.cpp
OBJECTS = stdafx.o \
exp5.o \
Gost_BS_MAA.o \
main.o \
longint2.o \
li_64.o \
li_32_64.o \
RSA.o \
AntiRobotCaptcha.o \
sha256/sha224-256.o \
sha256/sha384-512.o \
sha256/sha.o \
sha256/usha.o \
sha256/hmac.o \
sha256/sha_iface.o
DESTDIR =
TARGET = CryptLib.a
#first: all
all: Makefile $(TARGET)
../ToolsLib/ToolsLib.a: ../ToolsLib/
$(MAKE) -C ../ToolsLib
#li_64.o: li_64.nasm
# nasm -f elf64 -g -F dwarf li_64.nasm
#li_32_64.o: li_32_64.nasm
# nasm -f elf64 -g -F dwarf li_32_64.nasm
# nasm -f elf64 -g -F dwarf li_64.nasm -l hello.lst
$(TARGET): $(OBJECTS) ../ToolsLib/ToolsLib.a
$(AR) $(TARGET) $(OBJECTS)
ls -l *.a
install:
uninstall:
include ../Makefile_debug.inc
OBJECTS_DIR = ./
HEADERS =
SOURCES = stdafx.cpp \
exp3.cpp \
exp4.cpp \
exp5.cpp \
Gost_BS_MAA.cpp \
main.cpp \
longint2.cpp \
RSA.cpp \
AntiRobotCaptcha.cpp
OBJECTS = stdafx.o \
exp3.o \
exp4.o \
exp5.o \
Gost_BS_MAA.o \
main.o \
longint2.o \
RSA.o \
AntiRobotCaptcha.o
DESTDIR =
TARGET = CryptLib.a
#first: all
all: Makefile $(TARGET)
../ToolsLib/ToolsLib.a: ../ToolsLib/
$(MAKE) -C ../ToolsLib
$(TARGET): $(OBJECTS) ../ToolsLib/ToolsLib.a
$(AR) $(TARGET) $(OBJECTS)
# ls -l *.a
install:
uninstall:
include ../Makefile.inc_static
OBJECTS_DIR = ./
HEADERS =
SOURCES = stdafx.cpp \
exp3.cpp \
exp4.cpp \
exp5.cpp \
Gost_BS_MAA.cpp \
main.cpp \
longint2.cpp \
RSA.cpp \
AntiRobotCaptcha.cpp
OBJECTS = stdafx.o \
exp3.o \
exp4.o \
exp5.o \
Gost_BS_MAA.o \
main.o \
longint2.o \
RSA.o \
AntiRobotCaptcha.o
DESTDIR =
TARGET = CryptLib.a
#first: all
all: Makefile $(TARGET)
../ToolsLib/ToolsLib.a: ../ToolsLib/
$(MAKE) -C ../ToolsLib
$(TARGET): $(OBJECTS) ../ToolsLib/ToolsLib.a
$(AR) $(TARGET) $(OBJECTS)
# ls -l *.a
install:
uninstall:
Это отличие свёрнуто
Это отличие свёрнуто
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать