const int align_offset)
 {
        const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm));
+       size_t digest_size = crypto_ahash_digestsize(tfm);
        unsigned int i, j, k, temp;
        struct scatterlist sg[8];
        char *result;
        char *xbuf[XBUFSIZE];
        int ret = -ENOMEM;
 
-       result = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
+       result = kmalloc(digest_size, GFP_KERNEL);
        if (!result)
                return ret;
        key = kmalloc(MAX_KEYLEN, GFP_KERNEL);
                        goto out;
 
                j++;
-               memset(result, 0, MAX_DIGEST_SIZE);
+               memset(result, 0, digest_size);
 
                hash_buff = xbuf[0];
                hash_buff += align_offset;
                        continue;
 
                j++;
-               memset(result, 0, MAX_DIGEST_SIZE);
+               memset(result, 0, digest_size);
 
                temp = 0;
                sg_init_table(sg, template[i].np);
                        continue;
 
                j++;
-               memset(result, 0, MAX_DIGEST_SIZE);
+               memset(result, 0, digest_size);
 
                ret = -EINVAL;
                hash_buff = xbuf[0];