1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box64context.h"
#include "emu/x64emu_private.h"
#include "myalign.h"
const char* libhogweed6Name = "libhogweed.so.6";
#define LIBNAME libhogweed6
#define ADDED_FUNCTIONS()
#include "generated/wrappedlibhogweed6types.h"
#include "wrappercallback.h"
#define SUPER() \
GO(0) \
GO(1) \
GO(2) \
GO(3) \
GO(4) \
GO(5) \
GO(6) \
GO(7) \
GO(8) \
GO(9) \
GO(10) \
// nettle_random_func
#define GO(A) \
static uintptr_t my_nettle_random_func_fct_##A = 0; \
static void my_nettle_random_func_##A(void* a, size_t b, void* c) \
{ \
RunFunctionFmt(my_nettle_random_func_fct_##A, "pLp", a, b, c); \
}
SUPER()
#undef GO
static void* findnettle_random_funcFct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_nettle_random_func_fct_##A == (uintptr_t)fct) return my_nettle_random_func_##A;
SUPER()
#undef GO
#define GO(A) if(my_nettle_random_func_fct_##A == 0) {my_nettle_random_func_fct_##A = (uintptr_t)fct; return my_nettle_random_func_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libhogweed.so.6 nettle_random_func callback\n");
return NULL;
}
// nettle_progress_func
#define GO(A) \
static uintptr_t my_nettle_progress_func_fct_##A = 0; \
static void my_nettle_progress_func_##A(void* a, int b) \
{ \
RunFunctionFmt(my_nettle_progress_func_fct_##A, "pi", a, b); \
}
SUPER()
#undef GO
static void* findnettle_progress_funcFct(void* fct)
{
if(!fct) return fct;
if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
#define GO(A) if(my_nettle_progress_func_fct_##A == (uintptr_t)fct) return my_nettle_progress_func_##A;
SUPER()
#undef GO
#define GO(A) if(my_nettle_progress_func_fct_##A == 0) {my_nettle_progress_func_fct_##A = (uintptr_t)fct; return my_nettle_progress_func_##A; }
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libhogweed.so.6 nettle_progress_func callback\n");
return NULL;
}
#undef SUPER
EXPORT int my_nettle_dsa_generate_params(x64emu_t* emu, void* params, void* rnd_ctx, void* rnd, void* progress_ctx, void* progress, uint32_t p_bits, uint32_t q_bits)
{
return my->nettle_dsa_generate_params(params, rnd_ctx, findnettle_random_funcFct(rnd), progress_ctx, findnettle_progress_funcFct(progress), p_bits, q_bits);
}
EXPORT int my_nettle_dsa_sign(x64emu_t* emu, void* params, void* x, void* rnd_ctx, void* rnd, size_t len, void* digest, void* sign)
{
return my->nettle_dsa_sign(params, x, rnd_ctx, findnettle_random_funcFct(rnd), len, digest, sign);
}
EXPORT void my_nettle_ecdsa_generate_keypair(x64emu_t* emu, void* pub, void* key, void* ctx, void* f)
{
my->nettle_ecdsa_generate_keypair(pub, key, ctx, findnettle_random_funcFct(f));
}
EXPORT void my_nettle_ecdsa_sign(x64emu_t* emu, void* key, void* ctx, void* f, size_t len, void* digest, void* sign)
{
my->nettle_ecdsa_sign(key, ctx, findnettle_random_funcFct(f), len, digest, sign);
}
EXPORT void my_nettle_gostdsa_sign(x64emu_t* emu, void* key, void* ctx, void* f, size_t len, void* digest, void* sign)
{
my->nettle_gostdsa_sign(key, ctx, findnettle_random_funcFct(f), len, digest, sign);
}
EXPORT void my_nettle_mpz_random(x64emu_t* emu, void* x, void* ctx, void* f, void* n)
{
my->nettle_mpz_random(x, ctx, findnettle_random_funcFct(f), n);
}
EXPORT void my_nettle_mpz_random_size(x64emu_t* emu, void* x, void* ctx, void* f, void* n)
{
my->nettle_mpz_random_size(x, ctx, findnettle_random_funcFct(f), n);
}
EXPORT int my_nettle_rsa_decrypt_tr(x64emu_t* emu, void* pub, void* key, void* ctx, void* f, void* len, void* msg, void* gib)
{
return my->nettle_rsa_decrypt_tr(pub, key, ctx, findnettle_random_funcFct(f), len, msg, gib);
}
EXPORT int my_nettle_rsa_encrypt(x64emu_t* emu, void* key, void* ctx, void* f, size_t len, void* txt, void* cipher)
{
return my->nettle_rsa_encrypt(key, ctx, findnettle_random_funcFct(f), len, txt, cipher);
}
EXPORT int my_nettle_rsa_generate_keypair(x64emu_t* emu, void* pub, void* key, void* ctx_rnd, void* rnd, void* ctx_progress, void* progress, uint32_t n_size, uint32_t e_size)
{
return my->nettle_rsa_generate_keypair(pub, key, ctx_rnd, findnettle_random_funcFct(rnd), ctx_progress, findnettle_progress_funcFct(progress), n_size, e_size);
}
EXPORT int my_nettle_rsa_pkcs1_sign_tr(x64emu_t* emu, void* pub, void* key, void* ctx, void* f, size_t len, void* info, void* s)
{
return my->nettle_rsa_pkcs1_sign_tr(pub, key, ctx, findnettle_random_funcFct(f), len, info, s);
}
#define NEEDED_LIBS "libnettle.so.8"
#include "wrappedlib_init.h"
|