Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/ssl_openssl.c

    re046390 r327af51  
    116116        {
    117117                initialized = TRUE;
    118                 SSLeay_add_ssl_algorithms();
     118                SSL_library_init();
     119                //SSLeay_add_ssl_algorithms();
     120                //OpenSSL_add_all_algorithms();
    119121        }
    120122       
     
    205207        }
    206208       
     209        if( 0 && getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st );
     210       
    207211        return st;
    208212}
     
    219223       
    220224        st = SSL_write( ((struct scd*)conn)->ssl, buf, len );
     225       
     226        if( 0 && getenv( "BITLBEE_DEBUG" ) && st > 0 ) write( 1, buf, st );
    221227       
    222228        ssl_errno = SSL_OK;
     
    272278        return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? B_EV_IO_WRITE : B_EV_IO_READ );
    273279}
     280
     281size_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)
     282{
     283        int output_length = 0;   
     284        EVP_CIPHER_CTX ctx;
     285       
     286        *res = g_new0(unsigned char, 72);
     287       
     288        /* Don't set key or IV because we will modify the parameters */
     289        EVP_CIPHER_CTX_init(&ctx);
     290        EVP_CipherInit_ex(&ctx, EVP_des_ede3_cbc(), NULL, NULL, NULL, 1);
     291        EVP_CIPHER_CTX_set_key_length(&ctx, key_len);
     292        EVP_CIPHER_CTX_set_padding(&ctx, 0);
     293        /* We finished modifying parameters so now we can set key and IV */
     294        EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, 1);
     295        EVP_CipherUpdate(&ctx, *res, &output_length, input, input_len);
     296        EVP_CipherFinal_ex(&ctx, *res, &output_length);
     297        EVP_CIPHER_CTX_cleanup(&ctx);   
     298        //EVP_cleanup();
     299       
     300        return output_length;
     301}
Note: See TracChangeset for help on using the changeset viewer.