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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
Index: luaxyssl-0.2+svn65/lxyssl.c
===================================================================
--- luaxyssl-0.2+svn65.orig/lxyssl.c 2008-07-01 17:28:52.000000000 +0200
+++ luaxyssl-0.2+svn65/lxyssl.c 2008-07-01 17:32:00.000000000 +0200
@@ -5,6 +5,7 @@
* This code can be distributed under the LGPL license
*/
+#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <fcntl.h>
@@ -12,6 +13,7 @@
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/time.h>
+#include <unistd.h>
#else
#include <time.h>
#include <winsock.h>
@@ -326,7 +328,7 @@
return 1;
}
if (lua_isstring(L, -1)) {
- int len;
+ size_t len;
const char *master = luaL_checklstring(L, -1, &len);
memcpy(ssl->session->master, master, len < sizeof(ssl->session->master) ? len : sizeof(ssl->session->master));
lua_pop(L, 1);
@@ -479,7 +481,7 @@
static int Laes(lua_State *L)
{
- int klen;
+ size_t klen;
const unsigned char *key = luaL_checklstring(L, 1, &klen);
int bits = luaL_optinteger(L, 2, 128);
dual_aes_context *aes = lua_newuserdata(L,sizeof(dual_aes_context));
@@ -503,7 +505,7 @@
static int Lrc4(lua_State *L)
{
- int klen;
+ size_t klen;
const unsigned char *key = luaL_checklstring(L, 1, &klen);
arc4_context *rc4 = lua_newuserdata(L,sizeof(arc4_context));
arc4_setup(rc4, (unsigned char *)key, klen);
@@ -750,7 +752,7 @@
static int Lhash(lua_State *L)
{
const char *type = luaL_checkstring(L,1);
- int klen=0;
+ size_t klen=0;
const unsigned char *key = luaL_optlstring(L, 2, NULL, &klen);
hash_context *obj = lua_newuserdata(L,sizeof(hash_context));
@@ -869,7 +871,7 @@
static int Laes_encrypt(lua_State *L)
{
dual_aes_context *obj=Pget_aes(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
int i;
luaL_Buffer B;
@@ -890,7 +892,7 @@
static int Laes_decrypt(lua_State *L)
{
dual_aes_context *obj=Pget_aes(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
int i;
luaL_Buffer B;
@@ -911,7 +913,7 @@
static int Lrc4_crypt(lua_State *L)
{
arc4_context *obj=Pget_rc4(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
luaL_Buffer B;
unsigned char temp[256];
@@ -938,9 +940,9 @@
static int Laes_cbc_encrypt(lua_State *L)
{
dual_aes_context *obj=Pget_aes(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
- int iv_len;
+ size_t iv_len;
const char *IV = luaL_checklstring(L, 3, &iv_len);
int i=0;
luaL_Buffer B;
@@ -970,9 +972,9 @@
static int Laes_cbc_decrypt(lua_State *L)
{
dual_aes_context *obj=Pget_aes(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
- int iv_len;
+ size_t iv_len;
const char *IV = luaL_checklstring(L, 3, &iv_len);
int i;
luaL_Buffer B;
@@ -1002,9 +1004,9 @@
static int Laes_cfb_encrypt(lua_State *L)
{
dual_aes_context *obj=Pget_aes(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
- int iv_len;
+ size_t iv_len;
const char *IV = luaL_checklstring(L, 3, &iv_len);
int start = luaL_optinteger(L,4,0);
int i;
@@ -1039,9 +1041,9 @@
static int Laes_cfb_decrypt(lua_State *L)
{
dual_aes_context *obj=Pget_aes(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
- int iv_len;
+ size_t iv_len;
const char *IV = luaL_checklstring(L, 3, &iv_len);
int start = luaL_optinteger(L,4,0);
int i;
@@ -1079,7 +1081,7 @@
static int Lhash_update(lua_State *L)
{
hash_context *obj=Pget_hash(L,1);
- int len;
+ size_t len;
const char *data = luaL_checklstring(L, 2, &len);
obj->update(&obj->eng, (unsigned char *)data, len);
lua_pushvalue(L, 1);
@@ -1091,7 +1093,7 @@
{
hash_context *obj=Pget_hash(L,1);
unsigned char out[64];
- int len;
+ size_t len;
const char *data = luaL_optlstring(L, 2, "", &len);
obj->update(&obj->eng, (unsigned char *)data, len);
obj->finish(&obj->eng, out);
@@ -1166,7 +1168,7 @@
static int LaddTrustedCA(lua_State *L)
{
int ret;
- int ca_len;
+ size_t ca_len;
const char *ca = luaL_checklstring(L, 1, &ca_len);
ret = x509_add_certs( &trustedCA, (unsigned char *) ca, ca_len);
@@ -1311,9 +1313,9 @@
static int Lsessinfo(lua_State *L) /** sessinfo(c) */
{
xyssl_context *xyssl=Pget(L,1);
- int id_len;
+ size_t id_len;
char *sessid = (char *)luaL_optlstring(L, 2, NULL, &id_len);
- int master_len;
+ size_t master_len;
char *master = (char *)luaL_optlstring(L, 3, NULL, &master_len);
int cipher = (int) luaL_optnumber(L,4,0);
time_t start = (time_t) luaL_optnumber(L,5,time(NULL));
@@ -1597,7 +1599,7 @@
static int LsessionCA(lua_State *L) /** setca(ca) **/
{
int top = lua_gettop(L);
- int ca_len;
+ size_t ca_len;
int ret;
xyssl_context *xyssl=Pget(L,1);
x509_cert *cacert = &xyssl->cacert;
@@ -1624,9 +1626,9 @@
ssl_context *ssl=&xyssl->ssl;
x509_cert *mycert= &xyssl->mycert;
rsa_context *rsa = &xyssl->mykey;
- int cert_len;
- int key_len;
- int pwd_len;
+ size_t cert_len;
+ size_t key_len;
+ size_t pwd_len;
int ret;
const char *cert = luaL_optlstring(L, 2, ssl->endpoint ? test_srv_crt: NULL, &cert_len);
const char *key = luaL_optlstring(L, 3, ssl->endpoint ? test_srv_key: NULL, &key_len);
@@ -1694,7 +1696,7 @@
ssl_context *ssl=&xyssl->ssl;
x509_cert *cacert = &xyssl->cacert;
int verification = luaL_optinteger(L,2,0);
- int peer_len;
+ size_t peer_len;
const char *expected_peer= luaL_optlstring(L, 3, NULL, &peer_len);
ssl_set_authmode( ssl, verification );
if (xyssl->peer_cn) free(xyssl->peer_cn);
@@ -1748,8 +1750,8 @@
static int Lx509verify(lua_State *L) /** x509verify(ca, crt) */
{
int top = lua_gettop(L);
- int crt_size;
- int ca_size;
+ size_t crt_size;
+ size_t ca_size;
int ret;
int flag;
x509_cert ca;
@@ -1797,9 +1799,9 @@
static int Lrsaverify(lua_State *L) /** rsaverify(data, sig, [crt]) */
{
int top = lua_gettop(L);
- int crt_size;
- int data_size;
- int sig_size;
+ size_t crt_size;
+ size_t data_size;
+ size_t sig_size;
int ret;
x509_cert cert;
const char *data = luaL_checklstring(L, 1, &data_size);
@@ -1833,8 +1835,8 @@
static int Lrsaencrypt(lua_State *L) /** rsaencrypt(data, [crt]) */
{
int top = lua_gettop(L);
- int crt_size;
- int data_size;
+ size_t crt_size;
+ size_t data_size;
unsigned char m[512];
int ret;
x509_cert cert;
@@ -1868,9 +1870,9 @@
static int Lrsasign(lua_State *L) /** rsasign(data, [key, [pw]]) */
{
int top = lua_gettop(L);
- int key_size;
- int data_size;
- int pwd_len;
+ size_t key_size;
+ size_t data_size;
+ size_t pwd_len;
int ret;
unsigned char sig[512];
rsa_context rsa;
@@ -1905,9 +1907,9 @@
static int Lrsadecrypt(lua_State *L) /** rsadecrypt(data, [key, [pw]]) */
{
int top = lua_gettop(L);
- int key_size;
- int data_size;
- int pwd_len;
+ size_t key_size;
+ size_t data_size;
+ size_t pwd_len;
int out_len;
int ret;
unsigned char m[512];
@@ -2076,8 +2078,8 @@
static int Ldhmsecret(lua_State *L) /** dhsecret(public, private, [P, [G]]) */
{
int top = lua_gettop(L);
- int public_size;
- int private_size;
+ size_t public_size;
+ size_t private_size;
int ret;
dhm_context dhm;
unsigned char buf[512];
|