Strange behavior with -static compilation flag
Dwight Kulkarni <[email protected]> Tue, 25 Apr 2023 11:33:22 -0700 (PDT)
| Newsgroups | gmane.comp.encryption.cryptopp |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
I have my RSA encrypt function as below.
I compile my program with the following:
g++ -g -c -static -pthread -I../ -I/data/prj/external-libs/include/cryptopp/
../src/threading/server.cpp
g++ -g ../lbin/*.o -static -pthread -o server -L/data/prj/external-libs/lib/
-l:libcryptopp.a
Here is what is strange.
If I include the -static flag, when I run the encrypt_rsa command below on
the remote server it correctly decrypts.
If I remove the -static flag, on the remove server it doesn't get the
proper message. However, the message that locally encrypted and decrypted
still works.
It doesn't throw any error, encryption completes, but when the server
receives it, it doesn't decrypt properly.
During compilation of the .a library from makefile it did not have a
-static flag.
std::string encrypt_rsa(std::string message, CryptoPP::RSA::PublicKey key)
{
try{
cout << " In encrypt rsa string " << endl;
message = b64encode(message);
CryptoPP::AutoSeededRandomPool rng;
//CryptoPP::RSAES_OAEP_SHA_Encryptor encryptor(key);
CryptoPP::RSAES_PKCS1v15_Encryptor encryptor(key);
std::string ciphertext;
CryptoPP::StringSource(message, true, new CryptoPP::PK_EncryptorFilter(rng,
encryptor, new CryptoPP::StringSink(ciphertext)));
return ciphertext;
}
catch(...)
{
std::cout << "error encrypting RSA";
return "";
}
}
--
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/601e1212-236c-4bf7-8ea8-4644fb8e66b3n%40googlegroups.com.