내가 놀고있어 BouncyCastle 1.46 놀랍게도 아래의 스 니펫에있는 catch 블록은 매우 자주 트립됩니다.BouncyCastle은 제공하는 알고리즘을 찾지 못합니까?
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, SHA1withRSA/ISO9796-2, SHA224withRSA/PSS, SHA224WITHCVC-ECDSA, RAWRSASS A-PSS, SHA256withRSA/PSS, NONEWITHDSA, SHA384WITHECNR, RIPEMD160withRSA/ISO9796-2, DSA, ECGOST3410, SHA224WITHECNR, 1.2.840.113549.1.1.10]
디버깅하여'service.getAlgorithm()'에 반환되는 것을 질문에 추가 할 수 있습니까? –
오스카 : 방금했습니다. – Guus