bouncycaSTLe - 如何将 JCE 算法名称转换为 AlgorithmIdentifier 对象?

标签 bouncycastle jce oid

我使用的是 BouncyCaSTLe 1.54。

我有一个 JCE 算法字符串 - 例如“ECDSAwithSHA256”。

我需要一个 org.bouncycaSTLe.asn1.x509.AlgorithmIdentifier 对象。

或者,我可以从 OID 创建 AlgorithmIdentifier 对象,但这引出了如何将算法字符串转换为 OID 的问题。

我可以创建一个巨大的 if/else,但必须有一个标准的方法来做到这一点。

最佳答案

您可以使用 BouncyCaSTLe 的算法查找器(请参阅 javadoc )

import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder;

AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find(signatureAlgorithm);
AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);

SHA256withECDSA 获取的 AlgorithmIdentifier OID(不是 ECDSAwithSHA256,请参阅 bouncycastle specifications)将为

1.2.840.10045.4.3.2
2.16.840.1.101.3.4.2.1

关于bouncycaSTLe - 如何将 JCE 算法名称转换为 AlgorithmIdentifier 对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38273270/

相关文章:

python - SNMP OID 解析器

c# - BouncyCaSTLe Open PGP - 流 47 中的未知对象

java - 在 Java 中使用 iaik_jce.jar 解密 pfx 或 p12 会抛出无法解密 PrivateKey!异常(exception)

java - 从私钥导出 ECDSA 公钥

java - 在 Openfire 上启用 AES-256 密码套件

java - 在没有 BouncyCaSTLe 的情况下用 Java 创建 X509 证书?

oracle - 使用瘦 JDBC 客户端通过 LDAP/OID 查找解决 Oracle SID 的问题

.net - Oracle 的 OID 服务、Oracle.DataAccess 和连接字符串

c# - 创建RSA公钥和私钥

java - BouncycaSTLe 签名数据消息中的附加八位字节字符串