static const struct hash_method hash_method_size = {
.name = "size",
+ .block_size = 1,
.context_size = sizeof(uint64_t),
.digest_size = sizeof(uint64_t),
struct hash_method {
const char *name;
+ /* Block size for the algorithm */
+ unsigned int block_size;
/* Number of bytes that must be allocated for context */
unsigned int context_size;
/* Number of bytes that must be allocated for result()'s digest */
const struct hash_method hash_method_md4 = {
.name = "md4",
+ .block_size = 64, /* block size is 512 bits */
.context_size = sizeof(struct md4_context),
.digest_size = MD4_RESULTLEN,
const struct hash_method hash_method_md5 = {
.name = "md5",
+ .block_size = 64, /* block size is 512 bits */
.context_size = sizeof(struct md5_context),
.digest_size = MD5_RESULTLEN,
const struct hash_method hash_method_sha1 = {
.name = "sha1",
+ .block_size = 64, /* block size is 512 bits */
.context_size = sizeof(struct sha1_ctxt),
.digest_size = SHA1_RESULTLEN,
const struct hash_method hash_method_sha256 = {
.name = "sha256",
+ .block_size = SHA256_BLOCK_SIZE,
.context_size = sizeof(struct sha256_ctx),
.digest_size = SHA256_RESULTLEN,
const struct hash_method hash_method_sha512 = {
.name = "sha512",
+ .block_size = SHA512_BLOCK_SIZE,
.context_size = sizeof(struct sha512_ctx),
.digest_size = SHA512_RESULTLEN,
const struct hash_method hash_method_sha3_256 = {
.name = "sha3-256",
+ .block_size = SHA256_BLOCK_SIZE,
.context_size = sizeof(struct sha3_ctx),
.digest_size = SHA256_RESULTLEN,
const struct hash_method hash_method_sha3_512 = {
.name = "sha3-512",
+ .block_size = SHA512_BLOCK_SIZE,
.context_size = sizeof(struct sha3_ctx),
.digest_size = SHA512_RESULTLEN,