我有一个我无法理解的问题。
首先,我正在制作使用Crypto ++ for RSA的程序。我已经分离了32位和64位mingw-w64的工具链。所以我下载了cryptopp源并为32位和64位构建了2次,并复制了lib和包含文件。我使用默认make ...
所以我编译了我的代码和静态库,当我在编译的机器上运行它时,32位和64位工作正常。但是当我将它复制到另一台机器XP 64bit或Win7 32bit时,它会在运行时崩溃。在Win7上我只使用32位,在XP上我使用32位和64位。
我正在搜索一段时间,发现它崩溃了这段代码:
StringSource ss1(message, true,
new SignerFilter(rng, signer,
new StringSink(signature)
)
);
但只运行它并没有崩溃。
new SignerFilter(rng, signer,
new StringSink(signature)
)
有没有人知道它会是什么?
这是我的测试代码
AutoSeededRandomPool rng;
string privKey, privKey_Base64 =
"MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMm4ybhUat8MwkHwWxwEFQ/7\
0wsJIT+Y3sIUFhwF8BslsJrhkTYYbhMYM9gHi/T5Y0m75h4jXesZNgfv0SUie1/6aWe61eZG\
bCMUgWh/6+onNtQOiJV88VgxBJG45OOinlG3l7NJpZZukiEXNqlv4dj2mWLgt6cIC8Gz2QQh\
cb9zAgERAoGANWWezukrWSkGPqGBh2p+C8KozjcfY6h3M1+rf+N0Q2vb7MM9Bso7QUor101K\
scmLOSo1YlSn62iOTWUgxhCoL4WbZK2UDxrMhdtEV+i4jtkopceJF6x5XBOBYdKPjEbJxd2m\
FPMBxA8NaI4D+WdSGCrzCSmAAp/A1qHFJZErdXkCQQD7P7htvv3slqYQMJZB+BLVMnE7TNOY\
YLCxbAVRTM70pvE/sn9DwXQEJQcOTavv6hr1AU0OC70KtYxQDo5eN7ppAkEAzYlPaAQEn0Kf\
x/lNQI/0j2rUGlJMA6m9bsw3TCR0hhmRa3HIb912o1bkYi9PTvp/JnO6UlaKvkTRq1N2EJXX\
ewJBAN2wsco/HEk5oZXQhJSPmCWG3GGABf7r5zMjE8A0tpuiXGVhQx2qsalN2Qye4wDdn1Cm\
y4TdLlS+TqD9yOm4s4kCQQC1WwnUP8fX0V/OkK2TUdfJ1rsmSJ1spNRStDDKtsErB4BPvr/q\
O+EmthTPGq9jzfe4hDr9W2tclxNa70oOolS3AkEA7qZDM0BHALxK/2Q6lU2zpjfh1gUxLAlg\
OGyIGTafq1o0y2b5HGrmwVYQAGaUPlBLVRLRBxhL+kXnSzXhTR1xRA==\
";
CryptoPP::StringSource tasdst(privKey_Base64, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(privKey)));
string pubKey, pubKey_Base64 =
"MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDJuMm4VGrfDMJB8FscBBUP+9MLCSE/mN7C\
FBYcBfAbJbCa4ZE2GG4TGDPYB4v0+WNJu+YeI13rGTYH79ElIntf+mlnutXmRmwjFIFof+vq\
JzbUDoiVfPFYMQSRuOTjop5Rt5ezSaWWbpIhFzapb+HY9pli4LenCAvBs9kEIXG/cwIBEQ==\
";
CryptoPP::StringSource tasdst2(pubKey_Base64, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(pubKey)));
RSA::PrivateKey privateKey;
char const *a = privKey.c_str();
size_t dataLen = privKey.size();
privateKey.Load(CryptoPP::StringStore((const byte*)a,(size_t)dataLen).Ref());
RSA::PublicKey publicKey;
char const *b = pubKey.c_str();
dataLen = pubKey.size();
publicKey.Load(CryptoPP::StringStore((const byte*)b,(size_t)dataLen).Ref());
string message = "RSA Signature", signature;
std::cout << message << std::endl;
RSASSA_PKCS1v15_SHA_Signer signer(privateKey);
StringSource ss1(message, true,
new SignerFilter(rng, signer,
new StringSink(signature)
)
);
string encoded, decoded;
CryptoPP::StringSource(signature, true, new CryptoPP::Base64Encoder(new CryptoPP::StringSink(encoded)));
CryptoPP::StringSource tasdst3(encoded, true, new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
RSASSA_PKCS1v15_SHA_Verifier verifier(publicKey);
StringSource ss2(message+decoded, true,
new SignatureVerificationFilter(
verifier, NULL,
SignatureVerificationFilter::THROW_EXCEPTION
)
);
答案 0 :(得分:0)
以下是GNUmakefile中要更改的内容: https://sites.google.com/site/ievgensychov/cryptopp
是的,问题已经解决了。