/*** * @method cryptobox_hash:base32() * Finalizes hash and return it as zbase32 string * @return {string} base32 value of hash */ static gint lua_cryptobox_hash_base32 (lua_State *L) { struct rspamd_lua_cryptobox_hash *h = lua_check_cryptobox_hash (L, 1); guchar out[rspamd_cryptobox_HASHBYTES], out_b32[rspamd_cryptobox_HASHBYTES * 2]; guint dlen; if (h && !h->is_finished) { memset (out_b32, 0, sizeof (out_b32)); if (h->is_ssl) { dlen = sizeof (out); EVP_DigestFinal_ex (h->c, out, &dlen); } else { dlen = sizeof (out); rspamd_cryptobox_hash_final (h->h, out); } rspamd_encode_base32_buf (out, dlen, out_b32, sizeof (out_b32)); lua_pushstring (L, out_b32); h->is_finished = TRUE; } else { return luaL_error (L, "invalid arguments"); } return 1; }
/*** * @method cryptobox_hash:base32() * Finalizes hash and return it as zbase32 string * @return {string} base32 value of hash */ static gint lua_cryptobox_hash_base32 (lua_State *L) { rspamd_cryptobox_hash_state_t *h = lua_check_cryptobox_hash (L, 1); guchar out[rspamd_cryptobox_HASHBYTES], out_b32[rspamd_cryptobox_HASHBYTES * 2]; if (h) { memset (out_b32, 0, sizeof (out_b32)); rspamd_cryptobox_hash_final (h, out); rspamd_encode_base32_buf (out, sizeof (out), out_b32, sizeof (out_b32)); lua_pushstring (L, out_b32); } else { return luaL_error (L, "invalid arguments"); } return 1; }