Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add libgcrypt error string prints when it fails #71

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_mac_open 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_LIBGCRYPT_ERROR;
return status;
}
Expand All @@ -588,6 +589,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_mac_setkey 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_LIBGCRYPT_ERROR;
gcry_mac_close(tmp_mac_hd);
return status;
Expand All @@ -600,6 +602,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
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;
return status;
}
Expand All @@ -625,6 +628,7 @@ static int32_t cryptography_authenticate(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
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;
return status;
}
Expand Down Expand Up @@ -669,6 +673,7 @@ static int32_t cryptography_validate_authentication(uint8_t* data_out, size_t le
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_mac_open 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_LIBGCRYPT_ERROR;
return status;
}
Expand All @@ -686,6 +691,7 @@ static int32_t cryptography_validate_authentication(uint8_t* data_out, size_t le
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_mac_setkey 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_LIBGCRYPT_ERROR;
gcry_mac_close(tmp_mac_hd);
return status;
Expand All @@ -697,6 +703,7 @@ static int32_t cryptography_validate_authentication(uint8_t* data_out, size_t le
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
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;
return status;
}
Expand All @@ -721,6 +728,7 @@ static int32_t cryptography_validate_authentication(uint8_t* data_out, size_t le
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
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;
return status;
}
Expand Down Expand Up @@ -752,6 +760,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_cipher_open 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_LIBGCRYPT_ERROR;
return status;
}
Expand All @@ -769,6 +778,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_cipher_setkey 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_LIBGCRYPT_ERROR;
gcry_cipher_close(tmp_hd);
return status;
Expand All @@ -777,6 +787,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_cipher_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_ERR_LIBGCRYPT_ERROR;
gcry_cipher_close(tmp_hd);
return status;
Expand Down Expand Up @@ -832,6 +843,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
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;
gcry_cipher_close(tmp_hd);
return status;
Expand Down Expand Up @@ -859,6 +871,7 @@ static int32_t cryptography_aead_encrypt(uint8_t* data_out, size_t len_data_out,
{
printf(KRED "ERROR: gcry_cipher_checktag 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_cipher_close(tmp_hd);
return status;
Expand Down Expand Up @@ -904,13 +917,15 @@ static int32_t cryptography_aead_decrypt(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_cipher_open 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_LIBGCRYPT_ERROR;
return status;
}
gcry_error = gcry_cipher_setkey(tmp_hd, key_ptr, len_key);
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_cipher_setkey 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_LIBGCRYPT_ERROR;
gcry_cipher_close(tmp_hd);
return status;
Expand All @@ -919,6 +934,7 @@ static int32_t cryptography_aead_decrypt(uint8_t* data_out, size_t len_data_out,
if ((gcry_error & GPG_ERR_CODE_MASK) != GPG_ERR_NO_ERROR)
{
printf(KRED "ERROR: gcry_cipher_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_ERR_LIBGCRYPT_ERROR;
gcry_cipher_close(tmp_hd);
return status;
Expand Down