Fixed issue where invalid key lengths were throwing ArrayIndexOutOfBoundsException