Я играю с BouncyCastle 1.46 К моему удивлению, блокировщик в приведенном ниже фрагменте срабатывает довольно часто. .
Security.addProvider(new BouncyCastleProvider());
final Set<String> found = new HashSet<String>();
final Set<String> missing = new HashSet<String>();
final DefaultSignatureAlgorithmIdentifierFinder finder = new DefaultSignatureAlgorithmIdentifierFinder();
for (Service service : new BouncyCastleProvider().getServices()) {
if ("Signature".equals(service.getType())) {
final String algorithm = service.getAlgorithm();
try {
finder.find(algorithm);
found.add(algorithm);
} catch (IllegalArgumentException ex) {
missing.add(algorithm);
}
}
}
System.out.println("Found: " + found);
System.out.println("Missing: " + missing);
Кажется, я не могу использовать большинство алгоритмов через Finder, хотя существуют службы, которые предоставляют эти алгоритмы. Что я делаю неправильно?
Обновление Я немного изменил код, чтобы лучше проиллюстрировать проблему. Что может быть интересно, так это то, что я использую версию BouncyCastle для JDK1.5. Приведенный выше код дает следующий результат:
Найдено: [RIPEMD256WithRSAEncryption, MD5WithRSAEncryption, MD2WithRSAEncryption, SHA384WithRSAEncryption, SHA224WITHECDSA, SHA384WITHDSA, SHA256WITHDSA, SHA512WithRSAEncryption, SHA512WITHDSA, RIPEMD160WithRSAEncryption, SHA224WithRSAEncryption, SHA256WITHECDSA, RIPEMD128WithRSAEncryption, SHA384WITHECDSA, SHA256WithRSAEncryption, SHA512WITHECDSA, SHA1WithRSAEncryption, SHA224WITHDSA]
Отсутствующие: [SHA1WITHECNR, NONEwithECDSA, ECDSA, SHA512withRSA / PSS, RIPEMD160WITHECDSA, RSA, GOST3410, SHA256WITHECNR, MD5withRSA / ISO9796-2, SHA1WITHCVC-ECDSA, SHA384withRSA / PSS, SHA1withRSA / PSS, MD4WithRSAEncryption, RSASSA-PSS, SHA512WITHECNR, SHA256WITHCVC-ECDSA , SHA1 с RSA / ISO9796-2, SHA224 с RSA / PSS, SHA224WITHCVC-ECDSA, RAWRSASSA-PSS, SHA256 с RSA / PSS, NONEWITHDSA, SHA384WITHECNR, RIPEMD160 с RSA / ISO9796-249, DSA / ISO976-224, DSA / ISO1201-224, 1.2.810.140.140.124, ECM.
service.getAlgorithm()
? - person Óscar López   schedule 08.01.2012