Changeset 523fb23 for lib/ssl_openssl.c
- Timestamp:
- 2010-08-11T08:08:39Z (15 years ago)
- Branches:
- master
- Children:
- 7f34ce2
- Parents:
- 7db65b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/ssl_openssl.c
r7db65b7 r523fb23 272 272 return( ((struct scd*)conn)->lasterr == SSL_ERROR_WANT_WRITE ? B_EV_IO_WRITE : B_EV_IO_READ ); 273 273 } 274 275 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) 276 { 277 OpenSSL_add_all_algorithms(); 278 int output_length = 0; 279 280 *res = g_new0(unsigned char, 72); 281 282 EVP_CIPHER_CTX ctx; 283 /* Don't set key or IV because we will modify the parameters */ 284 EVP_CIPHER_CTX_init(&ctx); 285 EVP_CipherInit_ex(&ctx, EVP_des_ede3_cbc(), NULL, NULL, NULL, 1); 286 EVP_CIPHER_CTX_set_key_length(&ctx, key_len); 287 EVP_CIPHER_CTX_set_padding(&ctx, 0); 288 /* We finished modifying parameters so now we can set key and IV */ 289 EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, 1); 290 EVP_CipherUpdate(&ctx, *res, &output_length, input, input_len); 291 EVP_CipherFinal_ex(&ctx, *res, &output_length); 292 293 EVP_CIPHER_CTX_cleanup(&ctx); 294 EVP_cleanup(); 295 296 return output_length; 297 }
Note: See TracChangeset
for help on using the changeset viewer.