00001
00002
00003 #define CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
00004 #define CRYPTOPP_DEFAULT_NO_DLL
00005
00006 #if defined(__GNUC__) && __GNUC__ > 3
00007 #define SKIP_EXPLICIT_INSTANTIATION
00008 #endif
00009
00010 #include "dll.h"
00011 #pragma warning(default: 4660)
00012
00013 #ifdef CRYPTOPP_WIN32_AVAILABLE
00014 #include <windows.h>
00015 #endif
00016
00017 #include "iterhash.cpp"
00018 #include "strciphr.cpp"
00019 #include "algebra.cpp"
00020 #include "eprecomp.cpp"
00021 #include "eccrypto.cpp"
00022
00023 #ifndef CRYPTOPP_IMPORTS
00024
00025 NAMESPACE_BEGIN(CryptoPP)
00026
00027 #ifdef __MWERKS__
00028
00029 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<ECP>;
00030 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<EC2N>;
00031 CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl<Integer>;
00032 CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
00033 CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
00034 CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
00035 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00036 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00037 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00038 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<>;
00039 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> >;
00040 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> >;
00041 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<Integer>;
00042 #endif
00043
00044 #if defined(__GNUC__) && __GNUC__ > 3
00045 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<ECP>;
00046 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupParameters_EC<EC2N>;
00047 CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl<Integer>;
00048 CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
00049 CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
00050 CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
00051 CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, MessageAuthenticationCode>;
00052 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00053 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00054 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >;
00055 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<>;
00056 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> >;
00057 CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> >;
00058 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<Integer>;
00059 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, SymmetricCipher> >;
00060 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<>;
00061 CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<>;
00062 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<PolynomialMod2>;
00063 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractRing<PolynomialMod2>;
00064 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractEuclideanDomain<PolynomialMod2>;
00065 CRYPTOPP_DLL_TEMPLATE_CLASS EuclideanDomainOf<PolynomialMod2>;
00066 CRYPTOPP_DLL_TEMPLATE_CLASS QuotientRing<EuclideanDomainOf<PolynomialMod2> >;
00067 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>;
00068 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_Encryption>;
00069 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_Decryption>;
00070 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption>;
00071 CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption>;
00072 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<EC2NPoint>;
00073 CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup<ECPPoint>;
00074 CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl<EC2N::Point>;
00075 CRYPTOPP_DLL_TEMPLATE_CLASS DL_GroupPrecomputation<EC2N::Point>;
00076 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_EC<ECP>;
00077 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_EC<EC2N>;
00078 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKeyImpl<DL_GroupParameters_EC<ECP> >;
00079 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKeyImpl<DL_GroupParameters_EC<EC2N> >;
00080 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<ECP>, ECDSA<ECP> >;
00081 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_EC<EC2N>, ECDSA<EC2N> >;
00082 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_EC<ECP>;
00083 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_EC<EC2N>;
00084 CRYPTOPP_DLL_TEMPLATE_CLASS DL_Algorithm_GDSA<ECP::Point>;
00085 CRYPTOPP_DLL_TEMPLATE_CLASS DL_Algorithm_GDSA<EC2N::Point>;
00086 CRYPTOPP_DLL_TEMPLATE_CLASS AutoSeededX917RNG<DES_EDE3>;
00087 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PublicKey_GFP<DL_GroupParameters_DSA>;
00088 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_GFP<DL_GroupParameters_DSA>;
00089 CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest<DL_PrivateKey_GFP<DL_GroupParameters_DSA>, DSA>;
00090 CRYPTOPP_DLL_TEMPLATE_CLASS SimpleKeyedTransformation<BlockTransformation>;
00091 CRYPTOPP_DLL_TEMPLATE_CLASS SimpleKeyedTransformation<StreamTransformation>;
00092 CRYPTOPP_DLL_TEMPLATE_CLASS SimpleKeyedTransformation<HashTransformation>;
00093 #endif
00094
00095 template<> const byte PKCS_DigestDecoration<SHA1>::decoration[] = {0x30,0x21,0x30,0x09,0x06,0x05,0x2B,0x0E,0x03,0x02,0x1A,0x05,0x00,0x04,0x14};
00096 template<> const unsigned int PKCS_DigestDecoration<SHA1>::length = sizeof(PKCS_DigestDecoration<SHA1>::decoration);
00097
00098 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};
00099 template<> const unsigned int PKCS_DigestDecoration<SHA224>::length = sizeof(PKCS_DigestDecoration<SHA224>::decoration);
00100
00101 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};
00102 template<> const unsigned int PKCS_DigestDecoration<SHA256>::length = sizeof(PKCS_DigestDecoration<SHA256>::decoration);
00103
00104 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};
00105 template<> const unsigned int PKCS_DigestDecoration<SHA384>::length = sizeof(PKCS_DigestDecoration<SHA384>::decoration);
00106
00107 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};
00108 template<> const unsigned int PKCS_DigestDecoration<SHA512>::length = sizeof(PKCS_DigestDecoration<SHA512>::decoration);
00109
00110 template<> const byte EMSA2HashId<SHA>::id = 0x33;
00111 template<> const byte EMSA2HashId<SHA224>::id = 0x38;
00112 template<> const byte EMSA2HashId<SHA256>::id = 0x34;
00113 template<> const byte EMSA2HashId<SHA384>::id = 0x36;
00114 template<> const byte EMSA2HashId<SHA512>::id = 0x35;
00115
00116 NAMESPACE_END
00117
00118 #endif
00119
00120 #ifdef CRYPTOPP_EXPORTS
00121
00122 USING_NAMESPACE(CryptoPP)
00123
00124 #if !(defined(_MSC_VER) && (_MSC_VER < 1300))
00125 using std::set_new_handler;
00126 #endif
00127
00128 static PNew s_pNew = NULL;
00129 static PDelete s_pDelete = NULL;
00130
00131 static void * New (size_t size)
00132 {
00133 void *p;
00134 while (!(p = malloc(size)))
00135 CallNewHandler();
00136
00137 return p;
00138 }
00139
00140 static void SetNewAndDeleteFunctionPointers()
00141 {
00142 void *p = NULL;
00143 HMODULE hModule = NULL;
00144 MEMORY_BASIC_INFORMATION mbi;
00145
00146 while (true)
00147 {
00148 VirtualQuery(p, &mbi, sizeof(mbi));
00149
00150 if (p >= (char *)mbi.BaseAddress + mbi.RegionSize)
00151 break;
00152
00153 p = (char *)mbi.BaseAddress + mbi.RegionSize;
00154
00155 if (!mbi.AllocationBase || mbi.AllocationBase == hModule)
00156 continue;
00157
00158 hModule = HMODULE(mbi.AllocationBase);
00159
00160 PGetNewAndDelete pGetNewAndDelete = (PGetNewAndDelete)GetProcAddress(hModule, "GetNewAndDeleteForCryptoPP");
00161 if (pGetNewAndDelete)
00162 {
00163 pGetNewAndDelete(s_pNew, s_pDelete);
00164 return;
00165 }
00166
00167 PSetNewAndDelete pSetNewAndDelete = (PSetNewAndDelete)GetProcAddress(hModule, "SetNewAndDeleteFromCryptoPP");
00168 if (pSetNewAndDelete)
00169 {
00170 s_pNew = &New;
00171 s_pDelete = &free;
00172 pSetNewAndDelete(s_pNew, s_pDelete, &set_new_handler);
00173 return;
00174 }
00175 }
00176
00177 hModule = GetModuleHandle("msvcrtd");
00178 if (!hModule)
00179 hModule = GetModuleHandle("msvcrt");
00180 if (hModule)
00181 {
00182 s_pNew = (PNew)GetProcAddress(hModule, "??2@YAPAXI@Z");
00183 s_pDelete = (PDelete)GetProcAddress(hModule, "??3@YAXPAX@Z");
00184 return;
00185 }
00186
00187 OutputDebugString("Crypto++ was not able to obtain new and delete function pointers.\n");
00188 throw 0;
00189 }
00190
00191 void * operator new (size_t size)
00192 {
00193 if (!s_pNew)
00194 SetNewAndDeleteFunctionPointers();
00195
00196 return s_pNew(size);
00197 }
00198
00199 void operator delete (void * p)
00200 {
00201 s_pDelete(p);
00202 }
00203
00204 void * operator new [] (size_t size)
00205 {
00206 return operator new (size);
00207 }
00208
00209 void operator delete [] (void * p)
00210 {
00211 operator delete (p);
00212 }
00213
00214 #endif // #ifdef CRYPTOPP_EXPORTS