Skip to content

Commit

Permalink
Fix AES functions export
Browse files Browse the repository at this point in the history
  • Loading branch information
shizzard committed Dec 12, 2024
1 parent 2cc6291 commit 50e38b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Copyright (c) 2019, The Monero Project
#
#
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
Expand All @@ -34,6 +34,7 @@ set(CMAKE_VERBOSE_MAKEFILE ON)

set(randomx_sources
src/aes_hash.cpp
src/aes_hash_bindgen.cpp
src/argon2_ref.c
src/argon2_ssse3.c
src/argon2_avx2.c
Expand Down
3 changes: 3 additions & 0 deletions src/aes_hash_bindgen.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "aes_hash.hpp"
#include "aes_hash_bindgen.h"

extern "C" {

void hashAes1Rx4_soft(const void *input, size_t inputSize, void *hash) {
hashAes1Rx4<true>(input, inputSize, hash);
}
Expand Down Expand Up @@ -32,4 +34,5 @@ extern "C" {
void hashAndFillAes1Rx4_hard(void *scratchpad, size_t scratchpadSize, void *hash, void* fill_state) {
hashAndFillAes1Rx4<false>(scratchpad, scratchpadSize, hash, fill_state);
}

}
6 changes: 3 additions & 3 deletions src/aes_hash_bindgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define AES_HASH_BINDGEN_H
#endif

#include <stddef.h>
#include "stddef.h"

#ifdef __cplusplus
#if defined(__cplusplus)
extern "C" {
#endif

Expand All @@ -20,6 +20,6 @@ void fillAes4Rx4_hard(void *state, size_t outputSize, void *buffer);
void hashAndFillAes1Rx4_soft(void *scratchpad, size_t scratchpadSize, void *hash, void* fill_state);
void hashAndFillAes1Rx4_hard(void *scratchpad, size_t scratchpadSize, void *hash, void* fill_state);

#ifdef __cplusplus
#if defined(__cplusplus)
}
#endif
8 changes: 6 additions & 2 deletions src/randomx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vm_compiled.hpp"
#include "vm_compiled_light.hpp"
#include "blake2/blake2.h"
#include "aes_hash_bindgen.h"
#include "cpu.hpp"
#include <cassert>
#include <limits>
Expand Down Expand Up @@ -442,12 +443,15 @@ extern "C" {
fegetenv(&fpstate);
#endif

alignas(16) uint64_t tempHash[8];
memcpy(tempHash, inHash, sizeof(tempHash));
int blakeResult;
for (int chain = 0; chain < randomxProgramCount; ++chain) {
machine->run(inHash);
blakeResult = randomx_blake2b(inHash, sizeof(inHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0);
machine->run(tempHash);
blakeResult = randomx_blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0);
assert(blakeResult == 0);
}
memcpy(inHash, tempHash, sizeof(tempHash));

#ifdef USE_CSR_INTRINSICS
_mm_setcsr(fpstate);
Expand Down

0 comments on commit 50e38b8

Please sign in to comment.