diff options
author | Jack Lloyd <[email protected]> | 2019-06-05 08:57:07 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-06-05 08:57:07 -0400 |
commit | da0ab423a62180ef5ac027a97c994b98075b25e9 (patch) | |
tree | 748f2592aa7aada11a781bfa9318bb7af4c3f27a /src/lib/prov/pkcs11 | |
parent | 55562154191077f5bdc71d0ca8714a0f97f2d753 (diff) | |
parent | 4a759ef0164942d3908841cb047f00892921b753 (diff) |
Merge GH #1979 Fix PKCS11 buffer output sizing
Diffstat (limited to 'src/lib/prov/pkcs11')
-rw-r--r-- | src/lib/prov/pkcs11/p11.h | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/lib/prov/pkcs11/p11.h b/src/lib/prov/pkcs11/p11.h index 043b1795a..46545b925 100644 --- a/src/lib/prov/pkcs11/p11.h +++ b/src/lib/prov/pkcs11/p11.h @@ -1817,11 +1817,16 @@ class BOTAN_PUBLIC_API(2,0) LowLevel } encrypted_data.resize(encrypted_size); - return C_Encrypt(session, + if (!C_Encrypt(session, const_cast<Byte*>(plaintext_data.data()), static_cast<Ulong>(plaintext_data.size()), encrypted_data.data(), - &encrypted_size, return_value); + &encrypted_size, return_value)) + { + return false; + } + encrypted_data.resize(encrypted_size); + return true; } /** @@ -1950,11 +1955,16 @@ class BOTAN_PUBLIC_API(2,0) LowLevel } decrypted_data.resize(decrypted_size); - return C_Decrypt(session, - const_cast<Byte*>(encrypted_data.data()), - static_cast<Ulong>(encrypted_data.size()), - decrypted_data.data(), - &decrypted_size, return_value); + if(!C_Decrypt(session, + const_cast<Byte*>(encrypted_data.data()), + static_cast<Ulong>(encrypted_data.size()), + decrypted_data.data(), + &decrypted_size, return_value)) + { + return false; + } + decrypted_data.resize(decrypted_size); + return true; } /** @@ -2189,12 +2199,17 @@ class BOTAN_PUBLIC_API(2,0) LowLevel } signature.resize(signature_size); - return C_Sign(session, + if (!C_Sign(session, const_cast<Byte*>(data.data()), static_cast<Ulong>(data.size()), signature.data(), &signature_size, - return_value); + return_value)) + { + return false; + } + signature.resize(signature_size); + return true; } /** @@ -2290,7 +2305,12 @@ class BOTAN_PUBLIC_API(2,0) LowLevel } signature.resize(signature_size); - return C_SignFinal(session, signature.data(), &signature_size, return_value); + if (!C_SignFinal(session, signature.data(), &signature_size, return_value)) + { + return false; + } + signature.resize(signature_size); + return true; } /** |