works except for large key sizes