Jeronimo Pellegrini pellegrini@mpcnet.com.br writes:
I know that the documentation says that RSA encrypt and decrypt functions are not working, but well,
Does the manual say that? Where? I thought these functions just weren't documented at all yet.
I have tried to make that work but rsa-decrypt complains that it can't decrypt the message, and I can't tell exactly how (the rsa-decrypt code may return zero in 4 different situations). Maybe it could set some error variable (like errno) to tell the user what went wrong?
It's always tricky to track down bugs in crypto code, since all intermediary results tend to look like gibberish. Try to isolate the problem, by looking at the binary date before base64 encoding and after decoding, to see that you recover the same data.
It's intentional that the return value doesn't give you any failure mode. If you use such an indication in real use of a program, you can easily leak information to an attacker. And when debugging, well, use the debugger to set a breakpoint on the rsa_decrypt function to see what happens.
BTW, I'm including the programs I was trying to use.
[...]
Is there something obviously wrong in this?
It looks basically right to me. But the call
done += base64_encode_final(&b64_ctx, result);
looks suspicious. It should probably be
done += base64_encode_final(&b64_ctx, result + done);
I'll send you further comments on your code in a private mail.
Regards, /Niels