Archive Index
This month's Index
|
Subject: [libssh2] PEM_read_RSAPrivateKey doesn't return
[libssh2] PEM_read_RSAPrivateKey doesn't return
From: Fujiwara, Daisuke <DFujiwara_at_syncsort.com>
Date: Tue, 11 Dec 2007 18:53:40 -0500
Hi,
I have build libssh2 version 0.18 on a Windows 32bit platform (through
This is how I built my openssl libraries.
perl Configure VC-WIN32 no-idea no-mdc2 no-rc5
ms/do_masm.bat
nmake -f ms/ntdll.mak
It seems to me that in openssl.c of libssh2, function calls to read the
If I use different functions, PEM_read_bio_RSAPrivateKey and
Does anyone know why this is happening? I have pasted the code snippets
Thank you.
- - - - - - - - - - -
#define BIO_BUFFER_DATA_SIZE 2048
BIO* getBufferBIOForFile(FILE *filePtr)
{
BUF_MEM *bioBuffer;
BIO *retBioPtr;
int dataRead;
retBioPtr = BIO_new(BIO_s_mem()); /* Create a memory BIO */
bioBuffer = malloc(sizeof(BUF_MEM));
bioBuffer->data = malloc(BIO_BUFFER_DATA_SIZE);
dataRead = (int)fread(bioBuffer->data, sizeof( char ),
bioBuffer->data[dataRead] = '\0';
bioBuffer->length = (int)strlen(bioBuffer->data);
bioBuffer->max = (int)strlen(bioBuffer->data);
BIO_puts(retBioPtr, bioBuffer->data);
free(bioBuffer->data);
free(bioBuffer);
return retBioPtr;
}/* end getBufferBIOForFile */
int
_libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
LIBSSH2_SESSION * session,
FILE * fp, unsigned const char *passphrase)
{
BIO *bufferPtr;
(void) session;
if (!EVP_get_cipherbyname("des")) {
/* If this cipher isn't loaded it's a pretty good indication that none
* I have *NO DOUBT* that there's a better way to deal with this
* Someone buy me an OpenSSL manual and I'll read up on it.
*/
OpenSSL_add_all_ciphers();
}
bufferPtr = getBufferBIOForFile(fp);
/*
*rsa = PEM_read_RSAPrivateKey(fp, NULL, (void *) passphrase_cb,
(void *) passphrase);
*/
*rsa = PEM_read_bio_RSAPrivateKey(bufferPtr, NULL, (void *)
(void *) passphrase);
if (!*rsa) {
return -1;
}
return 0;
}
int
_libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
LIBSSH2_SESSION * session,
FILE * fp, unsigned const char *passphrase)
{
BIO *bufferPtr;
(void) session;
if (!EVP_get_cipherbyname("des")) {
/* If this cipher isn't loaded it's a pretty good indication that none
* I have *NO DOUBT* that there's a better way to deal with this
* Someone buy me an OpenSSL manual and I'll read up on it.
*/
OpenSSL_add_all_ciphers();
}
bufferPtr = getBufferBIOForFile(fp);
/*
*dsa = PEM_read_DSAPrivateKey(fp, NULL, (void *) passphrase_cb,
(void *) passphrase);
*/
*dsa = PEM_read_bio_DSAPrivateKey(bufferPtr, NULL, (void *)
(void *) passphrase);
if (!*dsa) {
return -1;
}
return 0;
}
_____________________________________________________________________________
ATTENTION:
The information contained in this message (including any files transmitted
-------------------------------------------------------------------------
_______________________________________________
|