Updated keystore code to rely more on duck typing

Rather than enforce static type constraints on function parameters, I've
changed the code in some methods to rely on duck typing.