mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
packet: Reformat ssh_packet_hmac_verify()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -272,28 +272,45 @@ int ssh_packet_hmac_verify(ssh_session session,
|
|||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
crypto = ssh_packet_get_current_crypto(session, SSH_DIRECTION_IN);
|
crypto = ssh_packet_get_current_crypto(session,
|
||||||
|
SSH_DIRECTION_IN);
|
||||||
if (crypto == NULL) {
|
if (crypto == NULL) {
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = hmac_init(crypto->decryptMAC, hmac_digest_len(type), type);
|
ctx = hmac_init(crypto->decryptMAC,
|
||||||
|
hmac_digest_len(type),
|
||||||
|
type);
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
seq = htonl(session->recv_seq);
|
seq = htonl(session->recv_seq);
|
||||||
|
|
||||||
hmac_update(ctx, (unsigned char *) &seq, sizeof(uint32_t));
|
hmac_update(ctx,
|
||||||
hmac_update(ctx, data, len);
|
(unsigned char *)&seq,
|
||||||
hmac_final(ctx, hmacbuf, &hmaclen);
|
sizeof(uint32_t));
|
||||||
|
hmac_update(ctx,
|
||||||
|
data,
|
||||||
|
len);
|
||||||
|
hmac_final(ctx,
|
||||||
|
hmacbuf,
|
||||||
|
&hmaclen);
|
||||||
|
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_log_hexdump("received mac",mac,hmaclen);
|
ssh_log_hexdump("received mac",
|
||||||
ssh_log_hexdump("Computed mac",hmacbuf,hmaclen);
|
mac,
|
||||||
ssh_log_hexdump("seq",(unsigned char *)&seq,sizeof(uint32_t));
|
hmaclen);
|
||||||
|
ssh_log_hexdump("Computed mac",
|
||||||
|
hmacbuf,
|
||||||
|
hmaclen);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user