@@ -97,13 +97,14 @@ lws_jwe_encrypt_rsa_aes_cbc_hs(struct lws_jwe *jwe,
9797 return -1 ;
9898 }
9999
100- if ( lws_genrsa_create (& rsactx , jwe -> jws .jwk -> e , jwe -> jws .context ,
100+ int res = lws_genrsa_create (& rsactx , jwe -> jws .jwk -> e , jwe -> jws .context ,
101101 !strcmp (jwe -> jose .alg -> alg , "RSA-OAEP" ) ?
102102 LGRSAM_PKCS1_OAEP_PSS : LGRSAM_PKCS1_1_5 ,
103- LWS_GENHASH_TYPE_UNKNOWN )) {
103+ LWS_GENHASH_TYPE_UNKNOWN );
104+ if (res ) {
104105 lwsl_notice ("%s: lws_genrsa_create\n" ,
105106 __func__ );
106- return -1 ;
107+ return res < -1 ? res : -1 ;
107108 }
108109
109110 /* encrypt the CEK using RSA, mbedtls can't handle both in and out are
@@ -117,7 +118,7 @@ lws_jwe_encrypt_rsa_aes_cbc_hs(struct lws_jwe *jwe,
117118 lws_explicit_bzero (ekey , (unsigned int )hlen ); /* cleanse the temp CEK copy */
118119 if (n < 0 ) {
119120 lwsl_err ("%s: encrypt cek fail\n" , __func__ );
120- return -1 ;
121+ return n < -1 ? n : -1 ;
121122 }
122123 jwe -> jws .map .len [LJWE_EKEY ] = (unsigned int )n ; /* update to encrypted EKEY size */
123124
@@ -151,13 +152,14 @@ lws_jwe_auth_and_decrypt_rsa_aes_cbc_hs(struct lws_jwe *jwe)
151152
152153 /* Decrypt the JWE Encrypted Key to get the raw MAC || CEK */
153154
154- if ( lws_genrsa_create (& rsactx , jwe -> jws .jwk -> e , jwe -> jws .context ,
155+ int res = lws_genrsa_create (& rsactx , jwe -> jws .jwk -> e , jwe -> jws .context ,
155156 !strcmp (jwe -> jose .alg -> alg , "RSA-OAEP" ) ?
156157 LGRSAM_PKCS1_OAEP_PSS : LGRSAM_PKCS1_1_5 ,
157- LWS_GENHASH_TYPE_UNKNOWN )) {
158+ LWS_GENHASH_TYPE_UNKNOWN );
159+ if (res ) {
158160 lwsl_notice ("%s: lws_genrsa_public_decrypt_create\n" ,
159161 __func__ );
160- return -1 ;
162+ return res < -1 ? res : -1 ;
161163 }
162164
163165 n = lws_genrsa_private_decrypt (& rsactx ,
@@ -167,7 +169,7 @@ lws_jwe_auth_and_decrypt_rsa_aes_cbc_hs(struct lws_jwe *jwe)
167169 lws_genrsa_destroy (& rsactx );
168170 if (n < 0 ) {
169171 lwsl_err ("%s: decrypt cek fail: \n" , __func__ );
170- return -1 ;
172+ return n < -1 ? n : -1 ;
171173 }
172174
173175 n = lws_jwe_auth_and_decrypt_cbc_hs (jwe , enc_cek ,
0 commit comments