summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/util-sha.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/util-sha.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/util-sha.lua35
1 files changed, 23 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-sha.lua b/Master/texmf-dist/tex/context/base/mkiv/util-sha.lua
index 3e786a834f6..d84e46975fa 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/util-sha.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/util-sha.lua
@@ -8,6 +8,13 @@ if not modules then modules = { } end modules ['util-sha'] = {
comment3 = "due to bit operators this code only works in lua(tex) 5.3",
}
+if sha2 then
+ if utilities then
+ utilities.sha2 = sha2
+ end
+ return sha2
+end
+
-- This doesn't work in luajittex ... maybe some day it will have bit operators too.
-- I'm not really in the mood for making this module aware (by compiling the
-- function depending on the engine that I use but I probably won't use luajittex in
@@ -277,10 +284,10 @@ digest[224] = digest[256]
digest[384] = digest[512]
local finalize = {
- [224] = function(hash,tohex) return tohex(packstring(">I4I4I4I4I4I4I4", unpack(hash))) end, -- # 56
- [256] = function(hash,tohex) return tohex(packstring(">I4I4I4I4I4I4I4I4",unpack(hash))) end, -- # 64
- [384] = function(hash,tohex) return tohex(packstring(">I8I8I8I8I8I8", unpack(hash))) end, -- # 96
- [512] = function(hash,tohex) return tohex(packstring(">I8I8I8I8I8I8I8I8",unpack(hash))) end, -- # 128
+ [224] = function(hash,tohex) local s = packstring(">I4I4I4I4I4I4I4", unpack(hash)) return tohex and tohex(s) or s end, -- # 56
+ [256] = function(hash,tohex) local s = packstring(">I4I4I4I4I4I4I4I4",unpack(hash)) return tohex and tohex(s) or s end, -- # 64
+ [384] = function(hash,tohex) local s = packstring(">I8I8I8I8I8I8", unpack(hash)) return tohex and tohex(s) or s end, -- # 96
+ [512] = function(hash,tohex) local s = packstring(">I8I8I8I8I8I8I8I8",unpack(hash)) return tohex and tohex(s) or s end, -- # 128
}
local hash = { }
@@ -293,14 +300,18 @@ local function hashed(str,method,tohex)
end
local sha2 = {
- hash224 = function(str) return hashed(str,224,tohex) end,
- hash256 = function(str) return hashed(str,256,tohex) end,
- hash384 = function(str) return hashed(str,384,tohex) end,
- hash512 = function(str) return hashed(str,512,tohex) end,
- HASH224 = function(str) return hashed(str,224,toHEX) end,
- HASH256 = function(str) return hashed(str,256,toHEX) end,
- HASH384 = function(str) return hashed(str,384,toHEX) end,
- HASH512 = function(str) return hashed(str,512,toHEX) end,
+ digest224 = function(str) return hashed(str,224) end,
+ digest256 = function(str) return hashed(str,256) end,
+ digest384 = function(str) return hashed(str,384) end,
+ digest512 = function(str) return hashed(str,512) end,
+ hash224 = function(str) return hashed(str,224,tohex) end,
+ hash256 = function(str) return hashed(str,256,tohex) end,
+ hash384 = function(str) return hashed(str,384,tohex) end,
+ hash512 = function(str) return hashed(str,512,tohex) end,
+ HASH224 = function(str) return hashed(str,224,toHEX) end,
+ HASH256 = function(str) return hashed(str,256,toHEX) end,
+ HASH384 = function(str) return hashed(str,384,toHEX) end,
+ HASH512 = function(str) return hashed(str,512,toHEX) end,
}
-- local setmetatableindex = table.setmetatableindex