Skip to content

Commit

Permalink
Merge pull request #1 from migeyel/develop
Browse files Browse the repository at this point in the history
Various fixes
  • Loading branch information
migeyel authored Jul 19, 2023
2 parents 0a23090 + 91e6f32 commit 9d79439
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ccryptolib/internal/packing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if not string.pack or pcall(string.dump, string.pack) then
local w = {}
for i in fmt:gmatch("I([%d]+)") do
local n = tonumber(i) or 4
assert(n > 0 and n <= 4, "integral size out of limits")
assert(n > 0 and n <= 16, "integral size out of limits")
w[#w + 1] = n
end
return fn(w, e == ">")
Expand Down
3 changes: 2 additions & 1 deletion ccryptolib/random.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ end
--- Mixes extra entropy into the generator state.
--- @param data string The additional entropy to mix.
local function mix(data)
expect(1, data, "string")
state = blake3.digestKeyed(state, data)
end

Expand All @@ -39,7 +40,7 @@ end
local function random(len)
expect(1, len, "number")
lassert(initialized, "attempt to use an uninitialized random generator", 2)
local msg = ("\0"):rep(len + 32)
local msg = ("\0"):rep(math.max(len, 0) + 32)
local nonce = ("\0"):rep(12)
local out = chacha20.crypt(state, nonce, msg, 8, 0)
state = out:sub(1, 32)
Expand Down
2 changes: 1 addition & 1 deletion ccryptolib/util.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--- General utilities for handling byte strings.

local expect = require "cc.expect".expect
local random = require "cryptolib.random"
local random = require "ccryptolib.random"
local poly1305 = require "ccryptolib.poly1305"

--- Returns the hexadecimal version of a string.
Expand Down

0 comments on commit 9d79439

Please sign in to comment.