Make 'i' and 'len' the same type as 'digestlen'

Because they're being compared to it.  Fixes #561