If the encrypted data is the same on both sides, the other potential
problem is that the key is not the same. That is, the private key
doesn't match the public key.
Try the decrypt with no padding and view the raw bytes. If you see
padding plus your data, then the padding schemes don't match. If you
see random looking data, the keys don't match.
On 9/15/2012 3:54 PM, giozh wrote:
hi to all. I hope you can help me to fix my problem (i'm going crazy! ).
I have a client/server application that use RSA for encrypt exchanged message.
Now, until yesterday i'm running my app on localhost and all works fine. Today
i've try to run it on the net, but something goes wrong.
The app works like:
server listen for the incoming connection, and when a client call connect()
function, server send his publik key to client, and client do the same whit his
key.
Then client can start to send message encrypted with server public key.
this is the code ok key sharing (i don't paste system call return value and
handling):
const unsigned char *client_key;
int client_len;
//sending server public key len
send_pack->id = my_pk_len;
write(active_user_tail->prev->fd, send_pack, sizeof (packet));
signal(SIGALRM, timeout);
alarm(3);
//reading client public key len
read(active_user_tail->prev->fd, receive_pack, sizeof (packet));
alarm(0);
client_len = receive_pack->id;
//send server public key
write(active_user_tail->prev->fd, my_public_key, my_pk_len);
//reading client public key
signal(SIGALRM, timeout);
alarm(3);
read(active_user_tail->prev->fd, client_key, client_len);
alarm(0);
d2i_RSAPublicKey(&active_user_tail->prev->rsa_client, &client_key,
client_len);
}
client function is specular to this one.
Now if client try to send a encrypted message to server, when server calls
RSA_private_decrypt, i obtain this error:
error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2 : block type is not
02
what does it mean?
i paste the part of client code sending encrypted message:
strcpy(send_pack->op, "help\n");
RSA_public_encrypt(strlen(send_pack->op), send_pack->op,
encrypted_send->op, rsa_server, padding);
write(server, encrypted_send, sizeof (encrypted_pack));
the part of server that decrypt message and launch the error:
RSA_private_decrypt(RSA_size(rsa), encrypted_receive->op,
receive_pack->op, rsa, padding);
i've try to print the encrypted string on client and on server, and they are the
same.
Where i'm wrong?
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org