|
36 | 36 | import java.util.Set;
|
37 | 37 |
|
38 | 38 | import java.security.GeneralSecurityException;
|
39 |
| -import java.security.InvalidKeyException; |
40 |
| -import java.security.NoSuchAlgorithmException; |
41 | 39 | import java.security.PrivateKey;
|
42 | 40 | import java.security.PublicKey;
|
43 |
| -import java.security.SignatureException; |
44 | 41 | import java.security.cert.CRLException;
|
45 | 42 | import java.security.cert.CertificateFactory;
|
46 | 43 | import java.security.cert.X509CRLEntry;
|
|
60 | 57 | import org.bouncycastle.asn1.DERSequence;
|
61 | 58 | import org.bouncycastle.asn1.DLSequence;
|
62 | 59 | import org.bouncycastle.asn1.x500.X500Name;
|
63 |
| -import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
64 |
| -import org.bouncycastle.asn1.x509.CertificateList; |
65 | 60 | import org.bouncycastle.asn1.x509.Extension;
|
66 | 61 | import org.bouncycastle.asn1.x509.Extensions;
|
67 | 62 | import org.bouncycastle.cert.CertException;
|
|
71 | 66 | import org.bouncycastle.crypto.params.DSAParameters;
|
72 | 67 | import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
|
73 | 68 | import org.bouncycastle.crypto.params.RSAKeyParameters;
|
74 |
| -import org.bouncycastle.jce.provider.X509CRLObject; |
75 | 69 | import org.bouncycastle.operator.ContentSigner;
|
76 |
| -import org.bouncycastle.operator.ContentVerifier; |
77 | 70 | import org.bouncycastle.operator.ContentVerifierProvider;
|
78 | 71 | import org.bouncycastle.operator.DefaultDigestAlgorithmIdentifierFinder;
|
79 | 72 | import org.bouncycastle.operator.DigestAlgorithmIdentifierFinder;
|
@@ -671,7 +664,8 @@ private String getSignatureAlgorithm(final Ruby runtime, final PKey key, final D
|
671 | 664 | final String digAlg = digest.getShortAlgorithm();
|
672 | 665 |
|
673 | 666 | if ( "DSA".equalsIgnoreCase(keyAlg) ) {
|
674 |
| - if ( ( "MD5".equalsIgnoreCase( digAlg ) ) ) { |
| 667 | + if ( ( "MD5".equalsIgnoreCase( digAlg ) ) ) { // || |
| 668 | + // ( "SHA1".equals( digest.name().toString() ) ) ) { |
675 | 669 | throw newCRLError(runtime, "unsupported key / digest algorithm ("+ key +" / "+ digAlg +")");
|
676 | 670 | }
|
677 | 671 | }
|
@@ -745,38 +739,8 @@ public IRubyObject verify(final ThreadContext context, final IRubyObject key) {
|
745 | 739 | debug("CRL#verify() failed:", e);
|
746 | 740 | return context.runtime.getFalse();
|
747 | 741 | }
|
748 |
| -// catch (SignatureException e) { |
749 |
| -// debug("CRL#verify() failed:", e); |
750 |
| -// return context.runtime.getFalse(); |
751 |
| -// } |
752 |
| -// catch (NoSuchAlgorithmException e) { |
753 |
| -// return context.runtime.getFalse(); |
754 |
| -// } |
755 | 742 | }
|
756 | 743 |
|
757 |
| - /* |
758 |
| - private static boolean verify(final CertificateList crl, final PublicKey publicKey) |
759 |
| - throws CRLException, InvalidKeyException, SignatureException, NoSuchAlgorithmException { |
760 |
| -
|
761 |
| - final AlgorithmIdentifier tbsSignatureId = crl.getTBSCertList().getSignature(); |
762 |
| - if ( ! crl.getSignatureAlgorithm().equals( tbsSignatureId ) ) { |
763 |
| - if ( true ) return false; |
764 |
| - //throw new CRLException("Signature algorithm on CertificateList does not match TBSCertList."); |
765 |
| - } |
766 |
| -
|
767 |
| - final String sigAlgName = X509SignatureUtil.getSignatureName(crl.getSignatureAlgorithm()); |
768 |
| - final Signature signature = SecurityHelper.getSignature(sigAlgName, securityProvider); |
769 |
| -
|
770 |
| - signature.initVerify(publicKey); |
771 |
| - signature.update(crl.getTBSCertList()); |
772 |
| -
|
773 |
| - if ( ! signature.verify( crl.getSignature() ) ) { |
774 |
| - if ( true ) return false; |
775 |
| - //throw new SignatureException("CRL does not verify with supplied public key."); |
776 |
| - } |
777 |
| - return true; |
778 |
| - } */ |
779 |
| - |
780 | 744 | private static RubyClass _CRLError(final Ruby runtime) {
|
781 | 745 | return _X509(runtime).getClass("CRLError");
|
782 | 746 | }
|
|
0 commit comments