mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Use the gpgrt log functions if possible.
* common/logging.c: Do not build any code if we can use the gpgrt_log functions. (log_logv_with_prefix): Rename to log_logv_prefix and change order of args so that this function matches its printf like counterpart gpgrt_logv_prefix. Change all callers. (log_debug_with_string): Rename to log_debug_string. Change all callers. (log_printhex): Move first arg to end so that this function matches its printf like counterpart gpgrt_log_printhex. Change all callers. * common/logging.h: Divert to gpgrt/libgpg-error if we can use the gpgrt_log functions. (bug_at): Add inline versions if we can use the gpgrt_log functions. * configure.ac (GPGRT_ENABLE_LOG_MACROS): Add to AH_BOTTOM. (mycflags): Add -Wno-format-zero-length. -- This patch enables the use of the log function from libgpgrt (aka libgpg-error). Instead of checking a version number, we enable them depending on macros set by recent gpg-error versions. Eventually the whole divert stuff can be removed. The -Wno-format-zero-length is required because log_printhex can be called with an empty format string. Note that this is fully specified standard C behaviour. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
fe96ca8d86
commit
b56dfdfc18
25 changed files with 107 additions and 70 deletions
18
g10/ecdh.c
18
g10/ecdh.c
|
@ -76,7 +76,7 @@ pk_ecdh_default_params (unsigned int qbits)
|
|||
}
|
||||
log_assert (i < DIM (kek_params_table));
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ECDH KEK params are", kek_params, sizeof(kek_params) );
|
||||
log_printhex (kek_params, sizeof(kek_params), "ECDH KEK params are");
|
||||
|
||||
return gcry_mpi_set_opaque (NULL, kek_params, 4 * 8);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
memset (secret_x+secret_x_size, 0, nbytes-secret_x_size);
|
||||
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ECDH shared secret X is:", secret_x, secret_x_size );
|
||||
log_printhex (secret_x, secret_x_size, "ECDH shared secret X is:");
|
||||
}
|
||||
|
||||
/*** We have now the shared secret bytes in secret_x. ***/
|
||||
|
@ -179,7 +179,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
kek_params_size = (nbits+7)/8;
|
||||
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ecdh KDF params:", kek_params, kek_params_size);
|
||||
log_printhex (kek_params, kek_params_size, "ecdh KDF params:");
|
||||
|
||||
/* Expect 4 bytes 03 01 hash_alg symm_alg. */
|
||||
if (kek_params_size != 4 || kek_params[0] != 3 || kek_params[1] != 1)
|
||||
|
@ -236,7 +236,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
}
|
||||
|
||||
if(DBG_CRYPTO)
|
||||
log_printhex ("ecdh KDF message params are:", message, message_size);
|
||||
log_printhex (message, message_size, "ecdh KDF message params are:");
|
||||
}
|
||||
|
||||
/* Derive a KEK (key wrapping key) using MESSAGE and SECRET_X. */
|
||||
|
@ -272,7 +272,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
/* We could have allocated more, so clean the tail before returning. */
|
||||
memset (secret_x+secret_x_size, 0, old_size - secret_x_size);
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ecdh KEK is:", secret_x, secret_x_size );
|
||||
log_printhex (secret_x, secret_x_size, "ecdh KEK is:");
|
||||
}
|
||||
|
||||
/* And, finally, aeswrap with key secret_x. */
|
||||
|
@ -338,7 +338,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
}
|
||||
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ecdh encrypting :", in, data_buf_size );
|
||||
log_printhex (in, data_buf_size, "ecdh encrypting :");
|
||||
|
||||
err = gcry_cipher_encrypt (hd, data_buf+1, data_buf_size+8,
|
||||
in, data_buf_size);
|
||||
|
@ -354,7 +354,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
data_buf[0] = data_buf_size+8;
|
||||
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ecdh encrypted to:", data_buf+1, data_buf[0] );
|
||||
log_printhex (data_buf+1, data_buf[0], "ecdh encrypted to:");
|
||||
|
||||
result = gcry_mpi_set_opaque (NULL, data_buf, 8 * (1+data_buf[0]));
|
||||
if (!result)
|
||||
|
@ -391,7 +391,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
data_buf_size = data_buf[0];
|
||||
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ecdh decrypting :", data_buf+1, data_buf_size);
|
||||
log_printhex (data_buf+1, data_buf_size, "ecdh decrypting :");
|
||||
|
||||
err = gcry_cipher_decrypt (hd, in, data_buf_size, data_buf+1,
|
||||
data_buf_size);
|
||||
|
@ -407,7 +407,7 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
|
|||
data_buf_size -= 8;
|
||||
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("ecdh decrypted to :", in, data_buf_size);
|
||||
log_printhex (in, data_buf_size, "ecdh decrypted to :");
|
||||
|
||||
/* Padding is removed later. */
|
||||
/* if (in[data_buf_size-1] > 8 ) */
|
||||
|
|
|
@ -697,7 +697,7 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
|
|||
|
||||
make_session_key (cfx.dek);
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("DEK is: ", cfx.dek->key, cfx.dek->keylen );
|
||||
log_printhex (cfx.dek->key, cfx.dek->keylen, "DEK is: ");
|
||||
|
||||
rc = write_pubkey_enc_from_list (ctrl, pk_list, cfx.dek, out);
|
||||
if (rc)
|
||||
|
@ -891,7 +891,7 @@ encrypt_filter (void *opaque, int control,
|
|||
|
||||
make_session_key ( efx->cfx.dek );
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("DEK is: ", efx->cfx.dek->key, efx->cfx.dek->keylen);
|
||||
log_printhex (efx->cfx.dek->key, efx->cfx.dek->keylen, "DEK is: ");
|
||||
|
||||
rc = write_pubkey_enc_from_list (efx->ctrl,
|
||||
efx->pk_list, efx->cfx.dek, a);
|
||||
|
|
|
@ -978,7 +978,7 @@ keygrip_from_pk (PKT_public_key *pk, unsigned char *array)
|
|||
else
|
||||
{
|
||||
if (DBG_PACKET)
|
||||
log_printhex ("keygrip=", array, 20);
|
||||
log_printhex (array, 20, "keygrip=");
|
||||
/* FIXME: Save the keygrip in PK. */
|
||||
}
|
||||
gcry_sexp_release (s_pkey);
|
||||
|
|
|
@ -255,7 +255,7 @@ get_it (ctrl_t ctrl,
|
|||
* CSUM
|
||||
*/
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("DEK frame:", frame, nframe);
|
||||
log_printhex (frame, nframe, "DEK frame:");
|
||||
n = 0;
|
||||
|
||||
if (sk->pubkey_algo == PUBKEY_ALGO_ECDH)
|
||||
|
@ -361,7 +361,7 @@ get_it (ctrl_t ctrl,
|
|||
if (DBG_CLOCK)
|
||||
log_clock ("decryption ready");
|
||||
if (DBG_CRYPTO)
|
||||
log_printhex ("DEK is:", dek->key, dek->keylen);
|
||||
log_printhex (dek->key, dek->keylen, "DEK is:");
|
||||
|
||||
/* Check that the algo is in the preferences and whether it has
|
||||
* expired. Also print a status line with the key's fingerprint. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue