- Timestamp:
- 2010-10-17T06:44:35Z (14 years ago)
- Branches:
- master
- Children:
- 79b5c41
- Parents:
- 3fc6c32
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/ssl_gnutls.c
r3fc6c32 r83e47ec 25 25 26 26 #include <gnutls/gnutls.h> 27 #include <gcrypt.h> 27 28 #include <fcntl.h> 28 29 #include <unistd.h> … … 63 64 void ssl_init( void ) 64 65 { 66 if( initialized ) 67 return; 68 65 69 gnutls_global_init(); 66 70 initialized = TRUE; … … 127 131 } 128 132 129 if( !initialized ) 130 { 131 ssl_init(); 132 } 133 ssl_init(); 133 134 134 135 gnutls_certificate_allocate_credentials( &conn->xcred ); … … 255 256 B_EV_IO_WRITE : B_EV_IO_READ ); 256 257 } 258 259 size_t ssl_des3_encrypt( const unsigned char *key, size_t key_len, const unsigned char *input, 260 size_t input_len, const unsigned char *iv, unsigned char **res ) 261 { 262 gcry_cipher_hd_t gcr; 263 gcry_error_t st; 264 265 ssl_init(); 266 267 *res = g_malloc( input_len ); 268 st = gcry_cipher_open( &gcr, GCRY_CIPHER_3DES, GCRY_CIPHER_MODE_CBC, 0 ) || 269 gcry_cipher_setkey( gcr, key, key_len ) || 270 gcry_cipher_setiv( gcr, iv, 8 ) || 271 gcry_cipher_encrypt( gcr, *res, input_len, input, input_len ); 272 273 gcry_cipher_close( gcr ); 274 275 if( st == 0 ) 276 return input_len; 277 278 g_free( *res ); 279 return 0; 280 }
Note: See TracChangeset
for help on using the changeset viewer.