summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-04-13 06:48:15 +1000
committer Vas Crabb <vas@vastheman.com>2020-04-13 06:48:15 +1000
commit2add7c158c409b19853608fd6736346f876984a2 (patch)
treea4dba5969b8b458de37080b3ac4e6e67f49b6eb9 /src/tools
parentc2ca7ea90cf1a6a58da45bf19f711bcf9d8720ca (diff)
split was using sha1.h directly - fix that (nw)
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/chdman.cpp13
-rw-r--r--src/tools/split.cpp27
2 files changed, 18 insertions, 22 deletions
diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp
index 44e73083ff4..914ab850054 100644
--- a/src/tools/chdman.cpp
+++ b/src/tools/chdman.cpp
@@ -6,7 +6,6 @@
****************************************************************************/
#include <stdio.h> // must be stdio.h and here otherwise issues with I64FMT in MINGW
-#include <cassert>
#include "osdcore.h"
#include "corefile.h"
@@ -15,17 +14,17 @@
#include "avhuff.h"
#include "bitmap.h"
#include "md5.h"
-#include "sha1.h"
+#include "hashing.h"
#include "vbiparse.h"
+
+#include <cassert>
+#include <cctype>
#include <cstdarg>
-#include <cstdlib>
#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <ctime>
-#include <cctype>
-
#include <iostream>
-#include <cassert>
-#include <cstring>
#include <limits>
#include <memory>
#include <new>
diff --git a/src/tools/split.cpp b/src/tools/split.cpp
index ba455c04b51..1748edf7625 100644
--- a/src/tools/split.cpp
+++ b/src/tools/split.cpp
@@ -8,17 +8,19 @@
****************************************************************************/
+#include "corefile.h"
+#include "corestr.h"
+#include "hashing.h"
+
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
-#include "corefile.h"
-#include "corestr.h"
-#include "sha1.h"
#define DEFAULT_SPLIT_SIZE 100
#define MAX_PARTS 1000
+#define SHA1_DIGEST_SIZE 20
@@ -34,22 +36,17 @@
static void compute_hash_as_string(std::string &buffer, void *data, uint32_t length)
{
- char expanded[SHA1_DIGEST_SIZE * 2];
- uint8_t sha1digest[SHA1_DIGEST_SIZE];
- struct sha1_ctx sha1;
- int ch;
-
// compute the SHA1
- sha1_init(&sha1);
- sha1_update(&sha1, length, (const uint8_t *)data);
- sha1_final(&sha1);
- sha1_digest(&sha1, sizeof(sha1digest), sha1digest);
+ util::sha1_creator sha1;
+ sha1.append(data, length);
+ const util::sha1_t sha1digest = sha1.finish();
// expand the digest to a string
- for (ch = 0; ch < SHA1_DIGEST_SIZE; ch++)
+ char expanded[sizeof(sha1digest.m_raw) * 2];
+ for (int ch = 0; ch < sizeof(sha1digest.m_raw); ch++)
{
- expanded[ch * 2 + 0] = "0123456789ABCDEF"[sha1digest[ch] >> 4];
- expanded[ch * 2 + 1] = "0123456789ABCDEF"[sha1digest[ch] & 15];
+ expanded[ch * 2 + 0] = "0123456789ABCDEF"[sha1digest.m_raw[ch] >> 4];
+ expanded[ch * 2 + 1] = "0123456789ABCDEF"[sha1digest.m_raw[ch] & 15];
}
// copy it to the buffer