如何将带有私有 DSA 密钥(4096 位)的 DER 文件读入 AsymmetricKeyParameter 以在 DSASigner 中使用?
我尝试了以下代码:
byte[] privateKeyBytes = FileUtils.readFileToByteArray(new File(
"sign-key-private.der"));
AsymmetricKeyParameter privateKey = PrivateKeyFactory
.createKey(privateKeyBytes);
结果是一个例外:
java.lang.IllegalArgumentException: unknown object in getInstance: org.bouncycastle.asn1.ASN1Integer
at org.bouncycastle.asn1.ASN1Sequence.getInstance(Unknown Source)
at org.bouncycastle.asn1.x509.AlgorithmIdentifier.getInstance(Unknown Source)
at org.bouncycastle.asn1.pkcs.PrivateKeyInfo.<init>(Unknown Source)
at org.bouncycastle.asn1.pkcs.PrivateKeyInfo.getInstance(Unknown Source)
at org.bouncycastle.crypto.util.PrivateKeyFactory.createKey(Unknown Source)
at test.security.core.Program.main(Program.java:41)