Home | History | Annotate | Download | only in cms
      1 package org.bouncycastle.cms;
      2 
      3 import java.util.HashSet;
      4 import java.util.Set;
      5 
      6 import org.bouncycastle.asn1.DERNull;
      7 import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
      8 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
      9 import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
     10 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
     11 
     12 public class DefaultCMSSignatureEncryptionAlgorithmFinder
     13     implements CMSSignatureEncryptionAlgorithmFinder
     14 {
     15     private static final Set RSA_PKCS1d5 = new HashSet();
     16 
     17     static
     18     {
     19         // BEGIN android-removed
     20         // RSA_PKCS1d5.add(PKCSObjectIdentifiers.md2WithRSAEncryption);
     21         // RSA_PKCS1d5.add(PKCSObjectIdentifiers.md4WithRSAEncryption);
     22         // END android-removed
     23         RSA_PKCS1d5.add(PKCSObjectIdentifiers.md5WithRSAEncryption);
     24         RSA_PKCS1d5.add(PKCSObjectIdentifiers.sha1WithRSAEncryption);
     25         // BEGIN android-removed
     26         // RSA_PKCS1d5.add(PKCSObjectIdentifiers.sha224WithRSAEncryption);
     27         // END android-removed
     28         RSA_PKCS1d5.add(PKCSObjectIdentifiers.sha256WithRSAEncryption);
     29         RSA_PKCS1d5.add(PKCSObjectIdentifiers.sha384WithRSAEncryption);
     30         RSA_PKCS1d5.add(PKCSObjectIdentifiers.sha512WithRSAEncryption);
     31         // BEGIN android-removed
     32         // RSA_PKCS1d5.add(OIWObjectIdentifiers.md4WithRSAEncryption);
     33         // RSA_PKCS1d5.add(OIWObjectIdentifiers.md4WithRSA);
     34         // END android-removed
     35         RSA_PKCS1d5.add(OIWObjectIdentifiers.md5WithRSA);
     36         RSA_PKCS1d5.add(OIWObjectIdentifiers.sha1WithRSA);
     37         // BEGIN android-removed
     38         // RSA_PKCS1d5.add(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
     39         // RSA_PKCS1d5.add(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
     40         // RSA_PKCS1d5.add(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
     41         // END android-removed
     42     }
     43 
     44     public AlgorithmIdentifier findEncryptionAlgorithm(AlgorithmIdentifier signatureAlgorithm)
     45     {
     46                // RFC3370 section 3.2
     47         if (RSA_PKCS1d5.contains(signatureAlgorithm.getAlgorithm()))
     48         {
     49             return new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE);
     50         }
     51 
     52         return signatureAlgorithm;
     53     }
     54 }
     55