Page MenuHomeFreeBSD

flua: Add hash module
ClosedPublic

Authored by imp on Feb 13 2024, 10:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 14, 3:34 AM
Unknown Object (File)
Sep 20 2024, 2:30 PM
Unknown Object (File)
Sep 20 2024, 7:47 AM
Unknown Object (File)
Sep 19 2024, 8:53 PM
Unknown Object (File)
Sep 19 2024, 5:38 PM
Unknown Object (File)
Sep 17 2024, 3:05 AM
Unknown Object (File)
Sep 5 2024, 6:47 AM
Unknown Object (File)
Aug 12 2024, 11:42 PM
Subscribers
None

Details

Summary

Add the hash module, and the sha256 method. We support creation,
update(), digest(), and hexdigest() methods that are all thin wrappers
on SHA256_Init(), SHA256_Update(), SHA256_Final() and SHA256_End()
respectively. update() returns the underlying object so it can be chained:
hash.sha256():update("F"):update("r"):update("e"):update("d"):hexdigest()
is the same as hash.sha256("Fred"):hexdigest().

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

imp requested review of this revision.Feb 13 2024, 10:38 PM
imp created this revision.

Don't use SHA256_End. We don't have it in the boot laoder
and it's way easier to expand that inline than hook that file
into the build.

libexec/flua/Makefile
21 ↗(On Diff #134281)

Do you envision needing this in bootstrap flua, or would it be OK to move this out to it's own module (lib/flua/libhash)? The only requirement on a module is that it exports its luaopen_*() that matches the module's name and be installed in the right spot, then it should Just Work(TM).

libexec/flua/modules/lhash.c
40 ↗(On Diff #134281)

It would perhaps be a bit more efficient to instead lua_settop(L, 1) to trim the stack back to the context

131 ↗(On Diff #134281)

This and the statement after can be combined into a single luaL_setmetatable(L, SHA256_META) (it will set it for the object at the top of the stack)

libexec/flua/Makefile
21 ↗(On Diff #134281)

I'll have to give that a try. I'll have to change how I'm building the loader patch, but that's ok...

imp marked 2 inline comments as done.Feb 14 2024, 5:25 AM
imp retitled this revision from flua: Add hash module and support sha256 to flua: Add hash module.
This revision was not accepted when it landed; it landed in state Needs Review.Feb 16 2024, 4:01 AM
Closed by commit rGf7781d030ccd: flua: Add hash module (authored by imp). · Explain Why
This revision was automatically updated to reflect the committed changes.