void-packages/srcpkgs/vanitygen/patches/5f163e6fff7da52c4aecbd898d9...

99 lines
3.4 KiB
Diff

From 5f163e6fff7da52c4aecbd898d9df2e60a56f134 Mon Sep 17 00:00:00 2001
From: DesWurstes <DesWurstes@users.noreply.github.com>
Date: Sun, 3 Jun 2018 17:46:16 +0300
Subject: [PATCH] Privkey prefix OpenSSL 1.1 compatibility (#116)
Fixes #114
---
oclengine.c | 18 +++++++++++++-----
vanitygen.c | 12 ++++++++++--
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/oclengine.c b/oclengine.c
index 6585fc6..c69bd4b 100644
--- a/oclengine.c
+++ b/oclengine.c
@@ -5,7 +5,7 @@
* Vanitygen is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
- * any later version.
+ * any later version.
*
* Vanitygen is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -1058,7 +1058,7 @@ vg_ocl_kernel_arg_alloc(vg_ocl_context_t *vocp, int slot,
karg,
sizeof(clbuf),
&clbuf);
-
+
if (ret) {
fprintf(stderr,
"clSetKernelArg(%d,%d): ", knum, karg);
@@ -1090,7 +1090,7 @@ vg_ocl_copyout_arg(vg_ocl_context_t *vocp, int wslot, int arg,
buffer,
0, NULL,
NULL);
-
+
if (ret) {
fprintf(stderr, "clEnqueueWriteBuffer(%d): ", arg);
vg_ocl_error(vocp, ret, NULL);
@@ -2079,7 +2079,15 @@ vg_opencl_loop(vg_exec_context_t *arg)
npoints = 0;
if (vcp->vc_privkey_prefix_length > 0) {
BIGNUM *pkbn = BN_dup(EC_KEY_get0_private_key(pkey));
- memcpy((char *)pkbn->d + 32 - vcp->vc_privkey_prefix_length, vcp->vc_privkey_prefix, vcp->vc_privkey_prefix_length);
+ unsigned char pkey_arr[32];
+ assert(BN_bn2bin(pkbn, pkey_arr) < 33);
+ memcpy((char *) pkey_arr, vcp->vc_privkey_prefix, vcp->vc_privkey_prefix_length);
+ for (int i = 0; i < vcp->vc_privkey_prefix_length / 2; i++) {
+ int k = pkey_arr[i];
+ pkey_arr[i] = pkey_arr[vcp->vc_privkey_prefix_length - 1 - i];
+ pkey_arr[vcp->vc_privkey_prefix_length - 1 - i] = k;
+ }
+ BN_bin2bn(pkey_arr, 32, pkbn);
EC_KEY_set_private_key(pkey, pkbn);
EC_POINT *origin = EC_POINT_new(pgroup);
@@ -2240,7 +2248,7 @@ vg_opencl_loop(vg_exec_context_t *arg)
slot_busy = 1;
slot = (slot + 1) % nslots;
- } else {
+ } else {
if (slot_busy) {
pthread_mutex_lock(&vocp->voc_lock);
while (vocp->voc_ocl_slot != -1) {
diff --git a/vanitygen.c b/vanitygen.c
index 992e5d7..5e49df7 100644
--- a/vanitygen.c
+++ b/vanitygen.c
@@ -129,7 +129,15 @@ vg_thread_loop(void *arg)
EC_KEY_generate_key(pkey);
if (vcp->vc_privkey_prefix_length > 0) {
BIGNUM *pkbn = BN_dup(EC_KEY_get0_private_key(pkey));
- memcpy((char *)pkbn->d + 32 - vcp->vc_privkey_prefix_length, vcp->vc_privkey_prefix, vcp->vc_privkey_prefix_length);
+ unsigned char pkey_arr[32];
+ assert(BN_bn2bin(pkbn, pkey_arr) < 33);
+ memcpy((char *) pkey_arr, vcp->vc_privkey_prefix, vcp->vc_privkey_prefix_length);
+ for (int i = 0; i < vcp->vc_privkey_prefix_length / 2; i++) {
+ int k = pkey_arr[i];
+ pkey_arr[i] = pkey_arr[vcp->vc_privkey_prefix_length - 1 - i];
+ pkey_arr[vcp->vc_privkey_prefix_length - 1 - i] = k;
+ }
+ BN_bin2bn(pkey_arr, 32, pkbn);
EC_KEY_set_private_key(pkey, pkbn);
EC_POINT *origin = EC_POINT_new(pgroup);
@@ -1395,7 +1403,7 @@ main(int argc, char **argv)
addrtype = 60;
privtype = 128;
break;
- }
+ }
break;
/*END ALTCOIN GENERATOR*/