diff options
Diffstat (limited to 'plugins/coro-tls')
-rw-r--r-- | plugins/coro-tls/LICENSE | 22 | ||||
-rw-r--r-- | plugins/coro-tls/README.md | 2 | ||||
-rw-r--r-- | plugins/coro-tls/init.lua | 122 | ||||
-rw-r--r-- | plugins/coro-tls/plugin.json | 8 |
4 files changed, 0 insertions, 154 deletions
diff --git a/plugins/coro-tls/LICENSE b/plugins/coro-tls/LICENSE deleted file mode 100644 index 5789b767285..00000000000 --- a/plugins/coro-tls/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Tim Caswell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/plugins/coro-tls/README.md b/plugins/coro-tls/README.md deleted file mode 100644 index 50aae3f7657..00000000000 --- a/plugins/coro-tls/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# luv-coro-tls -A luv port of lit's coro-tls module diff --git a/plugins/coro-tls/init.lua b/plugins/coro-tls/init.lua deleted file mode 100644 index 03d6e1c3f76..00000000000 --- a/plugins/coro-tls/init.lua +++ /dev/null @@ -1,122 +0,0 @@ -local exports = {} -exports.name = "creationix/coro-tls" -exports.version = "1.2.1" -exports.homepage = "https://github.com/luvit/lit/blob/master/deps/coro-tls.lua" -exports.description = "A coro-stream wrapper implementing tls sessions." -exports.tags = {"coro", "tls", "ssl"} -exports.license = "MIT" -exports.author = { name = "Tim Caswell" } - -local openssl = require('openssl') -local bit = require('bit') - -local DEFAULT_CIPHERS = 'ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:' .. -- TLS 1.2 - 'RC4:HIGH:!MD5:!aNULL:!EDH' -- TLS 1.0 - --- Given a read/write pair, return a new read/write pair for plaintext -exports.wrap = function (read, write, options) - if not options then - options = {} - end - - local ctx = openssl.ssl.ctx_new(options.protocol or 'TLSv1_2', options.ciphers or DEFAULT_CIPHERS) - - local key, cert, ca - if options.key then - key = assert(openssl.pkey.read(options.key, true, 'pem')) - end - if options.cert then - cert = assert(openssl.x509.read(options.cert)) - end - if options.ca then - if type(options.ca) == "string" then - ca = { assert(openssl.x509.read(options.ca)) } - elseif type(options.ca) == "table" then - ca = {} - for i = 1, #options.ca do - ca[i] = assert(openssl.x509.read(options.ca[i])) - end - else - error("options.ca must be string or table of strings") - end - end - if key and cert then - assert(ctx:use(key, cert)) - end - if ca then - local store = openssl.x509.store:new() - for i = 1, #ca do - assert(store:add(ca[i])) - end - ctx:cert_store(store) - else - ctx:verify_mode({"none"}) - end - - ctx:options(bit.bor( - openssl.ssl.no_sslv2, - openssl.ssl.no_sslv3, - openssl.ssl.no_compression)) - local bin, bout = openssl.bio.mem(8192), openssl.bio.mem(8192) - local ssl = ctx:ssl(bin, bout, options.server) - - local function flush() - while bout:pending() > 0 do - write(bout:read()) - end - end - - -- Do handshake - while true do - if ssl:handshake() then break end - flush() - local chunk = read() - if chunk then - bin:write(chunk) - else - error("disconnect while handshaking") - end - end - flush() - - local done = false - local function shutdown() - if done then return end - done = true - while true do - if ssl:shutdown() then break end - flush() - local chunk = read() - if chunk then - bin:write(chunk) - else - break - end - end - flush() - write() - end - - local function plainRead() - while true do - local chunk = ssl:read() - if chunk then return chunk end - local cipher = read() - if not cipher then return end - bin:write(cipher) - end - end - - local function plainWrite(plain) - if not plain then - return shutdown() - end - ssl:write(plain) - flush() - end - - return plainRead, plainWrite - -end - -return exports diff --git a/plugins/coro-tls/plugin.json b/plugins/coro-tls/plugin.json deleted file mode 100644 index 257224e2ea3..00000000000 --- a/plugins/coro-tls/plugin.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "plugin": { - "name": "coro-tls", - "version": "1.2.1", - "author": "Tim Caswell", - "type": "library", - } -}
\ No newline at end of file |