11#include <codeanalysis\warnings.h>
13#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
53 inline bool IsOk() const noexcept
62 inline operator HCRYPTPROV() const noexcept
110 inline bool IsOk() const noexcept
119 inline operator HCRYPTHASH() const noexcept
135 _Success_(
return != 0) bool Hash(_In_reads_bytes_(size) const
void *data, _In_
size_t size);
147 inline _Success_(return != 0)
bool Hash(_In_ const wxMemoryBuffer &data)
149 return Hash(data.GetData(), data.GetDataLen());
162 inline _Success_(
return != 0) bool HashAsUTF8(_In_ const wxString &str)
164 const wxScopedCharBuffer buf(str.ToUTF8());
165 return Hash(buf.data(), buf.length());
178 inline _Success_(
return != 0) bool HashFile(_In_ const wxString &fileName)
180 wxFFile file(fileName, wxT(
"rb"));
181 if (file.IsOpened()) {
182 wxMemoryBuffer buf(4*1024);
183 void *data = buf.GetData();
184 const size_t nBlock = buf.GetBufSize();
186 Hash(data, file.Read(data, nBlock));
190 wxLogError(wxT(
"Can not open %s file for reading."), fileName);
205 virtual _Success_(
return != 0) bool GetValue(_Out_ wxMemoryBuffer &hash);
217 _Success_(return != 0)
bool Sign(_Inout_ wxMemoryBuffer &signature);
225 inline wxMemoryBuffer Sign()
227 wxMemoryBuffer signature;
255 virtual _Success_(
return != 0)
bool GetValue(_Out_ wxMemoryBuffer &hash);
259#if (NTDDI_VERSION > NTDDI_WINXPSP2)
282 virtual _Success_(
return != 0) bool GetValue(_Out_ wxMemoryBuffer &hash);
316 inline bool IsOk() const noexcept
325 inline operator HCRYPTKEY() const noexcept
334 _Success_(
return != 0) bool ImportPrivate(_Inout_
wxCryptoSession &session, _In_reads_bytes_(size) const
void *data, _In_
size_t size);
340 _Success_(return != 0)
bool ImportPublic(_Inout_
wxCryptoSession &session, _In_reads_bytes_(size) const
void *data, _In_
size_t size);
Cryptographics Hash Base.
Definition crypto.h:86
HCRYPTHASH m_h
Hash Handle.
Definition crypto.h:88
bool IsOk() const noexcept
Has the hash creation been successful?
Definition crypto.h:110
SHA-1 Cryptographics Hash.
Definition crypto.h:238
Cryptographics Key Base.
Definition crypto.h:292
HCRYPTKEY m_h
Key Handle.
Definition crypto.h:294
bool IsOk() const noexcept
Has the key creation been successful?
Definition crypto.h:316
Cryptographics Session Base Class.
Definition crypto.h:29
bool IsOk() const noexcept
Has the session creation been successful?
Definition crypto.h:53
HCRYPTPROV m_h
Session Handle.
Definition crypto.h:31
RSA AES Cryptographics Session.
Definition crypto.h:73
#define WXEXTEND_API
Public function calling convention.
Definition common.h:56
bool WXEXTEND_API wxCryptoVerifySignature(const wxCryptoHash &hash, _In_reads_bytes_(signature_size) const void *signature_data, size_t signature_size, const wxCryptoKey &key)
Verifies if the hash matches signature and the public key.
#define wxVERIFY(cond)
Test if condition is true. When not true, raise debug assertion with the given message.
Definition common.h:84