Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 4298

Show
Ignore:
Timestamp:
01/28/09 10:00:11 (3 years ago)
Author:
fawzi
Message:

making OpenSSL work on mac 10.5, using c_ulong (plus comment about to do for using it more consistently) fix #1349

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/net/c/OpenSSL.d

    r4188 r4298  
    1515private import tango.stdc.stdio; 
    1616private import tango.stdc.stringz; 
     17private import tango.stdc.config: c_long,c_ulong; 
    1718 
    1819private import tango.io.Stdout; 
     
    3839 
    3940   These will need to be reversed to support 64bit tango 
     41   (should use c_long and c_ulong from tango.stdc.config) 
    4042 
    4143   XXX TODO XXX 
     
    135137        void *ap_data; 
    136138        int key_len; 
    137         version (X86_64) 
    138             ulong flags; 
    139         else 
    140             uint flags; 
     139        c_ulong flags; 
    141140        void *cipher_data; 
    142141        int final_used; 
     
    144143        ubyte[EVP_MAX_BLOCK_LENGTH] finalv; 
    145144    }; 
     145     
     146    // fallback for OpenSSL 0.9.7l 28 Sep 2006 that defines only macros 
     147    int EVP_CIPHER_CTX_block_size_097l(EVP_CIPHER_CTX *e){ 
     148        return *((cast(int*)e.cipher)+1); 
     149    } 
    146150 
    147151    struct BIO  
     
    630634    static SharedLib eaylib = null; 
    631635} 
     636version(darwin){ 
     637    static SharedLib cryptolib = null; 
     638} 
    632639static ReadWriteMutex[] _locks = null; 
    633640 
     
    836843        bindFunc(EVP_DecryptFinal_ex, "EVP_DecryptFinal_ex", ssllib); 
    837844        bindFunc(EVP_aes_128_cbc, "EVP_aes_128_cbc", ssllib); 
    838         bindFunc(EVP_CIPHER_CTX_block_size, "EVP_CIPHER_CTX_block_size", ssllib); 
     845        try { 
     846            bindFunc(EVP_CIPHER_CTX_block_size, "EVP_CIPHER_CTX_block_size", ssllib); 
     847        } catch (Exception e){ 
     848            // openSSL 0.9.7l defines only macros, not the function 
     849            EVP_CIPHER_CTX_block_size=&EVP_CIPHER_CTX_block_size_097l; 
     850        } 
    839851        bindFunc(EVP_CIPHER_CTX_cleanup, "EVP_CIPHER_CTX_cleanup", ssllib); 
    840852    } 
     
    881893        version(Posix) 
    882894        { 
    883             bindCrypto(ssllib); 
     895            version(darwin){ 
     896                char[][] loadPathCrypto = [ "/usr/lib/libcrypto.dylib", "libcrypto.dylib" ]; 
     897                cryptolib = loadLib(loadPathCrypto); 
     898                if (cryptolib !is null) bindCrypto(cryptolib); 
     899            } else { 
     900                bindCrypto(ssllib); 
     901            } 
    884902        } 
    885903 
     
    906924    if (ssllib) 
    907925        ssllib.unload(); 
     926    version(darwin){ 
     927        if (cryptolib) 
     928            cryptolib.unload(); 
     929    } 
    908930    version(Win32) 
    909931    {