Hi,


I have build libssh2 version 0.18 on a Windows 32bit platform (through
the dsw file), using openssl-0.9.8e for the cryptographic operations.



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
given private key file (PEM_read_bio_RSAPrivateKey on line 228 and
PEM_read_DSAPrivateKey on line 249) do not work. In fact, those calls do
not even return.



If I use different functions, PEM_read_bio_RSAPrivateKey and
PEM_read_bio_DSAPrivateKey, the operation succeeds, given that the
private key file content is read into the buffer.



Does anyone know why this is happening? I have pasted the code snippets
below for your reference.



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 ),
BIO_BUFFER_DATA_SIZE, filePtr);

    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
are.

 * 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 *)
passphrase_cb,

                                  (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
are.

 * 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 *)
passphrase_cb,

                                  (void *) passphrase);

    if (!*dsa) {

        return -1;

    }

    return 0;

}



_____________________________________________________________________________

ATTENTION:

The information contained in this message (including any files transmitted 
with this message) may contain proprietary, trade secret or other 
confidential and/or legally privileged information. Any pricing 
information contained in this message or in any files transmitted with 
this message is always confidential and cannot be shared with any third 
parties without prior written approval from Syncsort. This message is 
intended to be read only by the individual or entity to whom it is 
addressed or by their designee. If the reader of this message is not the 
intended recipient, you are on notice that any use, disclosure, copying or 
distribution of this message, in any form, is strictly prohibited. If you 
have received this message in error, please immediately notify the sender 
and/or Syncsort and destroy all copies of this message in your possession, 
custody or control.
-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
libssh2-devel mailing list
libssh2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel

Reply via email to