From 195033316eeea141be27aded5f45deeefc16df87 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sun, 17 Aug 2014 11:35:52 +0000 Subject: [PATCH] Rename symbols for libbase58 --- base58.c | 19 ++++++++++++------- base58.h | 8 +++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/base58.c b/base58.c index ab26440..c042573 100644 --- a/base58.c +++ b/base58.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Luke Dashjr + * Copyright 2012-2014 Luke Dashjr * * This program is free software; you can redistribute it and/or modify it * under the terms of the standard MIT license. See COPYING for more details. @@ -12,10 +12,11 @@ #endif #include +#include #include #include -bool (*blkmk_sha256_impl)(void *, const void *, size_t) = NULL; +bool (*b58_sha256_impl)(void *, const void *, size_t) = NULL; static const int8_t b58digits[] = { -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, @@ -28,7 +29,8 @@ static const int8_t b58digits[] = { 47,48,49,50,51,52,53,54, 55,56,57,-1,-1,-1,-1,-1, }; -bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz) { +bool b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz) +{ const unsigned char *b58u = (void*)b58; unsigned char *binu = bin; size_t outisz = (binsz + 3) / 4; @@ -89,15 +91,18 @@ bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz) { } static -bool _blkmk_dblsha256(void *hash, const void *data, size_t datasz) { - return blkmk_sha256_impl(hash, data, datasz) && blkmk_sha256_impl(hash, hash, 32); +bool my_dblsha256(void *hash, const void *data, size_t datasz) +{ + uint8_t buf[0x20]; + return b58_sha256_impl(buf, data, datasz) && b58_sha256_impl(hash, buf, sizeof(buf)); } -int _blkmk_b58check(void *bin, size_t binsz, const char *base58str) { +int b58check(void *bin, size_t binsz, const char *base58str, size_t b58sz) +{ unsigned char buf[32]; unsigned char *binc = bin; unsigned i; - if (!_blkmk_dblsha256(buf, bin, binsz - 4)) + if (!my_dblsha256(buf, bin, binsz - 4)) return -2; if (memcmp(&binc[binsz - 4], buf, 4)) return -1; diff --git a/base58.h b/base58.h index 7e853fe..8ae312f 100644 --- a/base58.h +++ b/base58.h @@ -2,9 +2,11 @@ #define LIBBASE58_H #include -#include +#include -extern bool _blkmk_b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz); -extern int _blkmk_b58check(void *bin, size_t binsz, const char *b58); +extern bool (*b58_sha256_impl)(void *, const void *, size_t); + +extern bool b58tobin(void *bin, size_t binsz, const char *b58, size_t b58sz); +extern int b58check(void *bin, size_t binsz, const char *b58, size_t b58sz); #endif