summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2014-04-13 17:13:51 -0300
committerJohn Wiegley <johnw@newartisans.com>2014-04-17 14:27:21 -0500
commit0ef825640963d60e4733553ff0e8c590c0ce2c3b (patch)
treeacea3a68341bc8dda85533b4cf9678c8e58c39f8 /src
parentefffabadfa360eb083e1e403d1e240a6fb6f3efa (diff)
downloadfork-ledger-0ef825640963d60e4733553ff0e8c590c0ce2c3b.tar.gz
fork-ledger-0ef825640963d60e4733553ff0e8c590c0ce2c3b.tar.bz2
fork-ledger-0ef825640963d60e4733553ff0e8c590c0ce2c3b.zip
Replace sha1.cc with boost::uuid::details::sha1
sha1.cc is not redistributable by Debian because the license doesn't permit redistribution of modified versions. This isn't ideal since the ::details namespace is subject to change, but it avoids adding a dependency to ledger.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/filters.cc14
-rw-r--r--src/system.hh.in1
-rw-r--r--src/utils.h11
4 files changed, 16 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6304a50c..a77422db 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -254,7 +254,7 @@ include(GNUInstallDirs)
if(BUILD_LIBRARY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
- add_library(libledger SHARED ${LEDGER_SOURCES} ${PROJECT_SOURCE_DIR}/lib/sha1.cpp)
+ add_library(libledger SHARED ${LEDGER_SOURCES})
add_ledger_library_dependencies(libledger)
set_target_properties(libledger PROPERTIES
PREFIX ""
@@ -267,11 +267,9 @@ if(BUILD_LIBRARY)
install(TARGETS libledger DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${LEDGER_INCLUDES}
- ${PROJECT_SOURCE_DIR}/lib/sha1.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ledger)
else()
- add_executable(ledger
- ${LEDGER_SOURCES} ${PROJECT_SOURCE_DIR}/lib/sha1.cpp main.cc global.cc)
+ add_executable(ledger ${LEDGER_SOURCES} main.cc global.cc)
add_ledger_library_dependencies(ledger)
endif()
diff --git a/src/filters.cc b/src/filters.cc
index 4046ebda..bdc2983b 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -237,7 +237,7 @@ void anonymize_posts::render_commodity(amount_t& amt)
void anonymize_posts::operator()(post_t& post)
{
- SHA1 sha;
+ boost::uuids::detail::sha1 sha;
unsigned int message_digest[5];
bool copy_xact_details = false;
@@ -256,9 +256,9 @@ void anonymize_posts::operator()(post_t& post)
buf << reinterpret_cast<uintmax_t>(post.xact->payee.c_str())
<< integer_gen() << post.xact->payee.c_str();
- sha.Reset();
- sha << buf.str().c_str();
- sha.Result(message_digest);
+ sha.reset();
+ sha.process_bytes(buf.str().c_str(), buf.str().length());
+ sha.get_digest(message_digest);
xact.payee = to_hex(message_digest);
xact.note = none;
@@ -274,9 +274,9 @@ void anonymize_posts::operator()(post_t& post)
std::ostringstream buf;
buf << integer_gen() << acct << acct->fullname();
- sha.Reset();
- sha << buf.str().c_str();
- sha.Result(message_digest);
+ sha.reset();
+ sha.process_bytes(buf.str().c_str(), buf.str().length());
+ sha.get_digest(message_digest);
account_names.push_front(to_hex(message_digest));
}
diff --git a/src/system.hh.in b/src/system.hh.in
index fd5c47c6..952411f9 100644
--- a/src/system.hh.in
+++ b/src/system.hh.in
@@ -160,7 +160,6 @@ typedef std::ostream::pos_type ostream_pos_type;
#include <gmp.h>
#include <mpfr.h>
-#include "sha1.h"
#include "utf8.h"
#if HAVE_EDIT
diff --git a/src/utils.h b/src/utils.h
index 70b3bae9..95cc64fd 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -44,6 +44,8 @@
#ifndef _UTILS_H
#define _UTILS_H
+#include <boost/uuid/sha1.hpp>
+
/**
* @name Default values
*/
@@ -625,11 +627,12 @@ inline string to_hex(unsigned int * message_digest, const int len = 1)
inline string sha1sum(const string& str)
{
- SHA1 sha;
- sha.Reset();
- sha << str.c_str();
+ boost::uuids::detail::sha1 sha;
+
+ sha.process_bytes(str.c_str(), str.length());
+
unsigned int message_digest[5];
- sha.Result(message_digest);
+ sha.get_digest(message_digest);
return to_hex(message_digest, 5);
}