Skip to content

Commit 39a9766

Browse files
committed
Crypto APIs are avaliable on Windows Phone 8.0.
1 parent 9f48c86 commit 39a9766

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Release/include/cpprest/web_utilities.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class zero_memory_deleter
5151
};
5252
typedef std::unique_ptr<std::wstring, zero_memory_deleter> plaintext_string;
5353
#if defined(__cplusplus_winrt)
54+
#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800)
5455
class winrt_encryption
5556
{
5657
public:
@@ -60,6 +61,7 @@ class winrt_encryption
6061
private:
6162
::pplx::task<Windows::Storage::Streams::IBuffer ^> m_buffer;
6263
};
64+
#endif
6365
#else
6466
class win32_encryption
6567
{
@@ -138,14 +140,23 @@ class credentials
138140
#if defined(_MS_WINDOWS)
139141
details::plaintext_string decrypt() const
140142
{
143+
// Encryption APIs not supported on Windows Phone 8.0
144+
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800
145+
return plaintext_string(new string_t(m_password));
146+
#else
141147
return m_password.decrypt();
148+
#endif
142149
}
143150
#endif
144151

145152
::utility::string_t m_username;
146153
#if defined(_MS_WINDOWS)
147154
#if defined(__cplusplus_winrt)
155+
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800
156+
::utility::string_t m_password;
157+
#else
148158
details::winrt_encryption m_password;
159+
#endif
149160
#else
150161
details::win32_encryption m_password;
151162
#endif

Release/src/utilities/web_utilities.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ namespace details
4242
#if defined(_MS_WINDOWS)
4343
#if defined(__cplusplus_winrt)
4444

45+
// Not available on Windows Phone 8.0
46+
#if !(WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP && _MSC_VER < 1800)
47+
4548
// Helper function to zero out memory of an IBuffer.
4649
void winrt_secure_zero_buffer(Windows::Storage::Streams::IBuffer ^buffer)
4750
{
@@ -91,6 +94,7 @@ plaintext_string winrt_encryption::decrypt() const
9194
SecureZeroMemory(rawPlaintext, plaintext->Length);
9295
return std::move(data);
9396
}
97+
#endif
9498
#else
9599
win32_encryption::win32_encryption(const std::wstring &data) :
96100
m_numCharacters(data.size())

0 commit comments

Comments
 (0)