Skip to content

Commit

Permalink
Add gcry_mac_close statements
Browse files Browse the repository at this point in the history
  • Loading branch information
dccutrig committed Mar 7, 2022
1 parent e0895de commit cd85081
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/crypto_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
#define CRYPTO_LIB_ERR_IV_OUTSIDE_WINDOW (-23)
#define CRYPTO_LIB_ERR_NULL_ARSN (-24)
#define CRYPTO_LIB_ERR_NULL_SA (-25)
#define CRYPTO_LIB_ERR_ENCRYPTION_ERROR (-26)

#endif //_crypto_error_h_
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
printf(KRED "ERROR: gcry_mac_setiv error code %d\n" RESET, gcry_error & GPG_ERR_CODE_MASK);
printf(KRED "Failure: %s/%s\n", gcry_strsource(gcry_error), gcry_strerror(gcry_error));
status = CRYPTO_LIB_ERROR;
gcry_mac_close(tmp_mac_hd);
return status;
}
}
Expand All @@ -618,6 +619,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
gcry_error & GPG_ERR_CODE_MASK);
printf(KRED "Failure: %s/%s\n", gcry_strsource(gcry_error), gcry_strerror(gcry_error));
status = CRYPTO_LIB_ERROR;
gcry_mac_close(tmp_mac_hd);
return status;
}

Expand All @@ -630,6 +632,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
printf(KRED "ERROR: gcry_mac_read error code %d\n" RESET, gcry_error & GPG_ERR_CODE_MASK);
printf(KRED "Failure: %s/%s\n", gcry_strsource(gcry_error), gcry_strerror(gcry_error));
status = CRYPTO_LIB_ERR_MAC_RETRIEVAL_ERROR;
gcry_mac_close(tmp_mac_hd);
return status;
}

Expand Down Expand Up @@ -849,7 +852,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
{
printf(KRED "ERROR: gcry_cipher_encrypt error code %d\n" RESET, gcry_error & GPG_ERR_CODE_MASK);
printf(KRED "Failure: %s/%s\n", gcry_strsource(gcry_error), gcry_strerror(gcry_error));
status = CRYPTO_LIB_ERROR;
status = CRYPTO_LIB_ERR_ENCRYPTION_ERROR;
gcry_cipher_close(tmp_hd);
return status;
}
Expand All @@ -866,7 +869,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,



if ( authenticate_bool == CRYPTO_TRUE )
if (authenticate_bool == CRYPTO_TRUE)
{
gcry_error = gcry_cipher_gettag(tmp_hd,
mac, // tag output
Expand All @@ -893,8 +896,6 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
}

gcry_cipher_close(tmp_hd);


return status;
}

Expand Down Expand Up @@ -1009,6 +1010,5 @@ static int32_t cryptography_aead_decrypt(uint8_t* data_out, size_t len_data_out,
}

gcry_cipher_close(tmp_hd);

return status;
}

0 comments on commit cd85081

Please sign in to comment.