Skip to content

Commit

Permalink
Mitigate HMAC signature side-channel attack
Browse files Browse the repository at this point in the history
Thanks to Erwan Legrand
  • Loading branch information
babelouest committed Feb 5, 2024
1 parent 1b899d1 commit f9fd9a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jws.c
Expand Up @@ -479,7 +479,10 @@ static int r_jws_verify_sig_hmac(jws_t * jws, jwk_t * jwk) {
unsigned char * sig = r_jws_sign_hmac(jws, jwk);
int ret;

if (sig != NULL && 0 == o_strcmp((const char *)jws->signature_b64url, (const char *)sig)) {
if (!o_strnullempty((const char *)jws->signature_b64url) &&
!o_strnullempty((const char *)sig) &&
o_strlen((const char *)sig) == o_strlen((const char *)jws->signature_b64url) &&
0 == gnutls_memcmp(jws->signature_b64url, sig, o_strlen((const char *)sig))) {
ret = RHN_OK;
} else {
ret = RHN_ERROR_INVALID;
Expand Down

0 comments on commit f9fd9a1

Please sign in to comment.