Does anyone know a pure Lua assymmetric encryption library?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
I know all of you are going to want to say "you don't want that", but please simply accept that pure Lua is the requirement.
Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Vadim A. Misbakh-Soloviov
> I know all of you are going to want to say "you don't want that", but
> please simply accept that pure Lua is the requirement.

Depends on what kind of assymetric encryption do you want.

For example, I did pure-lua sha256_crypt few years ago just for fun (and
failed to find the sources now).

Or what do you want to have?

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Emeka
Elliptic curve ??

On Tue, Aug 8, 2017 at 3:51 PM, Vadim A. Misbakh-Soloviov <[hidden email]> wrote:
> I know all of you are going to want to say "you don't want that", but
> please simply accept that pure Lua is the requirement.

Depends on what kind of assymetric encryption do you want.

For example, I did pure-lua sha256_crypt few years ago just for fun (and
failed to find the sources now).

Or what do you want to have?




--
P.S Please join our groups:  [hidden email]
 or [hidden email]  These are platforms for learning and sharing  of knowledge.                                                                                      www.satajanus.com | Satajanus  Nig. Ltd


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Ed F.
In reply to this post by Xazo -Tak
On Tue, Aug 8, 2017 at 7:13 AM, Xazo -Tak <[hidden email]> wrote:
> I know all of you are going to want to say "you don't want that", but please
> simply accept that pure Lua is the requirement.

PLC - Pure Lua Crypto  (https://github.com/philanc/plc)

Ed

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
In reply to this post by Vadim A. Misbakh-Soloviov
>Depends on what kind of assymetric encryption do you want.
Anything suitable for digital signatures, but one needs to be fast, and one needs to be strong.
The bulk of the data I'm sending only causes slight issues if it's tampered with.
If Adam cracked Bob's key, he could cause Bob to sometimes appear as "Gaylord Hitler" instead of "Bob".

But one key, if cracked, would allow Adam to do the same attack to all users.

On 9 August 2017 at 02:51, Vadim A. Misbakh-Soloviov <[hidden email]> wrote:
> I know all of you are going to want to say "you don't want that", but
> please simply accept that pure Lua is the requirement.

Depends on what kind of assymetric encryption do you want.

For example, I did pure-lua sha256_crypt few years ago just for fun (and
failed to find the sources now).

Or what do you want to have?


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
In reply to this post by Ed F.
>PLC - Pure Lua Crypto  (https://github.com/philanc/plc)
That doesn't appear to contain anything asymmetric.

On 9 August 2017 at 09:56, Ed F. <[hidden email]> wrote:
On Tue, Aug 8, 2017 at 7:13 AM, Xazo -Tak <[hidden email]> wrote:
> I know all of you are going to want to say "you don't want that", but please
> simply accept that pure Lua is the requirement.

PLC - Pure Lua Crypto  (https://github.com/philanc/plc)

Ed


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Pierre Chapuis
On Wed, Aug 9, 2017, at 07:11, Xazo -Tak wrote:
> >PLC - Pure Lua Crypto  (https://github.com/philanc/plc)
> That doesn't appear to contain anything asymmetric.

It looks like it contains the primitives to implement something similar
to libsodium's crypto_box (ec25519 for ECDH, chacha20 and poly1305). The
scheme itself is not implemented though.

--
Pierre Chapuis

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
I don't know nearly enough about cryptography or Lua to turn that into something working.

On 9 August 2017 at 20:19, Pierre Chapuis <[hidden email]> wrote:
On Wed, Aug 9, 2017, at 07:11, Xazo -Tak wrote:
> >PLC - Pure Lua Crypto  (https://github.com/philanc/plc)
> That doesn't appear to contain anything asymmetric.

It looks like it contains the primitives to implement something similar
to libsodium's crypto_box (ec25519 for ECDH, chacha20 and poly1305). The
scheme itself is not implemented though.

--
Pierre Chapuis


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Daniel Silverstone
In reply to this post by Xazo -Tak
On Wed, Aug 09, 2017 at 15:44:30 +1200, Xazo -Tak wrote:
> >Depends on what kind of assymetric encryption do you want.
> Anything suitable for digital signatures, but one needs to be fast, and one
> needs to be strong.

https://gist.github.com/1lann/6604c8d3d8e5fdad0832

May help.

D.

--
Daniel Silverstone                         http://www.digital-scurf.org/
PGP mail accepted and encouraged.            Key Id: 3CCE BABE 206C 3B69

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
I've obviously seen it already, as it's one of the first things to appear in searches.
Also, people commenting on it say it's broken, which it is. It's huge pile of spaghetti code.

On 10 August 2017 at 00:01, Daniel Silverstone <[hidden email]> wrote:
On Wed, Aug 09, 2017 at 15:44:30 +1200, Xazo -Tak wrote:
> >Depends on what kind of assymetric encryption do you want.
> Anything suitable for digital signatures, but one needs to be fast, and one
> needs to be strong.

https://gist.github.com/1lann/6604c8d3d8e5fdad0832

May help.

D.

--
Daniel Silverstone                         http://www.digital-scurf.org/
PGP mail accepted and encouraged.            Key Id: 3CCE BABE 206C 3B69


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
Oh wait, I mixed it up with the matching key pair generation library (one by the same person).
That one has comments saying it's broken.

On 10 August 2017 at 09:01, Xazo -Tak <[hidden email]> wrote:
I've obviously seen it already, as it's one of the first things to appear in searches.
Also, people commenting on it say it's broken, which it is. It's huge pile of spaghetti code.

On 10 August 2017 at 00:01, Daniel Silverstone <[hidden email]> wrote:
On Wed, Aug 09, 2017 at 15:44:30 +1200, Xazo -Tak wrote:
> >Depends on what kind of assymetric encryption do you want.
> Anything suitable for digital signatures, but one needs to be fast, and one
> needs to be strong.

https://gist.github.com/1lann/6604c8d3d8e5fdad0832

May help.

D.

--
Daniel Silverstone                         http://www.digital-scurf.org/
PGP mail accepted and encouraged.            Key Id: 3CCE BABE 206C 3B69



Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Ricardo Ramos Massaro
In reply to this post by Daniel Silverstone
On Wed, Aug 9, 2017 at 9:01 AM, Daniel Silverstone
<[hidden email]> wrote:
> https://gist.github.com/1lann/6604c8d3d8e5fdad0832
>
> May help.

Note that this is just plain RSA, which is not very secure[1]. To be
secure, RSA must be used with some padding scheme, which is more
complicated than it sounds (PKCS v1.5 was one such scheme that was
eventually found vulnerable, for example).

When in doubt, one really should prefer existing crypto libraries that
have been checked by people who understand crypto.

[1] https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Attacks_against_plain_RSA

- Ricardo

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Sam Chang
openssl-seal is a best solution for your requirement.


Regards,
Sam

在 2017年8月10日,05:41,Ricardo Ramos Massaro <[hidden email]> 写道:

On Wed, Aug 9, 2017 at 9:01 AM, Daniel Silverstone
<[hidden email]> wrote:
https://gist.github.com/1lann/6604c8d3d8e5fdad0832

May help.

Note that this is just plain RSA, which is not very secure[1]. To be
secure, RSA must be used with some padding scheme, which is more
complicated than it sounds (PKCS v1.5 was one such scheme that was
eventually found vulnerable, for example).

When in doubt, one really should prefer existing crypto libraries that
have been checked by people who understand crypto.

[1] https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Attacks_against_plain_RSA

- Ricardo

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
Sam, I said "pure Lua".
A Lua frontend to a non-Lua program doesn't count.
This shouldn't be hard to understand.

On 10 August 2017 at 13:39, Sam Chang <[hidden email]> wrote:
openssl-seal is a best solution for your requirement.


Regards,
Sam

在 2017年8月10日,05:41,Ricardo Ramos Massaro <[hidden email]> 写道:

On Wed, Aug 9, 2017 at 9:01 AM, Daniel Silverstone
<[hidden email]> wrote:
https://gist.github.com/1lann/6604c8d3d8e5fdad0832

May help.

Note that this is just plain RSA, which is not very secure[1]. To be
secure, RSA must be used with some padding scheme, which is more
complicated than it sounds (PKCS v1.5 was one such scheme that was
eventually found vulnerable, for example).

When in doubt, one really should prefer existing crypto libraries that
have been checked by people who understand crypto.

[1] https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Attacks_against_plain_RSA

- Ricardo


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Pierre Chapuis
In reply to this post by Xazo -Tak
On Wed, Aug 9, 2017, at 10:32, Xazo -Tak wrote:
> I don't know nearly enough about cryptography or Lua to turn that into something working.

Not having that in pure Lua bothered me,  so I ended up implementing it.

You can find the result here for now:
https://github.com/catwell/plc/commits/pr-box

I submitted a pull request to have it merged into upstream PLC.

--
Pierre Chapuis

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
I'm guessing that box.lua (and what it requires) is the asymmetric encryption algorithm, but where is the documentation?
It uses an unusual set of jargon, doesn't say how it should be used, and doesn't say anything about itself.

From what I can gather, it's hardcoded to generate 256 bit keys; so unless this blows RSA out of the water in terms of efficiency, it's either going to be too insecure to protect the small amount of sensitive data or too slow to protect the large amount of less-sensitive data.

On 13 August 2017 at 09:42, Pierre Chapuis <[hidden email]> wrote:
On Wed, Aug 9, 2017, at 10:32, Xazo -Tak wrote:
> I don't know nearly enough about cryptography or Lua to turn that into something working.

Not having that in pure Lua bothered me,  so I ended up implementing it.

You can find the result here for now:
https://github.com/catwell/plc/commits/pr-box

I submitted a pull request to have it merged into upstream PLC.

--
Pierre Chapuis


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Pierre Chapuis
On Sun, Aug 13, 2017, at 02:15, Xazo -Tak wrote:
> I'm guessing that box.lua (and what it requires) is the asymmetric encryption algorithm, but where is the documentation?
> It uses an unusual set of jargon, doesn't say how it should be used, and doesn't say anything about itself.
> From what I can gather, it's hardcoded to generate 256 bit keys; so unless this blows RSA out of the water in terms of efficiency, it's either going to be too insecure to protect the small amount of sensitive data or too slow to protect the large amount of less-sensitive data.

It's elliptic curves, the short key lengths are an advantage over RSA.
See https://en.wikipedia.org/wiki/Elliptic_curve_cryptography#Key_sizes

This is a straightforward port of the same API from NaCL, see
https://nacl.cr.yp.to/box.html /
https://download.libsodium.org/doc/public-key_cryptography/authenticated_encryption.html.
It is compatible with it, and you can check that it gives the same
results as the C code (besides the private key generation, everything is
deterministic).

This scheme has been designed by D.J. Bernstein and is generally
admitted to be good, but don't take my word for it...

The main issue IMO is generating good random bytes in pure Lua. After
discussing it with the author of PLC I just sent a pull request [4] that
removes key generation from the API, only exposing a function to deduce
a public key from a private key. You are expected to provide a private
key yourself, it should be 32 bytes with the best entropy possible.

I know it lacks documentation, we are not entirely sure on the final API
we want yet. Like I said for now I just copied the tweetnacl API.

But yeah, it's a 1 day old crypto code in a dynamic language, I wouldn't
trust it beyond what's reasonable. The disclaimer at the bottom of the
PLC readme applies.

[1] https://en.wikipedia.org/wiki/Elliptic_curve_cryptography#Key_sizes
[2] https://nacl.cr.yp.to/box.html 
[3]
https://download.libsodium.org/doc/public-key_cryptography/authenticated_encryption.html
[4] https://github.com/philanc/plc/pull/8
[5] https://github.com/philanc/plc#test-vectors-tests-and-disclaimer

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Pierre Chapuis
In reply to this post by Xazo -Tak
Same email as the previous one with the links fixed, sorry for the
noise...

On Sun, Aug 13, 2017, at 02:15, Xazo -Tak wrote:
> I'm guessing that box.lua (and what it requires) is the asymmetric encryption algorithm, but where is the documentation?
> It uses an unusual set of jargon, doesn't say how it should be used, and doesn't say anything about itself.
> From what I can gather, it's hardcoded to generate 256 bit keys; so unless this blows RSA out of the water in terms of efficiency, it's either going to be too insecure to protect the small amount of sensitive data or too slow to protect the large amount of less-sensitive data.

It's elliptic curves, the short key lengths are an advantage over RSA
[1].

This is a straightforward port of the same API from NaCL, see [2] and
[3].
It is compatible with it, and you can check that it gives the same
results as the C code (besides the private key generation, everything is
deterministic).

This scheme has been designed by D.J. Bernstein and is generally
admitted to be good, but don't take my word for it...

The main issue IMO is generating good random bytes in pure Lua. After
discussing it with the author of PLC I just sent a pull request [4] that
removes key generation from the API, only exposing a function to deduce
a public key from a private key. You are expected to provide a private
key yourself, it should be 32 bytes with the best entropy possible.

I know it lacks documentation, we are not entirely sure on the final API
we want yet. Like I said for now I just copied the tweetnacl API.

But yeah, it's a 1 day old crypto code in a dynamic language, I wouldn't
trust it beyond what's reasonable. The disclaimer at the bottom of the
PLC readme applies [5].

[1] https://en.wikipedia.org/wiki/Elliptic_curve_cryptography#Key_sizes
[2] https://nacl.cr.yp.to/box.html 
[3]
https://download.libsodium.org/doc/public-key_cryptography/authenticated_encryption.html
[4] https://github.com/philanc/plc/pull/8
[5] https://github.com/philanc/plc#test-vectors-tests-and-disclaimer

--
Pierre Chapuis

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Xazo -Tak
At least no one knows how to crack one day old crypto code!
Also, it would be nice to have some usage documentation.
Even a small amount, enough to just know what to type to generate keys from a given set of bytes, and what to type to encrypt and decrypt.

On 13 August 2017 at 22:34, Pierre Chapuis <[hidden email]> wrote:
Same email as the previous one with the links fixed, sorry for the
noise...

On Sun, Aug 13, 2017, at 02:15, Xazo -Tak wrote:
> I'm guessing that box.lua (and what it requires) is the asymmetric encryption algorithm, but where is the documentation?
> It uses an unusual set of jargon, doesn't say how it should be used, and doesn't say anything about itself.
> From what I can gather, it's hardcoded to generate 256 bit keys; so unless this blows RSA out of the water in terms of efficiency, it's either going to be too insecure to protect the small amount of sensitive data or too slow to protect the large amount of less-sensitive data.

It's elliptic curves, the short key lengths are an advantage over RSA
[1].

This is a straightforward port of the same API from NaCL, see [2] and
[3].
It is compatible with it, and you can check that it gives the same
results as the C code (besides the private key generation, everything is
deterministic).

This scheme has been designed by D.J. Bernstein and is generally
admitted to be good, but don't take my word for it...

The main issue IMO is generating good random bytes in pure Lua. After
discussing it with the author of PLC I just sent a pull request [4] that
removes key generation from the API, only exposing a function to deduce
a public key from a private key. You are expected to provide a private
key yourself, it should be 32 bytes with the best entropy possible.

I know it lacks documentation, we are not entirely sure on the final API
we want yet. Like I said for now I just copied the tweetnacl API.

But yeah, it's a 1 day old crypto code in a dynamic language, I wouldn't
trust it beyond what's reasonable. The disclaimer at the bottom of the
PLC readme applies [5].
--
Pierre Chapuis


Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know a pure Lua assymmetric encryption library?

Pierre Chapuis
On Sun, Aug 13, 2017, at 12:58, Xazo -Tak wrote:
> At least no one knows how to crack one day old crypto code!
> Also, it would be nice to have some usage documentation.
> Even a small amount, enough to just know what to type to generate keys from a given set of bytes, and what to type to encrypt and decrypt.

Sure, we'll add that at some point. In the meantime, you can look at
test_box.lua.

Also I found a bug so I have to fix this first. Like I said, not ready
for prime time.

--
Pierre Chapuis

12