Crypto++
8.4
Free C++ class library of cryptographic schemes
|
6 #if CRYPTOPP_MSC_VERSION
7 # pragma warning(disable: 4189)
8 # if (CRYPTOPP_MSC_VERSION >= 1400)
9 # pragma warning(disable: 6237)
13 #ifndef CRYPTOPP_IMPORTS
31 return reinterpret_cast<byte*
>(str.
data());
38 return reinterpret_cast<const byte*
>(str.
data());
46 void xorbuf(
byte *buf,
const byte *mask,
size_t count)
53 if (IsAligned<word32>(buf) && IsAligned<word32>(mask))
57 for (i=0; i<count/8; i++)
66 for (i=0; i<count/4; i++)
75 for (i=0; i<count; i++)
79 void xorbuf(
byte *output,
const byte *input,
const byte *mask,
size_t count)
86 if (IsAligned<word32>(output) && IsAligned<word32>(input) && IsAligned<word32>(mask))
90 for (i=0; i<count/8; i++)
100 for (i=0; i<count/4; i++)
110 for (i=0; i<count; i++)
111 output[i] = input[i] ^ mask[i];
123 if (IsAligned<word32>(buf) && IsAligned<word32>(mask) && count)
129 for (i=0; i<count/8; i++)
130 acc64 |= ((
word64*)(
void*)buf)[i] ^ ((
word64*)(
void*)mask)[i];
139 for (i=0; i<count/4; i++)
140 acc32 |= ((
word32*)(
void*)buf)[i] ^ ((
word32*)(
void*)mask)[i];
149 for (i=0; i<count; i++)
150 acc8 |= buf[i] ^ mask[i];
154 std::string
StringNarrow(
const wchar_t *str,
bool throwOnError)
160 #if (CRYPTOPP_MSC_VERSION >= 1400)
161 size_t len=0, size=0;
168 err = wcstombs_s(&size, NULLPTR, 0, str, len*
sizeof(
wchar_t));
175 return std::string();
179 err = wcstombs_s(&size, &result[0], size, str, len*
sizeof(
wchar_t));
186 return std::string();
190 if (!result.empty() && result[size - 1] ==
'\0')
191 result.erase(size - 1);
193 size_t size = wcstombs(NULLPTR, str, 0);
195 if (size == (
size_t)-1)
200 return std::string();
204 size = wcstombs(&result[0], str, size);
206 if (size == (
size_t)-1)
211 return std::string();
218 std::wstring
StringWiden(
const char *str,
bool throwOnError)
224 #if (CRYPTOPP_MSC_VERSION >= 1400)
225 size_t len=0, size=0;
230 len = std::strlen(str)+1;
232 err = mbstowcs_s(&size, NULLPTR, 0, str, len);
239 return std::wstring();
243 err = mbstowcs_s(&size, &result[0], size, str, len);
250 return std::wstring();
254 if (!result.empty() && result[size - 1] ==
'\0')
255 result.erase(size - 1);
257 size_t size = mbstowcs(NULLPTR, str, 0);
259 if (size == (
size_t)-1)
264 return std::wstring();
268 size = mbstowcs(&result[0], str, size);
270 if (size == (
size_t)-1)
275 return std::wstring();
size_t BytePtrSize(const std::string &str)
Size of a string.
std::wstring StringWiden(const char *str, bool throwOnError=true)
Converts a multibyte C-string to a wide character string.
Debugging and diagnostic assertions.
const byte * ConstBytePtr(const std::string &str)
Const pointer to the first element of a string.
unsigned char byte
8-bit unsigned datatype
bool empty() const
Determines if the SecBlock is empty.
Classes and functions for secure memory allocations.
CRYPTOPP_DLL bool VerifyBufsEqual(const byte *buf1, const byte *buf2, size_t count)
Performs a near constant-time comparison of two equally sized buffers.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
unsigned long long word64
64-bit unsigned datatype
unsigned int word32
32-bit unsigned datatype
Support functions for word operations.
Utility functions for the Crypto++ library.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
size_type size() const
Provides the count of elements in the SecBlock.
#define CRYPTOPP_BOOL_SLOW_WORD64
Declare ops on word64 are slow.
An invalid argument was detected.
std::string StringNarrow(const wchar_t *str, bool throwOnError=true)
Converts a wide character C-string to a multibyte string.
Crypto++ library namespace.
Library configuration file.
CRYPTOPP_DLL void xorbuf(byte *buf, const byte *mask, size_t count)
Performs an XOR of a buffer with a mask.
A::pointer data()
Provides a pointer to the first element in the memory block.
byte * BytePtr(std::string &str)
Pointer to the first element of a string.
Multiple precision integer with arithmetic operations.