Skip to content

Commit d40e724

Browse files
committed
main/lua-ossl: align with latest patch set
available at wahern/luaossl#128 Earlier, an empty password was returned when the callback raised a Lua error. Now the error is propagated to the OpenSSL level. This commit also enables the -dbg subpackage.
1 parent 1503d16 commit d40e724

11 files changed

Lines changed: 119 additions & 154 deletions

main/lua-ossl/0001-pkey.toPEM-opts-rename-const-array.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 4589f5b1a5c2cbeab2069f9cdce605bc3a3096fb Mon Sep 17 00:00:00 2001
1+
From db281ae9a12ce7518a92002c782ef697fc875f9c Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Sun, 2 Sep 2018 13:07:20 +0300
4-
Subject: [PATCH 01/10] pkey.toPEM: opts: rename const array
4+
Subject: [PATCH 1/9] pkey.toPEM: opts: rename const array
55

66
---
77
src/openssl.c | 4 ++--
88
1 file changed, 2 insertions(+), 2 deletions(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index 9a9de0f..acb8289 100644
11+
index c3547bb..35ff49a 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
1414
@@ -4675,14 +4675,14 @@ static int pk_toPEM(lua_State *L) {
@@ -29,5 +29,5 @@ index 9a9de0f..acb8289 100644
2929
if (!PEM_write_bio_PUBKEY(bio, key))
3030
return auxL_error(L, auxL_EOPENSSL, "pkey:__tostring");
3131
--
32-
2.24.1
32+
2.48.1
3333

main/lua-ossl/0002-pkey.toPEM-accept-table-arguments.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 2fb6331a5304927fcfe915d5d42535d3d500f540 Mon Sep 17 00:00:00 2001
1+
From 24ff6dab4a15529b1c71e3c70119cde65976dfcf Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Sun, 2 Sep 2018 13:18:48 +0300
4-
Subject: [PATCH 02/10] pkey.toPEM: accept table arguments
4+
Subject: [PATCH 2/9] pkey.toPEM: accept table arguments
55

66
---
77
src/openssl.c | 11 ++++++++++-
88
1 file changed, 10 insertions(+), 1 deletion(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index acb8289..1905693 100644
11+
index 35ff49a..6df0a17 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
1414
@@ -4681,8 +4681,17 @@ static int pk_toPEM(lua_State *L) {
@@ -31,5 +31,5 @@ index acb8289..1905693 100644
3131
if (!PEM_write_bio_PUBKEY(bio, key))
3232
return auxL_error(L, auxL_EOPENSSL, "pkey:__tostring");
3333
--
34-
2.24.1
34+
2.48.1
3535

main/lua-ossl/0003-pkey.toPEM-private-key-encryption.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 367597c9fbbd8c0179a8b2a75e5b0819ef5bc5d6 Mon Sep 17 00:00:00 2001
1+
From 2f246ccfaba1c7a83274157ef917c0c169810d49 Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Mon, 30 Apr 2018 13:26:16 +0300
4-
Subject: [PATCH 03/10] pkey.toPEM: private key encryption
4+
Subject: [PATCH 3/9] pkey.toPEM: private key encryption
55

66
---
77
src/openssl.c | 25 +++++++++++++++++++------
88
1 file changed, 19 insertions(+), 6 deletions(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index 1905693..9b10165 100644
11+
index 6df0a17..9432407 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
1414
@@ -31,7 +31,7 @@
@@ -59,5 +59,5 @@ index 1905693..9b10165 100644
5959

6060
len = BIO_get_mem_data(bio, &pem);
6161
--
62-
2.24.1
62+
2.48.1
6363

main/lua-ossl/0004-pkey.new-type-rename-variable.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From f287bd7a314458a3870ee4e7fbdfc7e0ea41a4b6 Mon Sep 17 00:00:00 2001
1+
From 312269de413d42c7049e87ed81a6449807c79069 Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Sun, 2 Sep 2018 14:22:43 +0300
4-
Subject: [PATCH 04/10] pkey.new: type: rename variable
4+
Subject: [PATCH 4/9] pkey.new: type: rename variable
55

66
---
77
src/openssl.c | 6 +++---
88
1 file changed, 3 insertions(+), 3 deletions(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index 9b10165..ed18e60 100644
11+
index 9432407..7fef0e3 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
1414
@@ -4299,7 +4299,7 @@ static int pk_new(lua_State *L) {
@@ -39,5 +39,5 @@ index 9b10165..ed18e60 100644
3939
BIO_reset(bio);
4040

4141
--
42-
2.24.1
42+
2.48.1
4343

main/lua-ossl/0005-pkey.new-opt-rename-variable.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 31403e7892b554458edc28a43f6f0552f3f27bac Mon Sep 17 00:00:00 2001
1+
From 1d6f15950ae7834e2d49e7709e4a723a96eb8f46 Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Sun, 2 Sep 2018 14:24:51 +0300
4-
Subject: [PATCH 05/10] pkey.new: opt: rename variable
4+
Subject: [PATCH 5/9] pkey.new: opt: rename variable
55

66
---
77
src/openssl.c | 10 +++++-----
88
1 file changed, 5 insertions(+), 5 deletions(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index ed18e60..5904bf1 100644
11+
index 7fef0e3..e5a19b8 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
1414
@@ -4301,20 +4301,20 @@ static int pk_new(lua_State *L) {
@@ -38,5 +38,5 @@ index ed18e60..5904bf1 100644
3838
}
3939

4040
--
41-
2.24.1
41+
2.48.1
4242

main/lua-ossl/0006-optencoding-allow-negative-indices.patch

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
From 07e298a09b20f24d7a1efede41c04f398bb1022a Mon Sep 17 00:00:00 2001
1+
From 53fd95f0c06d3c521c48dd01206f7d8b002f4625 Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Sun, 2 Sep 2018 14:44:46 +0300
4-
Subject: [PATCH 07/10] pkey.new: accept option table
4+
Subject: [PATCH 6/9] pkey.new: accept option table
55

66
---
7-
src/openssl.c | 15 +++++++++++----
8-
1 file changed, 11 insertions(+), 4 deletions(-)
7+
src/openssl.c | 20 +++++++++++++++-----
8+
1 file changed, 15 insertions(+), 5 deletions(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index cb38f2f..2aaa5d8 100644
11+
index e5a19b8..9de08b4 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
14-
@@ -4073,7 +4073,7 @@ static BIO *getbio(lua_State *L) {
14+
@@ -4065,7 +4065,7 @@ static BIO *getbio(lua_State *L) {
1515
static int pk_new(lua_State *L) {
1616
EVP_PKEY **ud;
1717

@@ -20,7 +20,7 @@ index cb38f2f..2aaa5d8 100644
2020
lua_settop(L, 3);
2121

2222
if (lua_istable(L, 1) || lua_isnil(L, 1)) {
23-
@@ -4307,7 +4307,7 @@ static int pk_new(lua_State *L) {
23+
@@ -4299,7 +4299,7 @@ static int pk_new(lua_State *L) {
2424
#endif
2525
} /* switch() */
2626
} else if (lua_isstring(L, 1)) {
@@ -29,22 +29,26 @@ index cb38f2f..2aaa5d8 100644
2929
int pubonly = 0, prvtonly = 0;
3030
const char *type, *data;
3131
size_t len;
32-
@@ -4315,14 +4315,21 @@ static int pk_new(lua_State *L) {
32+
@@ -4307,6 +4307,18 @@ static int pk_new(lua_State *L) {
3333
EVP_PKEY *pub = NULL, *prvt = NULL;
3434
int goterr = 0;
3535

3636
+ if (lua_istable(L, 2)) {
37+
+ lua_pop(L, 1);
3738
+ lua_getfield(L, 2, "format");
3839
+ lua_getfield(L, 2, "type");
40+
+ lua_remove(L, 2);
3941
+ }
4042
+
41-
+ format = optencoding(L, -2, "*", X509_ANY|X509_PEM|X509_DER);
43+
+ /* #1 key, #2 format, #3 type */
44+
+
45+
+ data = luaL_checklstring(L, 1, &len);
46+
+ format = optencoding(L, 2, "*", X509_ANY|X509_PEM|X509_DER);
4247
+
4348
/* check if specified publickey or privatekey */
44-
- if ((type = luaL_optstring(L, 3, NULL))) {
45-
+ if ((type = luaL_optstring(L, -1, NULL))) {
49+
if ((type = luaL_optstring(L, 3, NULL))) {
4650
if (xtolower(type[0]) == 'p' && xtolower(type[1]) == 'u') {
47-
pubonly = 1;
51+
@@ -4314,12 +4326,10 @@ static int pk_new(lua_State *L) {
4852
} else if (xtolower(type[0]) == 'p' && xtolower(type[1]) == 'r') {
4953
prvtonly = 1;
5054
} else {
@@ -53,6 +57,11 @@ index cb38f2f..2aaa5d8 100644
5357
}
5458
}
5559

60+
- data = luaL_checklstring(L, 1, &len);
61+
-
62+
ud = prepsimple(L, PKEY_CLASS);
63+
64+
if (!(bio = BIO_new_mem_buf((void *)data, len)))
5665
--
57-
2.24.1
66+
2.48.1
5867

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
From 132ac48cea935829c31f873aaab920a940bc6b98 Mon Sep 17 00:00:00 2001
1+
From e66093e81cacacfabed9519b9cf4d58db6424256 Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Mon, 30 Apr 2018 13:49:57 +0300
4-
Subject: [PATCH 08/10] pkey.new: decryption
4+
Subject: [PATCH 7/9] pkey.new: decryption
55

66
---
7-
src/openssl.c | 32 +++++++++++++++++++++++++-------
8-
1 file changed, 25 insertions(+), 7 deletions(-)
7+
src/openssl.c | 30 ++++++++++++++++++++++++------
8+
1 file changed, 24 insertions(+), 6 deletions(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index 2aaa5d8..937ffa6 100644
11+
index 9de08b4..dd46fb9 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
1414
@@ -31,7 +31,7 @@
@@ -20,13 +20,13 @@ index 2aaa5d8..937ffa6 100644
2020
#include <math.h> /* INFINITY fabs(3) floor(3) frexp(3) fmod(3) round(3) isfinite(3) */
2121
#include <time.h> /* struct tm time_t strptime(3) time(2) */
2222
#include <ctype.h> /* isdigit(3), isxdigit(3), tolower(3) */
23-
@@ -4070,6 +4070,15 @@ static BIO *getbio(lua_State *L) {
23+
@@ -4062,6 +4062,15 @@ static BIO *getbio(lua_State *L) {
2424
} /* getbio() */
2525

2626

2727
+static int pem_pw_cb(char *buf, int size, int rwflag, void *u) {
2828
+ if (!u)
29-
+ return 0;
29+
+ return -1;
3030
+ char *pass = (char *) u;
3131
+ strncpy(buf, pass, size);
3232
+ return MIN(strlen(pass), (unsigned int) size);
@@ -36,7 +36,7 @@ index 2aaa5d8..937ffa6 100644
3636
static int pk_new(lua_State *L) {
3737
EVP_PKEY **ud;
3838

39-
@@ -4309,7 +4318,7 @@ static int pk_new(lua_State *L) {
39+
@@ -4301,7 +4310,7 @@ static int pk_new(lua_State *L) {
4040
} else if (lua_isstring(L, 1)) {
4141
int format;
4242
int pubonly = 0, prvtonly = 0;
@@ -45,39 +45,36 @@ index 2aaa5d8..937ffa6 100644
4545
size_t len;
4646
BIO *bio;
4747
EVP_PKEY *pub = NULL, *prvt = NULL;
48-
@@ -4318,12 +4327,14 @@ static int pk_new(lua_State *L) {
49-
if (lua_istable(L, 2)) {
48+
@@ -4311,10 +4320,12 @@ static int pk_new(lua_State *L) {
49+
lua_pop(L, 1);
5050
lua_getfield(L, 2, "format");
5151
lua_getfield(L, 2, "type");
52-
- }
5352
+ lua_getfield(L, 2, "password");
53+
lua_remove(L, 2);
54+
- }
5455
+ } else
5556
+ lua_pushnil(L);
5657

57-
- format = optencoding(L, -2, "*", X509_ANY|X509_PEM|X509_DER);
58-
+ format = optencoding(L, -3, "*", X509_ANY|X509_PEM|X509_DER);
58+
- /* #1 key, #2 format, #3 type */
59+
+ /* #1 key, #2 format, #3 type, #4 password or callback */
5960

60-
/* check if specified publickey or privatekey */
61-
- if ((type = luaL_optstring(L, -1, NULL))) {
62-
+ if ((type = luaL_optstring(L, -2, NULL))) {
63-
if (xtolower(type[0]) == 'p' && xtolower(type[1]) == 'u') {
64-
pubonly = 1;
65-
} else if (xtolower(type[0]) == 'p' && xtolower(type[1]) == 'r') {
66-
@@ -4333,6 +4344,13 @@ static int pk_new(lua_State *L) {
61+
data = luaL_checklstring(L, 1, &len);
62+
format = optencoding(L, 2, "*", X509_ANY|X509_PEM|X509_DER);
63+
@@ -4330,6 +4341,13 @@ static int pk_new(lua_State *L) {
6764
}
6865
}
6966

70-
+ pass = luaL_optstring(L, -1, NULL);
67+
+ pass = luaL_optstring(L, 4, NULL);
7168
+ if (pass) {
7269
+ if (format == X509_DER)
7370
+ return luaL_error(L, "decryption supported only for PEM keys");
7471
+ else format = X509_PEM;
7572
+ }
7673
+
77-
data = luaL_checklstring(L, 1, &len);
78-
7974
ud = prepsimple(L, PKEY_CLASS);
80-
@@ -4349,14 +4367,14 @@ static int pk_new(lua_State *L) {
75+
76+
if (!(bio = BIO_new_mem_buf((void *)data, len)))
77+
@@ -4344,14 +4362,14 @@ static int pk_new(lua_State *L) {
8178
*/
8279
BIO_reset(bio);
8380

@@ -95,5 +92,5 @@ index 2aaa5d8..937ffa6 100644
9592
}
9693
}
9794
--
98-
2.24.1
95+
2.48.1
9996

main/lua-ossl/0009-pkey.toPEM-use-password-callback.patch renamed to main/lua-ossl/0008-pkey.toPEM-use-password-callback.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
From 4899a210dfdd91fa75b77601d29df0152aecc382 Mon Sep 17 00:00:00 2001
1+
From 482c51d69e7985a17c560c9d44e2c60105a814f2 Mon Sep 17 00:00:00 2001
22
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
33
Date: Thu, 3 May 2018 21:21:16 +0300
4-
Subject: [PATCH 09/10] pkey.toPEM: use password callback
4+
Subject: [PATCH 8/9] pkey.toPEM: use password callback
55

66
---
77
src/openssl.c | 2 +-
88
1 file changed, 1 insertion(+), 1 deletion(-)
99

1010
diff --git a/src/openssl.c b/src/openssl.c
11-
index 937ffa6..3af285b 100644
11+
index dd46fb9..9857603 100644
1212
--- a/src/openssl.c
1313
+++ b/src/openssl.c
14-
@@ -4748,7 +4748,7 @@ static int pk_toPEM(lua_State *L) {
14+
@@ -4743,7 +4743,7 @@ static int pk_toPEM(lua_State *L) {
1515
return luaL_error(L, "pkey:toPEM: password not defined");
1616
}
1717

@@ -21,5 +21,5 @@ index 937ffa6..3af285b 100644
2121

2222
len = BIO_get_mem_data(bio, &pem);
2323
--
24-
2.24.1
24+
2.48.1
2525

0 commit comments

Comments
 (0)