Is this really a ValueError? The user doesn't control the algorithm types digest size, they just choose what type it is. Having said that I'm not sure TypeError is the best choice either.