From 128035d5e86db8d640d2d81bf3b8bfe916b9d674 Mon Sep 17 00:00:00 2001 From: div72 Date: Mon, 15 Jul 2024 16:46:57 +0300 Subject: [PATCH] refactor: replace be32enc with WriteBE32 be32enc is a function on BSDs which can lead to conflicts. Use the WriteBE32 function that's used in crypto code instead. --- src/pbkdf2.cpp | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/pbkdf2.cpp b/src/pbkdf2.cpp index bcd75f3f86..9a20e0aa6d 100644 --- a/src/pbkdf2.cpp +++ b/src/pbkdf2.cpp @@ -1,33 +1,10 @@ // Copyright (c) 2013 NovaCoin Developers -#include -#include "pbkdf2.h" - -// Only commented out since it will be used in Big endian support -// in the future. -/* -static inline uint32_t -be32dec(const void *pp) -{ - const uint8_t *p = (uint8_t const *)pp; - - return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) + - ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24)); -} -*/ +#include +#include -#ifndef __FreeBSD__ -static inline void -be32enc(void *pp, uint32_t x) -{ - uint8_t * p = (uint8_t *)pp; +#include - p[3] = x & 0xff; - p[2] = (x >> 8) & 0xff; - p[1] = (x >> 16) & 0xff; - p[0] = (x >> 24) & 0xff; -} -#endif /** * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): @@ -54,7 +31,7 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt, /* Iterate through the blocks. */ for (i = 0; i * 32 < dkLen; i++) { /* Generate INT(i + 1). */ - be32enc(ivec, (uint32_t)(i + 1)); + WriteBE32(ivec, (uint32_t)(i + 1)); /* Compute U_1 = PRF(P, S || INT(i)). */ CHMAC_SHA256 U_1 = salted;