- Timestamp:
- 2008-04-02T13:28:23Z (17 years ago)
- Branches:
- master
- Children:
- 6ff51ff, 85d7b85
- Parents:
- 0db75ad (diff), fa75134 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- lib
- Files:
-
- 14 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
lib/Makefile
r0db75ad rdd34575 10 10 11 11 # [SH] Program variables 12 objects = arc.o base64.o $(EVENT_HANDLER) http_client.o ini.o md5.o misc.o proxy.o sha1.o $(SSL_CLIENT) url.o 12 objects = arc.o base64.o $(EVENT_HANDLER) http_client.o ini.o md5.o misc.o proxy.o sha1.o $(SSL_CLIENT) url.o xmltree.o 13 13 14 14 CFLAGS += -Wall -
lib/arc.c
r0db75ad rdd34575 131 131 132 132 Both functions return the number of bytes in the result string. 133 134 Note that if you use the pad_to argument, you will need zero-termi- 135 nation to find back the original string length after decryption. So 136 it shouldn't be used if your string contains \0s by itself! 133 137 */ 134 138 135 int arc_encode( char *clear, int clear_len, unsigned char **crypt, char *password )139 int arc_encode( char *clear, int clear_len, unsigned char **crypt, char *password, int pad_to ) 136 140 { 137 141 struct arc_state *st; 138 142 unsigned char *key; 139 int key_len, i; 143 char *padded = NULL; 144 int key_len, i, padded_len; 140 145 141 146 key_len = strlen( password ) + ARC_IV_LEN; 142 147 if( clear_len <= 0 ) 143 148 clear_len = strlen( clear ); 149 150 /* Pad the string to the closest multiple of pad_to. This makes it 151 impossible to see the exact length of the password. */ 152 if( pad_to > 0 && ( clear_len % pad_to ) > 0 ) 153 { 154 padded_len = clear_len + pad_to - ( clear_len % pad_to ); 155 padded = g_malloc( padded_len ); 156 memcpy( padded, clear, clear_len ); 157 158 /* First a \0 and then random data, so we don't have to do 159 anything special when decrypting. */ 160 padded[clear_len] = 0; 161 random_bytes( (unsigned char*) padded + clear_len + 1, padded_len - clear_len - 1 ); 162 163 clear = padded; 164 clear_len = padded_len; 165 } 144 166 145 167 /* Prepare buffers and the key + IV */ … … 161 183 162 184 g_free( st ); 185 g_free( padded ); 163 186 164 187 return clear_len + ARC_IV_LEN; -
lib/arc.h
r0db75ad rdd34575 31 31 }; 32 32 33 struct arc_state *arc_keymaker( unsigned char *key, int kl, int cycles );33 G_GNUC_MALLOC struct arc_state *arc_keymaker( unsigned char *key, int kl, int cycles ); 34 34 unsigned char arc_getbyte( struct arc_state *st ); 35 int arc_encode( char *clear, int clear_len, unsigned char **crypt, char *password );35 int arc_encode( char *clear, int clear_len, unsigned char **crypt, char *password, int pad_to ); 36 36 int arc_decode( unsigned char *crypt, int crypt_len, char **clear, char *password ); -
lib/base64.c
r0db75ad rdd34575 118 118 int i, outlen = 0; 119 119 120 for( i = 0; in[i] ; i += 4 )120 for( i = 0; in[i] && in[i+1] && in[i+2] && in[i+3]; i += 4 ) 121 121 { 122 122 int sx; -
lib/events_glib.c
r0db75ad rdd34575 51 51 } GaimIOClosure; 52 52 53 static GMainLoop *loop ;53 static GMainLoop *loop = NULL; 54 54 55 55 void b_main_init() 56 56 { 57 loop = g_main_new( FALSE ); 57 if( loop == NULL ) 58 loop = g_main_new( FALSE ); 58 59 } 59 60 -
lib/misc.c
r0db75ad rdd34575 33 33 #define BITLBEE_CORE 34 34 #include "nogaim.h" 35 #include "base64.h" 35 36 #include <stdio.h> 36 37 #include <stdlib.h> … … 597 598 return sockerr_again(); 598 599 } 600 601 /* Returns values: -1 == Failure (base64-decoded to something unexpected) 602 0 == Okay 603 1 == Password doesn't match the hash. */ 604 int md5_verify_password( char *password, char *hash ) 605 { 606 md5_byte_t *pass_dec = NULL; 607 md5_byte_t pass_md5[16]; 608 md5_state_t md5_state; 609 int ret, i; 610 611 if( base64_decode( hash, &pass_dec ) != 21 ) 612 { 613 ret = -1; 614 } 615 else 616 { 617 md5_init( &md5_state ); 618 md5_append( &md5_state, (md5_byte_t*) password, strlen( password ) ); 619 md5_append( &md5_state, (md5_byte_t*) pass_dec + 16, 5 ); /* Hmmm, salt! */ 620 md5_finish( &md5_state, pass_md5 ); 621 622 for( i = 0; i < 16; i ++ ) 623 { 624 if( pass_dec[i] != pass_md5[i] ) 625 { 626 ret = 1; 627 break; 628 } 629 } 630 631 /* If we reached the end of the loop, it was a match! */ 632 if( i == 16 ) 633 ret = 0; 634 } 635 636 g_free( pass_dec ); 637 638 return ret; 639 } -
lib/misc.h
r0db75ad rdd34575 67 67 G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl ); 68 68 69 G_MODULE_EXPORT int md5_verify_password( char *password, char *hash ); 70 69 71 #endif -
lib/proxy.c
r0db75ad rdd34575 530 530 struct PHB *phb; 531 531 532 if (!host || !port || (port == -1)|| !func || strlen(host) > 128) {532 if (!host || port <= 0 || !func || strlen(host) > 128) { 533 533 return -1; 534 534 } … … 538 538 phb->data = data; 539 539 540 if ( (proxytype == PROXY_NONE) || strlen(proxyhost) > 0 || !proxyport || (proxyport == -1))540 if (proxytype == PROXY_NONE || !proxyhost[0] || proxyport <= 0) 541 541 return proxy_connect_none(host, port, phb); 542 542 else if (proxytype == PROXY_HTTP) -
lib/ssl_client.h
r0db75ad rdd34575 60 60 G_MODULE_EXPORT int ssl_write( void *conn, const char *buf, int len ); 61 61 62 /* See ssl_openssl.c for an explanation. */ 63 G_MODULE_EXPORT int ssl_pending( void *conn ); 64 62 65 /* Abort the SSL connection and disconnect the socket. Do not use close() 63 66 directly, both the SSL library and the peer will be unhappy! */ -
lib/ssl_gnutls.c
r0db75ad rdd34575 211 211 } 212 212 213 /* See ssl_openssl.c for an explanation. */ 214 int ssl_pending( void *conn ) 215 { 216 return 0; 217 } 218 213 219 void ssl_disconnect( void *conn_ ) 214 220 { -
lib/ssl_nss.c
r0db75ad rdd34575 169 169 } 170 170 171 /* See ssl_openssl.c for an explanation. */ 172 int ssl_pending( void *conn ) 173 { 174 return 0; 175 } 176 171 177 void ssl_disconnect( void *conn_ ) 172 178 { -
lib/ssl_openssl.c
r0db75ad rdd34575 62 62 63 63 conn->fd = proxy_connect( host, port, ssl_connected, conn ); 64 if( conn->fd < 0 ) 65 { 66 g_free( conn ); 67 return NULL; 68 } 69 64 70 conn->func = func; 65 71 conn->data = data; 66 72 conn->inpa = -1; 67 68 if( conn->fd < 0 )69 {70 g_free( conn );71 return NULL;72 }73 73 74 74 return conn; … … 231 231 } 232 232 233 /* Only OpenSSL *really* needs this (and well, maybe NSS). See for more info: 234 http://www.gnu.org/software/gnutls/manual/gnutls.html#index-gnutls_005frecord_005fcheck_005fpending-209 235 http://www.openssl.org/docs/ssl/SSL_pending.html 236 237 Required because OpenSSL empties the TCP buffer completely but doesn't 238 necessarily give us all the unencrypted data. 239 240 Returns 0 if there's nothing left or if we don't have to care (GnuTLS), 241 1 if there's more data. */ 242 int ssl_pending( void *conn ) 243 { 244 return ( ((struct scd*)conn) && ((struct scd*)conn)->established ) ? 245 SSL_pending( ((struct scd*)conn)->ssl ) > 0 : 0; 246 } 247 233 248 void ssl_disconnect( void *conn_ ) 234 249 { -
lib/url.c
r0db75ad rdd34575 26 26 #include "url.h" 27 27 28 /* Convert an URL to a url_t structure 28 /* Convert an URL to a url_t structure */ 29 29 int url_set( url_t *url, char *set_url ) 30 30 { 31 char s[MAX_STRING ];31 char s[MAX_STRING+1]; 32 32 char *i; 33 33 34 /* protocol:// */ 34 memset( url, 0, sizeof( url_t ) ); 35 memset( s, 0, sizeof( s ) ); 36 37 /* protocol:// */ 35 38 if( ( i = strstr( set_url, "://" ) ) == NULL ) 36 39 { … … 49 52 url->proto = PROTO_SOCKS5; 50 53 else 51 { 52 return( 0 ); 53 } 54 return 0; 55 54 56 strncpy( s, i + 3, MAX_STRING ); 55 57 } 56 58 57 /* Split 59 /* Split */ 58 60 if( ( i = strchr( s, '/' ) ) == NULL ) 59 61 { … … 67 69 strncpy( url->host, s, MAX_STRING ); 68 70 69 /* Check for username in host field 71 /* Check for username in host field */ 70 72 if( strrchr( url->host, '@' ) != NULL ) 71 73 { … … 76 78 *url->pass = 0; 77 79 } 78 /* If not: Fill in defaults 80 /* If not: Fill in defaults */ 79 81 else 80 82 { … … 82 84 } 83 85 84 /* Password? 86 /* Password? */ 85 87 if( ( i = strchr( url->user, ':' ) ) != NULL ) 86 88 { … … 88 90 strcpy( url->pass, i + 1 ); 89 91 } 90 /* Port number? 92 /* Port number? */ 91 93 if( ( i = strchr( url->host, ':' ) ) != NULL ) 92 94 { -
lib/url.h
r0db75ad rdd34575 26 26 #include "bitlbee.h" 27 27 28 #define PROTO_HTTP 29 #define PROTO_HTTPS 30 #define PROTO_SOCKS4 31 #define PROTO_SOCKS5 32 #define PROTO_DEFAULT 28 #define PROTO_HTTP 2 29 #define PROTO_HTTPS 5 30 #define PROTO_SOCKS4 3 31 #define PROTO_SOCKS5 4 32 #define PROTO_DEFAULT PROTO_HTTP 33 33 34 34 typedef struct url … … 36 36 int proto; 37 37 int port; 38 char host[MAX_STRING ];39 char file[MAX_STRING ];40 char user[MAX_STRING ];41 char pass[MAX_STRING ];38 char host[MAX_STRING+1]; 39 char file[MAX_STRING+1]; 40 char user[MAX_STRING+1]; 41 char pass[MAX_STRING+1]; 42 42 } url_t; 43 43 -
lib/xmltree.c
r0db75ad rdd34575 111 111 }; 112 112 113 struct xt_parser *xt_new( gpointer data )113 struct xt_parser *xt_new( const struct xt_handler_entry *handlers, gpointer data ) 114 114 { 115 115 struct xt_parser *xt = g_new0( struct xt_parser, 1 ); 116 116 117 117 xt->data = data; 118 xt->handlers = handlers; 118 119 xt_reset( xt ); 119 120 -
lib/xmltree.h
r0db75ad rdd34575 71 71 struct xt_node *cur; 72 72 73 struct xt_handler_entry *handlers;73 const struct xt_handler_entry *handlers; 74 74 gpointer data; 75 75 … … 77 77 }; 78 78 79 struct xt_parser *xt_new( gpointer data );79 struct xt_parser *xt_new( const struct xt_handler_entry *handlers, gpointer data ); 80 80 void xt_reset( struct xt_parser *xt ); 81 81 int xt_feed( struct xt_parser *xt, char *text, int text_len );
Note: See TracChangeset
for help on using the changeset viewer.