Dim alias As String = "Test"
Dim Keysize As Int = 512
Dim KeyProperties As JavaObject
KeyProperties.InitializeStatic("android.security.keystore.KeyProperties")
Dim builder As JavaObject
builder.InitializeNewInstance("android.security.keystore.KeyGenParameterSpec.Builder", _
Array(alias, Bit.Or(KeyProperties.GetField("PURPOSE_SIGN"), KeyProperties.GetField("PURPOSE_VERIFY"))))
builder.RunMethod("setDigests", Array(Array As String(KeyProperties.GetField("DIGEST_SHA256"), KeyProperties.GetField("DIGEST_SHA512"))))
builder.RunMethod("setKeySize", Array(Keysize))
Dim kpg As JavaObject
kpg = kpg.InitializeStatic("java.security.KeyPairGenerator").RunMethod("getInstance", Array("RSA", "AndroidKeyStore"))
kpg.RunMethod("initialize", Array(builder.RunMethod("build", Null)))
Dim KeyPair As JavaObject = kpg.RunMethod("generateKeyPair", Null)
Dim keystore As JavaObject
keystore = keystore.InitializeStatic("java.security.KeyStore").RunMethod("getInstance", Array("AndroidKeyStore"))
keystore.RunMethod("load", Array(Null))
Dim entry As JavaObject = keystore.RunMethod("getEntry", Array(alias, Null))
Dim PrivateKey As JavaObject = entry.RunMethod("getPrivateKey", Null)
Dim PublicKey As JavaObject = keystore.RunMethodJO("getCertificate", Array(alias)).RunMethod("getPublicKey", Null)