Hi all:

ldd ./server  compiled without the -static flag shows following .so 
dependencies.

Since the -static flag will add the same libraries as .a form, it will 
compile a slightly different version. I am trying to think why the 
encryption would produce two different results, maybe something like big 
endian or little endian treatment in a particular function ? Maybe 
difference in the random generator ? Maybe byte size differences due to 
typedef ? 

linux-vdso.so.1 (0x00007ffc5e0d7000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 
(0x00007f8712987000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f87125e9000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f87123d1000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 
(0x00007f87121b2000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8711dc1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f87131e2000)

On Tuesday, April 25, 2023 at 2:47:34 PM UTC-4 Dwight Kulkarni wrote:

> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/cryptopp-users/64a04b0e-d8ed-4eb5-a1e2-901b49a9824cn%40googlegroups.com.

Reply via email to