Further info: *without -static*, this is the output from the remote server:
broker got data of size 512 Broker handler thread started... 512 first two bytes are 128 and 198 and 154 *clear text begins with 68 180 -------------->> this should be 00 02* Either no 00 02 beginning block or no 00 separator byte found in proper range Decryption failed Exception occurred: 'NoneType' object has no attribute 'decode' with -static flag, this is the output from the remote server: broker got data of size 512 Broker handler thread started... 512 first two bytes are 51 and 252 and 242 *clear text begins with 0 2 -------------> this is the correct value* Got base64 bytes b'eyJtZXNzYWdlIjoiMSIsInRybiI6MzM0NjQ1NjksInNlc3Npb24iOiJzc2Vzc2lvbiIsInBhc3Njb2RlIjoic3Bhc3Njb2RlIiwiZGF0ZXRpbWUiOiIwNC8yNS8yMDIzIDE4OjE1OjA0LjEwOCIsInNlcmlhbCI6InNzZXJpYWwiLCJjYW1lcmFfcG9ydCI6NTAwMCwia2V5IjoiTURObE1XWTBOMlUyTnpFNE1HTXdaak5pWkRZeE1UZ3haVGcyT0dFd05XST0iLCJpdiI6Ik9ETmtZMk0zTVdJek5UUmtaVFUyTUROak1HVTRaakptWlRNME5UQmhZMk09IiwidCI6Mn0=' initializing the lock... On Tuesday, April 25, 2023 at 2:33:23 PM UTC-4 Dwight Kulkarni wrote: > 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 cryptopp-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/c66e7ca1-bf74-4a38-8beb-cf30ee4172c9n%40googlegroups.com.