diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-10-02 19:45:26 -0700 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-10-02 19:45:26 -0700 |
commit | 8e9e2b7d9e54744cee32b3724391bf0ad04e8aff (patch) | |
tree | 6cafdc57bb8143306daf8ef8288d09754f39b451 /lib/ssl_openssl.c | |
parent | 88de0c96136313e553113f69cfc6ae544a5f5954 (diff) | |
parent | 2af3e232ff468b288dd4e0dbdab1a17312d801c5 (diff) |
Merging mainline, which includes a huge msnp13 merge.
Not 100% sure about the OpenSSL merge, should double check that but I'm
currently offline.
Diffstat (limited to 'lib/ssl_openssl.c')
-rw-r--r-- | lib/ssl_openssl.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/ssl_openssl.c b/lib/ssl_openssl.c index c0105687..64bc9257 100644 --- a/lib/ssl_openssl.c +++ b/lib/ssl_openssl.c @@ -59,7 +59,8 @@ static gboolean ssl_handshake( gpointer data, gint source, b_input_condition con void ssl_init( void ) { initialized = TRUE; - SSLeay_add_ssl_algorithms(); + SSL_library_init(); + // SSLeay_add_ssl_algorithms(); } void *ssl_connect( char *host, int port, ssl_input_function func, gpointer data ) @@ -209,6 +210,8 @@ int ssl_read( void *conn, char *buf, int len ) ssl_errno = SSL_AGAIN; } + if( 0 && getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); + return st; } @@ -224,6 +227,8 @@ int ssl_write( void *conn, const char *buf, int len ) st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); + if( 0 && getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); + ssl_errno = SSL_OK; if( st <= 0 ) { @@ -276,3 +281,25 @@ b_input_condition ssl_getdirection( void *conn ) { return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? B_EV_IO_WRITE : B_EV_IO_READ ); } + +size_t ssl_des3_encrypt(const unsigned char *key, size_t key_len, const unsigned char *input, size_t input_len, const unsigned char *iv, unsigned char **res) +{ + int output_length = 0; + EVP_CIPHER_CTX ctx; + + *res = g_new0(unsigned char, 72); + + /* Don't set key or IV because we will modify the parameters */ + EVP_CIPHER_CTX_init(&ctx); + EVP_CipherInit_ex(&ctx, EVP_des_ede3_cbc(), NULL, NULL, NULL, 1); + EVP_CIPHER_CTX_set_key_length(&ctx, key_len); + EVP_CIPHER_CTX_set_padding(&ctx, 0); + /* We finished modifying parameters so now we can set key and IV */ + EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, 1); + EVP_CipherUpdate(&ctx, *res, &output_length, input, input_len); + EVP_CipherFinal_ex(&ctx, *res, &output_length); + EVP_CIPHER_CTX_cleanup(&ctx); + //EVP_cleanup(); + + return output_length; +} |