Skip to content

Commit

Permalink
Fixes for stupid long int size of 32bit in windows and other small fi…
Browse files Browse the repository at this point in the history
…xes.
  • Loading branch information
bogdanadnan committed Aug 15, 2018
1 parent 5cbffc8 commit 94896d9
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 195 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
/win32/argon2_fill_blocks/x64
/win32/ariominer/.vs/ariominer/v15
/win32/ariominer/ariominer.vcxproj.user
/win32/argon2_fill_blocks/argon2_fill_blocks.vcxproj.user
/win32/ariominer/x64
2 changes: 1 addition & 1 deletion common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <unistd.h>
#include <sys/time.h>
#else
#include <win32_compatibility_layer.h>
#include <win64_compatibility_layer.h>
#endif

#include <config.h>
Expand Down
7 changes: 4 additions & 3 deletions hash/argon2/argon2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ argon2::argon2(argon2_blocks_filler_ptr filler, void *seed_memory, void *user_da
__seed_memory_offset = argon2profile_default->memsize;
__lane_length = -1;
__user_data = user_data;
srand(microseconds());
}

vector<string> argon2::generate_hashes(const argon2profile &profile, const string &base, const string &salt_) {
Expand Down Expand Up @@ -102,13 +103,13 @@ void argon2::__initial_hash(const argon2profile &profile, uint8_t *blockhash, co
value = ARGON2_TYPE_VALUE;
blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));

value = base.length();
value = (uint32_t)base.length();
blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));

blake2b_update(&BlakeHash, (const uint8_t *)base.c_str(),
base.length());

value = salt.length();
value = (uint32_t)salt.length();
blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value));

blake2b_update(&BlakeHash, (const uint8_t *)salt.c_str(),
Expand Down Expand Up @@ -150,7 +151,7 @@ string argon2::__encode_string(const argon2profile &profile, const string &salt,
char salt_b64[50];
char hash_b64[50];

mg_base64_encode((unsigned char *)salt.c_str(), salt.length(), salt_b64);
mg_base64_encode((unsigned char *)salt.c_str(), (int)salt.length(), salt_b64);
mg_base64_encode(hash, ARGON2_RAW_LENGTH, hash_b64);

salt_b64[22] = 0;
Expand Down
2 changes: 1 addition & 1 deletion hash/cpu/cpu_hasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void cpu_hasher::__run() {

if(!input.base.empty()) {
hash_factory.set_seed_memory_offset(profile->memsize);
hash_factory.set_threads(argon2profile_default->memsize / profile->memsize);
hash_factory.set_threads((int)(argon2profile_default->memsize / profile->memsize));

vector<string> hashes = hash_factory.generate_hashes(*profile, input.base, input.salt);
for(vector<string>::iterator it = hashes.begin(); it != hashes.end(); ++it) {
Expand Down
18 changes: 9 additions & 9 deletions hash/gpu/gpu_hasher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ bool gpu_hasher::configure(arguments &args) {
return false;
}

_intensity = (intensity_cpu + intensity_gpu) / 2.0;
_intensity = (int)((intensity_cpu + intensity_gpu) / 2.0);

__running = true;
for(vector<gpu_device_info>::iterator d = __devices.begin(); d != __devices.end(); d++) {
Expand Down Expand Up @@ -520,8 +520,8 @@ void kernel_filler(void *memory, int threads, argon2profile *profile, void *user

clSetKernelArg(device->kernel, 9, sizeof(device->arguments.seed_memory), &device->arguments.seed_memory);

size_t total_work_items = threads * 32;
size_t local_work_items = 32;
size_t total_work_items = threads * KERNEL_WORKGROUP_SIZE;
size_t local_work_items = KERNEL_WORKGROUP_SIZE;

uint32_t threads_per_chunk;
uint32_t memsize;
Expand All @@ -531,16 +531,16 @@ void kernel_filler(void *memory, int threads, argon2profile *profile, void *user

if(strcmp(profile->profile_name, "1_1_524288") == 0) {
threads_per_chunk = device->profile_info.threads_per_chunk_profile_1_1_524288;
memsize = argon2profile_1_1_524288.memsize;
addrsize = argon2profile_1_1_524288.block_refs_size;
xor_limit = argon2profile_1_1_524288.xor_limit;
memsize = (uint32_t)argon2profile_1_1_524288.memsize;
addrsize = (uint32_t)argon2profile_1_1_524288.block_refs_size;
xor_limit = (uint32_t)argon2profile_1_1_524288.xor_limit;
profile_id = 0;
}
else {
threads_per_chunk = device->profile_info.threads_per_chunk_profile_4_4_16384;
memsize = argon2profile_4_4_16384.memsize;
addrsize = argon2profile_4_4_16384.block_refs_size;
xor_limit = argon2profile_4_4_16384.xor_limit;
memsize = (uint32_t)argon2profile_4_4_16384.memsize;
addrsize = (uint32_t)argon2profile_4_4_16384.block_refs_size;
xor_limit = (uint32_t)argon2profile_4_4_16384.xor_limit;
profile_id = 1;
}

Expand Down
19 changes: 10 additions & 9 deletions http/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct http_result_response {
};

static void mg_ev_handler(struct mg_connection *c, int ev, void *p) {
if (ev == MG_EV_HTTP_REPLY) {
if (ev == MG_EV_HTTP_REPLY) {
http_message *hm = (http_message *)p;
c->flags |= MG_F_CLOSE_IMMEDIATELY;
strncpy(((http_result_response*)(c->user_data))->reply, hm->body.p, hm->body.len);
Expand Down Expand Up @@ -51,15 +51,15 @@ string http::__http_post(const string &url, const string &post_data) {
post_data.empty() ? NULL : "Content-Type: application/x-www-form-urlencoded\r\n",
post_data.empty() ? NULL : post_data.c_str());

char *result = (char *)malloc(1000);
http_result_response http_rsp;
http_rsp.reply = result;
http_rsp.reply_received = false;
conn->user_data = (void *)&http_rsp;
char *result = new char[1000];
http_result_response *http_rsp = new http_result_response();
http_rsp->reply = result;
http_rsp->reply_received = false;
conn->user_data = (void *)http_rsp;

time_t initial_timestamp = time(NULL);
while(!(http_rsp.reply_received)) {
if(time(NULL) - initial_timestamp > 10) { //10 sec timeout
while(!(http_rsp->reply_received)) {
if(time(NULL) - initial_timestamp > 30) { //30 sec timeout
return string("");
}
if(!__poll_running) {
Expand All @@ -72,7 +72,8 @@ string http::__http_post(const string &url, const string &post_data) {

string t = result;
if(time(NULL) - initial_timestamp <= 10) {
free(result);
delete[] result;
delete http_rsp;
}
return t;
}
Expand Down
Loading

0 comments on commit 94896d9

Please sign in to comment.