-
Type:
Bug
-
Status: Closed
-
Priority:
Minor
-
Resolution: Incomplete
-
Affects Version/s: OpenDNSSEC 1.4.4
-
Fix Version/s: None
-
Component/s: PKCS#11 Interface
-
Labels:None
-
Environment:
Proprietary embedded development platform.
In OSSLEVPSymmetricAlgorithm.cpp the member functions encryptUpdate() and decryptUpdate() both set the required output buffer size for the calls to the OpenSSL functions EVP_EncryptUpdate() and EVP_DecryptUpdate() with code like:
data.resize(incommingData.size() + getBlockSize() - 1);
That is correct for the call EVP_EncryptUpdate, but one byte too short for the call to EVP_DecryptUpdate. The OpenSSL doc https://www.openssl.org/docs/manmaster/crypto/EVP_EncryptInit.html first describes EVP_EncryptUpdate:
The amount of data written depends on the block alignment of the encrypted data: as a result the amount of data written may be anything from zero bytes to (inl + cipher_block_size - 1) so out should contain sufficient room.
Then describes the decryption version as almost the same:
The parameters and restrictions are identical to the encryption operations except that if padding is enabled the decrypted data buffer out passed to EVP_DecryptUpdate() should have sufficient room for (inl + cipher_block_size) bytes unless the cipher block size is 1 in which case inl bytes is sufficient.
Note the one-byte difference in the required output buffer size. Obviously the fix is to remove the "- 1" from the argument to data.resize() in decryptUpdate().