Check the return values of functions RSA_public_encrypt and RSA_private_decrypt appropriately.
Signed-off-by: Ramon de Carvalho Valle <[email protected]> --- usr/lib/pkcs11/soft_stdll/soft_specific.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/usr/lib/pkcs11/soft_stdll/soft_specific.c b/usr/lib/pkcs11/soft_stdll/soft_specific.c index 90d20fd..2d09fec 100644 --- a/usr/lib/pkcs11/soft_stdll/soft_specific.c +++ b/usr/lib/pkcs11/soft_stdll/soft_specific.c @@ -1111,12 +1111,13 @@ token_specific_rsa_encrypt( CK_BYTE * in_data, // Do an RSA public encryption rc = RSA_public_encrypt(in_data_len, in_data, out_data, rsa, RSA_NO_PADDING); - if (rc != 0) { - rc = CKR_OK; - } else { + if (rc == -1) { st_err_log(4, __FILE__, __LINE__, __FUNCTION__); rc = CKR_FUNCTION_FAILED; + RSA_free(rsa); + goto done; } + rc = CKR_OK; // Clean up after ourselves RSA_free(rsa); done: @@ -1143,13 +1144,13 @@ token_specific_rsa_decrypt( CK_BYTE * in_data, // Do the private decryption rc = RSA_private_decrypt(in_data_len, in_data, out_data, rsa, RSA_NO_PADDING); - if (rc != 0) { - rc = CKR_OK; - } else { + if (rc == -1) { st_err_log(4, __FILE__, __LINE__, __FUNCTION__); rc = CKR_FUNCTION_FAILED; + RSA_free(rsa); + goto done; } - + rc = CKR_OK; // Clean up RSA_free(rsa); done: -- 1.6.3.3 ------------------------------------------------------------------------------ SOLARIS 10 is the OS for Data Centers - provides features such as DTrace, Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW http://p.sf.net/sfu/solaris-dev2dev _______________________________________________ Opencryptoki-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech
