00001
00002
00003 #define CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
00004 #define CRYPTOPP_DEFAULT_NO_DLL
00005
00006 #include "dll.h"
00007 #pragma warning(default: 4660)
00008
00009 #ifdef CRYPTOPP_WIN32_AVAILABLE
00010 #include <windows.h>
00011 #endif
00012
00013 #include "iterhash.cpp"
00014 #include "strciphr.cpp"
00015 #include "algebra.cpp"
00016 #include "eprecomp.cpp"
00017 #include "eccrypto.cpp"
00018
00019 #ifndef CRYPTOPP_IMPORTS
00020
00021 NAMESPACE_BEGIN(CryptoPP)
00022
00023 #ifdef __MWERKS__
00024
00025 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<ECP>;
00026 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<EC2N>;
00027 CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl<Integer>;
00028 CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
00029 CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
00030 CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
00031 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00032 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00033 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00034 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<>;
00035 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> >;
00036 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> >;
00037 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<Integer>;
00038 #endif
00039
00040 template<> const byte PKCS_DigestDecoration<SHA1>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};
00041 template<> const unsigned int PKCS_DigestDecoration<SHA1>::length = sizeof(PKCS_DigestDecoration<SHA1>::decoration);
00042
00043 template<> const byte PKCS_DigestDecoration<SHA224>::decoration[] = {0x30,0x2d,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x04,0x05,0x00,0x04,0x1c};
00044 template<> const unsigned int PKCS_DigestDecoration<SHA224>::length = sizeof(PKCS_DigestDecoration<SHA224>::decoration);
00045
00046 template<> const byte PKCS_DigestDecoration<SHA256>::decoration[] = {0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05,0x00,0x04,0x20};
00047 template<> const unsigned int PKCS_DigestDecoration<SHA256>::length = sizeof(PKCS_DigestDecoration<SHA256>::decoration);
00048
00049 template<> const byte PKCS_DigestDecoration<SHA384>::decoration[] = {0x30,0x41,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x02,0x05,0x00,0x04,0x30};
00050 template<> const unsigned int PKCS_DigestDecoration<SHA384>::length = sizeof(PKCS_DigestDecoration<SHA384>::decoration);
00051
00052 template<> const byte PKCS_DigestDecoration<SHA512>::decoration[] = {0x30,0x51,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x03,0x05,0x00,0x04,0x40};
00053 template<> const unsigned int PKCS_DigestDecoration<SHA512>::length = sizeof(PKCS_DigestDecoration<SHA512>::decoration);
00054
00055 template<> const byte EMSA2HashId<SHA>::id = 0x33;
00056 template<> const byte EMSA2HashId<SHA224>::id = 0x38;
00057 template<> const byte EMSA2HashId<SHA256>::id = 0x34;
00058 template<> const byte EMSA2HashId<SHA384>::id = 0x36;
00059 template<> const byte EMSA2HashId<SHA512>::id = 0x35;
00060
00061 NAMESPACE_END
00062
00063 #endif
00064
00065 #ifdef CRYPTOPP_EXPORTS
00066
00067 USING_NAMESPACE(CryptoPP)
00068
00069 #if !(defined(_MSC_VER) && (_MSC_VER < 1300))
00070 using std::set_new_handler;
00071 #endif
00072
00073 static PNew s_pNew = NULL;
00074 static PDelete s_pDelete = NULL;
00075
00076 static void * New (size_t size)
00077 {
00078 void *p;
00079 while (!(p = malloc(size)))
00080 CallNewHandler();
00081
00082 return p;
00083 }
00084
00085 static void SetNewAndDeleteFunctionPointers()
00086 {
00087 void *p = NULL;
00088 HMODULE hModule = NULL;
00089 MEMORY_BASIC_INFORMATION mbi;
00090
00091 while (true)
00092 {
00093 VirtualQuery(p, &mbi, sizeof(mbi));
00094
00095 if (p >= (char *)mbi.BaseAddress + mbi.RegionSize)
00096 break;
00097
00098 p = (char *)mbi.BaseAddress + mbi.RegionSize;
00099
00100 if (!mbi.AllocationBase || mbi.AllocationBase == hModule)
00101 continue;
00102
00103 hModule = HMODULE(mbi.AllocationBase);
00104
00105 PGetNewAndDelete pGetNewAndDelete = (PGetNewAndDelete)GetProcAddress(hModule, "GetNewAndDeleteForCryptoPP");
00106 if (pGetNewAndDelete)
00107 {
00108 pGetNewAndDelete(s_pNew, s_pDelete);
00109 return;
00110 }
00111
00112 PSetNewAndDelete pSetNewAndDelete = (PSetNewAndDelete)GetProcAddress(hModule, "SetNewAndDeleteFromCryptoPP");
00113 if (pSetNewAndDelete)
00114 {
00115 s_pNew = &New;
00116 s_pDelete = &free;
00117 pSetNewAndDelete(s_pNew, s_pDelete, &set_new_handler);
00118 return;
00119 }
00120 }
00121
00122 hModule = GetModuleHandle("msvcrtd");
00123 if (!hModule)
00124 hModule = GetModuleHandle("msvcrt");
00125 if (hModule)
00126 {
00127 s_pNew = (PNew)GetProcAddress(hModule, "??2@YAPAXI@Z");
00128 s_pDelete = (PDelete)GetProcAddress(hModule, "??3@YAXPAX@Z");
00129 return;
00130 }
00131
00132 OutputDebugString("Crypto++ was not able to obtain new and delete function pointers.\n");
00133 throw 0;
00134 }
00135
00136 void * operator new (size_t size)
00137 {
00138 if (!s_pNew)
00139 SetNewAndDeleteFunctionPointers();
00140
00141 return s_pNew(size);
00142 }
00143
00144 void operator delete (void * p)
00145 {
00146 s_pDelete(p);
00147 }
00148
00149 void * operator new [] (size_t size)
00150 {
00151 return operator new (size);
00152 }
00153
00154 void operator delete [] (void * p)
00155 {
00156 operator delete (p);
00157 }
00158
00159 #endif // #ifdef CRYPTOPP_EXPORTS