@@ -245,6 +245,9 @@ int encrypt_rsa_message(const char *plaintext, EVP_PKEY *public_key, unsigned ch
245
245
ctx = EVP_PKEY_CTX_new_from_pkey (NULL , public_key , "" );
246
246
/* See evp_pkey_rsa(7) and provider-keymgmt(7) */
247
247
rc = EVP_PKEY_get_int_param (public_key , OSSL_PKEY_PARAM_MAX_SIZE , & keysize ); /* XXX not really keysize */
248
+ if (!rc ) {
249
+ goto errreturn ;
250
+ }
248
251
#else
249
252
rsa = EVP_PKEY_get1_RSA (public_key );
250
253
keysize = RSA_size (rsa );
@@ -267,11 +270,14 @@ int encrypt_rsa_message(const char *plaintext, EVP_PKEY *public_key, unsigned ch
267
270
BIO_free (bioBuff );
268
271
269
272
if (encryptedtext_len <= 0 ) {
270
- /* We probably shouldn't be printing stuff like this */
271
- fprintf (stderr , "%s\n" , ERR_error_string (ERR_get_error (), NULL ));
273
+ goto errreturn ;
272
274
}
273
275
274
276
return encryptedtext_len ;
277
+
278
+ errreturn :
279
+ fprintf (stderr , "%s\n" , ERR_error_string (ERR_get_error (), NULL ));
280
+ return 0 ;
275
281
}
276
282
277
283
int decrypt_rsa_message (const unsigned char * encryptedtext , const int encryptedtext_len , EVP_PKEY * private_key , unsigned char * * plaintext ) {
@@ -289,6 +295,9 @@ int decrypt_rsa_message(const unsigned char *encryptedtext, const int encryptedt
289
295
ctx = EVP_PKEY_CTX_new_from_pkey (NULL , private_key , "" );
290
296
/* See evp_pkey_rsa(7) and provider-keymgmt(7) */
291
297
rc = EVP_PKEY_get_int_param (private_key , OSSL_PKEY_PARAM_MAX_SIZE , & keysize ); /* XXX not really keysize */
298
+ if (!rc ) {
299
+ goto errreturn ;
300
+ }
292
301
#else
293
302
rsa = EVP_PKEY_get1_RSA (private_key );
294
303
keysize = RSA_size (rsa );
@@ -312,11 +321,14 @@ int decrypt_rsa_message(const unsigned char *encryptedtext, const int encryptedt
312
321
BIO_free (bioBuff );
313
322
314
323
if (plaintext_len <= 0 ) {
315
- /* We probably shouldn't be printing stuff like this */
316
- fprintf (stderr , "%s\n" , ERR_error_string (ERR_get_error (), NULL ));
324
+ goto errreturn ;
317
325
}
318
326
319
327
return plaintext_len ;
328
+
329
+ errreturn :
330
+ fprintf (stderr , "%s\n" , ERR_error_string (ERR_get_error (), NULL ));
331
+ return 0 ;
320
332
}
321
333
322
334
int encode_auth_setting (const char * username , const char * password , EVP_PKEY * public_key , char * * authtoken ){
0 commit comments