From 773ef1f7414e60dfdd3a3ea73b89d9deda5e74d4 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 3 May 2016 10:51:36 +0100 Subject: [PATCH] [Feature] Allow partial hash updates --- src/lua/lua_cryptobox.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index b95b1f2f6..7f267fe71 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -662,6 +662,17 @@ lua_cryptobox_hash_update (lua_State *L) data = luaL_checklstring (L, 2, &len); } + if (lua_isnumber (L, 3)) { + gsize nlen = lua_tonumber (L, 3); + + if (nlen > len) { + return luaL_error (L, "invalid length: %d while %d is available", + (int)nlen, (int)len); + } + + len = nlen; + } + if (h && data) { rspamd_cryptobox_hash_update (h, data, len); } -- 2.39.5