Changeset 2840


Ignore:
Timestamp:
Nov 6, 2019 8:57:34 PM (5 weeks ago)
Author:
gegorbet
Message:

Kip changes so us_crypto works with openssl 1.x (pointer ctx)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/us_crypto.cpp

    r2722 r2840  
    3838   uchar*     plain_ptr  = (uchar*)plain_ba.data();
    3939
    40    EVP_CIPHER_CTX ctx;
     40  // EVP_CIPHER_CTX ctx;
     41   EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
    4142   uchar          out[ 100 ];   // Assume the plaintext is < 99 characters
    4243   int            out_length;
    4344   int            final_length;
    4445
    45    EVP_EncryptInit  ( &ctx, EVP_aes_128_cbc(), key, iv_ptr );
    46    EVP_EncryptUpdate( &ctx, out, &out_length, plain_ptr, plaintext.size() );
    47    EVP_EncryptFinal ( &ctx, &out[ out_length ], &final_length );
     46   EVP_EncryptInit  ( ctx, EVP_aes_128_cbc(), key, iv_ptr );
     47   EVP_EncryptUpdate( ctx, out, &out_length, plain_ptr, plaintext.size() );
     48   EVP_EncryptFinal ( ctx, &out[ out_length ], &final_length );
    4849
    4950   int c_size = out_length + final_length;
    5051
    5152   QByteArray cipher_ba = QByteArray( (const char*)out, c_size );
     53
     54   EVP_CIPHER_CTX_free(ctx);
    5255
    5356   result << cipher_ba.toHex() << iv_ba.toHex();
     
    7780
    7881   int            ol;
    79    EVP_CIPHER_CTX ctx;
     82   //EVP_CIPHER_CTX ctx;
     83   EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
    8084
    81    EVP_DecryptInit  ( &ctx, EVP_aes_128_cbc(), key, iv_ptr );
    82    EVP_DecryptUpdate( &ctx, out, &ol, cipher_ptr, cipher_ba.size() );
    83    EVP_DecryptFinal ( &ctx, final, &ol );
     85   EVP_DecryptInit  ( ctx, EVP_aes_128_cbc(), key, iv_ptr );
     86   EVP_DecryptUpdate( ctx, out, &ol, cipher_ptr, cipher_ba.size() );
     87   EVP_DecryptFinal ( ctx, final, &ol );
    8488
    8589   QByteArray final_ba( (char*)final, ol );
     90   EVP_CIPHER_CTX_free(ctx);
    8691
    8792   return final_ba;
Note: See TracChangeset for help on using the changeset viewer.