improve the generator code documentation, and be more consitent with the bytes/bits
This commit is contained in:
parent
fb40e72be4
commit
f3edfc70f1
54
gen/Gen.hs
54
gen/Gen.hs
@ -13,34 +13,34 @@ data GenHashModule = GenHashModule
|
||||
{ ghmModuleName :: String
|
||||
, ghmHeaderFile :: String
|
||||
, ghmHashName :: String
|
||||
, ghmContextSize :: Int
|
||||
, ghmDigestSize :: Int
|
||||
, ghmBlockLength :: Int
|
||||
, ghmCustomizable :: [(Int, Int)]
|
||||
, ghmContextSize :: Int -- in bytes
|
||||
, ghmDigestSize :: Int -- in bytes
|
||||
, ghmBlockLength :: Int -- in bytes
|
||||
, ghmCustomizable :: [(Int, Int)] -- list of (digest output size in *bits*, block size in bytes)
|
||||
} deriving (Show,Eq)
|
||||
|
||||
hashModules =
|
||||
-- module header hash ctx dg blk
|
||||
[ GenHashModule "BLAKE2s" "blake2.h" "blake2s" 185 32 64 []
|
||||
, GenHashModule "BLAKE2sp" "blake2.h" "blake2sp" 2185 32 64 []
|
||||
, GenHashModule "BLAKE2b" "blake2.h" "blake2b" 361 64 128 []
|
||||
, GenHashModule "BLAKE2bp" "blake2.h" "blake2sp" 2325 64 128 []
|
||||
, GenHashModule "MD2" "md2.h" "md2" 96 16 16 []
|
||||
, GenHashModule "MD4" "md4.h" "md4" 96 16 64 []
|
||||
, GenHashModule "MD5" "md5.h" "md5" 96 16 64 []
|
||||
, GenHashModule "SHA1" "sha1.h" "sha1" 96 20 64 []
|
||||
, GenHashModule "SHA224" "sha256.h" "sha224" 192 28 64 []
|
||||
, GenHashModule "SHA256" "sha256.h" "sha256" 192 32 64 []
|
||||
, GenHashModule "SHA384" "sha512.h" "sha384" 256 48 128 []
|
||||
, GenHashModule "SHA512" "sha512.h" "sha512" 256 64 128 []
|
||||
, GenHashModule "SHA512t" "sha512.h" "sha512t" 264 64 128 [(224,128),(256,128)]
|
||||
, GenHashModule "Keccak" "keccak.h" "keccak" 360 64 64 [(224,144),(256,136),(384,104),(512,72)]
|
||||
, GenHashModule "SHA3" "sha3.h" "sha3" 360 64 64 [(224,144),(256,136),(384,104),(512,72)]
|
||||
, GenHashModule "RIPEMD160" "ripemd.h" "ripemd160" 128 20 64 []
|
||||
, GenHashModule "Skein256" "skein256.h" "skein256" 96 32 32 [(224,32),(256,32)]
|
||||
, GenHashModule "Skein512" "skein512.h" "skein512" 160 64 64 [(224,64),(256,64),(384,64),(512,64)]
|
||||
, GenHashModule "Tiger" "tiger.h" "tiger" 96 24 64 []
|
||||
, GenHashModule "Whirlpool" "whirlpool.h" "whirlpool" 168 64 64 []
|
||||
[ GenHashModule "BLAKE2s" "blake2.h" "blake2s" 185 256 64 []
|
||||
, GenHashModule "BLAKE2sp" "blake2.h" "blake2sp" 2185 256 64 []
|
||||
, GenHashModule "BLAKE2b" "blake2.h" "blake2b" 361 512 128 []
|
||||
, GenHashModule "BLAKE2bp" "blake2.h" "blake2sp" 2325 512 128 []
|
||||
, GenHashModule "MD2" "md2.h" "md2" 96 128 16 []
|
||||
, GenHashModule "MD4" "md4.h" "md4" 96 128 64 []
|
||||
, GenHashModule "MD5" "md5.h" "md5" 96 128 64 []
|
||||
, GenHashModule "SHA1" "sha1.h" "sha1" 96 160 64 []
|
||||
, GenHashModule "SHA224" "sha256.h" "sha224" 192 224 64 []
|
||||
, GenHashModule "SHA256" "sha256.h" "sha256" 192 256 64 []
|
||||
, GenHashModule "SHA384" "sha512.h" "sha384" 256 384 128 []
|
||||
, GenHashModule "SHA512" "sha512.h" "sha512" 256 512 128 []
|
||||
, GenHashModule "SHA512t" "sha512.h" "sha512t" 264 512 128 [(224,128),(256,128)]
|
||||
, GenHashModule "Keccak" "keccak.h" "keccak" 360 512 64 [(224,144),(256,136),(384,104),(512,72)]
|
||||
, GenHashModule "SHA3" "sha3.h" "sha3" 360 512 64 [(224,144),(256,136),(384,104),(512,72)]
|
||||
, GenHashModule "RIPEMD160" "ripemd.h" "ripemd160" 128 160 64 []
|
||||
, GenHashModule "Skein256" "skein256.h" "skein256" 96 256 32 [(224,32),(256,32)]
|
||||
, GenHashModule "Skein512" "skein512.h" "skein512" 160 512 64 [(224,64),(256,64),(384,64),(512,64)]
|
||||
, GenHashModule "Tiger" "tiger.h" "tiger" 96 192 64 []
|
||||
, GenHashModule "Whirlpool" "whirlpool.h" "whirlpool" 168 512 64 []
|
||||
]
|
||||
|
||||
renderHashModules genOpts = do
|
||||
@ -54,13 +54,13 @@ renderHashModules genOpts = do
|
||||
-- context size (compat)
|
||||
, ("SIZECTX" , show (ghmContextSize ghm))
|
||||
, ("SIZECTX8" , show (ghmContextSize ghm `div` 8))
|
||||
, ("DIGESTSIZE" , show (ghmDigestSize ghm))
|
||||
, ("DIGESTSIZE" , show (ghmDigestSize ghm `div` 8))
|
||||
, ("BLOCKLEN" , show (ghmBlockLength ghm))
|
||||
-- context size
|
||||
, ("CTX_SIZE_BYTES" , show (ghmContextSize ghm))
|
||||
, ("CTX_SIZE_WORD64" , show (ghmContextSize ghm `div` 8))
|
||||
, ("DIGEST_SIZE_BITS" , show (ghmDigestSize ghm * 8))
|
||||
, ("DIGEST_SIZE_BYTES", show (ghmDigestSize ghm))
|
||||
, ("DIGEST_SIZE_BITS" , show (ghmDigestSize ghm))
|
||||
, ("DIGEST_SIZE_BYTES", show (ghmDigestSize ghm `div` 8))
|
||||
, ("BLOCK_SIZE_BYTES" , show (ghmBlockLength ghm))
|
||||
] :: Attrs
|
||||
let mainDir = "Crypto/Hash"
|
||||
|
||||
@ -20,9 +20,9 @@ data %%MODULENAME%% = %%MODULENAME%%
|
||||
deriving (Show)
|
||||
|
||||
instance HashAlgorithm %%MODULENAME%% where
|
||||
hashBlockSize _ = %%BLOCKLEN%%
|
||||
hashDigestSize _ = %%DIGESTSIZE%%
|
||||
hashInternalContextSize _ = %%SIZECTX%%
|
||||
hashBlockSize _ = %%BLOCK_SIZE_BYTES%%
|
||||
hashDigestSize _ = %%DIGEST_SIZE_BYTES%%
|
||||
hashInternalContextSize _ = %%CTX_SIZE_BYTES%%
|
||||
hashInternalInit = c_%%HASHNAME%%_init
|
||||
hashInternalUpdate = c_%%HASHNAME%%_update
|
||||
hashInternalFinalize = c_%%HASHNAME%%_finalize
|
||||
|
||||
Loading…
Reference in New Issue
Block a user