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:
Andreas Schneider
2022-07-13 16:17:15 +02:00
parent 46e0703c6e
commit 5c629f22f6

View File

@@ -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;
} }