Android KeyStore private exponent cannot be extracted

谁说我不能喝 提交于 2019-12-03 02:42:00

According to the code, I think that the OpenSSL provider prevents the private exponent to be exported when the key has been generated into the device.

@Override
public final BigInteger getPrivateExponent() {
    if (key.isEngineBased()) {
        throw new UnsupportedOperationException("private exponent cannot be extracted");
    }

    ensureReadParams();
    return privateExponent;
}

Thus, you probably need to specify that you want to use the same crypto provider when retrieving the cipher instance. This provider supports these RSA ciphers:

  • RSA/ECB/NoPadding
  • RSA/ECB/PKCS1Padding

You should create an instance of the cipher this way:

Cipher cipher1 = Cipher.getInstance("RSA/ECB/PKCS1Padding", "AndroidOpenSSL");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!