mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
packet: Use consistent return codes in ssh_packet_hmac_verify()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit e27ee9d0a4)
This commit is contained in:
@@ -265,6 +265,7 @@ int ssh_packet_hmac_verify(ssh_session session,
|
|||||||
HMACCTX ctx;
|
HMACCTX ctx;
|
||||||
size_t hmaclen = DIGEST_MAX_LEN;
|
size_t hmaclen = DIGEST_MAX_LEN;
|
||||||
uint32_t seq;
|
uint32_t seq;
|
||||||
|
int cmp;
|
||||||
|
|
||||||
/* AEAD types have no mac checking */
|
/* AEAD types have no mac checking */
|
||||||
if (type == SSH_HMAC_AEAD_POLY1305 ||
|
if (type == SSH_HMAC_AEAD_POLY1305 ||
|
||||||
@@ -282,7 +283,7 @@ int ssh_packet_hmac_verify(ssh_session session,
|
|||||||
hmac_digest_len(type),
|
hmac_digest_len(type),
|
||||||
type);
|
type);
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
return -1;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
seq = htonl(session->recv_seq);
|
seq = htonl(session->recv_seq);
|
||||||
@@ -308,11 +309,12 @@ int ssh_packet_hmac_verify(ssh_session session,
|
|||||||
(unsigned char *)&seq,
|
(unsigned char *)&seq,
|
||||||
sizeof(uint32_t));
|
sizeof(uint32_t));
|
||||||
#endif
|
#endif
|
||||||
if (secure_memcmp(mac,
|
cmp = secure_memcmp(mac,
|
||||||
hmacbuf,
|
hmacbuf,
|
||||||
hmaclen) == 0) {
|
hmaclen);
|
||||||
return 0;
|
if (cmp == 0) {
|
||||||
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user