From 523fb2324a351e9607ad2a803c6e866c5175aa16 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 11 Aug 2010 09:08:39 +0100 Subject: Implement MSNP15 SSO (Sadistic Sign-On). --- lib/ssl_openssl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/ssl_openssl.c') diff --git a/lib/ssl_openssl.c b/lib/ssl_openssl.c index 8abff390..1c70eb0f 100644 --- a/lib/ssl_openssl.c +++ b/lib/ssl_openssl.c @@ -271,3 +271,27 @@ 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) +{ + OpenSSL_add_all_algorithms(); + int output_length = 0; + + *res = g_new0(unsigned char, 72); + + EVP_CIPHER_CTX ctx; + /* 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; +} -- cgit v1.2.3 From 50b8978f0662fc83aa2e3db1d40081c315c9e6cf Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 13 Aug 2010 10:12:54 +0100 Subject: OpenSSL fixes + debugging. --- lib/ssl_openssl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/ssl_openssl.c') diff --git a/lib/ssl_openssl.c b/lib/ssl_openssl.c index 1c70eb0f..0feed4ca 100644 --- a/lib/ssl_openssl.c +++ b/lib/ssl_openssl.c @@ -115,7 +115,9 @@ static gboolean ssl_connected( gpointer data, gint source, b_input_condition con if( !initialized ) { initialized = TRUE; - SSLeay_add_ssl_algorithms(); + SSL_library_init(); + //SSLeay_add_ssl_algorithms(); + //OpenSSL_add_all_algorithms(); } meth = TLSv1_client_method(); @@ -204,6 +206,8 @@ int ssl_read( void *conn, char *buf, int len ) ssl_errno = SSL_AGAIN; } + if( getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); + return st; } @@ -219,6 +223,8 @@ int ssl_write( void *conn, const char *buf, int len ) st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); + if( getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); + ssl_errno = SSL_OK; if( st <= 0 ) { @@ -274,12 +280,11 @@ b_input_condition ssl_getdirection( void *conn ) 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) { - OpenSSL_add_all_algorithms(); int output_length = 0; + EVP_CIPHER_CTX ctx; *res = g_new0(unsigned char, 72); - EVP_CIPHER_CTX ctx; /* 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); @@ -289,9 +294,8 @@ size_t ssl_des3_encrypt(const unsigned char *key, size_t key_len, const unsigned 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(); + //EVP_cleanup(); return output_length; } -- cgit v1.2.3 From 327af51a28fe292cfc4a68caa086a13175a69719 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 21 Aug 2010 18:27:32 +0100 Subject: Some general cleanup, plus fixing a bug in the memberlist parsing code: the lists can come in in any order, so parse it *completely* before showing auth requests. --- lib/ssl_openssl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/ssl_openssl.c') diff --git a/lib/ssl_openssl.c b/lib/ssl_openssl.c index 0feed4ca..e0143791 100644 --- a/lib/ssl_openssl.c +++ b/lib/ssl_openssl.c @@ -206,7 +206,7 @@ int ssl_read( void *conn, char *buf, int len ) ssl_errno = SSL_AGAIN; } - if( getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); + if( 0 && getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); return st; } @@ -223,7 +223,7 @@ int ssl_write( void *conn, const char *buf, int len ) st = SSL_write( ((struct scd*)conn)->ssl, buf, len ); - if( getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); + if( 0 && getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st ); ssl_errno = SSL_OK; if( st <= 0 ) -- cgit v1.2.3