* Various tidying to reduce warnings in build
+ Allow libsymcrypt to be found from root of SymCrypt-OpenSSL directory
+ Update README to make compilation instructions a little clearer
+ Add CMake version/description
* Address PR comments
* Implement EVP_CTRL_GCM_IV_GEN / EVP_CTRL_GCM_IV_INV
+ Required for OpenSSH which directly calls EVP_CTRL_GCM_IV_GEN to
increment invocation field in IV
+ Also required to make AES-GCM's IV distinct on a series of calls to
AES-GCM encrypt in TLS context
* Add some documentation about how IV Invocation Field works
+ Fix overlooked piece when entire IV is set by
EVP_CTRL_GCM_SET_IV_FIXED
+ Core _scossl_log_bytes_valist takes a valist, and we only unpack a
variadic argument list once before reaching the core logging function
+ Previously we were incorrectly passing a valist to a variadic
function, which did not work as intended!
* Various logging tweaks
+ Do not leak CRYPTO_RWLOCK
+ Introduce ability to set different levels of logging verbosity for
using OpenSSL ERR and stderr/logfile. Set default level of logging for
OpenSSL ERR to ERROR to avoid problems in OpenSSL unit tests.
+ Update Engine id and name
+ Use new SYMCRYPT_ROOT_DIR variable in cmake to find SymCrypt headers
+ Update README appropriately
+ Rename libsymcryptengine.so -> symcryptengine.so to indicate the
shared object is not a generic Linux shared object but an OpenSSL
Engine
+ Avoid calling fopen with NULL filename
+ Add SslPlay test case which uses default OpenSSL implementation
+ Call DH_OpenSSL finish method in scossl_dh_finish to free anything
which may have been allocated in fallback to OpenSSL
+ Free BNs in cleanup in DH (technically had some memory leaks in
failure cases before)
* Log SCOSSL errors to OpenSSL's ERR infrastructure
+ This is in addition to logging to stderr or a log file specified by
the caller
+ Log additional information with the errors indicating the function
and error reason using the existing data that SCOSSL provides to
error logging functions
+ Define enums for SCOSSL functions which can generate log messages, and
general reason for SCOSSL functions to fail
+ Update all logging sites to use function and reason codes in addition
to any specific logging data previously included
+ Log SCOSSL messages to OpenSSL's ERR infrastructure with codes (to
allow callers to lookup the general error with ERR_error_string) and
also put the call-site specific string as error data for callers which
do more involved error logging
+ Ensure the count of enum entries and ERR_STRING_DATA entries is equal
at compile time with C_ASSERTs
+ Ideally we would ensure function codes given by the logs match the
functions that are doing the logging, but this would need something
more powerful that C preprocessor - may investigate this more deeply
if this logging becomes a maintenance headache!
+ Maintain static file for logging rather than repeatedly
opening/closing
+ Put logging into a region protected by CRYPTO_RWLOCK to avoid multiple
errors writing to ERR / log file concurrently
+ Simplify SYMCRYPT_ERROR logging
+ Enable compiler warnings for C source files
+ Fix various compiler warnings (unsigned/signed comparison, unused
variables, etc.)
+ Remove redundant information from SCOSSL data structures
+ Remove redundant includes
+ Initialize long-lived static variables once at Engine load time,
rather than on demand to avoid race conditions when algorithms are
called concurrently without needing to introduce locking.
+ Check various returns for OpenSSL functions (e.g. BN_bin2bn et. al)
and gracefully error rather than potentially failing in unexpected
ways in low memory conditions
+ Fix memory leaks in new FFC DH implementation
+ Ensure all externally visible symbols have a scossl or sc_ossl prefix
(should settle on a single prefix in a followup PR)
+ Fallback to OpenSSL for ECDSA signatures with a specific kinv or r
+ Use stderr rather than stdout for error messages in debug build
+ Correctly set verify_init function in PKEY rsa method!
+ Only log error messages on signature verification error, rather than
expected signature verification failure
+ Remove a lot of useless work in RSA key setup
+ Error in RSA key import/generation if the requested public exponent is
larger than 2^64-1
+ Rename similar ECC functions to have _ecc in the name
+ Remove needless long-lived buffer in SC_OSSL_ECC_KEY_CONTEXT
+ Avoid redundant checks using BN_num_bytes preceding BN_bn2binpad calls
+ Add ECDH and DH tests to SslPlay
+ CCM support with the EVP APIs is a bit strange, we track the stage of
the process of performing CCM encryption with SCOSSL_CCM_STAGE and
document how callers can move a context from one state to the next
+ Make some tweaks to GCM in preparation for supporting variable IV
length in the future and to use EVP constants rather than locally
defined versions to improve clarity a bit
* Remove debug from ECC
* Intermediate SAL changes
* Function descriptions and SAL, various fixes
* Fix const warning
* Cleanup for internal functions
* Feedback
* Fix SAL headers
Co-authored-by: snofz <spnofzin@microsoft.com>