diff options
author | B. Stack <bgstack15@gmail.com> | 2022-12-16 21:08:02 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-12-16 21:08:02 -0500 |
commit | d35a4795f16e51f5773d00dce796f6948f82dae2 (patch) | |
tree | b37279f6f8b354407507cc1a0e44691d6c63ffe8 /zen/open_ssl.cpp | |
parent | add upstream 11.28 (diff) | |
download | FreeFileSync-11.29.tar.gz FreeFileSync-11.29.tar.bz2 FreeFileSync-11.29.zip |
add upstream 11.2911.29
Diffstat (limited to 'zen/open_ssl.cpp')
-rw-r--r-- | zen/open_ssl.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/zen/open_ssl.cpp b/zen/open_ssl.cpp index 1f556656..9278b6dd 100644 --- a/zen/open_ssl.cpp +++ b/zen/open_ssl.cpp @@ -151,7 +151,13 @@ std::shared_ptr<EVP_PKEY> streamToKey(const std::string& keyStream, RsaStreamTyp throw SysError(formatLastOpenSSLError("OSSL_DECODER_CTX_new_for_pkey")); ZEN_ON_SCOPE_EXIT(::OSSL_DECODER_CTX_free(decCtx)); - //key stream is password-protected? => OSSL_DECODER_CTX_set_passphrase() +#if 0 //key stream is password-protected? => OSSL_DECODER_CTX_set_passphrase() + if (!password.empty()) + if (::OSSL_DECODER_CTX_set_passphrase(decCtx, //OSSL_DECODER_CTX *ctx + reinterpret_cast<const unsigned char*>(password.c_str()), //const unsigned char* kstr + password.size()) != 1) //size_t klen + throw SysError(formatLastOpenSSLError("OSSL_DECODER_CTX_set_passphrase")); +#endif const unsigned char* keyBuf = reinterpret_cast<const unsigned char*>(keyStream.c_str()); size_t keyLen = keyStream.size(); @@ -409,11 +415,9 @@ void zen::verifySignature(const std::string& message, const std::string& signatu } -bool zen::isPuttyKeyStream(const std::string& keyStream) +bool zen::isPuttyKeyStream(const std::string_view keyStream) { - std::string firstLine(keyStream.begin(), std::find_if(keyStream.begin(), keyStream.end(), isLineBreak<char>)); - trim(firstLine); - return startsWith(firstLine, "PuTTY-User-Key-File-2:"); + return startsWith(trimCpy(keyStream, true, false), "PuTTY-User-Key-File-"); } @@ -548,7 +552,7 @@ std::string zen::convertPuttyKeyToPkix(const std::string& keyStream, const std:: auto numToBeString = [](size_t n) -> std::string { - static_assert(std::endian::native == std::endian::little && sizeof(n) >= 4); + static_assert(std::endian::native == std::endian::little&& sizeof(n) >= 4); const char* numStr = reinterpret_cast<const char*>(&n); return {numStr[3], numStr[2], numStr[1], numStr[0]}; //big endian! }; |