You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. --- a/lib/ssl_openssl.c
  2. +++ b/lib/ssl_openssl.c
  3. @@ -64,11 +64,17 @@ void ssl_init(void)
  4. {
  5. const SSL_METHOD *meth;
  6. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  7. SSL_library_init();
  8. meth = SSLv23_client_method();
  9. ssl_ctx = SSL_CTX_new(meth);
  10. SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
  11. +#else
  12. + meth = TLS_client_method();
  13. + ssl_ctx = SSL_CTX_new(meth);
  14. + SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION);
  15. +#endif
  16. initialized = TRUE;
  17. }
  18. @@ -300,20 +306,20 @@ size_t ssl_des3_encrypt(const unsigned c
  19. const unsigned char *iv, unsigned char **res)
  20. {
  21. int output_length = 0;
  22. - EVP_CIPHER_CTX ctx;
  23. + EVP_CIPHER_CTX *ctx;
  24. *res = g_new0(unsigned char, 72);
  25. /* Don't set key or IV because we will modify the parameters */
  26. - EVP_CIPHER_CTX_init(&ctx);
  27. - EVP_CipherInit_ex(&ctx, EVP_des_ede3_cbc(), NULL, NULL, NULL, 1);
  28. - EVP_CIPHER_CTX_set_key_length(&ctx, key_len);
  29. - EVP_CIPHER_CTX_set_padding(&ctx, 0);
  30. + ctx = EVP_CIPHER_CTX_new();
  31. + EVP_CipherInit_ex(ctx, EVP_des_ede3_cbc(), NULL, NULL, NULL, 1);
  32. + EVP_CIPHER_CTX_set_key_length(ctx, key_len);
  33. + EVP_CIPHER_CTX_set_padding(ctx, 0);
  34. /* We finished modifying parameters so now we can set key and IV */
  35. - EVP_CipherInit_ex(&ctx, NULL, NULL, key, iv, 1);
  36. - EVP_CipherUpdate(&ctx, *res, &output_length, input, input_len);
  37. - EVP_CipherFinal_ex(&ctx, *res, &output_length);
  38. - EVP_CIPHER_CTX_cleanup(&ctx);
  39. + EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, 1);
  40. + EVP_CipherUpdate(ctx, *res, &output_length, input, input_len);
  41. + EVP_CipherFinal_ex(ctx, *res, &output_length);
  42. + EVP_CIPHER_CTX_free(ctx);
  43. //EVP_cleanup();
  44. return output_length;