Skip to content

Commit

Permalink
move problematic hash functions to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
sskeirik committed May 30, 2020
1 parent 76fb3dd commit 986cce9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ INCLUDES := -I $(K_RELEASE)/include/kllvm -I $(PREFIX)/include -I dummy-version
CPPFLAGS += --std=c++14 $(INCLUDES)

.PHONY: build libcryptopp libff libsecp256k1
build: client-c/json.o client-c/main.o plugin-c/blake2.o plugin-c/blockchain.o plugin-c/crypto.o plugin-c/world.o
build: client-c/json.o client-c/main.o plugin-c/blake2.o plugin-c/blockchain.o plugin-c/crypto.o plugin-c/plugin_util.o plugin-c/world.o

plugin-c/blockchain.o: plugin/proto/msg.pb.h

Expand Down
17 changes: 0 additions & 17 deletions plugin-c/crypto.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#include <cstdint>
#include <cryptopp/blake2.h>
#include <cryptopp/keccak.h>
#include <cryptopp/ripemd.h>
#include <cryptopp/sha.h>
#include <cryptopp/sha3.h>
#include <secp256k1_recovery.h>
#include <gmp.h>
#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
#include <libff/common/profiling.hpp>
#include "blake2.h"
Expand All @@ -30,20 +27,6 @@ struct string *hook_KRYPTO_sha512(struct string *str) {
return hexEncode(digest, sizeof(digest));
}

struct string *hook_KRYPTO_blake2b256raw(struct string *str) {
BLAKE2b h(false,32);
unsigned char digest[32];
h.CalculateDigest(digest, (unsigned char *)str->data, len(str));
return raw(digest, sizeof(digest));
}

struct string *hook_KRYPTO_blake2b256(struct string *str) {
BLAKE2b h(false,32);
unsigned char digest[32];
h.CalculateDigest(digest, (unsigned char *)str->data, len(str));
return hexEncode(digest, sizeof(digest));
}

struct string *hook_KRYPTO_sha3raw(struct string *str) {
SHA3_256 h;
unsigned char digest[32];
Expand Down
22 changes: 22 additions & 0 deletions plugin-c/hash_ext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <cryptopp/blake2.h>
#include "plugin_util.h"

using namespace CryptoPP;

extern "C" {

struct string *hook_KRYPTO_blake2b256raw(struct string *str) {
BLAKE2b h(false,32);
unsigned char digest[32];
h.CalculateDigest(digest, (unsigned char *)str->data, len(str));
return raw(digest, sizeof(digest));
}

struct string *hook_KRYPTO_blake2b256(struct string *str) {
BLAKE2b h(false,32);
unsigned char digest[32];
h.CalculateDigest(digest, (unsigned char *)str->data, len(str));
return hexEncode(digest, sizeof(digest));
}

}

0 comments on commit 986cce9

Please sign in to comment.