diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-05-12 19:03:58 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-05-12 19:03:58 +0200 |
commit | ef5846e612d315e89b3101ef280f7ef0a7e3556e (patch) | |
tree | 211f449c0b245917b7e5306be0141b017203d6dc /cpp/src/IceWS/Util.cpp | |
parent | Minor build system fixes (diff) | |
download | ice-ef5846e612d315e89b3101ef280f7ef0a7e3556e.tar.bz2 ice-ef5846e612d315e89b3101ef280f7ef0a7e3556e.tar.xz ice-ef5846e612d315e89b3101ef280f7ef0a7e3556e.zip |
Added IceWS support to WinRT
Diffstat (limited to 'cpp/src/IceWS/Util.cpp')
-rw-r--r-- | cpp/src/IceWS/Util.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cpp/src/IceWS/Util.cpp b/cpp/src/IceWS/Util.cpp index 417acc68cb2..b4ee81fc485 100644 --- a/cpp/src/IceWS/Util.cpp +++ b/cpp/src/IceWS/Util.cpp @@ -12,8 +12,10 @@ #include <Ice/LocalException.h> #include <IceUtil/StringUtil.h> -#include <openssl/err.h> -#include <openssl/sha.h> +#ifndef ICE_OS_WINRT +# include <openssl/err.h> +# include <openssl/sha.h> +#endif #include <IceUtil/DisableWarnings.h> @@ -24,9 +26,22 @@ using namespace IceWS; vector<unsigned char> IceWS::calcSHA1(const vector<unsigned char>& data) { +#ifndef ICE_OS_WINRT vector<unsigned char> hash(SHA_DIGEST_LENGTH); ::SHA1(&data[0], static_cast<unsigned long>(data.size()), &hash[0]); return hash; +#else + auto dataA = ref new Platform::Array<unsigned char>(const_cast<unsigned char*>(&data[0]), data.size()); + auto hasher = Windows::Security::Cryptography::Core::HashAlgorithmProvider::OpenAlgorithm("SHA1"); + auto hashed = hasher->HashData(Windows::Security::Cryptography::CryptographicBuffer::CreateFromByteArray(dataA)); + auto reader = ::Windows::Storage::Streams::DataReader::FromBuffer(hashed); + std::vector<unsigned char> result(reader->UnconsumedBufferLength); + if(!result.empty()) + { + reader->ReadBytes(::Platform::ArrayReference<unsigned char>(&result[0], result.size())); + } + return result; +#endif } WebSocketException::WebSocketException(const string& r) : |