1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

Replace ssh_print_hexa() with ssh_log_hexdump()

Replace all occurrences of the deprecated function ssh_print_hexa() with
the introduced ssh_log_hexdump().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Anderson Toshiyuki Sasaki
2019-07-29 17:40:35 +02:00
committed by Andreas Schneider
parent 33927f3ae8
commit 68baebbd62
11 changed files with 59 additions and 59 deletions

View File

@@ -109,11 +109,11 @@ static void chacha20_poly1305_aead_encrypt(struct ssh_cipher_struct *cipher,
out_packet->payload, out_packet->payload,
len - sizeof(uint32_t)); len - sizeof(uint32_t));
/* ssh_print_hexa("poly1305_ctx", poly1305_ctx, sizeof(poly1305_ctx)); */ /* ssh_log_hexdump("poly1305_ctx", poly1305_ctx, sizeof(poly1305_ctx)); */
/* step 4, compute the MAC */ /* step 4, compute the MAC */
poly1305_auth(tag, (uint8_t *)out_packet, len, poly1305_ctx); poly1305_auth(tag, (uint8_t *)out_packet, len, poly1305_ctx);
/* ssh_print_hexa("poly1305 src", (uint8_t *)out_packet, len); /* ssh_log_hexdump("poly1305 src", (uint8_t *)out_packet, len);
ssh_print_hexa("poly1305 tag", tag, POLY1305_TAGLEN); */ ssh_log_hexdump("poly1305 tag", tag, POLY1305_TAGLEN); */
} }
static int chacha20_poly1305_aead_decrypt_length( static int chacha20_poly1305_aead_decrypt_length(
@@ -159,17 +159,17 @@ static int chacha20_poly1305_aead_decrypt(struct ssh_cipher_struct *cipher,
poly1305_ctx, poly1305_ctx,
POLY1305_KEYLEN); POLY1305_KEYLEN);
#if 0 #if 0
ssh_print_hexa("poly1305_ctx", poly1305_ctx, sizeof(poly1305_ctx)); ssh_log_hexdump("poly1305_ctx", poly1305_ctx, sizeof(poly1305_ctx));
#endif #endif
poly1305_auth(tag, (uint8_t *)complete_packet, encrypted_size + poly1305_auth(tag, (uint8_t *)complete_packet, encrypted_size +
sizeof(uint32_t), poly1305_ctx); sizeof(uint32_t), poly1305_ctx);
#if 0 #if 0
ssh_print_hexa("poly1305 src", ssh_log_hexdump("poly1305 src",
(uint8_t*)complete_packet, (uint8_t*)complete_packet,
encrypted_size + 4); encrypted_size + 4);
ssh_print_hexa("poly1305 tag", tag, POLY1305_TAGLEN); ssh_log_hexdump("poly1305 tag", tag, POLY1305_TAGLEN);
ssh_print_hexa("received tag", mac, POLY1305_TAGLEN); ssh_log_hexdump("received tag", mac, POLY1305_TAGLEN);
#endif #endif
cmp = memcmp(tag, mac, POLY1305_TAGLEN); cmp = memcmp(tag, mac, POLY1305_TAGLEN);

View File

@@ -101,9 +101,9 @@ static int ssh_curve25519_build_k(ssh_session session) {
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("Session server cookie", ssh_log_hexdump("Session server cookie",
session->next_crypto->server_kex.cookie, 16); session->next_crypto->server_kex.cookie, 16);
ssh_print_hexa("Session client cookie", ssh_log_hexdump("Session client cookie",
session->next_crypto->client_kex.cookie, 16); session->next_crypto->client_kex.cookie, 16);
ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret); ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret);
#endif #endif

View File

@@ -277,9 +277,9 @@ static void ssh_dh_debug(ssh_session session)
ssh_print_bignum("e", e); ssh_print_bignum("e", e);
ssh_print_bignum("f", f); ssh_print_bignum("f", f);
ssh_print_hexa("Session server cookie", ssh_log_hexdump("Session server cookie",
session->next_crypto->server_kex.cookie, 16); session->next_crypto->server_kex.cookie, 16);
ssh_print_hexa("Session client cookie", ssh_log_hexdump("Session client cookie",
session->next_crypto->client_kex.cookie, 16); session->next_crypto->client_kex.cookie, 16);
ssh_print_bignum("k", session->next_crypto->shared_secret); ssh_print_bignum("k", session->next_crypto->shared_secret);
} }

View File

@@ -181,9 +181,9 @@ int ecdh_build_k(ssh_session session) {
session->next_crypto->ecdh_privkey = NULL; session->next_crypto->ecdh_privkey = NULL;
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("Session server cookie", ssh_log_hexdump("Session server cookie",
session->next_crypto->server_kex.cookie, 16); session->next_crypto->server_kex.cookie, 16);
ssh_print_hexa("Session client cookie", ssh_log_hexdump("Session client cookie",
session->next_crypto->client_kex.cookie, 16); session->next_crypto->client_kex.cookie, 16);
ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret); ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret);
#endif #endif

View File

@@ -242,9 +242,9 @@ int ecdh_build_k(ssh_session session)
session->next_crypto->ecdh_privkey = NULL; session->next_crypto->ecdh_privkey = NULL;
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("Session server cookie", ssh_log_hexdump("Session server cookie",
session->next_crypto->server_kex.cookie, 16); session->next_crypto->server_kex.cookie, 16);
ssh_print_hexa("Session client cookie", ssh_log_hexdump("Session client cookie",
session->next_crypto->client_kex.cookie, 16); session->next_crypto->client_kex.cookie, 16);
ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret); ssh_print_bignum("Shared secret key", session->next_crypto->shared_secret);
#endif #endif

View File

@@ -547,7 +547,7 @@ void ssh_list_kex(struct ssh_kex_struct *kex) {
int i = 0; int i = 0;
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("session cookie", kex->cookie, 16); ssh_log_hexdump("session cookie", kex->cookie, 16);
#endif #endif
for(i = 0; i < SSH_KEX_METHODS; i++) { for(i = 0; i < SSH_KEX_METHODS; i++) {
@@ -1119,7 +1119,7 @@ int ssh_make_sessionid(ssh_session session)
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("hash buffer", ssh_buffer_get(buf), ssh_buffer_get_len(buf)); ssh_log_hexdump("hash buffer", ssh_buffer_get(buf), ssh_buffer_get_len(buf));
#endif #endif
switch (session->next_crypto->kex_type) { switch (session->next_crypto->kex_type) {
@@ -1195,8 +1195,8 @@ int ssh_make_sessionid(ssh_session session)
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
printf("Session hash: \n"); printf("Session hash: \n");
ssh_print_hexa("secret hash", session->next_crypto->secret_hash, session->next_crypto->digest_len); ssh_log_hexdump("secret hash", session->next_crypto->secret_hash, session->next_crypto->digest_len);
ssh_print_hexa("session id", session->next_crypto->session_id, session->next_crypto->digest_len); ssh_log_hexdump("session id", session->next_crypto->session_id, session->next_crypto->digest_len);
#endif #endif
rc = SSH_OK; rc = SSH_OK;
@@ -1383,15 +1383,15 @@ int ssh_generate_session_keys(ssh_session session)
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("Client to Server IV", IV_cli_to_srv, IV_len); ssh_log_hexdump("Client to Server IV", IV_cli_to_srv, IV_len);
ssh_print_hexa("Server to Client IV", IV_srv_to_cli, IV_len); ssh_log_hexdump("Server to Client IV", IV_srv_to_cli, IV_len);
ssh_print_hexa("Client to Server Encryption Key", enckey_cli_to_srv, ssh_log_hexdump("Client to Server Encryption Key", enckey_cli_to_srv,
enckey_cli_to_srv_len); enckey_cli_to_srv_len);
ssh_print_hexa("Server to Client Encryption Key", enckey_srv_to_cli, ssh_log_hexdump("Server to Client Encryption Key", enckey_srv_to_cli,
enckey_srv_to_cli_len); enckey_srv_to_cli_len);
ssh_print_hexa("Client to Server Integrity Key", intkey_cli_to_srv, ssh_log_hexdump("Client to Server Integrity Key", intkey_cli_to_srv,
intkey_cli_to_srv_len); intkey_cli_to_srv_len);
ssh_print_hexa("Server to Client Integrity Key", intkey_srv_to_cli, ssh_log_hexdump("Server to Client Integrity Key", intkey_srv_to_cli,
intkey_srv_to_cli_len); intkey_srv_to_cli_len);
#endif #endif

View File

@@ -196,11 +196,11 @@ unsigned char *ssh_packet_encrypt(ssh_session session, void *data, uint32_t len)
hmac_final(ctx, crypto->hmacbuf, &finallen); hmac_final(ctx, crypto->hmacbuf, &finallen);
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("mac: ",data,hmac_digest_len(type)); ssh_log_hexdump("mac: ",data,hmac_digest_len(type));
if (finallen != hmac_digest_len(type)) { if (finallen != hmac_digest_len(type)) {
printf("Final len is %d\n",finallen); printf("Final len is %d\n",finallen);
} }
ssh_print_hexa("Packet hmac", crypto->hmacbuf, hmac_digest_len(type)); ssh_log_hexdump("Packet hmac", crypto->hmacbuf, hmac_digest_len(type));
#endif #endif
} }
explicit_bzero(out, len); explicit_bzero(out, len);
@@ -264,9 +264,9 @@ int ssh_packet_hmac_verify(ssh_session session,
hmac_final(ctx, hmacbuf, &hmaclen); hmac_final(ctx, hmacbuf, &hmaclen);
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("received mac",mac,hmaclen); ssh_log_hexdump("received mac",mac,hmaclen);
ssh_print_hexa("Computed mac",hmacbuf,hmaclen); ssh_log_hexdump("Computed mac",hmacbuf,hmaclen);
ssh_print_hexa("seq",(unsigned char *)&seq,sizeof(uint32_t)); ssh_log_hexdump("seq",(unsigned char *)&seq,sizeof(uint32_t));
#endif #endif
if (secure_memcmp(mac, hmacbuf, hmaclen) == 0) { if (secure_memcmp(mac, hmacbuf, hmaclen) == 0) {
return 0; return 0;

View File

@@ -1064,12 +1064,12 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
rc = pki_privkey_build_dss(key, p, q, g, pubkey, privkey); rc = pki_privkey_build_dss(key, p, q, g, pubkey, privkey);
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("p", ssh_string_data(p), ssh_string_len(p)); ssh_log_hexdump("p", ssh_string_data(p), ssh_string_len(p));
ssh_print_hexa("q", ssh_string_data(q), ssh_string_len(q)); ssh_log_hexdump("q", ssh_string_data(q), ssh_string_len(q));
ssh_print_hexa("g", ssh_string_data(g), ssh_string_len(g)); ssh_log_hexdump("g", ssh_string_data(g), ssh_string_len(g));
ssh_print_hexa("pubkey", ssh_string_data(pubkey), ssh_log_hexdump("pubkey", ssh_string_data(pubkey),
ssh_string_len(pubkey)); ssh_string_len(pubkey));
ssh_print_hexa("privkey", ssh_string_data(privkey), ssh_log_hexdump("privkey", ssh_string_data(privkey),
ssh_string_len(privkey)); ssh_string_len(privkey));
#endif #endif
ssh_string_burn(p); ssh_string_burn(p);
@@ -1105,13 +1105,13 @@ int pki_import_privkey_buffer(enum ssh_keytypes_e type,
rc = pki_privkey_build_rsa(key, n, e, d, iqmp, p, q); rc = pki_privkey_build_rsa(key, n, e, d, iqmp, p, q);
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("n", ssh_string_data(n), ssh_string_len(n)); ssh_log_hexdump("n", ssh_string_data(n), ssh_string_len(n));
ssh_print_hexa("e", ssh_string_data(e), ssh_string_len(e)); ssh_log_hexdump("e", ssh_string_data(e), ssh_string_len(e));
ssh_print_hexa("d", ssh_string_data(d), ssh_string_len(d)); ssh_log_hexdump("d", ssh_string_data(d), ssh_string_len(d));
ssh_print_hexa("iqmp", ssh_string_data(iqmp), ssh_log_hexdump("iqmp", ssh_string_data(iqmp),
ssh_string_len(iqmp)); ssh_string_len(iqmp));
ssh_print_hexa("p", ssh_string_data(p), ssh_string_len(p)); ssh_log_hexdump("p", ssh_string_data(p), ssh_string_len(p));
ssh_print_hexa("q", ssh_string_data(q), ssh_string_len(q)); ssh_log_hexdump("q", ssh_string_data(q), ssh_string_len(q));
#endif #endif
ssh_string_burn(n); ssh_string_burn(n);
ssh_string_free(n); ssh_string_free(n);
@@ -1237,9 +1237,9 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
rc = pki_pubkey_build_dss(key, p, q, g, pubkey); rc = pki_pubkey_build_dss(key, p, q, g, pubkey);
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("p", ssh_string_data(p), ssh_string_len(p)); ssh_log_hexdump("p", ssh_string_data(p), ssh_string_len(p));
ssh_print_hexa("q", ssh_string_data(q), ssh_string_len(q)); ssh_log_hexdump("q", ssh_string_data(q), ssh_string_len(q));
ssh_print_hexa("g", ssh_string_data(g), ssh_string_len(g)); ssh_log_hexdump("g", ssh_string_data(g), ssh_string_len(g));
#endif #endif
ssh_string_burn(p); ssh_string_burn(p);
ssh_string_free(p); ssh_string_free(p);
@@ -1268,8 +1268,8 @@ static int pki_import_pubkey_buffer(ssh_buffer buffer,
rc = pki_pubkey_build_rsa(key, e, n); rc = pki_pubkey_build_rsa(key, e, n);
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("e", ssh_string_data(e), ssh_string_len(e)); ssh_log_hexdump("e", ssh_string_data(e), ssh_string_len(e));
ssh_print_hexa("n", ssh_string_data(n), ssh_string_len(n)); ssh_log_hexdump("n", ssh_string_data(n), ssh_string_len(n));
#endif #endif
ssh_string_burn(e); ssh_string_burn(e);
ssh_string_free(e); ssh_string_free(e);

View File

@@ -1519,7 +1519,7 @@ static int pki_signature_from_rsa_blob(const ssh_key pubkey,
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
SSH_LOG(SSH_LOG_WARN, "RSA signature len: %lu", (unsigned long)len); SSH_LOG(SSH_LOG_WARN, "RSA signature len: %lu", (unsigned long)len);
ssh_print_hexa("RSA signature", ssh_string_data(sig_blob), len); ssh_log_hexdump("RSA signature", ssh_string_data(sig_blob), len);
#endif #endif
if (len == rsalen) { if (len == rsalen) {
@@ -1583,8 +1583,8 @@ static int pki_signature_from_dsa_blob(UNUSED_PARAM(const ssh_key pubkey),
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("r", ssh_string_data(sig_blob), 20); ssh_log_hexdump("r", ssh_string_data(sig_blob), 20);
ssh_print_hexa("s", (unsigned char *)ssh_string_data(sig_blob) + 20, 20); ssh_log_hexdump("s", (unsigned char *)ssh_string_data(sig_blob) + 20, 20);
#endif #endif
r = ssh_string_new(20); r = ssh_string_new(20);
@@ -1695,7 +1695,7 @@ static int pki_signature_from_ecdsa_blob(UNUSED_PARAM(const ssh_key pubkey),
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("r", ssh_string_data(r), ssh_string_len(r)); ssh_log_hexdump("r", ssh_string_data(r), ssh_string_len(r));
#endif #endif
pr = ssh_make_string_bn(r); pr = ssh_make_string_bn(r);
@@ -1723,7 +1723,7 @@ static int pki_signature_from_ecdsa_blob(UNUSED_PARAM(const ssh_key pubkey),
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("s", ssh_string_data(s), ssh_string_len(s)); ssh_log_hexdump("s", ssh_string_data(s), ssh_string_len(s));
#endif #endif
ps = ssh_make_string_bn(s); ps = ssh_make_string_bn(s);
@@ -2074,7 +2074,7 @@ ssh_signature pki_sign_data(const ssh_key privkey,
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("Generated signature", raw_sig_data, raw_sig_len); ssh_log_hexdump("Generated signature", raw_sig_data, raw_sig_len);
#endif #endif
/* Allocate and fill output signature */ /* Allocate and fill output signature */

View File

@@ -1945,7 +1945,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
SSH_LOG(SSH_LOG_DEBUG, SSH_LOG(SSH_LOG_DEBUG,
"DSA signature len: %lu", "DSA signature len: %lu",
(unsigned long)len); (unsigned long)len);
ssh_print_hexa("DSA signature", ssh_string_data(sig_blob), len); ssh_log_hexdump("DSA signature", ssh_string_data(sig_blob), len);
#endif #endif
err = gcry_sexp_build(&sig->dsa_sig, err = gcry_sexp_build(&sig->dsa_sig,
@@ -1980,7 +1980,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
SSH_LOG(SSH_LOG_DEBUG, "RSA signature len: %lu", (unsigned long)len); SSH_LOG(SSH_LOG_DEBUG, "RSA signature len: %lu", (unsigned long)len);
ssh_print_hexa("RSA signature", ssh_string_data(sig_blob), len); ssh_log_hexdump("RSA signature", ssh_string_data(sig_blob), len);
#endif #endif
err = gcry_sexp_build(&sig->rsa_sig, err = gcry_sexp_build(&sig->rsa_sig,
@@ -2055,8 +2055,8 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("r", ssh_string_data(r), ssh_string_len(r)); ssh_log_hexdump("r", ssh_string_data(r), ssh_string_len(r));
ssh_print_hexa("s", ssh_string_data(s), ssh_string_len(s)); ssh_log_hexdump("s", ssh_string_data(s), ssh_string_len(s));
#endif #endif
err = gcry_sexp_build(&sig->ecdsa_sig, err = gcry_sexp_build(&sig->ecdsa_sig,

View File

@@ -873,7 +873,7 @@ static ssh_signature pki_signature_from_rsa_blob(const ssh_key pubkey, const
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
SSH_LOG(SSH_LOG_WARN, "RSA signature len: %lu", (unsigned long)len); SSH_LOG(SSH_LOG_WARN, "RSA signature len: %lu", (unsigned long)len);
ssh_print_hexa("RSA signature", ssh_string_data(sig_blob), len); ssh_log_hexdump("RSA signature", ssh_string_data(sig_blob), len);
#endif #endif
if (len == rsalen) { if (len == rsalen) {
@@ -966,7 +966,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
return NULL; return NULL;
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("r", ssh_string_data(r), ssh_string_len(r)); ssh_log_hexdump("r", ssh_string_data(r), ssh_string_len(r));
#endif #endif
sig->ecdsa_sig.r = ssh_make_string_bn(r); sig->ecdsa_sig.r = ssh_make_string_bn(r);
ssh_string_burn(r); ssh_string_burn(r);
@@ -986,7 +986,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
} }
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO
ssh_print_hexa("s", ssh_string_data(s), ssh_string_len(s)); ssh_log_hexdump("s", ssh_string_data(s), ssh_string_len(s));
#endif #endif
sig->ecdsa_sig.s = ssh_make_string_bn(s); sig->ecdsa_sig.s = ssh_make_string_bn(s);
ssh_string_burn(s); ssh_string_burn(s);