mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
jwe: strip padding after rsa-aes
This commit is contained in:
parent
043700a4b0
commit
8587e164f0
3 changed files with 15 additions and 1 deletions
|
@ -154,7 +154,7 @@ lws_jwe_encrypt_cbc_hs(struct lws_jwe *jwe, uint8_t *cek,
|
|||
|
||||
int
|
||||
lws_jwe_auth_and_decrypt_cbc_hs(struct lws_jwe *jwe, uint8_t *enc_cek,
|
||||
uint8_t *aad, int aad_len)
|
||||
uint8_t *aad, int aad_len)
|
||||
{
|
||||
int n, hlen = lws_genhmac_size(jwe->jose.enc_alg->hmac_type);
|
||||
uint8_t digest[LWS_GENHASH_LARGEST];
|
||||
|
|
|
@ -178,5 +178,12 @@ lws_jwe_auth_and_decrypt_rsa_aes_cbc_hs(struct lws_jwe *jwe)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* strip padding */
|
||||
|
||||
n = jwe->jws.map.buf[LJWE_CTXT][jwe->jws.map.len[LJWE_CTXT] - 1];
|
||||
if (n > 16)
|
||||
return -1;
|
||||
jwe->jws.map.len[LJWE_CTXT] -= n;
|
||||
|
||||
return jwe->jws.map.len[LJWE_CTXT];
|
||||
}
|
||||
|
|
|
@ -170,5 +170,12 @@ lws_jwe_auth_and_decrypt_rsa_aes_gcm(struct lws_jwe *jwe)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* strip padding */
|
||||
|
||||
n = jwe->jws.map.buf[LJWE_CTXT][jwe->jws.map.len[LJWE_CTXT] - 1];
|
||||
if (n > 16)
|
||||
return -1;
|
||||
jwe->jws.map.len[LJWE_CTXT] -= n;
|
||||
|
||||
return jwe->jws.map.len[LJWE_CTXT];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue