File tree 1 file changed +19
-3
lines changed
providers/implementations/signature
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -208,13 +208,29 @@ static int rsa_pss_compute_saltlen(PROV_RSA_CTX *ctx)
208
208
* Provide a way to use at most the digest length, so that the default does
209
209
* not violate FIPS 186-4. */
210
210
if (saltlen == RSA_PSS_SALTLEN_DIGEST ) {
211
- saltlen = EVP_MD_get_size (ctx -> md );
211
+ if ((saltlen = EVP_MD_get_size (ctx -> md )) <= 0 ) {
212
+ ERR_raise (ERR_LIB_PROV , PROV_R_INVALID_DIGEST );
213
+ return -1 ;
214
+ }
212
215
} else if (saltlen == RSA_PSS_SALTLEN_AUTO_DIGEST_MAX ) {
213
216
saltlen = RSA_PSS_SALTLEN_MAX ;
214
- saltlenMax = EVP_MD_get_size (ctx -> md );
217
+ if ((saltlenMax = EVP_MD_get_size (ctx -> md )) <= 0 ) {
218
+ ERR_raise (ERR_LIB_PROV , PROV_R_INVALID_DIGEST );
219
+ return -1 ;
220
+ }
215
221
}
216
222
if (saltlen == RSA_PSS_SALTLEN_MAX || saltlen == RSA_PSS_SALTLEN_AUTO ) {
217
- saltlen = RSA_size (ctx -> rsa ) - EVP_MD_get_size (ctx -> md ) - 2 ;
223
+ int mdsize , rsasize ;
224
+
225
+ if ((mdsize = EVP_MD_get_size (ctx -> md )) <= 0 ) {
226
+ ERR_raise (ERR_LIB_PROV , PROV_R_INVALID_DIGEST );
227
+ return -1 ;
228
+ }
229
+ if ((rsasize = RSA_size (ctx -> rsa )) <= 2 || rsasize - 2 < mdsize ) {
230
+ ERR_raise (ERR_LIB_PROV , PROV_R_INVALID_KEY );
231
+ return -1 ;
232
+ }
233
+ saltlen = rsasize - mdsize - 2 ;
218
234
if ((RSA_bits (ctx -> rsa ) & 0x7 ) == 1 )
219
235
saltlen -- ;
220
236
if (saltlenMax >= 0 && saltlen > saltlenMax )
You can’t perform that action at this time.
0 commit comments