Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
noloader committed Jun 25, 2023
1 parent acb48cc commit d6bc19d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
40 changes: 20 additions & 20 deletions misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ inline size_t PtrByteDiff(const PTR pointer1, const PTR pointer2)
}

/// \brief Pointer to the first element of a string
/// \param str std::string
/// \param str string
/// \details BytePtr returns NULL pointer for an empty string.
/// \return Pointer to the first element of a string
/// \since Crypto++ 8.0
Expand All @@ -456,7 +456,7 @@ inline byte* BytePtr(std::string& str)
byte* BytePtr(SecByteBlock& str);

/// \brief Const pointer to the first element of a string
/// \param str std::string
/// \param str string
/// \details ConstBytePtr returns non-NULL pointer for an empty string.
/// \return Pointer to the first element of a string
/// \since Crypto++ 8.0
Expand All @@ -475,7 +475,7 @@ inline const byte* ConstBytePtr(const std::string& str)
const byte* ConstBytePtr(const SecByteBlock& str);

/// \brief Size of a string
/// \param str std::string
/// \param str string
/// \return size of a string
/// \since Crypto++ 8.3
inline size_t BytePtrSize(const std::string& str)
Expand Down Expand Up @@ -506,14 +506,14 @@ constexpr int EnumToInt(T v) {

#if (!__STDC_WANT_SECURE_LIB__ && !defined(_MEMORY_S_DEFINED)) || defined(CRYPTOPP_WANT_SECURE_LIB)

/// \brief Bounds checking replacement for std::memcpy()
/// \brief Bounds checking replacement for memcpy()
/// \param dest pointer to the destination memory block
/// \param sizeInBytes size of the destination memory block, in bytes
/// \param src pointer to the source memory block
/// \param count the number of bytes to copy
/// \throw InvalidArgument
/// \details ISO/IEC TR-24772 provides bounds checking interfaces for potentially
/// unsafe functions like std::memcpy(), strcpy() and std::memmove(). However,
/// unsafe functions like memcpy(), strcpy() and memmove(). However,
/// not all standard libraries provides them, like Glibc. The library's
/// memcpy_s() is a near-drop in replacement. Its only a near-replacement
/// because the library's version throws an InvalidArgument on a bounds violation.
Expand Down Expand Up @@ -552,14 +552,14 @@ inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t cou
#endif
}

/// \brief Bounds checking replacement for std::memmove()
/// \brief Bounds checking replacement for memmove()
/// \param dest pointer to the destination memory block
/// \param sizeInBytes size of the destination memory block, in bytes
/// \param src pointer to the source memory block
/// \param count the number of bytes to copy
/// \throw InvalidArgument
/// \details ISO/IEC TR-24772 provides bounds checking interfaces for potentially
/// unsafe functions like std::memcpy(), strcpy() and std::memmove(). However,
/// unsafe functions like memcpy(), strcpy() and memmove(). However,
/// not all standard libraries provides them, like Glibc. The library's
/// memmove_s() is a near-drop in replacement. Its only a near-replacement
/// because the library's version throws an InvalidArgument on a bounds violation.
Expand Down Expand Up @@ -632,7 +632,7 @@ inline void vec_swap(T& a, T& b)
/// \param ptr pointer to the memory block being written
/// \param val the integer value to write for each byte
/// \param num the size of the source memory block, in bytes
/// \details Internally the function calls std::memset with the value <tt>val</tt>.
/// \details Internally the function calls memset with the value <tt>val</tt>.
/// memset_z can be used to initialize a freshly allocated memory block.
/// To zeroize a memory block on destruction use <tt>SecureWipeBuffer</tt>.
/// \return the pointer to the memory block
Expand Down Expand Up @@ -736,7 +736,7 @@ inline bool SafeConvert(T1 from, T2 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(sword64 from, word64 &to)
{
Expand All @@ -752,7 +752,7 @@ inline bool SafeConvert(sword64 from, word64 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(word32 from, word64 &to)
{
Expand All @@ -766,7 +766,7 @@ inline bool SafeConvert(word32 from, word64 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(sword32 from, word64 &to)
{
Expand All @@ -782,7 +782,7 @@ inline bool SafeConvert(sword32 from, word64 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(word64 from, sword64 &to)
{
Expand All @@ -798,7 +798,7 @@ inline bool SafeConvert(word64 from, sword64 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(word32 from, sword64 &to)
{
Expand All @@ -812,7 +812,7 @@ inline bool SafeConvert(word32 from, sword64 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(sword32 from, sword64 &to)
{
Expand All @@ -826,7 +826,7 @@ inline bool SafeConvert(sword32 from, sword64 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(word64 from, word32 &to)
{
Expand All @@ -842,7 +842,7 @@ inline bool SafeConvert(word64 from, word32 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(sword64 from, word32 &to)
{
Expand All @@ -860,7 +860,7 @@ inline bool SafeConvert(sword64 from, word32 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(sword32 from, word32 &to)
{
Expand All @@ -876,7 +876,7 @@ inline bool SafeConvert(sword32 from, word32 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(word64 from, sword32 &to)
{
Expand All @@ -892,7 +892,7 @@ inline bool SafeConvert(word64 from, sword32 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(sword64 from, sword32 &to)
{
Expand All @@ -910,7 +910,7 @@ inline bool SafeConvert(sword64 from, sword32 &to)
/// \return true if its safe to convert from \p from to \p to, false otherwise.
/// \details if the function returns true, then it is safe to use \p to. If the function
/// returns false, then \p to is undefined and should not be used.
/// \since Crypto++ 8.7
/// \since Crypto++ 8.8
template<>
inline bool SafeConvert(word32 from, sword32 &to)
{
Expand Down
6 changes: 3 additions & 3 deletions osrng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ OS_RNG_Err::OS_RNG_Err(const std::string &operation)
#if defined(USE_MS_CNGAPI)
inline DWORD NtStatusToErrorCode(NTSTATUS status)
{
if (status == (NTSTATUS)STATUS_INVALID_PARAMETER)
if (status == static_cast<NTSTATUS>(STATUS_INVALID_PARAMETER))
return ERROR_INVALID_PARAMETER;
else if (status == (NTSTATUS)STATUS_INVALID_HANDLE)
else if (status == static_cast<NTSTATUS>(STATUS_INVALID_HANDLE))
return ERROR_INVALID_HANDLE;
else
return (DWORD)status;
return static_cast<DWORD>(status);
}
#endif

Expand Down

0 comments on commit d6bc19d

Please sign in to comment.