Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/extra/sha1/config.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <endian.h>

#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 4321
#endif
Expand All @@ -7,5 +9,9 @@
#endif

#ifndef BYTE_ORDER
#if defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)
#define BYTE_ORDER BIG_ENDIAN
#else
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#endif
8 changes: 8 additions & 0 deletions test/graph/filter_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#include "gtest/gtest.h"

#include <endian.h>

extern "C" {
#include "sha1/sha1.h"
}
Expand Down Expand Up @@ -40,7 +42,13 @@ void hash_buffer(const AuditBuffer<T> &buf, unsigned p, unsigned width, unsigned

for (unsigned i = 0; i < height; ++i) {
const unsigned char *ptr = static_cast<const unsigned char *>(image_buffer[p][i]);
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
SHA1Update(&sha_ctx, ptr, width * sizeof(T));
#else
for (unsigned j = 0; j < width; j++)
for (int k = sizeof(T) - 1; k >= 0; k--)
SHA1Update(&sha_ctx, ptr + (j * sizeof(T)) + k, 1);
#endif
}

SHA1Final(digest, &sha_ctx);
Expand Down