我正在使用 BouncyCastle 1.54。
我有一个 JCE 算法字符串 - 例如“ECDSAwithSHA256”。
我需要一个 org.bouncycastle.asn1.x509.AlgorithmIdentifier 对象。
或者,我可以从 OID 创建 AlgorithmIdentifier 对象,但这引出了如何将算法字符串转换为 OID 的问题。
我可以创建一个巨大的 if/else,但必须有一个标准的方法来做到这一点。
您可以使用 BouncyCastle 的算法查找器(请参阅javadoc https://www.bouncycastle.org/docs/pkixdocs1.5on/index.html?org/bouncycastle/operator/DefaultSignatureAlgorithmIdentifierFinder.html)
import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder;
AlgorithmIdentifier sigAlgId = new DefaultSignatureAlgorithmIdentifierFinder().find(signatureAlgorithm);
AlgorithmIdentifier digAlgId = new DefaultDigestAlgorithmIdentifierFinder().find(sigAlgId);
The AlgorithmIdentifier
获得的 OID 用于SHA256withECDSA
(not ECDSAwithSHA256
, see 充气城堡规格 https://bouncycastle.org/specifications.html) 将
1.2.840.10045.4.3.2
2.16.840.1.101.3.4.2.1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)