Hi list !!!!
Thank you very much Dr Stephen, decrypting PBE privkey problems were fixed on my app and now works pretty good.
 
Now I have another problem. For design reasons (not my design) I must use both RSA_private_encrypt and RSa_public_encrypt in my app. Designers think that it's better by this way. So, I need encrypt with RSA privkey (1024 bits) a string that I call "message", message is 40 bytes size length.
Now I have another problem. For design reasons (not my design) I must use both RSA_private_encrypt and RSa_public_encrypt in my app. Designers think that is better by this way. So, I need encrypt with RSA privkey (1024 bits) a string that I call "message", message is 40 bytes length.
As I read in Openssl docs and  a Richar Levitte message, for this type of encryption I must "complete" to privkey_length (128 bytes) the message to be encrypted; so I added ceros '0' to message until it has 128 bytes length, an then I use RSA_private_encrypt function, follows my code:
 
unsigned char message[sizeRSAkey], *firma, *sobre;
 
firma=(unsigned char *) malloc ( RSA_size(rsa) );
flen=strlen(message);
res = RSA_private_encrypt (flen, menssge, firma, rsa, RSA_NO_PADDING); /*rsa is the RSA priv key to use*/
 if (res== -1)
 {
// Error messages
}
This part seems finishes ok, function encrypts res(128) bytes ok;  then follows the public encrypt phase of the previous result (I do this in two parts: 64+64 bytes):
 
sobre=(unsigned char *) malloc (256 * sizeof(char) );
 /*sobre=(unsigned char *) malloc (2 * RSA_size(clave)); this breaks my app and I don't know why, "clave" is the RSA pub key to use*/ 
/*firts part*/
res1 = RSA_public_encrypt (res/2, firma, sobre, clave, RSA_PKCS1_OAEP_PADDING ); /*here breaks my app,  tips?? */
/*second part*/
res2= RSA_public_encrypt (res/2, firma+res/2, sobre, clave, RSA_PKCS1_OAEP_PADDING );
 
I'm really convinced that this must not does by this way, I would prefer to use RSA_sign but how I said before, this is for design reasons :-(.
 
My first attempt was try to encrypt all in one step: RSA_public_encrypt with RSA_NO PADDING but I had problems, finally I thought better encrypting in two parts. But following this procedure my app also breaks.
What I'm doing wrong ??

One more time, thanks in advance for your reply
 
Zainos



Do You Yahoo!?
Yahoo! Net: La mejor conexión a internet y 25MB extra a tu correo por $100 al mes.

Reply via email to