upravy opravy
This commit is contained in:
@@ -162,7 +162,10 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
|
||||
/* Create and initialise the context */
|
||||
if (!(ctx = EVP_CIPHER_CTX_new()))
|
||||
{
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialise the decryption operation. IMPORTANT - ensure you use a key
|
||||
@@ -172,14 +175,20 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
* is 128 bits
|
||||
*/
|
||||
if (1 != EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, key, iv))
|
||||
{
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Provide the message to be decrypted, and obtain the plaintext output.
|
||||
* EVP_DecryptUpdate can be called multiple times if necessary.
|
||||
*/
|
||||
if (1 != EVP_DecryptUpdate(ctx, plaintext, &len, ciphertext, ciphertext_len))
|
||||
{
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return -1;
|
||||
}
|
||||
plaintext_len = len;
|
||||
|
||||
/*
|
||||
@@ -187,7 +196,10 @@ int decrypt(const unsigned char *ciphertext, int ciphertext_len, unsigned char *
|
||||
* this stage.
|
||||
*/
|
||||
if (1 != EVP_DecryptFinal_ex(ctx, plaintext + len, &len))
|
||||
{
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
plaintext_len += len;
|
||||
|
||||
@@ -397,7 +409,7 @@ uint16_t calculateCRC16(std::vector<unsigned char> &charVector, int removeCount)
|
||||
uint16_t crc = 0xFFFF; // Initial value
|
||||
|
||||
size_t length = charVector.size();
|
||||
length = length-removeCount;
|
||||
length = length - removeCount;
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user