Add null check to getSecretKeyType