src/ssl.c

Fri, 05 Nov 2010 02:21:55 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 05 Nov 2010 02:21:55 +0000
changeset 9
bb7e0d7a0a08
parent 8
fbaccf44ea01
child 10
a4a1fd8c1b43
permissions
-rw-r--r--

Whitespace fix for clarity

0
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 /*--------------------------------------------------------------------------
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 * LuaSec 0.4
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2006-2009 Bruno Silvestre
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 *
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 *--------------------------------------------------------------------------*/
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 #include <string.h>
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 #include <openssl/ssl.h>
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 #include <openssl/err.h>
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 #include <lua.h>
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 #include <lauxlib.h>
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 #include "io.h"
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 #include "buffer.h"
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 #include "timeout.h"
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 #include "socket.h"
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 #include "ssl.h"
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 * Map error code into string.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 static const char *ssl_ioerror(void *ctx, int err)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 if (err == IO_SSL) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 p_ssl ssl = (p_ssl) ctx;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 switch(ssl->error) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 case SSL_ERROR_NONE: return "No error";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 case SSL_ERROR_ZERO_RETURN: return "closed";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 case SSL_ERROR_WANT_READ: return "wantread";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 case SSL_ERROR_WANT_WRITE: return "wantwrite";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 case SSL_ERROR_WANT_CONNECT: return "'connect' not completed";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 case SSL_ERROR_WANT_ACCEPT: return "'accept' not completed";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 case SSL_ERROR_WANT_X509_LOOKUP: return "Waiting for callback";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 case SSL_ERROR_SYSCALL: return "System error";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 case SSL_ERROR_SSL: return ERR_reason_error_string(ERR_get_error());
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 default: return "Unknown SSL error";
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 return socket_strerror(err);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 * Close the connection before the GC collect the object.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 static int meth_destroy(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 p_ssl ssl = (p_ssl) lua_touserdata(L, 1);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 if (ssl->ssl) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 socket_setblocking(&ssl->sock);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 SSL_shutdown(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 socket_destroy(&ssl->sock);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 SSL_free(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 ssl->ssl = NULL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 return 0;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 * Perform the TLS/SSL handshake
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 static int handshake(p_ssl ssl)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 int err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 p_timeout tm = timeout_markstart(&ssl->tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 if (ssl->state == ST_SSL_CLOSED)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 for ( ; ; ) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 ERR_clear_error();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 err = SSL_do_handshake(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 ssl->error = SSL_get_error(ssl->ssl, err);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 switch(ssl->error) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 case SSL_ERROR_NONE:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 ssl->state = ST_SSL_CONNECTED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 return IO_DONE;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 case SSL_ERROR_WANT_READ:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 err = socket_waitfd(&ssl->sock, WAITFD_R, tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 if (err == IO_TIMEOUT) return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 if (err != IO_DONE) return err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 case SSL_ERROR_WANT_WRITE:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 err = socket_waitfd(&ssl->sock, WAITFD_W, tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 if (err == IO_TIMEOUT) return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 if (err != IO_DONE) return err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 case SSL_ERROR_SYSCALL:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 if (ERR_peek_error()) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 ssl->error = SSL_ERROR_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 if (err == 0)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 return socket_error();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 default:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 return IO_UNKNOWN;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 * Send data
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 static int ssl_send(void *ctx, const char *data, size_t count, size_t *sent,
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 p_timeout tm)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 int err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 p_ssl ssl = (p_ssl) ctx;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 if (ssl->state == ST_SSL_CLOSED)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 *sent = 0;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 for ( ; ; ) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 ERR_clear_error();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 err = SSL_write(ssl->ssl, data, (int) count);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 ssl->error = SSL_get_error(ssl->ssl, err);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 switch(ssl->error) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 case SSL_ERROR_NONE:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 *sent = err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 return IO_DONE;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 case SSL_ERROR_WANT_READ:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 err = socket_waitfd(&ssl->sock, WAITFD_R, tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 if (err == IO_TIMEOUT) return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 if (err != IO_DONE) return err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 case SSL_ERROR_WANT_WRITE:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 err = socket_waitfd(&ssl->sock, WAITFD_W, tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 if (err == IO_TIMEOUT) return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 if (err != IO_DONE) return err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 case SSL_ERROR_SYSCALL:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 if (ERR_peek_error()) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 ssl->error = SSL_ERROR_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 if (err == 0)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 return socket_error();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 default:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 return IO_UNKNOWN;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147 * Receive data
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 static int ssl_recv(void *ctx, char *data, size_t count, size_t *got,
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 p_timeout tm)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 int err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 p_ssl ssl = (p_ssl) ctx;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 if (ssl->state == ST_SSL_CLOSED)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 *got = 0;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 for ( ; ; ) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 ERR_clear_error();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 err = SSL_read(ssl->ssl, data, (int) count);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 ssl->error = SSL_get_error(ssl->ssl, err);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 switch(ssl->error) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 case SSL_ERROR_NONE:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 *got = err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 return IO_DONE;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 case SSL_ERROR_ZERO_RETURN:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 *got = err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 case SSL_ERROR_WANT_READ:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 err = socket_waitfd(&ssl->sock, WAITFD_R, tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 if (err == IO_TIMEOUT) return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 if (err != IO_DONE) return err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
173 case SSL_ERROR_WANT_WRITE:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
174 err = socket_waitfd(&ssl->sock, WAITFD_W, tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
175 if (err == IO_TIMEOUT) return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 if (err != IO_DONE) return err;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
178 case SSL_ERROR_SYSCALL:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179 if (ERR_peek_error()) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180 ssl->error = SSL_ERROR_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
181 return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
182 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
183 if (err == 0)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
184 return IO_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
185 return socket_error();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
186 default:
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
187 return IO_SSL;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
188 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
189 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
190 return IO_UNKNOWN;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
191 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
192
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
193 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
194 * Create a new TLS/SSL object and mark it as new.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
195 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
196 static int meth_create(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
197 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
198 p_ssl ssl;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
199 int mode = ctx_getmode(L, 1);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
200 SSL_CTX *ctx = ctx_getcontext(L, 1);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
201
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
202 if (mode == MD_CTX_INVALID) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
203 lua_pushnil(L);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
204 lua_pushstring(L, "invalid mode");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
205 return 2;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
206 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
207 ssl = (p_ssl) lua_newuserdata(L, sizeof(t_ssl));
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
208 if (!ssl) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
209 lua_pushnil(L);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
210 lua_pushstring(L, "error creating SSL object");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
211 return 2;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
212 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
213 ssl->ssl = SSL_new(ctx);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
214 if (!ssl->ssl) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
215 lua_pushnil(L);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
216 lua_pushstring(L, "error creating SSL object");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
217 return 2;;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
218 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
219 ssl->state = ST_SSL_NEW;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
220 SSL_set_fd(ssl->ssl, (int) SOCKET_INVALID);
2
0cfca30f1ce3 ssl.c: Set SSL_MODE_RELEASE_BUFFERS mode when supported
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
221 SSL_set_mode(ssl->ssl, SSL_MODE_ENABLE_PARTIAL_WRITE |
0
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
222 SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
2
0cfca30f1ce3 ssl.c: Set SSL_MODE_RELEASE_BUFFERS mode when supported
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
223
0cfca30f1ce3 ssl.c: Set SSL_MODE_RELEASE_BUFFERS mode when supported
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
224 #ifdef SSL_MODE_RELEASE_BUFFERS
0cfca30f1ce3 ssl.c: Set SSL_MODE_RELEASE_BUFFERS mode when supported
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
225 SSL_set_mode(ssl->ssl, SSL_MODE_RELEASE_BUFFERS);
0cfca30f1ce3 ssl.c: Set SSL_MODE_RELEASE_BUFFERS mode when supported
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
226 #endif
0cfca30f1ce3 ssl.c: Set SSL_MODE_RELEASE_BUFFERS mode when supported
Matthew Wild <mwild1@gmail.com>
parents: 0
diff changeset
227
0
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228 if (mode == MD_CTX_SERVER)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
229 SSL_set_accept_state(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
230 else
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
231 SSL_set_connect_state(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
232
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 io_init(&ssl->io, (p_send) ssl_send, (p_recv) ssl_recv,
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234 (p_error) ssl_ioerror, ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
235 timeout_init(&ssl->tm, -1, -1);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
236 buffer_init(&ssl->buf, &ssl->io, &ssl->tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
237
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
238 luaL_getmetatable(L, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
239 lua_setmetatable(L, -2);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
240 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
241 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
242
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
243 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
244 * Buffer send function
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
245 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246 static int meth_send(lua_State *L) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
247 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
248 return buffer_meth_send(L, &ssl->buf);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
249 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
250
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
251 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
252 * Buffer receive function
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
253 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
254 static int meth_receive(lua_State *L) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
255 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
256 return buffer_meth_receive(L, &ssl->buf);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
257 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
258
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
259 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
260 * Select support methods
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
261 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
262 static int meth_getfd(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
263 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
264 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
265 lua_pushnumber(L, ssl->sock);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
266 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
267 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
268
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
269 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
270 * Set the TLS/SSL file descriptor.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
271 * This is done *before* the handshake.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
272 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
273 static int meth_setfd(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
274 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
275 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
276 if (ssl->state != ST_SSL_NEW)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
277 luaL_argerror(L, 1, "invalid SSL object state");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
278 ssl->sock = luaL_checkint(L, 2);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
279 socket_setnonblocking(&ssl->sock);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
280 SSL_set_fd(ssl->ssl, (int)ssl->sock);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
281 return 0;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
282 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
283
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
284 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
285 * Lua handshake function.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
286 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
287 static int meth_handshake(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
288 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
289 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
290 int err = handshake(ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
291 if (err == IO_DONE) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
292 lua_pushboolean(L, 1);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
293 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
294 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
295 lua_pushboolean(L, 0);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
296 lua_pushstring(L, ssl_ioerror((void*)ssl, err));
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
297 return 2;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
298 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
299
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
300 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
301 * Close the connection.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
302 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
303 static int meth_close(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
304 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
305 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
306 meth_destroy(L);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
307 ssl->state = ST_SSL_CLOSED;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
308 return 0;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
309 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
310
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
311 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
312 * Set timeout.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
313 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
314 static int meth_settimeout(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
315 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
316 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
317 return timeout_meth_settimeout(L, &ssl->tm);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
318 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
319
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
320 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
321 * Check if there is data in the buffer.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
322 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
323 static int meth_dirty(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
324 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
325 int res = 0;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
326 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
327 if (ssl->state != ST_SSL_CLOSED)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
328 res = !buffer_isempty(&ssl->buf) || SSL_pending(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
329 lua_pushboolean(L, res);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
330 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
331 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
332
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
333 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
334 * Return the state information about the SSL object.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
335 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
336 static int meth_want(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
337 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
338 p_ssl ssl = (p_ssl) luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
339 int code = (ssl->state == ST_SSL_CLOSED) ? SSL_NOTHING : SSL_want(ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
340 switch(code) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
341 case SSL_NOTHING: lua_pushstring(L, "nothing"); break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
342 case SSL_READING: lua_pushstring(L, "read"); break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
343 case SSL_WRITING: lua_pushstring(L, "write"); break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
344 case SSL_X509_LOOKUP: lua_pushstring(L, "x509lookup"); break;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
345 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
346 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
347 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
348
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
349 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
350 * Return a pointer to SSL structure.
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
351 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
352 static int meth_rawconn(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
353 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
354 p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
355 lua_pushlightuserdata(L, (void*)ssl->ssl);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
356 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
357 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
358
3
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
359 /**
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
360 * Return the compression method used.
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
361 */
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
362 static int meth_compression(lua_State *L)
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
363 {
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
364 const COMP_METHOD *comp;
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
365 p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
366 comp = SSL_get_current_compression(ssl->ssl);
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
367 if (comp) {
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
368 lua_pushstring(L, SSL_COMP_get_name(comp));
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
369 return 1;
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
370 } else {
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
371 lua_pushboolean(L, 0);
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
372 return 1;
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
373 }
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
374 }
4
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
375
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
376 /**
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
377 * Return the peer certificate.
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
378 */
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
379 static int meth_getpeercertificate(lua_State *L)
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
380 {
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
381 X509 *peer;
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
382 p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
383 peer = SSL_get_peer_certificate(ssl->ssl);
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
384 if (peer == NULL) {
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
385 /* No client certificate available */
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
386 lua_pushboolean(L, 0);
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
387 return 1;
7
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
388 }
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
389 else
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
390 {
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
391 X509_NAME *subject;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
392 int i, n_entries, len;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
393 char buffer[4096];
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
394
8
fbaccf44ea01 Fix to remove duplicated table on the stack, causing the 'trusted' flag to disappear from the returned cert
Matthew Wild <mwild1@gmail.com>
parents: 7
diff changeset
395 lua_newtable(L); /* ret */
7
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
396
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
397 lua_pushboolean(L, (SSL_get_verify_result(ssl->ssl) == X509_V_OK));
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
398 lua_setfield(L, -2, "trusted");
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
399
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
400 subject = X509_get_subject_name(peer);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
401
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
402 n_entries = X509_NAME_entry_count(subject);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
403
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
404 lua_newtable(L); /* {} */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
405 lua_pushvalue(L, -1);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
406 lua_setfield(L, -3, "subject"); /* ret.subject = {} */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
407 for(i = 0; i <= n_entries; i++)
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
408 {
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
409 X509_NAME_ENTRY *entry;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
410 ASN1_OBJECT *object;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
411 ASN1_STRING *value;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
412 int len;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
413
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
414 entry = X509_NAME_get_entry(subject, i);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
415 object = X509_NAME_ENTRY_get_object(entry);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
416
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
417 /* Get numeric ID as string into buffer */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
418 len = OBJ_obj2txt(buffer, sizeof(buffer), object, 1);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
419
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
420 if(len == 0)
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
421 continue;
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
422
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
423 /* Push numeric ID to Lua (e.g. 1.22.3...) */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
424 lua_pushlstring(L, buffer, (len>sizeof(buffer))?sizeof(buffer):(len));
9
bb7e0d7a0a08 Whitespace fix for clarity
Matthew Wild <mwild1@gmail.com>
parents: 8
diff changeset
425
7
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
426 lua_pushvalue(L, -1); /* k */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
427 lua_gettable(L, -4); /* ret.subject[k] */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
428
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
429 if(lua_isnil(L, -1))
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
430 {
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
431 lua_pop(L, 1);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
432 lua_newtable(L);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
433 lua_pushvalue(L, -2); /* k */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
434 lua_pushvalue(L, -2); /* v */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
435 lua_settable(L, -6); /* ret.subject[k] = v */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
436 /* Get short/long name of the entry */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
437 len = OBJ_obj2txt(buffer, sizeof(buffer), object, 0);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
438 lua_pushlstring(L, buffer, (len>sizeof(buffer))?sizeof(buffer):(len));
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
439 lua_setfield(L, -2, "name");
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
440 }
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
441
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
442 value = X509_NAME_ENTRY_get_data(entry);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
443 if(value)
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
444 {
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
445 lua_pushlstring(L, (char*)ASN1_STRING_data(value), ASN1_STRING_length(value));
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
446 lua_rawseti(L, -2, lua_objlen(L, -2)+1);
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
447 }
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
448
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
449 lua_pop(L, 2); /* k, v */
4
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
450 }
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
451 }
7
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
452 lua_pop(L, 1); /* ret.subject */
da3cf40976f6 Modify :getpeercertificate() to return a decoded certificate (subject only at the moment)
Matthew Wild <mwild1@gmail.com>
parents: 6
diff changeset
453 return 1;
4
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
454 }
5
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
455
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
456 static int meth_getfinished(lua_State *L)
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
457 {
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
458 p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
459 SSL *conn = ssl->ssl;
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
460 char *buffer = NULL;
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
461 size_t len = 0;
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
462 if ((len = SSL_get_finished(conn, NULL, 0)) != 0) {
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
463 buffer = malloc(len);
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
464 if (buffer == NULL) return 0;
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
465 len = SSL_get_finished(conn, buffer, len);
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
466 lua_pushlstring(L, buffer, len);
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
467 free(buffer);
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
468 return 1;
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
469 } else {
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
470 return 0;
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
471 }
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
472 }
6
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
473
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
474 static int meth_getpeerfinished(lua_State *L)
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
475 {
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
476 p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
477 SSL *conn = ssl->ssl;
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
478 char *buffer = NULL;
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
479 size_t len = 0;
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
480 if ((len = SSL_get_peer_finished(conn, NULL, 0)) != 0) {
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
481 buffer = malloc(len);
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
482 if (buffer == NULL) return 0;
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
483 len = SSL_get_peer_finished(conn, buffer, len);
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
484 lua_pushlstring(L, buffer, len);
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
485 free(buffer);
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
486 return 1;
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
487 } else {
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
488 return 0;
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
489 }
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
490 }
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
491
0
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
492 /*---------------------------------------------------------------------------*/
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
493
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
494
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
495 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
496 * SSL metamethods
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
497 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
498 static luaL_Reg meta[] = {
3
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
499 {"close", meth_close},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
500 {"getfd", meth_getfd},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
501 {"dirty", meth_dirty},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
502 {"dohandshake", meth_handshake},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
503 {"receive", meth_receive},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
504 {"send", meth_send},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
505 {"settimeout", meth_settimeout},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
506 {"want", meth_want},
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
507 {"compression", meth_compression},
4
718837c61318 Add :getpeercertificate() method to get peer's certificate
Tobias Markmann <tm@ayena.de>
parents: 3
diff changeset
508 {"getpeercertificate",meth_getpeercertificate},
5
2d5a8f963181 Add :getfinished() method to get local TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 4
diff changeset
509 {"getfinished", meth_getfinished},
6
d559a15eeb40 Add :getpeerfinished() connection method to get peer's TLS Finished message
Tobias Markmann <tm@ayena.de>
parents: 5
diff changeset
510 {"getpeerfinished", meth_getpeerfinished},
3
bd2b1836f0ba Add :compression() connection method to get the compression method in use (if any)
Tobias Markmann <tm@ayena.de>
parents: 2
diff changeset
511 {NULL, NULL}
0
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
512 };
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
513
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
514 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
515 * SSL functions
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
516 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
517 static luaL_Reg funcs[] = {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
518 {"create", meth_create},
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
519 {"setfd", meth_setfd},
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
520 {"rawconnection", meth_rawconn},
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
521 {NULL, NULL}
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
522 };
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
523
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
524 /**
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
525 * Initialize modules
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
526 */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
527 LUASEC_API int luaopen_ssl_core(lua_State *L)
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
528 {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
529 /* Initialize SSL */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
530 if (!SSL_library_init()) {
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
531 lua_pushstring(L, "unable to initialize SSL library");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
532 lua_error(L);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
533 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
534 SSL_load_error_strings();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
535
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
536 /* Initialize internal library */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
537 socket_open();
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
538
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
539 /* Registre the functions and tables */
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
540 luaL_newmetatable(L, "SSL:Connection");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
541 lua_newtable(L);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
542 luaL_register(L, NULL, meta);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
543 lua_setfield(L, -2, "__index");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
544 lua_pushcfunction(L, meth_destroy);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
545 lua_setfield(L, -2, "__gc");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
546
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
547 luaL_register(L, "ssl.core", funcs);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
548 lua_pushnumber(L, SOCKET_INVALID);
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
549 lua_setfield(L, -2, "invalidfd");
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
550
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
551 return 1;
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
552 }
f7d2d78eb424 Initial commit (LuaSec 0.4)
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
553

mercurial