Browse Source

md5.hpp: remove md5_uint32 alias

master
Niklas Rosenstein 3 years ago
parent
commit
b565d326f7
Signed by: NiklasRosenstein GPG Key ID: 06D269B33D25F6C6
2 changed files with 12 additions and 14 deletions
  1. + 3
    - 5
      include/NiklasRosenstein/md5.hpp
  2. + 9
    - 9
      include/NiklasRosenstein/md5_impl.cpp

+ 3
- 5
include/NiklasRosenstein/md5.hpp

@ -33,14 +33,12 @@
namespace niklasrosenstein {
typedef uint32_t md5_uint32;
struct md5 {
public: /* Data members */
md5_uint32 lo, hi;
md5_uint32 a, b, c, d;
uint32_t lo, hi;
uint32_t a, b, c, d;
unsigned char buffer[64];
md5_uint32 block[16];
uint32_t block[16];
public: /* Methods */
md5();

+ 9
- 9
include/NiklasRosenstein/md5_impl.cpp

@ -73,23 +73,23 @@ using niklasrosenstein::md5;
*
* Unfortunately, this optimization may be a C strict aliasing rules violation
* if the caller's data buffer has effective type that cannot be aliased by
* md5_uint32. In practice, this problem may occur if these MD5 routines are
* uint32_t. In practice, this problem may occur if these MD5 routines are
* inlined into a calling function, or with future and dangerously advanced
* link-time optimizations. For the time being, keeping these MD5 routines in
* their own translation unit avoids the problem.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
(*(md5_uint32 *)&ptr[(n) * 4])
(*(uint32_t *)&ptr[(n) * 4])
#define GET(n) \
SET(n)
#else
#define SET(n) \
(this->block[(n)] = \
(md5_uint32)ptr[(n) * 4] | \
((md5_uint32)ptr[(n) * 4 + 1] << 8) | \
((md5_uint32)ptr[(n) * 4 + 2] << 16) | \
((md5_uint32)ptr[(n) * 4 + 3] << 24))
(uint32_t)ptr[(n) * 4] | \
((uint32_t)ptr[(n) * 4 + 1] << 8) | \
((uint32_t)ptr[(n) * 4 + 2] << 16) | \
((uint32_t)ptr[(n) * 4 + 3] << 24))
#define GET(n) \
(this->block[(n)])
#endif
@ -101,8 +101,8 @@ using niklasrosenstein::md5;
void const* md5::body(const void *data, size_t size)
{
unsigned char const* ptr;
md5_uint32 a, b, c, d;
md5_uint32 saved_a, saved_b, saved_c, saved_d;
uint32_t a, b, c, d;
uint32_t saved_a, saved_b, saved_c, saved_d;
ptr = reinterpret_cast<unsigned char const*>(data);
@ -218,7 +218,7 @@ md5::md5()
void md5::update(const void *data, size_t size)
{
md5_uint32 saved_lo;
uint32_t saved_lo;
unsigned long used, available;
saved_lo = this->lo;

Loading…
Cancel
Save