Граф коммитов

149 Коммитов

Автор SHA1 Сообщение Дата
Samuel Lee 65232987b3
Do not Install static SCOSSL library by default (#40) 2022-01-31 21:04:02 +00:00
Mitch Lindgren 8ff8a955ac
Merge pull request #38 from microsoft/mitchl-symcrypt-api-changes
Prepare for upcoming SymCrypt API changes
2022-01-26 13:32:19 -08:00
Samuel Lee 7d76eb82b2
Fix variadic function use in logging (#39)
+ 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!
2022-01-26 13:57:24 +00:00
Mitch Lindgren 4a093be859 Prepare for upcoming SymCrypt API changes 2022-01-25 23:07:04 -08:00
Samuel Lee 7b2d988cbc
Various logging tweaks (#37)
* 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
2022-01-25 20:09:25 +00:00
Samuel Lee 1c142b0fa8
Fix memory leak in DH when falling back to OpenSSL (#36)
+ 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)
2022-01-19 19:34:33 +00:00
Samuel Lee 358aa635b6
Log SCOSSL errors to OpenSSL's ERR infrastructure (#35)
* 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
2022-01-19 19:21:07 +00:00
Samuel Lee 55826d6ac9
When verifying RSA-PSS signature with auto-saltlen always fallback (#34)
+ Previously would only fallback for RSA keys, not specifically RSA-PSS
  keys
+ Add test cases for DigestSign/Verify with RSA-PSS
2022-01-19 14:41:13 +00:00
Samuel Lee 853e5a44ff
Merge pull request #33 from microsoft/user/mitchl/multi_engine_support
Set SCOSSL methods as default RSA/ECC methods
2022-01-06 18:26:08 +00:00
Mitch Lindgren 72ae60d055 Set SCOSSL methods as default RSA/ECC methods 2022-01-06 09:26:24 -08:00
Samuel Lee ccdc1d9391
Merge pull request #32 from microsoft/saml-UpdateREADMEWithSupportedAlgorithmsList
Add list of supported algorithms to README
2021-12-15 19:25:29 +00:00
Samuel Lee 5922210a36 Add list of supported algorithms to README 2021-12-15 11:21:15 -08:00
Samuel Lee 1e79803ca2
Merge pull request #31 from microsoft/saml-RenameSymbolsToScossl
Rename symbols to scossl, crash SslPlay on failure, and use macros for common return values
2021-12-14 13:44:58 +00:00
Samuel Lee 2ce24b76f2 Use SCOSSL_SUCCESS and SCOSSL_FAILURE in a few more places
+ Return 0 from a successful SslPlay run
2021-12-14 05:42:03 -08:00
Mitch Lindgren 57c3c70eb2
Merge pull request #30 from microsoft/mitchl-cmake-changes
CMake compilation fixes for embedded platforms
2021-12-13 13:40:32 -08:00
Mitch Lindgren ebe943f741 Remove unnecessary march flags 2021-12-13 13:39:34 -08:00
Samuel Lee 17b35127e3 Create SCOSSL_ macros for common return value meanings 2021-12-13 09:56:31 -08:00
Samuel Lee 9d26bae12a Exit SslPlay application on error by default
+ Makes it easier to detect when something is broken
+ Fix a problem with RSA_NO_PADDING test case
2021-12-13 08:18:34 -08:00
Samuel Lee 1852e1423b Rename lingering sc_ossl -> scossl
+ Also rename symError -> scError
2021-12-13 08:17:30 -08:00
Mitch Lindgren d36d282b42 Use libdir/engines-1.1 as instead of trying to get engines directory from OpenSSL (the latter doesn't work with alternate sysroot). Add option to force use of default compiler for e.g. Yocto builds 2021-12-10 14:33:24 -08:00
Mitch Lindgren 605dbd091e Undo whitespace changes 2021-12-09 17:47:17 -08:00
Mitch Lindgren 6748e67efe Update CMakeLists to support native ARM compilation and install engine to OpenSSL ENGINESDIR 2021-12-09 17:42:23 -08:00
Samuel Lee 05ac8f4dba
Merge pull request #26 from microsoft/saml-VariousFixesForIssuesFoundInReview
Address various issues found in Code Review
2021-12-09 12:03:37 +00:00
Samuel Lee 7ff43aa621 Tidy up cipher iv_length
+ Remove EVP_CIPHER_meth_set_iv_length from ECB (unused) and GCM
  (EVP_CIPH_CUSTOM_IV_LENGTH)
+ Use SYMCRYPT_AES_BLOCK_SIZE for CBC iv_length
2021-12-09 03:43:25 -08:00
Samuel Lee 968ea7e1df Address PR comments
+ Rename SymError to symError
+ Update outdated comments
2021-12-08 07:30:24 -08:00
Samuel Lee 4534082f20 Address various issues found in Code Review
+ 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
2021-12-08 07:30:24 -08:00
Samuel Lee 766ad35ab1 Add DH support
+ 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
2021-12-08 15:17:21 +00:00
Spencer Nofzinger 31b8109541
Remove placeholder rng (#22)
Co-authored-by: spnofzin <spnofzin@microsoft.com>
2021-11-19 13:20:38 -08:00
Anna Dubovitskaya c84328d014
Fix improper hash truncation in ECDSA (#21) 2021-11-17 14:02:51 -08:00
Samuel Lee b7a177eac3
Merge pull request #20 from microsoft/saml-FixTimingForRSAPKCS1Decryption
Remove RSA PKCS1 side-channel
2021-11-16 23:05:28 +00:00
Samuel Lee 787c208d9c Improve readability 2021-11-16 12:13:53 -08:00
Samuel Lee d2ab694934
Merge pull request #19 from microsoft/saml-AddAesCcmSupport
Add AES-CCM support to Engine
2021-11-16 12:38:17 +00:00
Samuel Lee ae9103785f Address PR comments (SAL + debug) 2021-11-16 04:35:52 -08:00
Samuel Lee 14521cc2d2 Remove RSA PKCS1 side-channel 2021-11-15 09:57:14 -08:00
Samuel Lee 00c6b70467 Handle GCM and CCM tags correctly
+ Have minimum of 12B GCM tags
+ Use provided tag length rather than previously set tag length in call
  to get a tag
2021-11-08 03:31:12 -08:00
Samuel Lee 5d11dcab07 Add AES-CCM support to Engine
+ 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
2021-10-08 09:22:51 -07:00
Samuel Lee 8673c2d85d
Merge pull request #13 from microsoft/saml-IntroduceCMakeToolchainFiles
Introduce cmake-toolchain files for Linux AMD64 and ARM64
2021-10-04 17:23:30 +01:00
Spencer Nofzinger 5fbbb78b0a
Code quality: AES (#14)
* Remove debug logging

* Initial declaration comments and SAL annotations

* AES GCM do_cipher to SCOSSL_RETURNLENGTH

* Feedback

Co-authored-by: snofz <spnofzin@microsoft.com>
2021-10-01 16:19:12 -07:00
Spencer Nofzinger ebd31c3022
Code quality: HKDF, PKEY, RSAPSS, TLS1PRF + other fixes (#18)
* Remove debug

* SAL

* Pkey methods

* RSA PSS and variable name fixes

* TLS1PRF + fixes

* Remove more debug statements

* refactor rsa pss switch statements

* Typos, other feedback

* Line limit

Co-authored-by: snofz <spnofzin@microsoft.com>
2021-10-01 16:18:58 -07:00
Spencer Nofzinger 739e56e5c4
Code quality: ECC (#12)
* 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>
2021-09-24 14:55:38 -07:00
Samuel Lee ee41c68651
Merge pull request #16 from microsoft/saml-fixBuildBreakFromSAL
Define _Return_type_success_ to nothing if it is not already defined
2021-09-24 11:27:44 +01:00
Samuel Lee ab5f8b7be5 Define _Return_type_success_ to nothing if it is not defined
+ Fixes build break when trying to build SymCrypt-OpenSSL against older
  SymCrypt headers in a non-Windows environment
2021-09-24 03:23:56 -07:00
Samuel Lee 6a9ff76be0 Introduce cmake-toolchain files for Linux AMD64 and ARM64
+ Update README on how to use them
+ Compile out debug and info logging when building a release version of
  the engine, only leaving error logging
2021-09-22 06:28:07 -07:00
Samuel Lee c391a0062b
Merge pull request #10 from microsoft/spnofzin/dhdsa
Code quality: DH and DSA
2021-09-21 14:54:27 +01:00
snofz fc9aa4174a Moved function descriptions to header and changed one return type to SCOSSL_RETURNLENGTH 2021-09-20 14:10:23 -07:00
snofz 03e06f056f DSA cleanup 2021-09-20 14:02:56 -07:00
snofz a57482e350 DH cleanup 2021-09-20 14:02:56 -07:00
Spencer Nofzinger c23f80fc0b
Merge pull request #9 from microsoft/spnofzin/quality
Code quality: RSA and rand
2021-09-20 10:13:51 -07:00
snofz c4c1f88018 Handle unsigned return value, and siglen 2021-09-10 15:57:41 -07:00
snofz 5cfc632012 cbResult type change, various fixes 2021-09-09 17:27:08 -07:00