Re: Why would RSA_size() crash?

2011-05-16 Thread G S
Thanks to those who answered. It was a simple goof using std::string's substr() method; I was treating the second parameter as the end position rather than the character count, thus lopping off some essential characters and causing the failure. It works now.

Re: Why would RSA_size() crash?

2011-05-16 Thread Dr. Stephen Henson
On Mon, May 16, 2011, G S wrote: > A follow-up: After seeing an example, I tried printing the result of > ERR_reason_error_string(ERR_get_error()). It's null. ERR_print_errors_fp(stderr) might be more useful: see FAQ. Steve. -- Dr Stephen N. Henson. OpenSSL project core developer. Commercial te

Re: Why would RSA_size() crash?

2011-05-16 Thread Jeffrey Walton
On Mon, May 16, 2011 at 9:53 AM, John Hascall wrote: > >> Duh, thanks to the people who pointed out that the pointer returned by >> PEM_read_bio_RSA_PUBKEY might be null, and indeed it is (sadly I have to use >> Xcode, which refuses to show any local variables and GDB claims they don't >> exist).

Re: Why would RSA_size() crash?

2011-05-16 Thread G S
A follow-up: After seeing an example, I tried printing the result of ERR_reason_error_string(ERR_get_error()). It's null.

Re: Why would RSA_size() crash?

2011-05-16 Thread G S
OK, this is perplexing. I have a PEM-format RSA key in a character string called _publicKey, with newlines between the header, key data, and trailer. Like this: -BEGIN PUBLIC KEY MCwwHRTJKoZIhvcNAQEBBQADGwAwGAIRALPMoZzXMLIKhidteVfdR28CAwEAAQ== -END PUBLIC KEY- But PEM_read_bio_RS

Re: Why would RSA_size() crash?

2011-05-16 Thread G S
Ah, I see the g3 option generates extra debugging info. I'll give it a shot. I have a bug open with Apple about this anyway. It has proven to be very hard to pin down. Restarting Xcode will usually eliminate the problem and let you step through code... ONCE. If you want to do it again, you hav

Re: Why would RSA_size() crash?

2011-05-16 Thread G S
On Mon, May 16, 2011 at 6:53 AM, John Hascall wrote: > > > (sadly I have to use > > Xcode, which refuses to show any local variables and GDB claims they > don't > > exist). > >This is probably the optimizer, try compiling with -O0 -g3 > Thanks, John, I am building Debug. I verified that -O0

Re: Why would RSA_size() crash?

2011-05-16 Thread John Hascall
> Duh, thanks to the people who pointed out that the pointer returned by > PEM_read_bio_RSA_PUBKEY might be null, and indeed it is (sadly I have to use > Xcode, which refuses to show any local variables and GDB claims they don't > exist). This is probably the optimizer, try compiling with -O0

Re: Why would RSA_size() crash?

2011-05-16 Thread G S
Duh, thanks to the people who pointed out that the pointer returned by PEM_read_bio_RSA_PUBKEY might be null, and indeed it is (sadly I have to use Xcode, which refuses to show any local variables and GDB claims they don't exist). The question now is why it's null, since I know the string itself i

R: Why would RSA_size() crash?

2011-05-16 Thread Francesco Petruzzi
Is pubKey a valid pointer after PEM_read_bio_RSA_PUBKEY? If it is NULL there is an error in PEM data. Da: owner-openssl-us...@openssl.org [mailto:owner-openssl-us...@openssl.org] Per conto di G S Inviato: lunedì 16 maggio 2011 12:13 A: openssl-users@openssl.org Oggetto: Why would RSA_size

Re: Why would RSA_size() crash?

2011-05-16 Thread John Hascall
> I'm trying to use the OpenSSL crypto lib. I've generated a public/private > RSA key pair. Then I wrote some code to try to encrypt an eight-byte random > string. But it crashes in RSA_size(). Here's the code: > > BIO* bp = BIO_new_mem_buf(_publicKey, -1);// > Cr

Why would RSA_size() crash?

2011-05-16 Thread G S
Hi all. I'm trying to use the OpenSSL crypto lib. I've generated a public/private RSA key pair. Then I wrote some code to try to encrypt an eight-byte random string. But it crashes in RSA_size(). Here's the code: BIO* bp = BIO_new_mem_buf(_publicKey, -1);// Create