somesocks / lua-lockbox

A collection of cryptographic primitives written in pure Lua
MIT License
362 stars 75 forks source link

Replacing existing library/modules with lockbox #28

Closed nodecentral closed 3 years ago

nodecentral commented 3 years ago

Hi

I’m trying to replace some proprietary modules with something open-source, and was wondering which ones could lockbox replace for me. Below are the modules/functions current called in the code I’m using..

lmcore.strtohex(decrypted) 
lmcore.hextostr('15C95AC2B08AA7EB4E228F811E34D04FA54BA7DCAC9879FA8ACDA3FC244F3854', true)
aes_cbc:decrypt(encdec.base64dec(data))
aes_cbc:encrypt(payload)
encdec.hmacsha256(ciphertext, hmac_key, true)
encdec.base64enc(ciphertext .. sig)

I’ve got a replacement for the base64 one from here - http://lua-users.org/wiki/BaseSixtyFour

somesocks commented 3 years ago

Hi @nodecentral,

I think the lockbox should have everything you need, it has implementations of AES-128/192/256, CBC, HMAC, and SHA-256. It also has utils for base64 <-> bytes, hex <-> bytes, and string <-> bytes conversions.

You should look in the test cases for examples on how to set up and use AES+CBC and HMAC+SHA256