Suppose that we create an instance
of KeyStore
like this :
private val ANDROID_KEYSTORE = "AndroidKeyStore"
val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE)
What is the best and secure way for set ANDROID_KEYSTORE
String
in code or it does not matter?
And for generate paramsBuilder
we use key name like this :
private fun createSecretKey(keyName: String){
val paramsBuilder= KeyGenParameterSpec.Builder(keyName,...)
}
What is the best name for choosing keyName
that we pass it in fun
how should we hold on or it does not matter?
It doesn't matter how you key track of/store your keyName
. It is not a security concern. You may as well save it as a constant in your source file.
This is generally called a Keystore alias, like in the documentation. When you generate a key in the keystore, you will have to specify an alias. You will have to use the same alias to refer/access the key at a later time.
As far as I know, there are two things to remember for aliases: