A collection of cryptographic primitives for CC:Tweaked.
Find a file
2023-06-09 15:28:42 -03:00
.vscode Initial commit 2022-03-01 20:08:55 -03:00
ccryptolib Fix PBKDF2 password padding 2023-06-09 15:28:42 -03:00
spec Tag experimental function exports as experimental 2023-06-08 01:25:07 -03:00
LICENSE Create LICENSE 2023-06-08 01:26:25 -03:00
profile.lua Add a profiling program 2023-06-09 13:28:10 -03:00
README.md Add initialization instructions to README 2023-06-09 14:32:04 -03:00

CCryptoLib

An integrated collection of cryptographic primitives written in Lua using the ComputerCraft system API.

Initializing the Random Number Generator

All functions that take secret input may query the library's random generator, ccryptolib.random. CC doesn't have high-quality entropy sources, so instead of hoping for the best like other libraries do, CCryptoLib shifts that burden into you!

If you trust the tmpim Krist node, you can fetch a socket token and use it for initialization:

local random = require "ccryptolib.random"

-- Fetch a WebSocket token.
local postHandle = assert(http.post("https://krist.dev/ws/start", ""))
local data = textutils.unserializeJSON(postHandle.readAll())
postHandle.close()

-- Initialize the generator using the given URL.
random.init(data.url)

-- Be polite and actually open the socket too.
http.websocket(data.url).close()

Otherwise, you will need to find another high-quality random entropy source to initialize the generator. DO NOT INITIALIZE USING MATH.RANDOM.