• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/ASN1InputStream.java bcprov-jdk16-146/org/bouncycastle/asn1/ASN1InputStream.java
2--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/ASN1InputStream.java	2011-02-23 20:08:56.000000000 +0000
3+++ bcprov-jdk16-146/org/bouncycastle/asn1/ASN1InputStream.java	2011-09-08 21:28:50.000000000 +0000
4@@ -363,7 +363,9 @@
5             case BMP_STRING:
6                 return new DERBMPString(bytes);
7             case BOOLEAN:
8-                return new ASN1Boolean(bytes);
9+                // BEGIN android-changed
10+                return DERBoolean.getInstance(bytes);
11+                // END android-changed
12             case ENUMERATED:
13                 return new ASN1Enumerated(bytes);
14             case GENERALIZED_TIME:
15diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/ASN1Null.java bcprov-jdk16-146/org/bouncycastle/asn1/ASN1Null.java
16--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/ASN1Null.java	2011-02-23 20:08:56.000000000 +0000
17+++ bcprov-jdk16-146/org/bouncycastle/asn1/ASN1Null.java	2011-09-08 21:28:50.000000000 +0000
18@@ -8,9 +8,11 @@
19 public abstract class ASN1Null
20     extends ASN1Object
21 {
22-    public ASN1Null()
23+    // BEGIN android-changed
24+    /*package*/ ASN1Null()
25     {
26     }
27+    // END android-changed
28
29     public int hashCode()
30     {
31diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERBoolean.java bcprov-jdk16-146/org/bouncycastle/asn1/DERBoolean.java
32--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERBoolean.java	2011-02-23 20:08:56.000000000 +0000
33+++ bcprov-jdk16-146/org/bouncycastle/asn1/DERBoolean.java	2011-09-08 21:28:50.000000000 +0000
34@@ -5,7 +5,9 @@
35 public class DERBoolean
36     extends ASN1Object
37 {
38-    byte         value;
39+    // BEGIN android-changed
40+    private final byte  value;
41+    // END android-changed
42
43     public static final DERBoolean FALSE = new DERBoolean(false);
44     public static final DERBoolean TRUE  = new DERBoolean(true);
45@@ -35,6 +37,17 @@
46         return (value ? TRUE : FALSE);
47     }
48
49+    // BEGIN android-added
50+    /**
51+     * return a DERBoolean from the passed in array.
52+     */
53+    public static DERBoolean getInstance(
54+        byte[] octets)
55+    {
56+        return (octets[0] != 0) ? TRUE : FALSE;
57+    }
58+    // END android-added
59+
60     /**
61      * return a Boolean from a tagged object.
62      *
63@@ -56,23 +69,29 @@
64         }
65         else
66         {
67-            return new DERBoolean(((ASN1OctetString)o).getOctets());
68+            // BEGIN android-changed
69+            return getInstance(((ASN1OctetString)o).getOctets());
70+            // END android-changed
71         }
72     }
73
74-    public DERBoolean(
75-        byte[]       value)
76-    {
77-        if (value.length != 1)
78-        {
79-            throw new IllegalArgumentException("byte value should have 1 byte in it");
80-        }
81-
82-        this.value = value[0];
83-    }
84+    // BEGIN android-removed
85+    // public DERBoolean(
86+    //     byte[]       value)
87+    // {
88+    //     if (value.length != 1)
89+    //     {
90+    //         throw new IllegalArgumentException("byte value should have 1 byte in it");
91+    //     }
92+    //
93+    //     this.value = value[0];
94+    // }
95+    // END android-removed
96
97-    public DERBoolean(
98+    // BEGIN android-changed
99+    protected DERBoolean(
100         boolean     value)
101+    // END android-changed
102     {
103         this.value = (value) ? (byte)0xff : (byte)0;
104     }
105diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERNull.java bcprov-jdk16-146/org/bouncycastle/asn1/DERNull.java
106--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERNull.java	2011-02-23 20:08:56.000000000 +0000
107+++ bcprov-jdk16-146/org/bouncycastle/asn1/DERNull.java	2011-09-08 21:28:50.000000000 +0000
108@@ -10,9 +10,13 @@
109 {
110     public static final DERNull INSTANCE = new DERNull();
111
112-    byte[]  zeroBytes = new byte[0];
113+    // BEGIN android-changed
114+    private static final byte[]  zeroBytes = new byte[0];
115+    // END android-changed
116
117-    public DERNull()
118+    // BEGIN android-changed
119+    protected DERNull()
120+    // END android-changed
121     {
122     }
123
124diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERObjectIdentifier.java bcprov-jdk16-146/org/bouncycastle/asn1/DERObjectIdentifier.java
125--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERObjectIdentifier.java	2011-02-23 20:08:56.000000000 +0000
126+++ bcprov-jdk16-146/org/bouncycastle/asn1/DERObjectIdentifier.java	2011-09-08 21:28:50.000000000 +0000
127@@ -110,7 +110,13 @@
128             }
129         }
130
131-        this.identifier = objId.toString();
132+        // BEGIN android-changed
133+        /*
134+         * Intern the identifier so there aren't hundreds of duplicates
135+         * (in practice).
136+         */
137+        this.identifier = objId.toString().intern();
138+        // END android-changed
139     }
140
141     public DERObjectIdentifier(
142@@ -121,7 +127,13 @@
143             throw new IllegalArgumentException("string " + identifier + " not an OID");
144         }
145
146-        this.identifier = identifier;
147+        // BEGIN android-changed
148+        /*
149+         * Intern the identifier so there aren't hundreds of duplicates
150+         * (in practice).
151+         */
152+        this.identifier = identifier.intern();
153+        // END android-changed
154     }
155
156     public String getId()
157diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERPrintableString.java bcprov-jdk16-146/org/bouncycastle/asn1/DERPrintableString.java
158--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/DERPrintableString.java	2011-02-23 20:08:56.000000000 +0000
159+++ bcprov-jdk16-146/org/bouncycastle/asn1/DERPrintableString.java	2011-09-08 21:28:50.000000000 +0000
160@@ -9,7 +9,9 @@
161     extends ASN1Object
162     implements DERString
163 {
164-    String  string;
165+    // BEGIN android-changed
166+    private final String string;
167+    // END android-changed
168
169     /**
170      * return a printable string from the passed in object.
171@@ -65,7 +67,9 @@
172             cs[i] = (char)(string[i] & 0xff);
173         }
174
175-        this.string = new String(cs);
176+        // BEGIN android-changed
177+        this.string = new String(cs).intern();
178+        // END android-changed
179     }
180
181     /**
182@@ -94,7 +98,9 @@
183             throw new IllegalArgumentException("string contains illegal characters");
184         }
185
186-        this.string = string;
187+        // BEGIN android-changed
188+        this.string = string.intern();
189+        // END android-changed
190     }
191
192     public String getString()
193diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/cms/ContentInfo.java bcprov-jdk16-146/org/bouncycastle/asn1/cms/ContentInfo.java
194--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/cms/ContentInfo.java	2011-02-23 20:08:56.000000000 +0000
195+++ bcprov-jdk16-146/org/bouncycastle/asn1/cms/ContentInfo.java	2011-09-08 21:28:50.000000000 +0000
196@@ -12,7 +12,9 @@
197
198 public class ContentInfo
199     extends ASN1Encodable
200-    implements CMSObjectIdentifiers
201+    // BEGIN android-removed
202+    // implements CMSObjectIdentifiers
203+    // END android-removed
204 {
205     private ASN1ObjectIdentifier contentType;
206     private DEREncodable        content;
207diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java
208--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java	2011-02-23 20:08:56.000000000 +0000
209+++ bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java	2011-09-08 21:28:50.000000000 +0000
210@@ -37,10 +37,13 @@
211     public static EncryptedPrivateKeyInfo getInstance(
212         Object  obj)
213     {
214-        if (obj instanceof EncryptedData)
215+        // BEGIN android-changed
216+        //     fix copy and paste error in instanceof call
217+        if (obj instanceof EncryptedPrivateKeyInfo)
218         {
219             return (EncryptedPrivateKeyInfo)obj;
220         }
221+        // END android-changed
222         else if (obj instanceof ASN1Sequence)
223         {
224             return new EncryptedPrivateKeyInfo((ASN1Sequence)obj);
225diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java
226--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java	2011-02-23 20:08:56.000000000 +0000
227+++ bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java	2011-09-08 21:28:50.000000000 +0000
228@@ -10,8 +10,10 @@
229     //
230     static final ASN1ObjectIdentifier    pkcs_1                    = new ASN1ObjectIdentifier("1.2.840.113549.1.1");
231     static final ASN1ObjectIdentifier    rsaEncryption             = pkcs_1.branch("1");
232-    static final ASN1ObjectIdentifier    md2WithRSAEncryption      = pkcs_1.branch("2");
233-    static final ASN1ObjectIdentifier    md4WithRSAEncryption      = pkcs_1.branch("3");
234+    // BEGIN android-removed
235+    // static final ASN1ObjectIdentifier    md2WithRSAEncryption      = pkcs_1.branch("2");
236+    // static final ASN1ObjectIdentifier    md4WithRSAEncryption      = pkcs_1.branch("3");
237+    // END android-removed
238     static final ASN1ObjectIdentifier    md5WithRSAEncryption      = pkcs_1.branch("4");
239     static final ASN1ObjectIdentifier    sha1WithRSAEncryption     = pkcs_1.branch("5");
240     static final ASN1ObjectIdentifier    srsaOAEPEncryptionSET     = pkcs_1.branch("6");
241@@ -22,7 +24,9 @@
242     static final ASN1ObjectIdentifier    sha256WithRSAEncryption   = pkcs_1.branch("11");
243     static final ASN1ObjectIdentifier    sha384WithRSAEncryption   = pkcs_1.branch("12");
244     static final ASN1ObjectIdentifier    sha512WithRSAEncryption   = pkcs_1.branch("13");
245-    static final ASN1ObjectIdentifier    sha224WithRSAEncryption   = pkcs_1.branch("14");
246+    // BEGIN android-removed
247+    // static final ASN1ObjectIdentifier    sha224WithRSAEncryption   = pkcs_1.branch("14");
248+    // END android-removed
249
250     //
251     // pkcs-3 OBJECT IDENTIFIER ::= {
252@@ -65,13 +69,17 @@
253     // md2 OBJECT IDENTIFIER ::=
254     //      {iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 2}
255     //
256-    static final ASN1ObjectIdentifier    md2                    = digestAlgorithm.branch("2");
257+    // BEGIN android-removed
258+    // static final ASN1ObjectIdentifier    md2                    = digestAlgorithm.branch("2");
259+    // END android-removed
260
261     //
262     // md4 OBJECT IDENTIFIER ::=
263     //      {iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 4}
264     //
265-    static final ASN1ObjectIdentifier    md4 = digestAlgorithm.branch("4");
266+    // BEGIN android-removed
267+    // static final ASN1ObjectIdentifier    md4 = digestAlgorithm.branch("4");
268+    // END android-removed
269
270     //
271     // md5 OBJECT IDENTIFIER ::=
272@@ -80,7 +88,9 @@
273     static final ASN1ObjectIdentifier    md5                     = digestAlgorithm.branch("5");
274
275     static final ASN1ObjectIdentifier    id_hmacWithSHA1         = digestAlgorithm.branch("7");
276-    static final ASN1ObjectIdentifier    id_hmacWithSHA224       = digestAlgorithm.branch("8");
277+    // BEGIN android-removed
278+    // static final ASN1ObjectIdentifier    id_hmacWithSHA224       = digestAlgorithm.branch("8");
279+    // END android-removed
280     static final ASN1ObjectIdentifier    id_hmacWithSHA256       = digestAlgorithm.branch("9");
281     static final ASN1ObjectIdentifier    id_hmacWithSHA384       = digestAlgorithm.branch("10");
282     static final ASN1ObjectIdentifier    id_hmacWithSHA512       = digestAlgorithm.branch("11");
283diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java
284--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java	2011-02-23 20:08:56.000000000 +0000
285+++ bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java	2011-09-08 21:28:50.000000000 +0000
286@@ -19,7 +19,9 @@
287     private AlgorithmIdentifier maskGenAlgorithm;
288     private AlgorithmIdentifier pSourceAlgorithm;
289
290-    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
291+    // BEGIN android-changed
292+    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
293+    // END android-changed
294     public final static AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, DEFAULT_HASH_ALGORITHM);
295     public final static AlgorithmIdentifier DEFAULT_P_SOURCE_ALGORITHM = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(new byte[0]));
296
297diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java
298--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java	2011-02-23 20:08:56.000000000 +0000
299+++ bcprov-jdk16-146/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java	2011-09-08 21:28:50.000000000 +0000
300@@ -20,7 +20,9 @@
301     private DERInteger          saltLength;
302     private DERInteger          trailerField;
303
304-    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
305+    // BEGIN android-changed
306+    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
307+    // END android-changed
308     public final static AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, DEFAULT_HASH_ALGORITHM);
309     public final static DERInteger          DEFAULT_SALT_LENGTH = new DERInteger(20);
310     public final static DERInteger          DEFAULT_TRAILER_FIELD = new DERInteger(1);
311diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/util/ASN1Dump.java bcprov-jdk16-146/org/bouncycastle/asn1/util/ASN1Dump.java
312--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/util/ASN1Dump.java	2011-02-23 20:08:56.000000000 +0000
313+++ bcprov-jdk16-146/org/bouncycastle/asn1/util/ASN1Dump.java	2011-09-08 21:28:50.000000000 +0000
314@@ -79,7 +79,9 @@
315             {
316                 Object  o = e.nextElement();
317
318-                if (o == null || o.equals(new DERNull()))
319+                // BEGIN android-changed
320+                if (o == null || o.equals(DERNull.INSTANCE))
321+                // END android-changed
322                 {
323                     buf.append(tab);
324                     buf.append("NULL");
325diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/AttCertIssuer.java bcprov-jdk16-146/org/bouncycastle/asn1/x509/AttCertIssuer.java
326--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/AttCertIssuer.java	2011-02-23 20:08:56.000000000 +0000
327+++ bcprov-jdk16-146/org/bouncycastle/asn1/x509/AttCertIssuer.java	2011-09-08 21:28:50.000000000 +0000
328@@ -45,7 +45,7 @@
329         ASN1TaggedObject obj,
330         boolean          explicit)
331     {
332-        return getInstance(obj.getObject()); // must be explictly tagged
333+        return getInstance(obj.getObject()); // must be explicitly tagged
334     }
335
336     /**
337diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/BasicConstraints.java bcprov-jdk16-146/org/bouncycastle/asn1/x509/BasicConstraints.java
338--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/BasicConstraints.java	2011-02-23 20:08:56.000000000 +0000
339+++ bcprov-jdk16-146/org/bouncycastle/asn1/x509/BasicConstraints.java	2011-09-08 21:28:50.000000000 +0000
340@@ -14,7 +14,9 @@
341 public class BasicConstraints
342     extends ASN1Encodable
343 {
344-    DERBoolean  cA = new DERBoolean(false);
345+    // BEGIN android-changed
346+    DERBoolean  cA = DERBoolean.FALSE;
347+    // END android-changed
348     DERInteger  pathLenConstraint = null;
349
350     public static BasicConstraints getInstance(
351@@ -89,7 +91,9 @@
352     {
353         if (cA)
354         {
355-            this.cA = new DERBoolean(cA);
356+            // BEGIN android-changed
357+            this.cA = DERBoolean.getInstance(cA);
358+            // END android-changed
359             this.pathLenConstraint = new DERInteger(pathLenConstraint);
360         }
361         else
362@@ -104,7 +108,9 @@
363     {
364         if (cA)
365         {
366-            this.cA = new DERBoolean(true);
367+            // BEGIN android-changed
368+            this.cA = DERBoolean.TRUE;
369+            // END android-changed
370         }
371         else
372         {
373@@ -121,7 +127,9 @@
374     public BasicConstraints(
375         int     pathLenConstraint)
376     {
377-        this.cA = new DERBoolean(true);
378+        // BEGIN android-changed
379+        this.cA = DERBoolean.TRUE;
380+        // END android-changed
381         this.pathLenConstraint = new DERInteger(pathLenConstraint);
382     }
383
384diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java bcprov-jdk16-146/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java
385--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java	2011-02-23 20:08:56.000000000 +0000
386+++ bcprov-jdk16-146/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java	2011-09-08 21:28:50.000000000 +0000
387@@ -96,11 +96,15 @@
388         }
389         if (onlyContainsUserCerts)
390         {
391-            vec.add(new DERTaggedObject(false, 1, new DERBoolean(true)));
392+            // BEGIN android-changed
393+            vec.add(new DERTaggedObject(false, 1, DERBoolean.TRUE));
394+            // END android-changed
395         }
396         if (onlyContainsCACerts)
397         {
398-            vec.add(new DERTaggedObject(false, 2, new DERBoolean(true)));
399+            // BEGIN android-changed
400+            vec.add(new DERTaggedObject(false, 2, DERBoolean.TRUE));
401+            // END android-changed
402         }
403         if (onlySomeReasons != null)
404         {
405@@ -108,11 +112,15 @@
406         }
407         if (indirectCRL)
408         {
409-            vec.add(new DERTaggedObject(false, 4, new DERBoolean(true)));
410+            // BEGIN android-changed
411+            vec.add(new DERTaggedObject(false, 4, DERBoolean.TRUE));
412+            // END android-changed
413         }
414         if (onlyContainsAttributeCerts)
415         {
416-            vec.add(new DERTaggedObject(false, 5, new DERBoolean(true)));
417+            // BEGIN android-changed
418+            vec.add(new DERTaggedObject(false, 5, DERBoolean.TRUE));
419+            // END android-changed
420         }
421
422         seq = new DERSequence(vec);
423diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/X509Extensions.java bcprov-jdk16-146/org/bouncycastle/asn1/x509/X509Extensions.java
424--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/X509Extensions.java	2011-02-23 20:08:56.000000000 +0000
425+++ bcprov-jdk16-146/org/bouncycastle/asn1/x509/X509Extensions.java	2011-09-08 21:28:50.000000000 +0000
426@@ -400,7 +400,9 @@
427
428             if (ext.isCritical())
429             {
430-                v.add(new DERBoolean(true));
431+                // BEGIN android-changed
432+                v.add(DERBoolean.TRUE);
433+                // END android-changed
434             }
435
436             v.add(ext.getValue());
437diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/X509Name.java bcprov-jdk16-146/org/bouncycastle/asn1/x509/X509Name.java
438--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/X509Name.java	2011-02-23 20:08:56.000000000 +0000
439+++ bcprov-jdk16-146/org/bouncycastle/asn1/x509/X509Name.java	2011-09-08 21:28:50.000000000 +0000
440@@ -249,8 +249,10 @@
441      */
442     public static final Hashtable SymbolLookUp = DefaultLookUp;
443
444-    private static final Boolean TRUE = new Boolean(true); // for J2ME compatibility
445-    private static final Boolean FALSE = new Boolean(false);
446+    // BEGIN android-changed
447+    private static final Boolean TRUE = Boolean.TRUE;
448+    private static final Boolean FALSE = Boolean.FALSE;
449+    // END android-changed
450
451     static
452     {
453@@ -432,7 +434,9 @@
454                    {
455                        values.addElement("#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded())));
456                    }
457-                   added.addElement((i != 0) ? TRUE : FALSE);  // to allow earlier JDK compatibility
458+                   // BEGIN android-changed
459+                   added.addElement(Boolean.valueOf(i != 0));
460+                   // END android-changed
461             }
462         }
463     }
464@@ -689,7 +693,9 @@
465
466             if (index == -1)
467             {
468-                throw new IllegalArgumentException("badly formated directory string");
469+                // BEGIN android-changed
470+                throw new IllegalArgumentException("badly formatted directory string");
471+                // END android-changed
472             }
473
474             String              name = token.substring(0, index);
475diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/X509NameTokenizer.java bcprov-jdk16-146/org/bouncycastle/asn1/x509/X509NameTokenizer.java
476--- bcprov-jdk16-146.orig/org/bouncycastle/asn1/x509/X509NameTokenizer.java	2011-02-23 20:08:56.000000000 +0000
477+++ bcprov-jdk16-146/org/bouncycastle/asn1/x509/X509NameTokenizer.java	2011-09-08 21:28:50.000000000 +0000
478@@ -58,6 +58,17 @@
479                 }
480                 else
481                 {
482+                    // BEGIN android-added
483+                    // copied from a newer version of BouncyCastle
484+                    if (c == '#' && buf.charAt(buf.length() - 1) == '=')
485+                    {
486+                        buf.append('\\');
487+                    }
488+                    else if (c == '+' && seperator != '+')
489+                    {
490+                        buf.append('\\');
491+                    }
492+                    // END android-added
493                     buf.append(c);
494                 }
495                 escaped = false;
496@@ -96,4 +107,4 @@
497         index = end;
498         return buf.toString().trim();
499     }
500-}
501+}
502\ No newline at end of file
503diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/PBEParametersGenerator.java bcprov-jdk16-146/org/bouncycastle/crypto/PBEParametersGenerator.java
504--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/PBEParametersGenerator.java	2011-02-23 20:08:56.000000000 +0000
505+++ bcprov-jdk16-146/org/bouncycastle/crypto/PBEParametersGenerator.java	2011-09-08 21:28:49.000000000 +0000
506@@ -136,7 +136,8 @@
507     public static byte[] PKCS12PasswordToBytes(
508         char[]  password)
509     {
510-        if (password.length > 0)
511+        // BEGIN android-changed
512+        if (password != null && password.length > 0)
513         {
514                                        // +1 for extra 2 pad bytes.
515             byte[]  bytes = new byte[(password.length + 1) * 2];
516@@ -153,5 +154,6 @@
517         {
518             return new byte[0];
519         }
520+        // END android-changed
521     }
522 }
523diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/digests/OpenSSLDigest.java bcprov-jdk16-146/org/bouncycastle/crypto/digests/OpenSSLDigest.java
524--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/digests/OpenSSLDigest.java	1970-01-01 00:00:00.000000000 +0000
525+++ bcprov-jdk16-146/org/bouncycastle/crypto/digests/OpenSSLDigest.java	2011-09-08 21:28:49.000000000 +0000
526@@ -0,0 +1,159 @@
527+/*
528+ * Copyright (C) 2008 The Android Open Source Project
529+ *
530+ * Licensed under the Apache License, Version 2.0 (the "License");
531+ * you may not use this file except in compliance with the License.
532+ * You may obtain a copy of the License at
533+ *
534+ *      http://www.apache.org/licenses/LICENSE-2.0
535+ *
536+ * Unless required by applicable law or agreed to in writing, software
537+ * distributed under the License is distributed on an "AS IS" BASIS,
538+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539+ * See the License for the specific language governing permissions and
540+ * limitations under the License.
541+ */
542+
543+package org.bouncycastle.crypto.digests;
544+
545+import org.apache.harmony.xnet.provider.jsse.NativeCrypto;
546+import org.bouncycastle.crypto.ExtendedDigest;
547+
548+/**
549+ * Implements the BouncyCastle Digest interface using OpenSSL's EVP API.
550+ */
551+public class OpenSSLDigest implements ExtendedDigest {
552+
553+    /**
554+     * Holds the standard name of the hashing algorithm, e.g. "SHA-1";
555+     */
556+    private final String algorithm;
557+
558+    /**
559+     * Holds the EVP_MD for the hashing algorithm, e.g. EVP_get_digestbyname("sha1");
560+     */
561+    private final int evp_md;
562+
563+    /**
564+     * Holds the output size of the message digest.
565+     */
566+    private final int size;
567+
568+    /**
569+     * Holds the block size of the message digest.
570+     */
571+    private final int blockSize;
572+
573+    /**
574+     * Holds a pointer to the native message digest context. It is
575+     * lazily initialized to avoid having to reallocate on reset when
576+     * its unlikely to be reused.
577+     */
578+    private int ctx;
579+
580+    /**
581+     * Holds a dummy buffer for writing single bytes to the digest.
582+     */
583+    private final byte[] singleByte = new byte[1];
584+
585+    /**
586+     * Creates a new OpenSSLMessageDigest instance for the given algorithm
587+     * name.
588+     */
589+    private OpenSSLDigest(String algorithm, int evp_md, int size, int blockSize) {
590+        this.algorithm = algorithm;
591+        this.evp_md = evp_md;
592+        this.size = size;
593+        this.blockSize = blockSize;
594+    }
595+
596+    public String getAlgorithmName() {
597+        return algorithm;
598+    }
599+
600+    public int getDigestSize() {
601+        return size;
602+    }
603+
604+    public int getByteLength() {
605+        return blockSize;
606+    }
607+
608+    public void reset() {
609+        free();
610+    }
611+
612+    public void update(byte in) {
613+        singleByte[0] = in;
614+        update(singleByte, 0, 1);
615+    }
616+
617+    public void update(byte[] in, int inOff, int len) {
618+        NativeCrypto.EVP_DigestUpdate(getCtx(), in, inOff, len);
619+    }
620+
621+    public int doFinal(byte[] out, int outOff) {
622+        int i = NativeCrypto.EVP_DigestFinal(getCtx(), out, outOff);
623+        ctx = 0; // EVP_DigestFinal frees the context as a side effect
624+        reset();
625+        return i;
626+    }
627+
628+    private int getCtx() {
629+        if (ctx == 0) {
630+            ctx = NativeCrypto.EVP_DigestInit(evp_md);
631+        }
632+        return ctx;
633+    }
634+
635+    private void free() {
636+        if (ctx != 0) {
637+            NativeCrypto.EVP_MD_CTX_destroy(ctx);
638+            ctx = 0;
639+        }
640+    }
641+
642+    @Override
643+    protected void finalize() throws Throwable {
644+        try {
645+            free();
646+        } finally {
647+            super.finalize();
648+        }
649+    }
650+
651+    public static class MD5 extends OpenSSLDigest {
652+        private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("md5");
653+        private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD);
654+        private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD);
655+        public MD5() { super("MD5", EVP_MD, SIZE, BLOCK_SIZE); }
656+    }
657+
658+    public static class SHA1 extends OpenSSLDigest {
659+        private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha1");
660+        private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD);
661+        private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD);
662+        public SHA1() { super("SHA-1", EVP_MD, SIZE, BLOCK_SIZE); }
663+    }
664+
665+    public static class SHA256 extends OpenSSLDigest {
666+        private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha256");
667+        private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD);
668+        private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD);
669+        public SHA256() { super("SHA-256", EVP_MD, SIZE, BLOCK_SIZE); }
670+    }
671+
672+    public static class SHA384 extends OpenSSLDigest {
673+        private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha384");
674+        private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD);
675+        private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD);
676+        public SHA384() { super("SHA-384", EVP_MD, SIZE, BLOCK_SIZE); }
677+    }
678+
679+    public static class SHA512 extends OpenSSLDigest {
680+        private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha512");
681+        private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD);
682+        private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD);
683+        public SHA512() { super("SHA-512", EVP_MD, SIZE, BLOCK_SIZE); }
684+    }
685+}
686diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/engines/RC2Engine.java bcprov-jdk16-146/org/bouncycastle/crypto/engines/RC2Engine.java
687--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/engines/RC2Engine.java	2011-02-23 20:08:56.000000000 +0000
688+++ bcprov-jdk16-146/org/bouncycastle/crypto/engines/RC2Engine.java	2011-09-08 21:28:49.000000000 +0000
689@@ -313,4 +313,4 @@
690         out[outOff + 6] = (byte)x76;
691         out[outOff + 7] = (byte)(x76 >> 8);
692     }
693-}
694+}
695\ No newline at end of file
696diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/generators/DHParametersHelper.java bcprov-jdk16-146/org/bouncycastle/crypto/generators/DHParametersHelper.java
697--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/generators/DHParametersHelper.java	2011-02-23 20:08:56.000000000 +0000
698+++ bcprov-jdk16-146/org/bouncycastle/crypto/generators/DHParametersHelper.java	2011-09-08 21:28:49.000000000 +0000
699@@ -3,10 +3,17 @@
700 import java.math.BigInteger;
701 import java.security.SecureRandom;
702
703+// BEGIN android-added
704+import java.util.logging.Logger;
705+// END android-added
706 import org.bouncycastle.util.BigIntegers;
707
708 class DHParametersHelper
709 {
710+    // BEGIN android-added
711+    private static final Logger logger = Logger.getLogger(DHParametersHelper.class.getName());
712+    // END android-added
713+
714     private static final BigInteger ONE = BigInteger.valueOf(1);
715     private static final BigInteger TWO = BigInteger.valueOf(2);
716
717@@ -17,11 +24,19 @@
718      */
719     static BigInteger[] generateSafePrimes(int size, int certainty, SecureRandom random)
720     {
721+        // BEGIN android-added
722+        logger.info("Generating safe primes. This may take a long time.");
723+        long start = System.currentTimeMillis();
724+        int tries = 0;
725+        // END android-added
726         BigInteger p, q;
727         int qLength = size - 1;
728
729         for (;;)
730         {
731+            // BEGIN android-added
732+            tries++;
733+            // END android-added
734             q = new BigInteger(qLength, 2, random);
735
736             // p <- 2q + 1
737@@ -32,6 +47,11 @@
738                 break;
739             }
740         }
741+        // BEGIN android-added
742+        long end = System.currentTimeMillis();
743+        long duration = end - start;
744+        logger.info("Generated safe primes: " + tries + " tries took " + duration + "ms");
745+        // END android-added
746
747         return new BigInteger[] { p, q };
748     }
749diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/macs/HMac.java bcprov-jdk16-146/org/bouncycastle/crypto/macs/HMac.java
750--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/macs/HMac.java	2011-02-23 20:08:56.000000000 +0000
751+++ bcprov-jdk16-146/org/bouncycastle/crypto/macs/HMac.java	2011-09-08 21:28:49.000000000 +0000
752@@ -32,23 +32,23 @@
753     {
754         blockLengths = new Hashtable();
755
756-        blockLengths.put("GOST3411", new Integer(32));
757+        blockLengths.put("GOST3411", Integer.valueOf(32));
758
759-        blockLengths.put("MD2", new Integer(16));
760-        blockLengths.put("MD4", new Integer(64));
761-        blockLengths.put("MD5", new Integer(64));
762-
763-        blockLengths.put("RIPEMD128", new Integer(64));
764-        blockLengths.put("RIPEMD160", new Integer(64));
765-
766-        blockLengths.put("SHA-1", new Integer(64));
767-        blockLengths.put("SHA-224", new Integer(64));
768-        blockLengths.put("SHA-256", new Integer(64));
769-        blockLengths.put("SHA-384", new Integer(128));
770-        blockLengths.put("SHA-512", new Integer(128));
771+        blockLengths.put("MD2", Integer.valueOf(16));
772+        blockLengths.put("MD4", Integer.valueOf(64));
773+        blockLengths.put("MD5", Integer.valueOf(64));
774+
775+        blockLengths.put("RIPEMD128", Integer.valueOf(64));
776+        blockLengths.put("RIPEMD160", Integer.valueOf(64));
777+
778+        blockLengths.put("SHA-1", Integer.valueOf(64));
779+        blockLengths.put("SHA-224", Integer.valueOf(64));
780+        blockLengths.put("SHA-256", Integer.valueOf(64));
781+        blockLengths.put("SHA-384", Integer.valueOf(128));
782+        blockLengths.put("SHA-512", Integer.valueOf(128));
783
784-        blockLengths.put("Tiger", new Integer(64));
785-        blockLengths.put("Whirlpool", new Integer(64));
786+        blockLengths.put("Tiger", Integer.valueOf(64));
787+        blockLengths.put("Whirlpool", Integer.valueOf(64));
788     }
789
790     private static int getByteLength(
791diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/signers/RSADigestSigner.java bcprov-jdk16-146/org/bouncycastle/crypto/signers/RSADigestSigner.java
792--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/signers/RSADigestSigner.java	2011-02-23 20:08:56.000000000 +0000
793+++ bcprov-jdk16-146/org/bouncycastle/crypto/signers/RSADigestSigner.java	2011-09-08 21:28:49.000000000 +0000
794@@ -46,8 +46,10 @@
795         oidMap.put("SHA-384", NISTObjectIdentifiers.id_sha384);
796         oidMap.put("SHA-512", NISTObjectIdentifiers.id_sha512);
797
798-        oidMap.put("MD2", PKCSObjectIdentifiers.md2);
799-        oidMap.put("MD4", PKCSObjectIdentifiers.md4);
800+        // BEGIN android-removed
801+        // oidMap.put("MD2", PKCSObjectIdentifiers.md2);
802+        // oidMap.put("MD4", PKCSObjectIdentifiers.md4);
803+        // END android-removed
804         oidMap.put("MD5", PKCSObjectIdentifiers.md5);
805     }
806
807diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/util/PrivateKeyFactory.java bcprov-jdk16-146/org/bouncycastle/crypto/util/PrivateKeyFactory.java
808--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/util/PrivateKeyFactory.java	2011-02-23 20:08:56.000000000 +0000
809+++ bcprov-jdk16-146/org/bouncycastle/crypto/util/PrivateKeyFactory.java	2011-09-08 21:28:49.000000000 +0000
810@@ -12,7 +12,9 @@
811 import org.bouncycastle.asn1.DERObject;
812 import org.bouncycastle.asn1.DERObjectIdentifier;
813 import org.bouncycastle.asn1.nist.NISTNamedCurves;
814-import org.bouncycastle.asn1.oiw.ElGamalParameter;
815+// BEGIN android-removed
816+// import org.bouncycastle.asn1.oiw.ElGamalParameter;
817+// END android-removed
818 import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
819 import org.bouncycastle.asn1.pkcs.DHParameter;
820 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
821@@ -20,7 +22,9 @@
822 import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
823 import org.bouncycastle.asn1.sec.ECPrivateKeyStructure;
824 import org.bouncycastle.asn1.sec.SECNamedCurves;
825-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
826+// BEGIN android-removed
827+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
828+// END android-removed
829 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
830 import org.bouncycastle.asn1.x509.DSAParameter;
831 import org.bouncycastle.asn1.x9.X962NamedCurves;
832@@ -34,8 +38,10 @@
833 import org.bouncycastle.crypto.params.DSAPrivateKeyParameters;
834 import org.bouncycastle.crypto.params.ECDomainParameters;
835 import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
836-import org.bouncycastle.crypto.params.ElGamalParameters;
837-import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
838+// BEGIN android-removed
839+// import org.bouncycastle.crypto.params.ElGamalParameters;
840+// import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
841+// END android-removed
842 import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
843
844 /**
845@@ -103,15 +109,17 @@
846
847             return new DHPrivateKeyParameters(derX.getValue(), dhParams);
848         }
849-        else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
850-        {
851-            ElGamalParameter params = new ElGamalParameter(
852-                (ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
853-            DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
854-
855-            return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(
856-                params.getP(), params.getG()));
857-        }
858+        // BEGIN android-removed
859+        // else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
860+        // {
861+        //     ElGamalParameter params = new ElGamalParameter(
862+        //         (ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
863+        //     DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
864+        //
865+        //     return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(
866+        //         params.getP(), params.getG()));
867+        // }
868+        // END android-removed
869         else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa))
870         {
871             DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
872@@ -145,10 +153,12 @@
873                     {
874                         ecP = NISTNamedCurves.getByOID(oid);
875
876-                        if (ecP == null)
877-                        {
878-                            ecP = TeleTrusTNamedCurves.getByOID(oid);
879-                        }
880+                        // BEGIN android-removed
881+                        // if (ecP == null)
882+                        // {
883+                        //     ecP = TeleTrusTNamedCurves.getByOID(oid);
884+                        // }
885+                        // END android-removed
886                     }
887                 }
888
889diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/crypto/util/PublicKeyFactory.java bcprov-jdk16-146/org/bouncycastle/crypto/util/PublicKeyFactory.java
890--- bcprov-jdk16-146.orig/org/bouncycastle/crypto/util/PublicKeyFactory.java	2011-02-23 20:08:56.000000000 +0000
891+++ bcprov-jdk16-146/org/bouncycastle/crypto/util/PublicKeyFactory.java	2011-09-08 21:28:49.000000000 +0000
892@@ -15,12 +15,16 @@
893 import org.bouncycastle.asn1.DERObjectIdentifier;
894 import org.bouncycastle.asn1.DEROctetString;
895 import org.bouncycastle.asn1.nist.NISTNamedCurves;
896-import org.bouncycastle.asn1.oiw.ElGamalParameter;
897+// BEGIN android-removed
898+// import org.bouncycastle.asn1.oiw.ElGamalParameter;
899+// END android-removed
900 import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
901 import org.bouncycastle.asn1.pkcs.DHParameter;
902 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
903 import org.bouncycastle.asn1.sec.SECNamedCurves;
904-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
905+// BEGIN android-removed
906+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
907+// END android-removed
908 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
909 import org.bouncycastle.asn1.x509.DSAParameter;
910 import org.bouncycastle.asn1.x509.RSAPublicKeyStructure;
911@@ -42,8 +46,10 @@
912 import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
913 import org.bouncycastle.crypto.params.ECDomainParameters;
914 import org.bouncycastle.crypto.params.ECPublicKeyParameters;
915-import org.bouncycastle.crypto.params.ElGamalParameters;
916-import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
917+// BEGIN android-removed
918+// import org.bouncycastle.crypto.params.ElGamalParameters;
919+// import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
920+// END android-removed
921 import org.bouncycastle.crypto.params.RSAKeyParameters;
922
923 /**
924@@ -139,15 +145,17 @@
925
926             return new DHPublicKeyParameters(derY.getValue(), dhParams);
927         }
928-        else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
929-        {
930-            ElGamalParameter params = new ElGamalParameter(
931-                (ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
932-            DERInteger derY = (DERInteger)keyInfo.getPublicKey();
933-
934-            return new ElGamalPublicKeyParameters(derY.getValue(), new ElGamalParameters(
935-                params.getP(), params.getG()));
936-        }
937+        // BEGIN android-removed
938+        // else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
939+        // {
940+        //     ElGamalParameter params = new ElGamalParameter(
941+        //         (ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
942+        //     DERInteger derY = (DERInteger)keyInfo.getPublicKey();
943+        //
944+        //     return new ElGamalPublicKeyParameters(derY.getValue(), new ElGamalParameters(
945+        //         params.getP(), params.getG()));
946+        // }
947+        // END android-removed
948         else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa)
949             || algId.getObjectId().equals(OIWObjectIdentifiers.dsaWithSHA1))
950         {
951@@ -182,10 +190,12 @@
952                     {
953                         ecP = NISTNamedCurves.getByOID(oid);
954
955-                        if (ecP == null)
956-                        {
957-                            ecP = TeleTrusTNamedCurves.getByOID(oid);
958-                        }
959+                        // BEGIN android-removed
960+                        // if (ecP == null)
961+                        // {
962+                        //     ecP = TeleTrusTNamedCurves.getByOID(oid);
963+                        // }
964+                        // END android-removed
965                     }
966                 }
967
968diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/ECNamedCurveTable.java bcprov-jdk16-146/org/bouncycastle/jce/ECNamedCurveTable.java
969--- bcprov-jdk16-146.orig/org/bouncycastle/jce/ECNamedCurveTable.java	2011-02-23 20:08:56.000000000 +0000
970+++ bcprov-jdk16-146/org/bouncycastle/jce/ECNamedCurveTable.java	2011-09-08 21:28:49.000000000 +0000
971@@ -3,7 +3,9 @@
972 import org.bouncycastle.asn1.DERObjectIdentifier;
973 import org.bouncycastle.asn1.nist.NISTNamedCurves;
974 import org.bouncycastle.asn1.sec.SECNamedCurves;
975-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
976+// BEGIN android-removed
977+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
978+// END android-removed
979 import org.bouncycastle.asn1.x9.X962NamedCurves;
980 import org.bouncycastle.asn1.x9.X9ECParameters;
981 import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
982@@ -55,21 +57,23 @@
983             }
984         }
985
986-        if (ecP == null)
987-        {
988-            ecP = TeleTrusTNamedCurves.getByName(name);
989-            if (ecP == null)
990-            {
991-                try
992-                {
993-                    ecP = TeleTrusTNamedCurves.getByOID(new DERObjectIdentifier(name));
994-                }
995-                catch (IllegalArgumentException e)
996-                {
997-                    // ignore - not an oid
998-                }
999-            }
1000-        }
1001+        // BEGIN android-removed
1002+        // if (ecP == null)
1003+        // {
1004+        //     ecP = TeleTrusTNamedCurves.getByName(name);
1005+        //     if (ecP == null)
1006+        //     {
1007+        //         try
1008+        //         {
1009+        //             ecP = TeleTrusTNamedCurves.getByOID(new DERObjectIdentifier(name));
1010+        //         }
1011+        //         catch (IllegalArgumentException e)
1012+        //         {
1013+        //             // ignore - not an oid
1014+        //         }
1015+        //     }
1016+        // }
1017+        // END android-removed
1018
1019         if (ecP == null)
1020         {
1021@@ -102,7 +106,9 @@
1022         addEnumeration(v, X962NamedCurves.getNames());
1023         addEnumeration(v, SECNamedCurves.getNames());
1024         addEnumeration(v, NISTNamedCurves.getNames());
1025-        addEnumeration(v, TeleTrusTNamedCurves.getNames());
1026+        // BEGIN android-removed
1027+        // addEnumeration(v, TeleTrusTNamedCurves.getNames());
1028+        // END android-removed
1029
1030         return v.elements();
1031     }
1032diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/PKCS10CertificationRequest.java bcprov-jdk16-146/org/bouncycastle/jce/PKCS10CertificationRequest.java
1033--- bcprov-jdk16-146.orig/org/bouncycastle/jce/PKCS10CertificationRequest.java	2011-02-23 20:08:56.000000000 +0000
1034+++ bcprov-jdk16-146/org/bouncycastle/jce/PKCS10CertificationRequest.java	2011-09-08 21:28:49.000000000 +0000
1035@@ -80,15 +80,20 @@
1036
1037     static
1038     {
1039-        algorithms.put("MD2WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
1040-        algorithms.put("MD2WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
1041+        // BEGIN android-removed
1042+        // Dropping MD2
1043+        // algorithms.put("MD2WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
1044+        // algorithms.put("MD2WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
1045+        // END android-removed
1046         algorithms.put("MD5WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.4"));
1047         algorithms.put("MD5WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.4"));
1048         algorithms.put("RSAWITHMD5", new DERObjectIdentifier("1.2.840.113549.1.1.4"));
1049         algorithms.put("SHA1WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.5"));
1050         algorithms.put("SHA1WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.5"));
1051-        algorithms.put("SHA224WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha224WithRSAEncryption);
1052-        algorithms.put("SHA224WITHRSA", PKCSObjectIdentifiers.sha224WithRSAEncryption);
1053+        // BEGIN android-removed
1054+        // algorithms.put("SHA224WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha224WithRSAEncryption);
1055+        // algorithms.put("SHA224WITHRSA", PKCSObjectIdentifiers.sha224WithRSAEncryption);
1056+        // END android-removed
1057         algorithms.put("SHA256WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha256WithRSAEncryption);
1058         algorithms.put("SHA256WITHRSA", PKCSObjectIdentifiers.sha256WithRSAEncryption);
1059         algorithms.put("SHA384WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha384WithRSAEncryption);
1060@@ -96,57 +101,78 @@
1061         algorithms.put("SHA512WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha512WithRSAEncryption);
1062         algorithms.put("SHA512WITHRSA", PKCSObjectIdentifiers.sha512WithRSAEncryption);
1063         algorithms.put("SHA1WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
1064-        algorithms.put("SHA224WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
1065+        // BEGIN android-removed
1066+        // algorithms.put("SHA224WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
1067+        // END android-removed
1068         algorithms.put("SHA256WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
1069         algorithms.put("SHA384WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
1070         algorithms.put("SHA512WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
1071         algorithms.put("RSAWITHSHA1", new DERObjectIdentifier("1.2.840.113549.1.1.5"));
1072-        algorithms.put("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
1073-        algorithms.put("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
1074-        algorithms.put("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
1075-        algorithms.put("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
1076-        algorithms.put("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
1077-        algorithms.put("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
1078+        // BEGIN android-removed
1079+        // algorithms.put("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
1080+        // algorithms.put("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
1081+        // algorithms.put("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
1082+        // algorithms.put("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
1083+        // algorithms.put("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
1084+        // algorithms.put("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
1085+        // END android-removed
1086         algorithms.put("SHA1WITHDSA", new DERObjectIdentifier("1.2.840.10040.4.3"));
1087         algorithms.put("DSAWITHSHA1", new DERObjectIdentifier("1.2.840.10040.4.3"));
1088-        algorithms.put("SHA224WITHDSA", NISTObjectIdentifiers.dsa_with_sha224);
1089+        // BEGIN android-removed
1090+        // algorithms.put("SHA224WITHDSA", NISTObjectIdentifiers.dsa_with_sha224);
1091+        // END android-removed
1092         algorithms.put("SHA256WITHDSA", NISTObjectIdentifiers.dsa_with_sha256);
1093         algorithms.put("SHA384WITHDSA", NISTObjectIdentifiers.dsa_with_sha384);
1094         algorithms.put("SHA512WITHDSA", NISTObjectIdentifiers.dsa_with_sha512);
1095         algorithms.put("SHA1WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA1);
1096-        algorithms.put("SHA224WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA224);
1097+        // BEGIN android-removed
1098+        // algorithms.put("SHA224WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA224);
1099+        // END android-removed
1100         algorithms.put("SHA256WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA256);
1101         algorithms.put("SHA384WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA384);
1102         algorithms.put("SHA512WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA512);
1103         algorithms.put("ECDSAWITHSHA1", X9ObjectIdentifiers.ecdsa_with_SHA1);
1104-        algorithms.put("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
1105-        algorithms.put("GOST3410WITHGOST3411", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
1106-        algorithms.put("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1107-        algorithms.put("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1108-        algorithms.put("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1109+        // BEGIN android-removed
1110+        // algorithms.put("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
1111+        // algorithms.put("GOST3410WITHGOST3411", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
1112+        // algorithms.put("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1113+        // algorithms.put("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1114+        // algorithms.put("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1115+        // END android-removed
1116
1117         //
1118         // reverse mappings
1119         //
1120         oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.5"), "SHA1WITHRSA");
1121-        oids.put(PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WITHRSA");
1122+        // BEGIN android-removed
1123+        // oids.put(PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WITHRSA");
1124+        // END android-removed
1125         oids.put(PKCSObjectIdentifiers.sha256WithRSAEncryption, "SHA256WITHRSA");
1126         oids.put(PKCSObjectIdentifiers.sha384WithRSAEncryption, "SHA384WITHRSA");
1127         oids.put(PKCSObjectIdentifiers.sha512WithRSAEncryption, "SHA512WITHRSA");
1128-        oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3411WITHGOST3410");
1129-        oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "GOST3411WITHECGOST3410");
1130+        // BEGIN android-removed
1131+        // oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3411WITHGOST3410");
1132+        // oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "GOST3411WITHECGOST3410");
1133+        // END android-removed
1134
1135         oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.4"), "MD5WITHRSA");
1136-        oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA");
1137+        // BEGIN android-removed
1138+        // Dropping MD2
1139+        // oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA");
1140+        // END android-removed
1141         oids.put(new DERObjectIdentifier("1.2.840.10040.4.3"), "SHA1WITHDSA");
1142         oids.put(X9ObjectIdentifiers.ecdsa_with_SHA1, "SHA1WITHECDSA");
1143-        oids.put(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224WITHECDSA");
1144+        // BEGIN android-removed
1145+        // oids.put(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224WITHECDSA");
1146+        // END android-removed
1147         oids.put(X9ObjectIdentifiers.ecdsa_with_SHA256, "SHA256WITHECDSA");
1148         oids.put(X9ObjectIdentifiers.ecdsa_with_SHA384, "SHA384WITHECDSA");
1149         oids.put(X9ObjectIdentifiers.ecdsa_with_SHA512, "SHA512WITHECDSA");
1150         oids.put(OIWObjectIdentifiers.sha1WithRSA, "SHA1WITHRSA");
1151         oids.put(OIWObjectIdentifiers.dsaWithSHA1, "SHA1WITHDSA");
1152-        oids.put(NISTObjectIdentifiers.dsa_with_sha224, "SHA224WITHDSA");
1153+        // BEGIN android-removed
1154+        // oids.put(NISTObjectIdentifiers.dsa_with_sha224, "SHA224WITHDSA");
1155+        // END android-removed
1156         oids.put(NISTObjectIdentifiers.dsa_with_sha256, "SHA256WITHDSA");
1157
1158         //
1159@@ -160,35 +186,53 @@
1160         // The parameters field SHALL be NULL for RSA based signature algorithms.
1161         //
1162         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA1);
1163-        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA224);
1164+        // BEGIN android-removed
1165+        // noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA224);
1166+        // END android-removed
1167         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA256);
1168         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA384);
1169         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA512);
1170         noParams.add(X9ObjectIdentifiers.id_dsa_with_sha1);
1171-        noParams.add(NISTObjectIdentifiers.dsa_with_sha224);
1172+        // BEGIN android-removed
1173+        // noParams.add(NISTObjectIdentifiers.dsa_with_sha224);
1174+        // END android-removed
1175         noParams.add(NISTObjectIdentifiers.dsa_with_sha256);
1176
1177         //
1178         // RFC 4491
1179         //
1180-        noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
1181-        noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1182+        // BEGIN android-removed
1183+        // noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
1184+        // noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
1185+        // END android-removed
1186         //
1187         // explicit params
1188         //
1189-        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
1190+        // BEGIN android-changed
1191+        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
1192+        // END android-changed
1193         params.put("SHA1WITHRSAANDMGF1", creatPSSParams(sha1AlgId, 20));
1194
1195-        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, new DERNull());
1196-        params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28));
1197-
1198-        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, new DERNull());
1199+        // BEGIN android-removed
1200+        // // BEGIN android-changed
1201+        // AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE);
1202+        // // END android-changed
1203+        // params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28));
1204+        // END android-removed
1205+
1206+        // BEGIN android-changed
1207+        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE);
1208+        // END android-changed
1209         params.put("SHA256WITHRSAANDMGF1", creatPSSParams(sha256AlgId, 32));
1210
1211-        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, new DERNull());
1212+        // BEGIN android-changed
1213+        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE);
1214+        // END android-changed
1215         params.put("SHA384WITHRSAANDMGF1", creatPSSParams(sha384AlgId, 48));
1216
1217-        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, new DERNull());
1218+        // BEGIN android-changed
1219+        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE);
1220+        // END android-changed
1221         params.put("SHA512WITHRSAANDMGF1", creatPSSParams(sha512AlgId, 64));
1222     }
1223
1224@@ -594,10 +638,12 @@
1225         {
1226             return "SHA1";
1227         }
1228-        else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
1229-        {
1230-            return "SHA224";
1231-        }
1232+        // BEGIN android-removed
1233+        // else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
1234+        // {
1235+        //     return "SHA224";
1236+        // }
1237+        // END android-removed
1238         else if (NISTObjectIdentifiers.id_sha256.equals(digestAlgOID))
1239         {
1240             return "SHA256";
1241@@ -610,22 +656,24 @@
1242         {
1243             return "SHA512";
1244         }
1245-        else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
1246-        {
1247-            return "RIPEMD128";
1248-        }
1249-        else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
1250-        {
1251-            return "RIPEMD160";
1252-        }
1253-        else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
1254-        {
1255-            return "RIPEMD256";
1256-        }
1257-        else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
1258-        {
1259-            return "GOST3411";
1260-        }
1261+        // BEGIN android-removed
1262+        // else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
1263+        // {
1264+        //     return "RIPEMD128";
1265+        // }
1266+        // else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
1267+        // {
1268+        //     return "RIPEMD160";
1269+        // }
1270+        // else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
1271+        // {
1272+        //     return "RIPEMD256";
1273+        // }
1274+        // else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
1275+        // {
1276+        //     return "GOST3411";
1277+        // }
1278+        // END android-removed
1279         else
1280         {
1281             return digestAlgOID.getId();
1282diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/BouncyCastleProvider.java bcprov-jdk16-146/org/bouncycastle/jce/provider/BouncyCastleProvider.java
1283--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/BouncyCastleProvider.java	2011-02-23 20:08:56.000000000 +0000
1284+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/BouncyCastleProvider.java	2011-09-08 21:28:49.000000000 +0000
1285@@ -45,7 +45,10 @@
1286 {
1287     private static String info = "BouncyCastle Security Provider v1.46";
1288
1289-    public static String PROVIDER_NAME = "BC";
1290+    // BEGIN android-changed
1291+    //     this constant should be final
1292+    public static final String PROVIDER_NAME = "BC";
1293+    // END android-changed
1294
1295     /*
1296      * Configurable symmetric ciphers
1297@@ -53,8 +56,14 @@
1298     private static final String SYMMETRIC_CIPHER_PACKAGE = "org.bouncycastle.jce.provider.symmetric.";
1299     private static final String[] SYMMETRIC_CIPHERS =
1300     {
1301-        "AES", "ARC4", "Blowfish", "Camellia", "CAST5", "CAST6", "DESede", "Grainv1", "Grain128", "HC128", "HC256", "IDEA",
1302-        "Noekeon", "RC5", "RC6", "Rijndael", "Salsa20", "SEED", "Serpent", "Skipjack", "TEA", "Twofish", "VMPC", "VMPCKSA3", "XTEA"
1303+        // BEGIN android-removed
1304+        // "AES", "ARC4", "Blowfish", "Camellia", "CAST5", "CAST6", "DESede", "Grainv1", "Grain128", "HC128", "HC256", "IDEA",
1305+        // "Noekeon", "RC5", "RC6", "Rijndael", "Salsa20", "SEED", "Serpent", "Skipjack", "TEA", "Twofish", "VMPC", "VMPCKSA3", "XTEA"
1306+        // END android-removed
1307+        // BEGIN android-added
1308+        "AES", "ARC4", "Blowfish", "DESede",
1309+        // END android-added
1310+
1311     };
1312
1313     /*
1314@@ -90,26 +99,28 @@
1315         loadAlgorithms(SYMMETRIC_CIPHER_PACKAGE, SYMMETRIC_CIPHERS);
1316         loadAlgorithms(ASYMMETRIC_CIPHER_PACKAGE, ASYMMETRIC_CIPHERS);
1317
1318-        //
1319-        // X509Store
1320-        //
1321-        put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection");
1322-        put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection");
1323-        put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection");
1324-        put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection");
1325-
1326-        put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts");
1327-        put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs");
1328-        put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts");
1329-        put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs");
1330-
1331-        //
1332-        // X509StreamParser
1333-        //
1334-        put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser");
1335-        put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser");
1336-        put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser");
1337-        put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser");
1338+        // BEGIN android-removed
1339+        // //
1340+        // // X509Store
1341+        // //
1342+        // put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection");
1343+        // put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection");
1344+        // put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection");
1345+        // put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection");
1346+        //
1347+        // put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts");
1348+        // put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs");
1349+        // put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts");
1350+        // put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs");
1351+        //
1352+        // //
1353+        // // X509StreamParser
1354+        // //
1355+        // put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser");
1356+        // put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser");
1357+        // put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser");
1358+        // put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser");
1359+        // END android-removed
1360
1361
1362         //
1363@@ -118,14 +129,24 @@
1364         put("KeyStore.BKS", "org.bouncycastle.jce.provider.JDKKeyStore");
1365         put("KeyStore.BouncyCastle", "org.bouncycastle.jce.provider.JDKKeyStore$BouncyCastleStore");
1366         put("KeyStore.PKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
1367-        put("KeyStore.BCPKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
1368-        put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
1369-
1370-        put("KeyStore.PKCS12-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
1371-        put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES");
1372-
1373-        put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
1374-        put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES");
1375+        // BEGIN android-changed
1376+        put("Alg.Alias.KeyStore.BCPKCS12", "PKCS12");
1377+        // END android-changed
1378+        // BEGIN android-removed
1379+        // put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
1380+        // END android-removed
1381+
1382+        // BEGIN android-changed
1383+        put("Alg.Alias.KeyStore.PKCS12-3DES-40RC2", "PKCS12");
1384+        // END android-changed
1385+        // BEGIN android-removed
1386+        // put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES");
1387+        // END android-removed
1388+
1389+        // BEGIN android-removed
1390+        // put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
1391+        // put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES");
1392+        // END android-removed
1393
1394         put("Alg.Alias.KeyStore.UBER", "BouncyCastle");
1395         put("Alg.Alias.KeyStore.BOUNCYCASTLE", "BouncyCastle");
1396@@ -142,44 +163,63 @@
1397         //
1398         put("AlgorithmParameterGenerator.DH", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DH");
1399         put("AlgorithmParameterGenerator.DSA", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DSA");
1400-        put("AlgorithmParameterGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$GOST3410");
1401-        put("AlgorithmParameterGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$ElGamal");
1402-        put("AlgorithmParameterGenerator.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1403-        put("AlgorithmParameterGenerator.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1404-        put("AlgorithmParameterGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1405-        put("AlgorithmParameterGenerator." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1406-        put("AlgorithmParameterGenerator.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
1407-        put("AlgorithmParameterGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
1408+        // BEGIN android-removed
1409+        // put("AlgorithmParameterGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$GOST3410");
1410+        // put("AlgorithmParameterGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$ElGamal");
1411+        // put("AlgorithmParameterGenerator.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1412+        // put("AlgorithmParameterGenerator.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1413+        // put("AlgorithmParameterGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1414+        // put("AlgorithmParameterGenerator." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
1415+        // put("AlgorithmParameterGenerator.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
1416+        // put("AlgorithmParameterGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
1417+        // END android-removed
1418
1419         put("Alg.Alias.AlgorithmParameterGenerator.DIFFIEHELLMAN", "DH");
1420-        put("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410");
1421+        // BEGIN android-removed
1422+        // put("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410");
1423+        // END android-removed
1424         //
1425         // algorithm parameters
1426         //
1427         put("AlgorithmParameters.OAEP", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$OAEP");
1428-        put("AlgorithmParameters.PSS", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PSS");
1429+        // BEGIN android-removed
1430+        // put("AlgorithmParameters.PSS", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PSS");
1431+        // END android-removed
1432         put("AlgorithmParameters.DH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$DH");
1433         put("Alg.Alias.AlgorithmParameters.DIFFIEHELLMAN", "DH");
1434         put("AlgorithmParameters.DSA", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$DSA");
1435-        put("AlgorithmParameters.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$ElGamal");
1436-        put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES");
1437+        // BEGIN android-removed
1438+        // put("AlgorithmParameters.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$ElGamal");
1439+        // put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES");
1440+        // END android-removed
1441         put("AlgorithmParameters.PKCS12PBE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PKCS12PBE");
1442-        put("AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
1443-        put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2");
1444-
1445-        put("AlgorithmParameters.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$GOST3410");
1446-        put("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410");
1447+        // BEGIN android-changed
1448+        // redundant with below
1449+        // put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "DESede");
1450+        // END android-changed
1451+        // BEGIN android-removed
1452+        // put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2");
1453+        //
1454+        // put("AlgorithmParameters.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$GOST3410");
1455+        // put("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410");
1456+        // END android-removed
1457         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2", "PKCS12PBE");
1458-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE");
1459-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE");
1460-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE");
1461-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE");
1462+        // BEGIN android-removed
1463+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE");
1464+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE");
1465+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE");
1466+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE");
1467+        // END android-removed
1468         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH", "PKCS12PBE");
1469-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE");
1470+        // BEGIN android-removed
1471+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE");
1472+        // END android-removed
1473         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PKCS12PBE");
1474         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PKCS12PBE");
1475-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE");
1476-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE");
1477+        // BEGIN android-removed
1478+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE");
1479+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE");
1480+        // END android-removed
1481         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC2-CBC", "PKCS12PBE");
1482         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC4", "PKCS12PBE");
1483         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC2-CBC", "PKCS12PBE");
1484@@ -193,7 +233,7 @@
1485         put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.5", "PKCS12PBE");
1486         put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.6", "PKCS12PBE");
1487         put("Alg.Alias.AlgorithmParameters.PBEWithSHAAnd3KeyTripleDES", "PKCS12PBE");
1488-
1489+
1490         put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PKCS12PBE");
1491         put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PKCS12PBE");
1492         put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.getId(), "PKCS12PBE");
1493@@ -203,22 +243,24 @@
1494
1495         put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSAES_OAEP, "OAEP");
1496
1497-        put("Alg.Alias.AlgorithmParameters.RSAPSS", "PSS");
1498-        put("Alg.Alias.AlgorithmParameters.RSASSA-PSS", "PSS");
1499-        put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSASSA_PSS, "PSS");
1500-        put("Alg.Alias.AlgorithmParameters.SHA1withRSA/PSS", "PSS");
1501-        put("Alg.Alias.AlgorithmParameters.SHA224withRSA/PSS", "PSS");
1502-        put("Alg.Alias.AlgorithmParameters.SHA256withRSA/PSS", "PSS");
1503-        put("Alg.Alias.AlgorithmParameters.SHA384withRSA/PSS", "PSS");
1504-        put("Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS", "PSS");
1505-        put("Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1", "PSS");
1506-        put("Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1", "PSS");
1507-        put("Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1", "PSS");
1508-        put("Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1", "PSS");
1509-        put("Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1", "PSS");
1510-        put("Alg.Alias.AlgorithmParameters.RAWRSAPSS", "PSS");
1511-        put("Alg.Alias.AlgorithmParameters.NONEWITHRSAPSS", "PSS");
1512-        put("Alg.Alias.AlgorithmParameters.NONEWITHRSASSA-PSS", "PSS");
1513+        // BEGIN android-removed
1514+        // put("Alg.Alias.AlgorithmParameters.RSAPSS", "PSS");
1515+        // put("Alg.Alias.AlgorithmParameters.RSASSA-PSS", "PSS");
1516+        // put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSASSA_PSS, "PSS");
1517+        // put("Alg.Alias.AlgorithmParameters.SHA1withRSA/PSS", "PSS");
1518+        // put("Alg.Alias.AlgorithmParameters.SHA224withRSA/PSS", "PSS");
1519+        // put("Alg.Alias.AlgorithmParameters.SHA256withRSA/PSS", "PSS");
1520+        // put("Alg.Alias.AlgorithmParameters.SHA384withRSA/PSS", "PSS");
1521+        // put("Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS", "PSS");
1522+        // put("Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1", "PSS");
1523+        // put("Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1", "PSS");
1524+        // put("Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1", "PSS");
1525+        // put("Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1", "PSS");
1526+        // put("Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1", "PSS");
1527+        // put("Alg.Alias.AlgorithmParameters.RAWRSAPSS", "PSS");
1528+        // put("Alg.Alias.AlgorithmParameters.NONEWITHRSAPSS", "PSS");
1529+        // put("Alg.Alias.AlgorithmParameters.NONEWITHRSASSA-PSS", "PSS");
1530+        // END android-removed
1531
1532         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITAES-CBC-BC", "PKCS12PBE");
1533         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND192BITAES-CBC-BC", "PKCS12PBE");
1534@@ -235,12 +277,14 @@
1535         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND128BITAES-CBC-BC","PKCS12PBE");
1536         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND192BITAES-CBC-BC","PKCS12PBE");
1537         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND256BITAES-CBC-BC","PKCS12PBE");
1538-
1539-        put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1540-        put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1541-        put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1542-        put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1543-        put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1544+
1545+        // BEGIN android-removed
1546+        // put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1547+        // put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1548+        // put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1549+        // put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1550+        // put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
1551+        // END android-removed
1552
1553         //
1554         // key agreement
1555@@ -252,71 +296,91 @@
1556         // cipher engines
1557         //
1558         put("Cipher.DES", "org.bouncycastle.jce.provider.JCEBlockCipher$DES");
1559-        put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESCBC");
1560-
1561-        put("Cipher.RC2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2");
1562-        put("Cipher.RC2WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
1563-        put("Cipher.1.2.840.113549.1.9.16.3.7", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
1564-
1565-        put("Cipher.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2CBC");
1566+        // BEGIN android-removed
1567+        // put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESCBC");
1568+        //
1569+        // put("Cipher.RC2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2");
1570+        // put("Cipher.RC2WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
1571+        // put("Cipher.1.2.840.113549.1.9.16.3.7", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
1572+        //
1573+        // put("Cipher.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2CBC");
1574+        // END android-removed
1575
1576         put("Alg.Alias.Cipher.PBEWithSHAAnd3KeyTripleDES",  "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
1577
1578-        put("Cipher.GOST28147", "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147");
1579-        put("Alg.Alias.Cipher.GOST", "GOST28147");
1580-        put("Alg.Alias.Cipher.GOST-28147", "GOST28147");
1581-        put("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147cbc");
1582+        // BEGIN android-removed
1583+        // put("Cipher.GOST28147", "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147");
1584+        // put("Alg.Alias.Cipher.GOST", "GOST28147");
1585+        // put("Alg.Alias.Cipher.GOST-28147", "GOST28147");
1586+        // put("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147cbc");
1587+        // END android-removed
1588
1589         put("Cipher.RSA", "org.bouncycastle.jce.provider.JCERSACipher$NoPadding");
1590-        put("Cipher.RSA/RAW", "org.bouncycastle.jce.provider.JCERSACipher$NoPadding");
1591-        put("Cipher.RSA/PKCS1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
1592-        put("Cipher.1.2.840.113549.1.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
1593-        put("Cipher.2.5.8.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
1594-        put("Cipher.RSA/1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PrivateOnly");
1595-        put("Cipher.RSA/2", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PublicOnly");
1596-        put("Cipher.RSA/OAEP", "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
1597-        put("Cipher." + PKCSObjectIdentifiers.id_RSAES_OAEP, "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
1598-        put("Cipher.RSA/ISO9796-1", "org.bouncycastle.jce.provider.JCERSACipher$ISO9796d1Padding");
1599-
1600-        put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES");
1601-        put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES");
1602-        put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES");
1603-        put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES");
1604-        put("Cipher.ELGAMAL", "org.bouncycastle.jce.provider.JCEElGamalCipher$NoPadding");
1605-        put("Cipher.ELGAMAL/PKCS1", "org.bouncycastle.jce.provider.JCEElGamalCipher$PKCS1v1_5Padding");
1606+        // BEGIN android-changed
1607+        put("Alg.Alias.Cipher.RSA/RAW", "RSA");
1608+        // END android-changed
1609+        // BEGIN android-removed
1610+        // put("Cipher.RSA/PKCS1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
1611+        // put("Cipher.1.2.840.113549.1.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
1612+        // put("Cipher.2.5.8.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
1613+        // put("Cipher.RSA/1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PrivateOnly");
1614+        // put("Cipher.RSA/2", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PublicOnly");
1615+        // put("Cipher.RSA/OAEP", "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
1616+        // put("Cipher." + PKCSObjectIdentifiers.id_RSAES_OAEP, "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
1617+        // put("Cipher.RSA/ISO9796-1", "org.bouncycastle.jce.provider.JCERSACipher$ISO9796d1Padding");
1618+        //
1619+        // put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES");
1620+        // put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES");
1621+        // put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES");
1622+        // put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES");
1623+        // put("Cipher.ELGAMAL", "org.bouncycastle.jce.provider.JCEElGamalCipher$NoPadding");
1624+        // put("Cipher.ELGAMAL/PKCS1", "org.bouncycastle.jce.provider.JCEElGamalCipher$PKCS1v1_5Padding");
1625+        // END android-removed
1626
1627         put("Alg.Alias.Cipher.RSA//RAW", "RSA");
1628         put("Alg.Alias.Cipher.RSA//NOPADDING", "RSA");
1629-        put("Alg.Alias.Cipher.RSA//PKCS1PADDING", "RSA/PKCS1");
1630-        put("Alg.Alias.Cipher.RSA//OAEPPADDING", "RSA/OAEP");
1631-        put("Alg.Alias.Cipher.RSA//ISO9796-1PADDING", "RSA/ISO9796-1");
1632-
1633-        put("Alg.Alias.Cipher.ELGAMAL/ECB/PKCS1PADDING", "ELGAMAL/PKCS1");
1634-        put("Alg.Alias.Cipher.ELGAMAL/NONE/PKCS1PADDING", "ELGAMAL/PKCS1");
1635-        put("Alg.Alias.Cipher.ELGAMAL/NONE/NOPADDING", "ELGAMAL");
1636+        // BEGIN android-removed
1637+        // put("Alg.Alias.Cipher.RSA//PKCS1PADDING", "RSA/PKCS1");
1638+        // put("Alg.Alias.Cipher.RSA//OAEPPADDING", "RSA/OAEP");
1639+        // put("Alg.Alias.Cipher.RSA//ISO9796-1PADDING", "RSA/ISO9796-1");
1640+        //
1641+        // put("Alg.Alias.Cipher.ELGAMAL/ECB/PKCS1PADDING", "ELGAMAL/PKCS1");
1642+        // put("Alg.Alias.Cipher.ELGAMAL/NONE/PKCS1PADDING", "ELGAMAL/PKCS1");
1643+        // put("Alg.Alias.Cipher.ELGAMAL/NONE/NOPADDING", "ELGAMAL");
1644+        // END android-removed
1645
1646         put("Cipher.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndDES");
1647-        put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES");
1648+        // BEGIN android-removed
1649+        // put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES");
1650+        // END android-removed
1651         put("Cipher.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndRC2");
1652         put("Cipher.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndDES");
1653-        put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES");
1654+        // BEGIN android-removed
1655+        // put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES");
1656+        // END android-removed
1657         put("Cipher.PBEWITHSHA1ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndRC2");
1658         put("Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndDES3Key");
1659-        put("Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES3Key");
1660-        put("Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndDES3Key");
1661+        // BEGIN android-removed
1662+        // put("Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES3Key");
1663+        // put("Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndDES3Key");
1664+        // END android-removed
1665         put("Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndDES2Key");
1666-        put("Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES2Key");
1667+        // BEGIN android-removed
1668+        // put("Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES2Key");
1669+        // END android-removed
1670         put("Cipher.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd128BitRC2");
1671         put("Cipher.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd40BitRC2");
1672         put("Cipher.PBEWITHSHAAND128BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd128BitRC4");
1673         put("Cipher.PBEWITHSHAAND40BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd40BitRC4");
1674
1675-        put("Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC", "Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
1676-        put("Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC", "Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC");
1677-        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "Cipher.PBEWITHSHAAND128BITRC2-CBC");
1678-        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "Cipher.PBEWITHSHAAND40BITRC2-CBC");
1679-        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "Cipher.PBEWITHSHAAND128BITRC4");
1680-        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "Cipher.PBEWITHSHAAND40BITRC4");
1681+        // BEGIN android-changed
1682+        put("Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
1683+        put("Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC", "PBEWITHSHAAND2-KEYTRIPLEDES-CBC");
1684+        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "PBEWITHSHAAND128BITRC2-CBC");
1685+        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "PBEWITHSHAAND40BITRC2-CBC");
1686+        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "PBEWITHSHAAND128BITRC4");
1687+        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "PBEWITHSHAAND40BITRC4");
1688+        // END android-changed
1689
1690         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PBEWITHSHAAND128BITAES-CBC-BC");
1691         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PBEWITHSHAAND192BITAES-CBC-BC");
1692@@ -324,7 +388,7 @@
1693         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC");
1694         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC");
1695         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC");
1696-
1697+
1698         put("Cipher.PBEWITHSHAAND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
1699         put("Cipher.PBEWITHSHAAND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
1700         put("Cipher.PBEWITHSHAAND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
1701@@ -346,10 +410,12 @@
1702         put("Cipher.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
1703
1704         put("Cipher.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndTwofish");
1705-        put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish");
1706-
1707-        put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
1708-        put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
1709+        // BEGIN android-removed
1710+        // put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish");
1711+        //
1712+        // put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
1713+        // put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
1714+        // END android-removed
1715         put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
1716         put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDDES");
1717         put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
1718@@ -368,13 +434,15 @@
1719         put("KeyGenerator.DES", "org.bouncycastle.jce.provider.JCEKeyGenerator$DES");
1720         put("Alg.Alias.KeyGenerator." + OIWObjectIdentifiers.desCBC, "DES");
1721
1722-        put("KeyGenerator.RC2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
1723-        put("KeyGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
1724-
1725-        put("KeyGenerator.GOST28147", "org.bouncycastle.jce.provider.JCEKeyGenerator$GOST28147");
1726-        put("Alg.Alias.KeyGenerator.GOST", "GOST28147");
1727-        put("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147");
1728-        put("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147");
1729+        // BEGIN android-removed
1730+        // put("KeyGenerator.RC2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
1731+        // put("KeyGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
1732+        //
1733+        // put("KeyGenerator.GOST28147", "org.bouncycastle.jce.provider.JCEKeyGenerator$GOST28147");
1734+        // put("Alg.Alias.KeyGenerator.GOST", "GOST28147");
1735+        // put("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147");
1736+        // put("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147");
1737+        // END android-removed
1738
1739         //
1740         // key pair generators.
1741@@ -382,14 +450,18 @@
1742         put("KeyPairGenerator.RSA", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$RSA");
1743         put("KeyPairGenerator.DH", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$DH");
1744         put("KeyPairGenerator.DSA", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$DSA");
1745-        put("KeyPairGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$ElGamal");
1746+        // BEGIN android-removed
1747+        // put("KeyPairGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$ElGamal");
1748+        // END android-removed
1749
1750         put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.1", "RSA");
1751         put("Alg.Alias.KeyPairGenerator.DIFFIEHELLMAN", "DH");
1752
1753-        put("KeyPairGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$GOST3410");
1754-        put("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410");
1755-        put("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410");
1756+        // BEGIN android-removed
1757+        // put("KeyPairGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$GOST3410");
1758+        // put("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410");
1759+        // put("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410");
1760+        // END android-removed
1761
1762         //
1763         // key factories
1764@@ -397,20 +469,24 @@
1765         put("KeyFactory.RSA", "org.bouncycastle.jce.provider.JDKKeyFactory$RSA");
1766         put("KeyFactory.DH", "org.bouncycastle.jce.provider.JDKKeyFactory$DH");
1767         put("KeyFactory.DSA", "org.bouncycastle.jce.provider.JDKKeyFactory$DSA");
1768-        put("KeyFactory.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
1769-        put("KeyFactory.ElGamal", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
1770-
1771-        put("KeyFactory.X.509", "org.bouncycastle.jce.provider.JDKKeyFactory$X509");
1772+        // BEGIN android-removed
1773+        // put("KeyFactory.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
1774+        // put("KeyFactory.ElGamal", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
1775+        //
1776+        // put("KeyFactory.X.509", "org.bouncycastle.jce.provider.JDKKeyFactory$X509");
1777+        // END android-removed
1778
1779         put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.1", "RSA");
1780         put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
1781
1782         put("Alg.Alias.KeyFactory.DIFFIEHELLMAN", "DH");
1783
1784-        put("KeyFactory.GOST3410", "org.bouncycastle.jce.provider.JDKKeyFactory$GOST3410");
1785-        put("Alg.Alias.KeyFactory.GOST-3410", "GOST3410");
1786-        put("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410");
1787-        put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_94, "GOST3410");
1788+        // BEGIN android-removed
1789+        // put("KeyFactory.GOST3410", "org.bouncycastle.jce.provider.JDKKeyFactory$GOST3410");
1790+        // put("Alg.Alias.KeyFactory.GOST-3410", "GOST3410");
1791+        // put("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410");
1792+        // put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_94, "GOST3410");
1793+        // END android-removed
1794
1795         //
1796         // Algorithm parameters
1797@@ -418,24 +494,34 @@
1798         put("AlgorithmParameters.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
1799         put("Alg.Alias.AlgorithmParameters." + OIWObjectIdentifiers.desCBC, "DES");
1800         put("AlgorithmParameters.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
1801-        put("AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
1802-        put("AlgorithmParameters.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
1803-        put("AlgorithmParameters.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
1804+        // BEGIN android-changed
1805+        put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "DESEDE");
1806+        // END android-changed
1807+        // BEGIN android-removed
1808+        // put("AlgorithmParameters.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
1809+        // put("AlgorithmParameters.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
1810+        // END android-removed
1811
1812         //
1813         // secret key factories.
1814         //
1815         put("SecretKeyFactory.DES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$DES");
1816-        put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES");
1817-
1818-        put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
1819-        put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
1820+        // BEGIN android-removed
1821+        // put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES");
1822+        // END android-removed
1823+
1824+        // BEGIN android-removed
1825+        // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
1826+        // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
1827+        // END android-removed
1828         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
1829         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDDES");
1830         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
1831         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndRC2_CBC, "PBEWITHSHA1ANDRC2");
1832
1833-        put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2");
1834+        // BEGIN android-removed
1835+        // put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2");
1836+        // END android-removed
1837         put("SecretKeyFactory.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndDES");
1838         put("SecretKeyFactory.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndRC2");
1839         put("SecretKeyFactory.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA1AndDES");
1840@@ -447,31 +533,41 @@
1841         put("SecretKeyFactory.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd128BitRC2");
1842         put("SecretKeyFactory.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd40BitRC2");
1843         put("SecretKeyFactory.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndTwofish");
1844-        put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160");
1845+        // BEGIN android-removed
1846+        // put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160");
1847+        // END android-removed
1848         put("SecretKeyFactory.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA");
1849-        put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger");
1850+        // BEGIN android-removed
1851+        // put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger");
1852+        // END android-removed
1853
1854         put("SecretKeyFactory.PBEWITHMD5AND128BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And128BitAESCBCOpenSSL");
1855         put("SecretKeyFactory.PBEWITHMD5AND192BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And192BitAESCBCOpenSSL");
1856         put("SecretKeyFactory.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And256BitAESCBCOpenSSL");
1857
1858-        put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5");
1859-
1860-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5");
1861-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5");
1862-        put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
1863-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
1864-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12");
1865-        put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12");
1866-
1867-        put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES");
1868-        put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2");
1869+        // BEGIN android-removed
1870+        // put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5");
1871+        //
1872+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5");
1873+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5");
1874+        // put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
1875+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
1876+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12");
1877+        // put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12");
1878+        // END android-removed
1879+
1880+        // BEGIN android-removed
1881+        // put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES");
1882+        // put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2");
1883+        // END android-removed
1884         put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDDES-CBC", "PBEWITHMD5ANDDES");
1885         put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDRC2-CBC", "PBEWITHMD5ANDRC2");
1886         put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDDES-CBC", "PBEWITHSHA1ANDDES");
1887         put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDRC2-CBC", "PBEWITHSHA1ANDRC2");
1888-        put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
1889-        put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
1890+        // BEGIN android-removed
1891+        // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
1892+        // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
1893+        // END android-removed
1894         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
1895         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDRC2");
1896         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
1897@@ -508,6 +604,10 @@
1898         put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC");
1899         put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC");
1900         put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC");
1901+        // BEGIN android-added
1902+
1903+        put("SecretKeyFactory.PBKDF2WithHmacSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBKDF2WithHmacSHA1");
1904+        // END android-added
1905
1906         addMacAlgorithms();
1907
1908@@ -516,16 +616,23 @@
1909         addSignatureAlgorithms();
1910
1911     // Certification Path API
1912-        put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi");
1913-        put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi");
1914-        put("CertPathValidator.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi");
1915-        put("CertPathBuilder.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi");
1916+        // BEGIN android-removed
1917+        // put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi");
1918+        // put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi");
1919+        // END android-removed
1920+        // BEGIN android-changed
1921+        // Use Alg.Alias so RFC3280 doesn't show up when iterating provider services, only PKIX
1922+        put("Alg.Alias.CertPathValidator.RFC3280", "PKIX");
1923+        put("Alg.Alias.CertPathBuilder.RFC3280", "PKIX");
1924+        // END android-changed
1925         put("CertPathValidator.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi");
1926         put("CertPathBuilder.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi");
1927         put("CertStore.Collection", "org.bouncycastle.jce.provider.CertStoreCollectionSpi");
1928-        put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi");
1929-        put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi");
1930-        put("Alg.Alias.CertStore.X509LDAP", "LDAP");
1931+        // BEGIN android-removed
1932+        // put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi");
1933+        // put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi");
1934+        // put("Alg.Alias.CertStore.X509LDAP", "LDAP");
1935+        // END android-removed
1936     }
1937
1938     private void loadAlgorithms(String packageName, String[] names)
1939@@ -586,42 +693,46 @@
1940     //
1941     private void addMacAlgorithms()
1942     {
1943-        put("Mac.DESMAC", "org.bouncycastle.jce.provider.JCEMac$DES");
1944-        put("Alg.Alias.Mac.DES", "DESMAC");
1945-        put("Mac.DESMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESCFB8");
1946-        put("Alg.Alias.Mac.DES/CFB8", "DESMAC/CFB8");
1947-
1948-        put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
1949-        put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797");
1950-
1951-        put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
1952-        put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC");
1953-        put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4");
1954-        put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING");
1955-
1956-        put("Mac.RC2MAC", "org.bouncycastle.jce.provider.JCEMac$RC2");
1957-        put("Alg.Alias.Mac.RC2", "RC2MAC");
1958-        put("Mac.RC2MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC2CFB8");
1959-        put("Alg.Alias.Mac.RC2/CFB8", "RC2MAC/CFB8");
1960-
1961-
1962-        put("Mac.GOST28147MAC", "org.bouncycastle.jce.provider.JCEMac$GOST28147");
1963-        put("Alg.Alias.Mac.GOST28147", "GOST28147MAC");
1964-
1965-        put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384");
1966-
1967-        put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512");
1968-
1969-        addHMACAlgorithm("MD2", "org.bouncycastle.jce.provider.JCEMac$MD2", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD2HMAC");
1970-        addHMACAlgorithm("MD4", "org.bouncycastle.jce.provider.JCEMac$MD4", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD4HMAC");
1971+        // BEGIN android-removed
1972+        // put("Mac.DESMAC", "org.bouncycastle.jce.provider.JCEMac$DES");
1973+        // put("Alg.Alias.Mac.DES", "DESMAC");
1974+        // put("Mac.DESMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESCFB8");
1975+        // put("Alg.Alias.Mac.DES/CFB8", "DESMAC/CFB8");
1976+        //
1977+        // put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
1978+        // put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797");
1979+        //
1980+        // put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
1981+        // put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC");
1982+        // put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4");
1983+        // put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING");
1984+        //
1985+        // put("Mac.RC2MAC", "org.bouncycastle.jce.provider.JCEMac$RC2");
1986+        // put("Alg.Alias.Mac.RC2", "RC2MAC");
1987+        // put("Mac.RC2MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC2CFB8");
1988+        // put("Alg.Alias.Mac.RC2/CFB8", "RC2MAC/CFB8");
1989+        //
1990+        //
1991+        // put("Mac.GOST28147MAC", "org.bouncycastle.jce.provider.JCEMac$GOST28147");
1992+        // put("Alg.Alias.Mac.GOST28147", "GOST28147MAC");
1993+        //
1994+        // put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384");
1995+        //
1996+        // put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512");
1997+        //
1998+        // addHMACAlgorithm("MD2", "org.bouncycastle.jce.provider.JCEMac$MD2", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD2HMAC");
1999+        // addHMACAlgorithm("MD4", "org.bouncycastle.jce.provider.JCEMac$MD4", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD4HMAC");
2000+        // END android-removed
2001         addHMACAlgorithm("MD5", "org.bouncycastle.jce.provider.JCEMac$MD5", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD5HMAC");
2002         addHMACAlias("MD5", IANAObjectIdentifiers.hmacMD5);
2003
2004         addHMACAlgorithm("SHA1", "org.bouncycastle.jce.provider.JCEMac$SHA1", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA1");
2005         addHMACAlias("SHA1", PKCSObjectIdentifiers.id_hmacWithSHA1);
2006         addHMACAlias("SHA1", IANAObjectIdentifiers.hmacSHA1);
2007-        addHMACAlgorithm("SHA224", "org.bouncycastle.jce.provider.JCEMac$SHA224", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA224");
2008-        addHMACAlias("SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224);
2009+        // BEGIN android-removed
2010+        // addHMACAlgorithm("SHA224", "org.bouncycastle.jce.provider.JCEMac$SHA224", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA224");
2011+        // addHMACAlias("SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224);
2012+        // END android-removed
2013         addHMACAlgorithm("SHA256", "org.bouncycastle.jce.provider.JCEMac$SHA256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA256");
2014         addHMACAlias("SHA256", PKCSObjectIdentifiers.id_hmacWithSHA256);
2015         addHMACAlgorithm("SHA384", "org.bouncycastle.jce.provider.JCEMac$SHA384", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA384");
2016@@ -629,16 +740,20 @@
2017         addHMACAlgorithm("SHA512", "org.bouncycastle.jce.provider.JCEMac$SHA512", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA512");
2018         addHMACAlias("SHA512", PKCSObjectIdentifiers.id_hmacWithSHA512);
2019
2020-        addHMACAlgorithm("RIPEMD128", "org.bouncycastle.jce.provider.JCEMac$RIPEMD128", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD128HMAC");
2021-        addHMACAlgorithm("RIPEMD160", "org.bouncycastle.jce.provider.JCEMac$RIPEMD160", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD160HMAC");
2022-        addHMACAlias("RIPEMD160", IANAObjectIdentifiers.hmacRIPEMD160);
2023-
2024-        addHMACAlgorithm("TIGER", "org.bouncycastle.jce.provider.JCEMac$Tiger", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACTIGER");
2025-        addHMACAlias("TIGER", IANAObjectIdentifiers.hmacTIGER);
2026+        // BEGIN android-removed
2027+        // addHMACAlgorithm("RIPEMD128", "org.bouncycastle.jce.provider.JCEMac$RIPEMD128", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD128HMAC");
2028+        // addHMACAlgorithm("RIPEMD160", "org.bouncycastle.jce.provider.JCEMac$RIPEMD160", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD160HMAC");
2029+        // addHMACAlias("RIPEMD160", IANAObjectIdentifiers.hmacRIPEMD160);
2030+        //
2031+        // addHMACAlgorithm("TIGER", "org.bouncycastle.jce.provider.JCEMac$Tiger", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACTIGER");
2032+        // addHMACAlias("TIGER", IANAObjectIdentifiers.hmacTIGER);
2033+        // END android-removed
2034
2035         put("Mac.PBEWITHHMACSHA", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA");
2036         put("Mac.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA");
2037-        put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160");
2038+        // BEGIN android-removed
2039+        // put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160");
2040+        // END android-removed
2041         put("Alg.Alias.Mac.1.3.14.3.2.26", "PBEWITHHMACSHA");
2042     }
2043
2044@@ -676,9 +791,11 @@
2045         put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
2046         put("Alg.Alias.MessageDigest.SHA", "SHA-1");
2047         put("Alg.Alias.MessageDigest." + OIWObjectIdentifiers.idSHA1, "SHA-1");
2048-        put("MessageDigest.SHA-224", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA224");
2049-        put("Alg.Alias.MessageDigest.SHA224", "SHA-224");
2050-        put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224");
2051+        // BEGIN android-removed
2052+        // put("MessageDigest.SHA-224", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA224");
2053+        // put("Alg.Alias.MessageDigest.SHA224", "SHA-224");
2054+        // put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224");
2055+        // END android-removed
2056         put("MessageDigest.SHA-256", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA256");
2057         put("Alg.Alias.MessageDigest.SHA256", "SHA-256");
2058         put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha256, "SHA-256");
2059@@ -689,27 +806,31 @@
2060         put("Alg.Alias.MessageDigest.SHA512", "SHA-512");
2061         put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha512, "SHA-512");
2062
2063-        put("MessageDigest.MD2", "org.bouncycastle.jce.provider.JDKMessageDigest$MD2");
2064-        put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md2, "MD2");
2065-        put("MessageDigest.MD4", "org.bouncycastle.jce.provider.JDKMessageDigest$MD4");
2066-        put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md4, "MD4");
2067+        // BEGIN android-removed
2068+        // put("MessageDigest.MD2", "org.bouncycastle.jce.provider.JDKMessageDigest$MD2");
2069+        // put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md2, "MD2");
2070+        // put("MessageDigest.MD4", "org.bouncycastle.jce.provider.JDKMessageDigest$MD4");
2071+        // put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md4, "MD4");
2072+        // END android-removed
2073         put("MessageDigest.MD5", "org.bouncycastle.jce.provider.JDKMessageDigest$MD5");
2074         put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md5, "MD5");
2075-        put("MessageDigest.RIPEMD128", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD128");
2076-        put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd128, "RIPEMD128");
2077-        put("MessageDigest.RIPEMD160", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD160");
2078-        put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd160, "RIPEMD160");
2079-        put("MessageDigest.RIPEMD256", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD256");
2080-        put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd256, "RIPEMD256");
2081-        put("MessageDigest.RIPEMD320", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD320");
2082-        put("MessageDigest.Tiger", "org.bouncycastle.jce.provider.JDKMessageDigest$Tiger");
2083-
2084-        put("MessageDigest.WHIRLPOOL", "org.bouncycastle.jce.provider.JDKMessageDigest$Whirlpool");
2085-
2086-        put("MessageDigest.GOST3411", "org.bouncycastle.jce.provider.JDKMessageDigest$GOST3411");
2087-        put("Alg.Alias.MessageDigest.GOST", "GOST3411");
2088-        put("Alg.Alias.MessageDigest.GOST-3411", "GOST3411");
2089-        put("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411");
2090+        // BEGIN android-removed
2091+        // put("MessageDigest.RIPEMD128", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD128");
2092+        // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd128, "RIPEMD128");
2093+        // put("MessageDigest.RIPEMD160", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD160");
2094+        // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd160, "RIPEMD160");
2095+        // put("MessageDigest.RIPEMD256", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD256");
2096+        // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd256, "RIPEMD256");
2097+        // put("MessageDigest.RIPEMD320", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD320");
2098+        // put("MessageDigest.Tiger", "org.bouncycastle.jce.provider.JDKMessageDigest$Tiger");
2099+
2100+        // put("MessageDigest.WHIRLPOOL", "org.bouncycastle.jce.provider.JDKMessageDigest$Whirlpool");
2101+
2102+        // put("MessageDigest.GOST3411", "org.bouncycastle.jce.provider.JDKMessageDigest$GOST3411");
2103+        // put("Alg.Alias.MessageDigest.GOST", "GOST3411");
2104+        // put("Alg.Alias.MessageDigest.GOST-3411", "GOST3411");
2105+        // put("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411");
2106+        // END android-removed
2107     }
2108
2109     //
2110@@ -717,55 +838,70 @@
2111     //
2112     private void addSignatureAlgorithms()
2113     {
2114-        put("Signature.MD2WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD2WithRSAEncryption");
2115-        put("Signature.MD4WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD4WithRSAEncryption");
2116+        // BEGIN android-removed
2117+        // Dropping MD2
2118+        // put("Signature.MD2WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD2WithRSAEncryption");
2119+        // put("Signature.MD4WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD4WithRSAEncryption");
2120+        // END android-removed
2121         put("Signature.MD5WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD5WithRSAEncryption");
2122         put("Signature.SHA1WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA1WithRSAEncryption");
2123-        put("Signature.SHA224WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA224WithRSAEncryption");
2124+        // BEGIN android-removed
2125+        // put("Signature.SHA224WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA224WithRSAEncryption");
2126+        // END android-removed
2127         put("Signature.SHA256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA256WithRSAEncryption");
2128         put("Signature.SHA384WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA384WithRSAEncryption");
2129         put("Signature.SHA512WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA512WithRSAEncryption");
2130-        put("Signature.RIPEMD160WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD160WithRSAEncryption");
2131-        put("Signature.RIPEMD128WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD128WithRSAEncryption");
2132-        put("Signature.RIPEMD256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD256WithRSAEncryption");
2133-        put("Signature.DSA", "org.bouncycastle.jce.provider.JDKDSASigner$stdDSA");
2134+        // BEGIN android-removed
2135+        // put("Signature.RIPEMD160WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD160WithRSAEncryption");
2136+        // put("Signature.RIPEMD128WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD128WithRSAEncryption");
2137+        // put("Signature.RIPEMD256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD256WithRSAEncryption");
2138+        // END android-removed
2139+        // BEGIN android-changed
2140+        put("Signature.SHA1withDSA", "org.bouncycastle.jce.provider.JDKDSASigner$stdDSA");
2141+        // END android-changed
2142         put("Signature.NONEWITHDSA", "org.bouncycastle.jce.provider.JDKDSASigner$noneDSA");
2143-        put("Signature.SHA1withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$SHA1WithRSAEncryption");
2144-        put("Signature.MD5withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$MD5WithRSAEncryption");
2145-        put("Signature.RIPEMD160withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$RIPEMD160WithRSAEncryption");
2146-
2147-        put("Signature.RSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
2148-        put("Signature." + PKCSObjectIdentifiers.id_RSASSA_PSS, "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
2149-        put("Signature.SHA1withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA1withRSA");
2150-        put("Signature.SHA224withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA224withRSA");
2151-        put("Signature.SHA256withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA256withRSA");
2152-        put("Signature.SHA384withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA384withRSA");
2153-        put("Signature.SHA512withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA512withRSA");
2154-
2155-        put("Signature.RSA", "org.bouncycastle.jce.provider.JDKDigestSignature$noneRSA");
2156-        put("Signature.RAWRSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$nonePSS");
2157+        // BEGIN android-removed
2158+        // put("Signature.SHA1withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$SHA1WithRSAEncryption");
2159+        // put("Signature.MD5withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$MD5WithRSAEncryption");
2160+        // put("Signature.RIPEMD160withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$RIPEMD160WithRSAEncryption");
2161+        //
2162+        // put("Signature.RSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
2163+        // put("Signature." + PKCSObjectIdentifiers.id_RSASSA_PSS, "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
2164+        // put("Signature.SHA1withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA1withRSA");
2165+        // put("Signature.SHA224withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA224withRSA");
2166+        // put("Signature.SHA256withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA256withRSA");
2167+        // put("Signature.SHA384withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA384withRSA");
2168+        // put("Signature.SHA512withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA512withRSA");
2169+        //
2170+        // put("Signature.RSA", "org.bouncycastle.jce.provider.JDKDigestSignature$noneRSA");
2171+        // put("Signature.RAWRSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$nonePSS");
2172+        // END android-removed
2173
2174         put("Alg.Alias.Signature.RAWDSA", "NONEWITHDSA");
2175
2176-        put("Alg.Alias.Signature.RAWRSA", "RSA");
2177-        put("Alg.Alias.Signature.NONEWITHRSA", "RSA");
2178-        put("Alg.Alias.Signature.RAWRSAPSS", "RAWRSASSA-PSS");
2179-        put("Alg.Alias.Signature.NONEWITHRSAPSS", "RAWRSASSA-PSS");
2180-        put("Alg.Alias.Signature.NONEWITHRSASSA-PSS", "RAWRSASSA-PSS");
2181-
2182-        put("Alg.Alias.Signature.RSAPSS", "RSASSA-PSS");
2183-
2184-        put("Alg.Alias.Signature.SHA1withRSAandMGF1", "SHA1withRSA/PSS");
2185-        put("Alg.Alias.Signature.SHA224withRSAandMGF1", "SHA224withRSA/PSS");
2186-        put("Alg.Alias.Signature.SHA256withRSAandMGF1", "SHA256withRSA/PSS");
2187-        put("Alg.Alias.Signature.SHA384withRSAandMGF1", "SHA384withRSA/PSS");
2188-        put("Alg.Alias.Signature.SHA512withRSAandMGF1", "SHA512withRSA/PSS");
2189-
2190-        put("Alg.Alias.Signature.MD2withRSAEncryption", "MD2WithRSAEncryption");
2191-        put("Alg.Alias.Signature.MD4withRSAEncryption", "MD4WithRSAEncryption");
2192+        // BEGIN android-removed
2193+        // put("Alg.Alias.Signature.RAWRSA", "RSA");
2194+        // put("Alg.Alias.Signature.NONEWITHRSA", "RSA");
2195+        // put("Alg.Alias.Signature.RAWRSAPSS", "RAWRSASSA-PSS");
2196+        // put("Alg.Alias.Signature.NONEWITHRSAPSS", "RAWRSASSA-PSS");
2197+        // put("Alg.Alias.Signature.NONEWITHRSASSA-PSS", "RAWRSASSA-PSS");
2198+        //
2199+        // put("Alg.Alias.Signature.RSAPSS", "RSASSA-PSS");
2200+        //
2201+        // put("Alg.Alias.Signature.SHA1withRSAandMGF1", "SHA1withRSA/PSS");
2202+        // put("Alg.Alias.Signature.SHA224withRSAandMGF1", "SHA224withRSA/PSS");
2203+        // put("Alg.Alias.Signature.SHA256withRSAandMGF1", "SHA256withRSA/PSS");
2204+        // put("Alg.Alias.Signature.SHA384withRSAandMGF1", "SHA384withRSA/PSS");
2205+        // put("Alg.Alias.Signature.SHA512withRSAandMGF1", "SHA512withRSA/PSS");
2206+        //
2207+        // put("Alg.Alias.Signature.MD2withRSAEncryption", "MD2WithRSAEncryption");
2208+        // put("Alg.Alias.Signature.MD4withRSAEncryption", "MD4WithRSAEncryption");
2209+        // END android-removed
2210         put("Alg.Alias.Signature.MD5withRSAEncryption", "MD5WithRSAEncryption");
2211         put("Alg.Alias.Signature.SHA1withRSAEncryption", "SHA1WithRSAEncryption");
2212-        put("Alg.Alias.Signature.SHA224withRSAEncryption", "SHA224WithRSAEncryption");
2213+        // BEGIN android-removed
2214+        // put("Alg.Alias.Signature.SHA224withRSAEncryption", "SHA224WithRSAEncryption");
2215+        // END android-removed
2216
2217         put("Alg.Alias.Signature.SHA256withRSAEncryption", "SHA256WithRSAEncryption");
2218         put("Alg.Alias.Signature.SHA384withRSAEncryption", "SHA384WithRSAEncryption");
2219@@ -779,24 +915,30 @@
2220         put("Alg.Alias.Signature.SHA384WITHRSAENCRYPTION", "SHA384WithRSAEncryption");
2221         put("Alg.Alias.Signature.SHA512WITHRSAENCRYPTION", "SHA512WithRSAEncryption");
2222
2223-        put("Alg.Alias.Signature.RIPEMD160withRSAEncryption", "RIPEMD160WithRSAEncryption");
2224-
2225-        put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md2WithRSAEncryption, "MD2WithRSAEncryption");
2226-        put("Alg.Alias.Signature.MD2WithRSA", "MD2WithRSAEncryption");
2227-        put("Alg.Alias.Signature.MD2withRSA", "MD2WithRSAEncryption");
2228-        put("Alg.Alias.Signature.MD2/RSA", "MD2WithRSAEncryption");
2229+        // BEGIN android-removed
2230+        // Dropping MD2
2231+        // put("Alg.Alias.Signature.RIPEMD160withRSAEncryption", "RIPEMD160WithRSAEncryption");
2232+        // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md2WithRSAEncryption, "MD2WithRSAEncryption");
2233+        // put("Alg.Alias.Signature.MD2WithRSA", "MD2WithRSAEncryption");
2234+        // put("Alg.Alias.Signature.MD2withRSA", "MD2WithRSAEncryption");
2235+        // put("Alg.Alias.Signature.MD2/RSA", "MD2WithRSAEncryption");
2236+        // END android-removed
2237         put("Alg.Alias.Signature.MD5WithRSA", "MD5WithRSAEncryption");
2238         put("Alg.Alias.Signature.MD5withRSA", "MD5WithRSAEncryption");
2239         put("Alg.Alias.Signature.MD5/RSA", "MD5WithRSAEncryption");
2240         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md5WithRSAEncryption, "MD5WithRSAEncryption");
2241-        put("Alg.Alias.Signature.MD4WithRSA", "MD4WithRSAEncryption");
2242-        put("Alg.Alias.Signature.MD4withRSA", "MD4WithRSAEncryption");
2243-        put("Alg.Alias.Signature.MD4/RSA", "MD4WithRSAEncryption");
2244-        put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md4WithRSAEncryption, "MD4WithRSAEncryption");
2245+        // BEGIN android-removed
2246+        // put("Alg.Alias.Signature.MD4WithRSA", "MD4WithRSAEncryption");
2247+        // put("Alg.Alias.Signature.MD4withRSA", "MD4WithRSAEncryption");
2248+        // put("Alg.Alias.Signature.MD4/RSA", "MD4WithRSAEncryption");
2249+        // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md4WithRSAEncryption, "MD4WithRSAEncryption");
2250+        // END android-removed
2251         put("Alg.Alias.Signature.SHA1WithRSA", "SHA1WithRSAEncryption");
2252         put("Alg.Alias.Signature.SHA1withRSA", "SHA1WithRSAEncryption");
2253-        put("Alg.Alias.Signature.SHA224WithRSA", "SHA224WithRSAEncryption");
2254-        put("Alg.Alias.Signature.SHA224withRSA", "SHA224WithRSAEncryption");
2255+        // BEGIN android-removed
2256+        // put("Alg.Alias.Signature.SHA224WithRSA", "SHA224WithRSAEncryption");
2257+        // put("Alg.Alias.Signature.SHA224withRSA", "SHA224WithRSAEncryption");
2258+        // END android-removed
2259         put("Alg.Alias.Signature.SHA256WithRSA", "SHA256WithRSAEncryption");
2260         put("Alg.Alias.Signature.SHA256withRSA", "SHA256WithRSAEncryption");
2261         put("Alg.Alias.Signature.SHA384WithRSA", "SHA384WithRSAEncryption");
2262@@ -806,92 +948,110 @@
2263         put("Alg.Alias.Signature.SHA1/RSA", "SHA1WithRSAEncryption");
2264         put("Alg.Alias.Signature.SHA-1/RSA", "SHA1WithRSAEncryption");
2265         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha1WithRSAEncryption, "SHA1WithRSAEncryption");
2266-        put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WithRSAEncryption");
2267+        // BEGIN android-removed
2268+        // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WithRSAEncryption");
2269+        // END android-removed
2270         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha256WithRSAEncryption, "SHA256WithRSAEncryption");
2271         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha384WithRSAEncryption, "SHA384WithRSAEncryption");
2272         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha512WithRSAEncryption, "SHA512WithRSAEncryption");
2273         put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.1", "SHA1WithRSAEncryption");
2274         put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.5", "SHA1WithRSAEncryption");
2275         put("Alg.Alias.Signature.1.2.840.113549.2.5with1.2.840.113549.1.1.1", "MD5WithRSAEncryption");
2276-        put("Alg.Alias.Signature.RIPEMD160WithRSA", "RIPEMD160WithRSAEncryption");
2277-        put("Alg.Alias.Signature.RIPEMD160withRSA", "RIPEMD160WithRSAEncryption");
2278-        put("Alg.Alias.Signature.RIPEMD128WithRSA", "RIPEMD128WithRSAEncryption");
2279-        put("Alg.Alias.Signature.RIPEMD128withRSA", "RIPEMD128WithRSAEncryption");
2280-        put("Alg.Alias.Signature.RIPEMD256WithRSA", "RIPEMD256WithRSAEncryption");
2281-        put("Alg.Alias.Signature.RIPEMD256withRSA", "RIPEMD256WithRSAEncryption");
2282-        put("Alg.Alias.Signature.RIPEMD-160/RSA", "RIPEMD160WithRSAEncryption");
2283-        put("Alg.Alias.Signature.RMD160withRSA", "RIPEMD160WithRSAEncryption");
2284-        put("Alg.Alias.Signature.RMD160/RSA", "RIPEMD160WithRSAEncryption");
2285-        put("Alg.Alias.Signature.1.3.36.3.3.1.2", "RIPEMD160WithRSAEncryption");
2286-        put("Alg.Alias.Signature.1.3.36.3.3.1.3", "RIPEMD128WithRSAEncryption");
2287-        put("Alg.Alias.Signature.1.3.36.3.3.1.4", "RIPEMD256WithRSAEncryption");
2288+        // BEGIN android-removed
2289+        // put("Alg.Alias.Signature.RIPEMD160WithRSA", "RIPEMD160WithRSAEncryption");
2290+        // put("Alg.Alias.Signature.RIPEMD160withRSA", "RIPEMD160WithRSAEncryption");
2291+        // put("Alg.Alias.Signature.RIPEMD128WithRSA", "RIPEMD128WithRSAEncryption");
2292+        // put("Alg.Alias.Signature.RIPEMD128withRSA", "RIPEMD128WithRSAEncryption");
2293+        // put("Alg.Alias.Signature.RIPEMD256WithRSA", "RIPEMD256WithRSAEncryption");
2294+        // put("Alg.Alias.Signature.RIPEMD256withRSA", "RIPEMD256WithRSAEncryption");
2295+        // put("Alg.Alias.Signature.RIPEMD-160/RSA", "RIPEMD160WithRSAEncryption");
2296+        // put("Alg.Alias.Signature.RMD160withRSA", "RIPEMD160WithRSAEncryption");
2297+        // put("Alg.Alias.Signature.RMD160/RSA", "RIPEMD160WithRSAEncryption");
2298+        // put("Alg.Alias.Signature.1.3.36.3.3.1.2", "RIPEMD160WithRSAEncryption");
2299+        // put("Alg.Alias.Signature.1.3.36.3.3.1.3", "RIPEMD128WithRSAEncryption");
2300+        // put("Alg.Alias.Signature.1.3.36.3.3.1.4", "RIPEMD256WithRSAEncryption");
2301+        // END android-removed
2302         put("Alg.Alias.Signature." + OIWObjectIdentifiers.sha1WithRSA, "SHA1WithRSAEncryption");
2303
2304-        put("Alg.Alias.Signature.MD2WITHRSAENCRYPTION", "MD2WithRSAEncryption");
2305+        // BEGIN android-removed
2306+        // put("Alg.Alias.Signature.MD2WITHRSAENCRYPTION", "MD2WithRSAEncryption");
2307+        // END android-removed
2308         put("Alg.Alias.Signature.MD5WITHRSAENCRYPTION", "MD5WithRSAEncryption");
2309         put("Alg.Alias.Signature.SHA1WITHRSAENCRYPTION", "SHA1WithRSAEncryption");
2310-        put("Alg.Alias.Signature.RIPEMD160WITHRSAENCRYPTION", "RIPEMD160WithRSAEncryption");
2311+        // BEGIN android-removed
2312+        // put("Alg.Alias.Signature.RIPEMD160WITHRSAENCRYPTION", "RIPEMD160WithRSAEncryption");
2313+        // END android-removed
2314
2315         put("Alg.Alias.Signature.MD5WITHRSA", "MD5WithRSAEncryption");
2316         put("Alg.Alias.Signature.SHA1WITHRSA", "SHA1WithRSAEncryption");
2317-        put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
2318-        put("Alg.Alias.Signature.RMD160WITHRSA", "RIPEMD160WithRSAEncryption");
2319-        put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
2320-
2321-        addSignatureAlgorithm("SHA224", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa224", NISTObjectIdentifiers.dsa_with_sha224);
2322-        addSignatureAlgorithm("SHA256", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa256", NISTObjectIdentifiers.dsa_with_sha256);
2323-        addSignatureAlgorithm("SHA384", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa384", NISTObjectIdentifiers.dsa_with_sha384);
2324-        addSignatureAlgorithm("SHA512", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa512", NISTObjectIdentifiers.dsa_with_sha512);
2325-
2326-        put("Alg.Alias.Signature.SHA/DSA", "DSA");
2327-        put("Alg.Alias.Signature.SHA1withDSA", "DSA");
2328-        put("Alg.Alias.Signature.SHA1WITHDSA", "DSA");
2329-        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "DSA");
2330-        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3", "DSA");
2331-        put("Alg.Alias.Signature.DSAwithSHA1", "DSA");
2332-        put("Alg.Alias.Signature.DSAWITHSHA1", "DSA");
2333-        put("Alg.Alias.Signature.SHA1WithDSA", "DSA");
2334-        put("Alg.Alias.Signature.DSAWithSHA1", "DSA");
2335-        put("Alg.Alias.Signature.1.2.840.10040.4.3", "DSA");
2336-        put("Alg.Alias.Signature.MD5WithRSA/ISO9796-2", "MD5withRSA/ISO9796-2");
2337-        put("Alg.Alias.Signature.SHA1WithRSA/ISO9796-2", "SHA1withRSA/ISO9796-2");
2338-        put("Alg.Alias.Signature.RIPEMD160WithRSA/ISO9796-2", "RIPEMD160withRSA/ISO9796-2");
2339-
2340-        put("Signature.ECGOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$ecgost3410");
2341-        put("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410");
2342-        put("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410");
2343-        put("Alg.Alias.Signature.GOST3411withECGOST3410", "ECGOST3410");
2344-        put("Alg.Alias.Signature.GOST3411WITHECGOST3410", "ECGOST3410");
2345-        put("Alg.Alias.Signature.GOST3411WithECGOST3410", "ECGOST3410");
2346-        put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "ECGOST3410");
2347-
2348-        put("Signature.GOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$gost3410");
2349-        put("Alg.Alias.Signature.GOST-3410", "GOST3410");
2350-        put("Alg.Alias.Signature.GOST-3410-94", "GOST3410");
2351-        put("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410");
2352-        put("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410");
2353-        put("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410");
2354-        put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410");
2355-    }
2356-
2357-    private void addSignatureAlgorithm(
2358-        String digest,
2359-        String algorithm,
2360-        String className,
2361-        DERObjectIdentifier oid)
2362-    {
2363-        String mainName = digest + "WITH" + algorithm;
2364-        String jdk11Variation1 = digest + "with" + algorithm;
2365-        String jdk11Variation2 = digest + "With" + algorithm;
2366-        String alias = digest + "/" + algorithm;
2367-
2368-        put("Signature." + mainName, className);
2369-        put("Alg.Alias.Signature." + jdk11Variation1, mainName);
2370-        put("Alg.Alias.Signature." + jdk11Variation2, mainName);
2371-        put("Alg.Alias.Signature." + alias, mainName);
2372-        put("Alg.Alias.Signature." + oid, mainName);
2373-        put("Alg.Alias.Signature.OID." + oid, mainName);
2374-    }
2375+        // BEGIN android-removed
2376+        // put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
2377+        // put("Alg.Alias.Signature.RMD160WITHRSA", "RIPEMD160WithRSAEncryption");
2378+        // put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
2379+        // END android-removed
2380+
2381+        // BEGIN android-removed
2382+        // addSignatureAlgorithm("SHA224", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa224", NISTObjectIdentifiers.dsa_with_sha224);
2383+        // addSignatureAlgorithm("SHA256", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa256", NISTObjectIdentifiers.dsa_with_sha256);
2384+        // addSignatureAlgorithm("SHA384", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa384", NISTObjectIdentifiers.dsa_with_sha384);
2385+        // addSignatureAlgorithm("SHA512", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa512", NISTObjectIdentifiers.dsa_with_sha512);
2386+        // END android-removed
2387+
2388+        // BEGIN android-changed
2389+        put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
2390+        put("Alg.Alias.Signature.DSA", "SHA1withDSA");
2391+        put("Alg.Alias.Signature.SHA1WITHDSA", "SHA1withDSA");
2392+        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "SHA1withDSA");
2393+        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3", "SHA1withDSA");
2394+        put("Alg.Alias.Signature.DSAwithSHA1", "SHA1withDSA");
2395+        put("Alg.Alias.Signature.DSAWITHSHA1", "SHA1withDSA");
2396+        put("Alg.Alias.Signature.SHA1WithDSA", "SHA1withDSA");
2397+        put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
2398+        put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
2399+        // END android-changed
2400+        // BEGIN android-removed
2401+        // put("Alg.Alias.Signature.MD5WithRSA/ISO9796-2", "MD5withRSA/ISO9796-2");
2402+        // put("Alg.Alias.Signature.SHA1WithRSA/ISO9796-2", "SHA1withRSA/ISO9796-2");
2403+        // put("Alg.Alias.Signature.RIPEMD160WithRSA/ISO9796-2", "RIPEMD160withRSA/ISO9796-2");
2404+        //
2405+        // put("Signature.ECGOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$ecgost3410");
2406+        // put("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410");
2407+        // put("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410");
2408+        // put("Alg.Alias.Signature.GOST3411withECGOST3410", "ECGOST3410");
2409+        // put("Alg.Alias.Signature.GOST3411WITHECGOST3410", "ECGOST3410");
2410+        // put("Alg.Alias.Signature.GOST3411WithECGOST3410", "ECGOST3410");
2411+        // put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "ECGOST3410");
2412+        //
2413+        // put("Signature.GOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$gost3410");
2414+        // put("Alg.Alias.Signature.GOST-3410", "GOST3410");
2415+        // put("Alg.Alias.Signature.GOST-3410-94", "GOST3410");
2416+        // put("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410");
2417+        // put("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410");
2418+        // put("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410");
2419+        // put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410");
2420+        // END android-removed
2421+    }
2422+
2423+    // BEGIN android-removed
2424+    // private void addSignatureAlgorithm(
2425+    //     String digest,
2426+    //     String algorithm,
2427+    //     String className,
2428+    //     DERObjectIdentifier oid)
2429+    // {
2430+    //     String mainName = digest + "WITH" + algorithm;
2431+    //     String jdk11Variation1 = digest + "with" + algorithm;
2432+    //     String jdk11Variation2 = digest + "With" + algorithm;
2433+    //     String alias = digest + "/" + algorithm;
2434+    //
2435+    //     put("Signature." + mainName, className);
2436+    //     put("Alg.Alias.Signature." + jdk11Variation1, mainName);
2437+    //     put("Alg.Alias.Signature." + jdk11Variation2, mainName);
2438+    //     put("Alg.Alias.Signature." + alias, mainName);
2439+    //     put("Alg.Alias.Signature." + oid, mainName);
2440+    //     put("Alg.Alias.Signature.OID." + oid, mainName);
2441+    // }
2442+    // END android-removed
2443
2444     public void setParameter(String parameterName, Object parameter)
2445     {
2446diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java bcprov-jdk16-146/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java
2447--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java	2011-02-23 20:08:56.000000000 +0000
2448+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java	2011-09-08 21:28:49.000000000 +0000
2449@@ -24,6 +24,7 @@
2450 import java.security.spec.DSAPublicKeySpec;
2451 import java.text.ParseException;
2452 import java.util.ArrayList;
2453+import java.util.Arrays;
2454 import java.util.Collection;
2455 import java.util.Date;
2456 import java.util.Enumeration;
2457@@ -59,13 +60,17 @@
2458 import org.bouncycastle.asn1.x509.PolicyInformation;
2459 import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
2460 import org.bouncycastle.asn1.x509.X509Extensions;
2461-import org.bouncycastle.jce.X509LDAPCertStoreParameters;
2462+// BEGIN android-removed
2463+// import org.bouncycastle.jce.X509LDAPCertStoreParameters;
2464+// END android-removed
2465 import org.bouncycastle.jce.exception.ExtCertPathValidatorException;
2466 import org.bouncycastle.util.Selector;
2467 import org.bouncycastle.util.StoreException;
2468 import org.bouncycastle.x509.ExtendedPKIXBuilderParameters;
2469 import org.bouncycastle.x509.ExtendedPKIXParameters;
2470-import org.bouncycastle.x509.X509AttributeCertStoreSelector;
2471+// BEGIN android-removed
2472+// import org.bouncycastle.x509.X509AttributeCertStoreSelector;
2473+// END android-removed
2474 import org.bouncycastle.x509.X509AttributeCertificate;
2475 import org.bouncycastle.x509.X509CRLStoreSelector;
2476 import org.bouncycastle.x509.X509CertStoreSelector;
2477@@ -250,7 +255,9 @@
2478             {
2479                 // look for URI
2480                 List list = (List) it.next();
2481-                if (list.get(0).equals(new Integer(GeneralName.uniformResourceIdentifier)))
2482+                // BEGIN android-changed
2483+                if (list.get(0).equals(Integer.valueOf(GeneralName.uniformResourceIdentifier)))
2484+                // END android-changed
2485                 {
2486                     // found
2487                     String temp = (String) list.get(1);
2488@@ -660,38 +667,40 @@
2489         {
2490             try
2491             {
2492-                if (location.startsWith("ldap://"))
2493-                {
2494-                    // ldap://directory.d-trust.net/CN=D-TRUST
2495-                    // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE
2496-                    // skip "ldap://"
2497-                    location = location.substring(7);
2498-                    // after first / baseDN starts
2499-                    String base = null;
2500-                    String url = null;
2501-                    if (location.indexOf("/") != -1)
2502-                    {
2503-                        base = location.substring(location.indexOf("/"));
2504-                        // URL
2505-                        url = "ldap://"
2506-                            + location.substring(0, location.indexOf("/"));
2507-                    }
2508-                    else
2509-                    {
2510-                        url = "ldap://" + location;
2511-                    }
2512-                    // use all purpose parameters
2513-                    X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder(
2514-                        url, base).build();
2515-                    pkixParams.addAdditionalStore(X509Store.getInstance(
2516-                        "CERTIFICATE/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2517-                    pkixParams.addAdditionalStore(X509Store.getInstance(
2518-                        "CRL/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2519-                    pkixParams.addAdditionalStore(X509Store.getInstance(
2520-                        "ATTRIBUTECERTIFICATE/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2521-                    pkixParams.addAdditionalStore(X509Store.getInstance(
2522-                        "CERTIFICATEPAIR/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2523-                }
2524+                // BEGIN android-removed
2525+                // if (location.startsWith("ldap://"))
2526+                // {
2527+                //     // ldap://directory.d-trust.net/CN=D-TRUST
2528+                //     // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE
2529+                //     // skip "ldap://"
2530+                //     location = location.substring(7);
2531+                //     // after first / baseDN starts
2532+                //     String base = null;
2533+                //     String url = null;
2534+                //     if (location.indexOf("/") != -1)
2535+                //     {
2536+                //         base = location.substring(location.indexOf("/"));
2537+                //         // URL
2538+                //         url = "ldap://"
2539+                //             + location.substring(0, location.indexOf("/"));
2540+                //     }
2541+                //     else
2542+                //     {
2543+                //         url = "ldap://" + location;
2544+                //     }
2545+                //     // use all purpose parameters
2546+                //     X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder(
2547+                //         url, base).build();
2548+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
2549+                //         "CERTIFICATE/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2550+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
2551+                //         "CRL/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2552+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
2553+                //         "ATTRIBUTECERTIFICATE/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2554+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
2555+                //         "CERTIFICATEPAIR/LDAP", params, BouncyCastleProvider.PROVIDER_NAME));
2556+                // }
2557+                // END android-removed
2558             }
2559             catch (Exception e)
2560             {
2561@@ -758,35 +767,37 @@
2562         return certs;
2563     }
2564
2565-    protected static Collection findCertificates(X509AttributeCertStoreSelector certSelect,
2566-                                                 List certStores)
2567-    throws AnnotatedException
2568-    {
2569-        Set certs = new HashSet();
2570-        Iterator iter = certStores.iterator();
2571-
2572-        while (iter.hasNext())
2573-        {
2574-            Object obj = iter.next();
2575-
2576-            if (obj instanceof X509Store)
2577-            {
2578-                X509Store certStore = (X509Store)obj;
2579-                try
2580-                {
2581-                    certs.addAll(certStore.getMatches(certSelect));
2582-                }
2583-                catch (StoreException e)
2584-                {
2585-                    throw
2586-
2587-                        new AnnotatedException(
2588-                            "Problem while picking certificates from X.509 store.", e);
2589-                }
2590-            }
2591-        }
2592-        return certs;
2593-    }
2594+    // BEGIN android-removed
2595+    // protected static Collection findCertificates(X509AttributeCertStoreSelector certSelect,
2596+    //                                              List certStores)
2597+    // throws AnnotatedException
2598+    // {
2599+    //     Set certs = new HashSet();
2600+    //     Iterator iter = certStores.iterator();
2601+    //
2602+    //     while (iter.hasNext())
2603+    //     {
2604+    //         Object obj = iter.next();
2605+    //
2606+    //         if (obj instanceof X509Store)
2607+    //         {
2608+    //             X509Store certStore = (X509Store)obj;
2609+    //             try
2610+    //             {
2611+    //                 certs.addAll(certStore.getMatches(certSelect));
2612+    //             }
2613+    //             catch (StoreException e)
2614+    //             {
2615+    //                 throw
2616+    //
2617+    //                     new AnnotatedException(
2618+    //                         "Problem while picking certificates from X.509 store.", e);
2619+    //             }
2620+    //         }
2621+    //     }
2622+    //     return certs;
2623+    // }
2624+    // END android-removed
2625
2626     protected static void addAdditionalStoresFromCRLDistributionPoint(
2627         CRLDistPoint crldp, ExtendedPKIXParameters pkixParams)
2628diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEBlockCipher.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEBlockCipher.java
2629--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEBlockCipher.java	2011-02-23 20:08:56.000000000 +0000
2630+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEBlockCipher.java	2011-09-08 21:28:49.000000000 +0000
2631@@ -17,8 +17,10 @@
2632 import javax.crypto.ShortBufferException;
2633 import javax.crypto.spec.IvParameterSpec;
2634 import javax.crypto.spec.PBEParameterSpec;
2635-import javax.crypto.spec.RC2ParameterSpec;
2636-import javax.crypto.spec.RC5ParameterSpec;
2637+// BEGIN android-removed
2638+// import javax.crypto.spec.RC2ParameterSpec;
2639+// import javax.crypto.spec.RC5ParameterSpec;
2640+// END android-removed
2641
2642 import org.bouncycastle.crypto.BlockCipher;
2643 import org.bouncycastle.crypto.BufferedBlockCipher;
2644@@ -28,7 +30,9 @@
2645 import org.bouncycastle.crypto.engines.AESFastEngine;
2646 import org.bouncycastle.crypto.engines.DESEngine;
2647 import org.bouncycastle.crypto.engines.DESedeEngine;
2648-import org.bouncycastle.crypto.engines.GOST28147Engine;
2649+// BEGIN android-removed
2650+// import org.bouncycastle.crypto.engines.GOST28147Engine;
2651+// END android-removed
2652 import org.bouncycastle.crypto.engines.RC2Engine;
2653 import org.bouncycastle.crypto.engines.TwofishEngine;
2654 import org.bouncycastle.crypto.modes.AEADBlockCipher;
2655@@ -36,12 +40,16 @@
2656 import org.bouncycastle.crypto.modes.CCMBlockCipher;
2657 import org.bouncycastle.crypto.modes.CFBBlockCipher;
2658 import org.bouncycastle.crypto.modes.CTSBlockCipher;
2659-import org.bouncycastle.crypto.modes.EAXBlockCipher;
2660+// BEGIN android-removed
2661+// import org.bouncycastle.crypto.modes.EAXBlockCipher;
2662+// END android-removed
2663 import org.bouncycastle.crypto.modes.GCMBlockCipher;
2664 import org.bouncycastle.crypto.modes.GOFBBlockCipher;
2665 import org.bouncycastle.crypto.modes.OFBBlockCipher;
2666-import org.bouncycastle.crypto.modes.OpenPGPCFBBlockCipher;
2667-import org.bouncycastle.crypto.modes.PGPCFBBlockCipher;
2668+// BEGIN android-removed
2669+// import org.bouncycastle.crypto.modes.OpenPGPCFBBlockCipher;
2670+// import org.bouncycastle.crypto.modes.PGPCFBBlockCipher;
2671+// END android-removed
2672 import org.bouncycastle.crypto.modes.SICBlockCipher;
2673 import org.bouncycastle.crypto.paddings.BlockCipherPadding;
2674 import org.bouncycastle.crypto.paddings.ISO10126d2Padding;
2675@@ -53,10 +61,12 @@
2676 import org.bouncycastle.crypto.params.KeyParameter;
2677 import org.bouncycastle.crypto.params.ParametersWithIV;
2678 import org.bouncycastle.crypto.params.ParametersWithRandom;
2679-import org.bouncycastle.crypto.params.ParametersWithSBox;
2680-import org.bouncycastle.crypto.params.RC2Parameters;
2681-import org.bouncycastle.crypto.params.RC5Parameters;
2682-import org.bouncycastle.jce.spec.GOST28147ParameterSpec;
2683+// BEGIN android-removed
2684+// import org.bouncycastle.crypto.params.ParametersWithSBox;
2685+// import org.bouncycastle.crypto.params.RC2Parameters;
2686+// import org.bouncycastle.crypto.params.RC5Parameters;
2687+// import org.bouncycastle.jce.spec.GOST28147ParameterSpec;
2688+// END android-removed
2689 import org.bouncycastle.util.Strings;
2690
2691 public class JCEBlockCipher extends WrapCipherSpi
2692@@ -67,11 +77,15 @@
2693     //
2694     private Class[]                 availableSpecs =
2695                                     {
2696-                                        RC2ParameterSpec.class,
2697-                                        RC5ParameterSpec.class,
2698+                                        // BEGIN android-removed
2699+                                        // RC2ParameterSpec.class,
2700+                                        // RC5ParameterSpec.class,
2701+                                        // END android-removed
2702                                         IvParameterSpec.class,
2703                                         PBEParameterSpec.class,
2704-                                        GOST28147ParameterSpec.class
2705+                                        // BEGIN android-removed
2706+                                        // GOST28147ParameterSpec.class
2707+                                        // END android-removed
2708                                     };
2709
2710     private BlockCipher             baseEngine;
2711@@ -226,20 +240,22 @@
2712                         new CFBBlockCipher(baseEngine, 8 * baseEngine.getBlockSize()));
2713             }
2714         }
2715-        else if (modeName.startsWith("PGP"))
2716-        {
2717-            boolean inlineIV = modeName.equalsIgnoreCase("PGPCFBwithIV");
2718-
2719-            ivLength = baseEngine.getBlockSize();
2720-            cipher = new BufferedGenericBlockCipher(
2721-                new PGPCFBBlockCipher(baseEngine, inlineIV));
2722-        }
2723-        else if (modeName.equalsIgnoreCase("OpenPGPCFB"))
2724-        {
2725-            ivLength = 0;
2726-            cipher = new BufferedGenericBlockCipher(
2727-                new OpenPGPCFBBlockCipher(baseEngine));
2728-        }
2729+        // BEGIN android-removed
2730+        // else if (modeName.startsWith("PGP"))
2731+        // {
2732+        //     boolean inlineIV = modeName.equalsIgnoreCase("PGPCFBwithIV");
2733+        //
2734+        //     ivLength = baseEngine.getBlockSize();
2735+        //     cipher = new BufferedGenericBlockCipher(
2736+        //         new PGPCFBBlockCipher(baseEngine, inlineIV));
2737+        // }
2738+        // else if (modeName.equalsIgnoreCase("OpenPGPCFB"))
2739+        // {
2740+        //     ivLength = 0;
2741+        //     cipher = new BufferedGenericBlockCipher(
2742+        //         new OpenPGPCFBBlockCipher(baseEngine));
2743+        // }
2744+        // END android-removed
2745         else if (modeName.startsWith("SIC"))
2746         {
2747             ivLength = baseEngine.getBlockSize();
2748@@ -272,11 +288,13 @@
2749             ivLength = baseEngine.getBlockSize();
2750             cipher = new AEADGenericBlockCipher(new CCMBlockCipher(baseEngine));
2751         }
2752-        else if (modeName.startsWith("EAX"))
2753-        {
2754-            ivLength = baseEngine.getBlockSize();
2755-            cipher = new AEADGenericBlockCipher(new EAXBlockCipher(baseEngine));
2756-        }
2757+        // BEGIN android-removed
2758+        // else if (modeName.startsWith("EAX"))
2759+        // {
2760+        //     ivLength = baseEngine.getBlockSize();
2761+        //     cipher = new AEADGenericBlockCipher(new EAXBlockCipher(baseEngine));
2762+        // }
2763+        // END android-removed
2764         else if (modeName.startsWith("GCM"))
2765         {
2766             ivLength = baseEngine.getBlockSize();
2767@@ -365,13 +383,15 @@
2768             throw new InvalidKeyException("Key for algorithm " + key.getAlgorithm() + " not suitable for symmetric enryption.");
2769         }
2770
2771-        //
2772-        // for RC5-64 we must have some default parameters
2773-        //
2774-        if (params == null && baseEngine.getAlgorithmName().startsWith("RC5-64"))
2775-        {
2776-            throw new InvalidAlgorithmParameterException("RC5 requires an RC5ParametersSpec to be passed in.");
2777-        }
2778+        // BEGIN android-removed
2779+        // //
2780+        // // for RC5-64 we must have some default parameters
2781+        // //
2782+        // if (params == null && baseEngine.getAlgorithmName().startsWith("RC5-64"))
2783+        // {
2784+        //     throw new InvalidAlgorithmParameterException("RC5 requires an RC5ParametersSpec to be passed in.");
2785+        // }
2786+        // END android-removed
2787
2788         //
2789         // a note on iv's - if ivLength is zero the IV gets ignored (we don't use it).
2790@@ -437,63 +457,65 @@
2791                 param = new KeyParameter(key.getEncoded());
2792             }
2793         }
2794-        else if (params instanceof GOST28147ParameterSpec)
2795-        {
2796-            GOST28147ParameterSpec    gost28147Param = (GOST28147ParameterSpec)params;
2797-
2798-            param = new ParametersWithSBox(
2799-                       new KeyParameter(key.getEncoded()), ((GOST28147ParameterSpec)params).getSbox());
2800-
2801-            if (gost28147Param.getIV() != null && ivLength != 0)
2802-            {
2803-                param = new ParametersWithIV(param, gost28147Param.getIV());
2804-                ivParam = (ParametersWithIV)param;
2805-            }
2806-        }
2807-        else if (params instanceof RC2ParameterSpec)
2808-        {
2809-            RC2ParameterSpec    rc2Param = (RC2ParameterSpec)params;
2810-
2811-            param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits());
2812-
2813-            if (rc2Param.getIV() != null && ivLength != 0)
2814-            {
2815-                param = new ParametersWithIV(param, rc2Param.getIV());
2816-                ivParam = (ParametersWithIV)param;
2817-            }
2818-        }
2819-        else if (params instanceof RC5ParameterSpec)
2820-        {
2821-            RC5ParameterSpec    rc5Param = (RC5ParameterSpec)params;
2822-
2823-            param = new RC5Parameters(key.getEncoded(), ((RC5ParameterSpec)params).getRounds());
2824-            if (baseEngine.getAlgorithmName().startsWith("RC5"))
2825-            {
2826-                if (baseEngine.getAlgorithmName().equals("RC5-32"))
2827-                {
2828-                    if (rc5Param.getWordSize() != 32)
2829-                    {
2830-                        throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 32 not " + rc5Param.getWordSize() + ".");
2831-                    }
2832-                }
2833-                else if (baseEngine.getAlgorithmName().equals("RC5-64"))
2834-                {
2835-                    if (rc5Param.getWordSize() != 64)
2836-                    {
2837-                        throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 64 not " + rc5Param.getWordSize() + ".");
2838-                    }
2839-                }
2840-            }
2841-            else
2842-            {
2843-                throw new InvalidAlgorithmParameterException("RC5 parameters passed to a cipher that is not RC5.");
2844-            }
2845-            if ((rc5Param.getIV() != null) && (ivLength != 0))
2846-            {
2847-                param = new ParametersWithIV(param, rc5Param.getIV());
2848-                ivParam = (ParametersWithIV)param;
2849-            }
2850-        }
2851+        // BEGIN android-removed
2852+        // else if (params instanceof GOST28147ParameterSpec)
2853+        // {
2854+        //     GOST28147ParameterSpec    gost28147Param = (GOST28147ParameterSpec)params;
2855+        //
2856+        //     param = new ParametersWithSBox(
2857+        //                new KeyParameter(key.getEncoded()), ((GOST28147ParameterSpec)params).getSbox());
2858+        //
2859+        //     if (gost28147Param.getIV() != null && ivLength != 0)
2860+        //     {
2861+        //         param = new ParametersWithIV(param, gost28147Param.getIV());
2862+        //         ivParam = (ParametersWithIV)param;
2863+        //     }
2864+        // }
2865+        // else if (params instanceof RC2ParameterSpec)
2866+        // {
2867+        //     RC2ParameterSpec    rc2Param = (RC2ParameterSpec)params;
2868+        //
2869+        //     param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits());
2870+        //
2871+        //     if (rc2Param.getIV() != null && ivLength != 0)
2872+        //     {
2873+        //         param = new ParametersWithIV(param, rc2Param.getIV());
2874+        //         ivParam = (ParametersWithIV)param;
2875+        //     }
2876+        // }
2877+        // else if (params instanceof RC5ParameterSpec)
2878+        // {
2879+        //     RC5ParameterSpec    rc5Param = (RC5ParameterSpec)params;
2880+        //
2881+        //     param = new RC5Parameters(key.getEncoded(), ((RC5ParameterSpec)params).getRounds());
2882+        //     if (baseEngine.getAlgorithmName().startsWith("RC5"))
2883+        //     {
2884+        //         if (baseEngine.getAlgorithmName().equals("RC5-32"))
2885+        //         {
2886+        //             if (rc5Param.getWordSize() != 32)
2887+        //             {
2888+        //                 throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 32 not " + rc5Param.getWordSize() + ".");
2889+        //             }
2890+        //         }
2891+        //         else if (baseEngine.getAlgorithmName().equals("RC5-64"))
2892+        //         {
2893+        //             if (rc5Param.getWordSize() != 64)
2894+        //             {
2895+        //                 throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 64 not " + rc5Param.getWordSize() + ".");
2896+        //             }
2897+        //         }
2898+        //     }
2899+        //     else
2900+        //     {
2901+        //         throw new InvalidAlgorithmParameterException("RC5 parameters passed to a cipher that is not RC5.");
2902+        //     }
2903+        //     if ((rc5Param.getIV() != null) && (ivLength != 0))
2904+        //     {
2905+        //         param = new ParametersWithIV(param, rc5Param.getIV());
2906+        //         ivParam = (ParametersWithIV)param;
2907+        //     }
2908+        // }
2909+        // END android-removed
2910         else
2911         {
2912             throw new InvalidAlgorithmParameterException("unknown parameter type.");
2913@@ -697,10 +719,21 @@
2914         int     inputLen,
2915         byte[]  output,
2916         int     outputOffset)
2917-        throws IllegalBlockSizeException, BadPaddingException
2918+        throws IllegalBlockSizeException, BadPaddingException, ShortBufferException
2919     {
2920+        // BEGIN android-note
2921+        // added ShortBufferException to the throws statement
2922+        // END android-note
2923         int     len = 0;
2924
2925+        // BEGIN android-added
2926+        int outputLen = cipher.getOutputSize(inputLen);
2927+
2928+        if (outputLen + outputOffset > output.length) {
2929+            throw new ShortBufferException("need at least " + outputLen + " bytes");
2930+        }
2931+        // BEGIN android-added
2932+
2933         if (inputLen != 0)
2934         {
2935                 len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset);
2936@@ -742,62 +775,64 @@
2937         }
2938     }
2939
2940-    /**
2941-     * DESCBC
2942-     */
2943-    static public class DESCBC
2944-        extends JCEBlockCipher
2945-    {
2946-        public DESCBC()
2947-        {
2948-            super(new CBCBlockCipher(new DESEngine()), 64);
2949-        }
2950-    }
2951-
2952-    /**
2953-     *  GOST28147
2954-     */
2955-    static public class GOST28147
2956-        extends JCEBlockCipher
2957-    {
2958-        public GOST28147()
2959-        {
2960-            super(new GOST28147Engine());
2961-        }
2962-    }
2963-
2964-    static public class GOST28147cbc
2965-        extends JCEBlockCipher
2966-    {
2967-        public GOST28147cbc()
2968-        {
2969-            super(new CBCBlockCipher(new GOST28147Engine()), 64);
2970-        }
2971-    }
2972-
2973-    /**
2974-     * RC2
2975-     */
2976-    static public class RC2
2977-        extends JCEBlockCipher
2978-    {
2979-        public RC2()
2980-        {
2981-            super(new RC2Engine());
2982-        }
2983-    }
2984-
2985-    /**
2986-     * RC2CBC
2987-     */
2988-    static public class RC2CBC
2989-        extends JCEBlockCipher
2990-    {
2991-        public RC2CBC()
2992-        {
2993-            super(new CBCBlockCipher(new RC2Engine()), 64);
2994-        }
2995-    }
2996+    // BEGIN android-removed
2997+    // /**
2998+    //  * DESCBC
2999+    //  */
3000+    // static public class DESCBC
3001+    //     extends JCEBlockCipher
3002+    // {
3003+    //     public DESCBC()
3004+    //     {
3005+    //         super(new CBCBlockCipher(new DESEngine()), 64);
3006+    //     }
3007+    // }
3008+    //
3009+    // /**
3010+    //  *  GOST28147
3011+    //  */
3012+    // static public class GOST28147
3013+    //     extends JCEBlockCipher
3014+    // {
3015+    //     public GOST28147()
3016+    //     {
3017+    //         super(new GOST28147Engine());
3018+    //     }
3019+    // }
3020+    //
3021+    // static public class GOST28147cbc
3022+    //     extends JCEBlockCipher
3023+    // {
3024+    //     public GOST28147cbc()
3025+    //     {
3026+    //         super(new CBCBlockCipher(new GOST28147Engine()), 64);
3027+    //     }
3028+    // }
3029+    //
3030+    // /**
3031+    //  * RC2
3032+    //  */
3033+    // static public class RC2
3034+    //     extends JCEBlockCipher
3035+    // {
3036+    //     public RC2()
3037+    //     {
3038+    //         super(new RC2Engine());
3039+    //     }
3040+    // }
3041+    //
3042+    // /**
3043+    //  * RC2CBC
3044+    //  */
3045+    // static public class RC2CBC
3046+    //     extends JCEBlockCipher
3047+    // {
3048+    //     public RC2CBC()
3049+    //     {
3050+    //         super(new CBCBlockCipher(new RC2Engine()), 64);
3051+    //     }
3052+    // }
3053+    // END android-removed
3054
3055     /**
3056      * PBEWithMD5AndDES
3057@@ -822,7 +857,7 @@
3058             super(new CBCBlockCipher(new RC2Engine()));
3059         }
3060     }
3061-
3062+
3063     /**
3064      * PBEWithSHA1AndDES
3065      */
3066@@ -870,7 +905,7 @@
3067             super(new CBCBlockCipher(new DESedeEngine()));
3068         }
3069     }
3070-
3071+
3072     /**
3073      * PBEWithSHAAnd128BitRC2-CBC
3074      */
3075@@ -894,7 +929,7 @@
3076             super(new CBCBlockCipher(new RC2Engine()));
3077         }
3078     }
3079-
3080+
3081     /**
3082      * PBEWithSHAAndTwofish-CBC
3083      */
3084@@ -906,7 +941,7 @@
3085             super(new CBCBlockCipher(new TwofishEngine()));
3086         }
3087     }
3088-
3089+
3090     /**
3091      * PBEWithAES-CBC
3092      */
3093diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java
3094--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java	2011-02-23 20:08:56.000000000 +0000
3095+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java	2011-09-08 21:28:49.000000000 +0000
3096@@ -36,10 +36,12 @@
3097
3098     static
3099     {
3100-        Integer i64 = new Integer(64);
3101-        Integer i192 = new Integer(192);
3102-        Integer i128 = new Integer(128);
3103-        Integer i256 = new Integer(256);
3104+        // BEGIN android-changed
3105+        Integer i64 = Integer.valueOf(64);
3106+        Integer i192 = Integer.valueOf(192);
3107+        Integer i128 = Integer.valueOf(128);
3108+        Integer i256 = Integer.valueOf(256);
3109+        // END android-changed
3110
3111         algorithms.put("DES", i64);
3112         algorithms.put("DESEDE", i192);
3113diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEDigestUtil.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEDigestUtil.java
3114--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEDigestUtil.java	2011-02-23 20:08:56.000000000 +0000
3115+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEDigestUtil.java	2011-09-08 21:28:49.000000000 +0000
3116@@ -12,7 +12,9 @@
3117 import org.bouncycastle.crypto.Digest;
3118 import org.bouncycastle.crypto.digests.MD5Digest;
3119 import org.bouncycastle.crypto.digests.SHA1Digest;
3120-import org.bouncycastle.crypto.digests.SHA224Digest;
3121+// BEGIN android-removed
3122+// import org.bouncycastle.crypto.digests.SHA224Digest;
3123+// END android-removed
3124 import org.bouncycastle.crypto.digests.SHA256Digest;
3125 import org.bouncycastle.crypto.digests.SHA384Digest;
3126 import org.bouncycastle.crypto.digests.SHA512Digest;
3127@@ -22,7 +24,9 @@
3128 {
3129     private static Set md5 = new HashSet();
3130     private static Set sha1 = new HashSet();
3131-    private static Set sha224 = new HashSet();
3132+    // BEGIN android-removed
3133+    // private static Set sha224 = new HashSet();
3134+    // END android-removed
3135     private static Set sha256 = new HashSet();
3136     private static Set sha384 = new HashSet();
3137     private static Set sha512 = new HashSet();
3138@@ -38,9 +42,11 @@
3139         sha1.add("SHA-1");
3140         sha1.add(OIWObjectIdentifiers.idSHA1.getId());
3141
3142-        sha224.add("SHA224");
3143-        sha224.add("SHA-224");
3144-        sha224.add(NISTObjectIdentifiers.id_sha224.getId());
3145+        // BEGIN android-removed
3146+        // sha224.add("SHA224");
3147+        // sha224.add("SHA-224");
3148+        // sha224.add(NISTObjectIdentifiers.id_sha224.getId());
3149+        // END android-removed
3150
3151         sha256.add("SHA256");
3152         sha256.add("SHA-256");
3153@@ -61,9 +67,11 @@
3154         oids.put("SHA-1", OIWObjectIdentifiers.idSHA1);
3155         oids.put(OIWObjectIdentifiers.idSHA1.getId(), OIWObjectIdentifiers.idSHA1);
3156
3157-        oids.put("SHA224", NISTObjectIdentifiers.id_sha224);
3158-        oids.put("SHA-224", NISTObjectIdentifiers.id_sha224);
3159-        oids.put(NISTObjectIdentifiers.id_sha224.getId(), NISTObjectIdentifiers.id_sha224);
3160+        // BEGIN android-removed
3161+        // oids.put("SHA224", NISTObjectIdentifiers.id_sha224);
3162+        // oids.put("SHA-224", NISTObjectIdentifiers.id_sha224);
3163+        // oids.put(NISTObjectIdentifiers.id_sha224.getId(), NISTObjectIdentifiers.id_sha224);
3164+        // END android-removed
3165
3166         oids.put("SHA256", NISTObjectIdentifiers.id_sha256);
3167         oids.put("SHA-256", NISTObjectIdentifiers.id_sha256);
3168@@ -91,10 +99,12 @@
3169         {
3170             return new MD5Digest();
3171         }
3172-        if (sha224.contains(digestName))
3173-        {
3174-            return new SHA224Digest();
3175-        }
3176+        // BEGIN android-removed
3177+        // if (sha224.contains(digestName))
3178+        // {
3179+        //     return new SHA224Digest();
3180+        // }
3181+        // END android-removed
3182         if (sha256.contains(digestName))
3183         {
3184             return new SHA256Digest();
3185@@ -116,7 +126,9 @@
3186         String digest2)
3187     {
3188         return (sha1.contains(digest1) && sha1.contains(digest2))
3189-            || (sha224.contains(digest1) && sha224.contains(digest2))
3190+            // BEGIN android-removed
3191+            // || (sha224.contains(digest1) && sha224.contains(digest2))
3192+            // END android-removed
3193             || (sha256.contains(digest1) && sha256.contains(digest2))
3194             || (sha384.contains(digest1) && sha384.contains(digest2))
3195             || (sha512.contains(digest1) && sha512.contains(digest2))
3196diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEECPrivateKey.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEECPrivateKey.java
3197--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEECPrivateKey.java	2011-02-23 20:08:56.000000000 +0000
3198+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEECPrivateKey.java	2011-09-08 21:28:49.000000000 +0000
3199@@ -20,7 +20,9 @@
3200 import org.bouncycastle.asn1.DERObject;
3201 import org.bouncycastle.asn1.DERObjectIdentifier;
3202 import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers;
3203-import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
3204+// BEGIN android-removed
3205+// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
3206+// END android-removed
3207 import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
3208 import org.bouncycastle.asn1.sec.ECPrivateKeyStructure;
3209 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
3210@@ -199,21 +201,23 @@
3211             DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
3212             X9ECParameters ecP = ECUtil.getNamedCurveByOid(oid);
3213
3214-            if (ecP == null) // GOST Curve
3215-            {
3216-                ECDomainParameters gParam = ECGOST3410NamedCurves.getByOID(oid);
3217-                EllipticCurve ellipticCurve = EC5Util.convertCurve(gParam.getCurve(), gParam.getSeed());
3218-
3219-                ecSpec = new ECNamedCurveSpec(
3220-                        ECGOST3410NamedCurves.getName(oid),
3221-                        ellipticCurve,
3222-                        new ECPoint(
3223-                                gParam.getG().getX().toBigInteger(),
3224-                                gParam.getG().getY().toBigInteger()),
3225-                        gParam.getN(),
3226-                        gParam.getH());
3227-            }
3228-            else
3229+            // BEGIN android-removed
3230+            // if (ecP == null) // GOST Curve
3231+            // {
3232+            //     ECDomainParameters gParam = ECGOST3410NamedCurves.getByOID(oid);
3233+            //     EllipticCurve ellipticCurve = EC5Util.convertCurve(gParam.getCurve(), gParam.getSeed());
3234+            //
3235+            //     ecSpec = new ECNamedCurveSpec(
3236+            //             ECGOST3410NamedCurves.getName(oid),
3237+            //             ellipticCurve,
3238+            //             new ECPoint(
3239+            //                     gParam.getG().getX().toBigInteger(),
3240+            //                     gParam.getG().getY().toBigInteger()),
3241+            //             gParam.getN(),
3242+            //             gParam.getH());
3243+            // }
3244+            // else
3245+            // END android-removed
3246             {
3247                 EllipticCurve ellipticCurve = EC5Util.convertCurve(ecP.getCurve(), ecP.getSeed());
3248
3249@@ -324,11 +328,13 @@
3250             keyStructure = new ECPrivateKeyStructure(this.getS(), params);
3251         }
3252
3253-        if (algorithm.equals("ECGOST3410"))
3254-        {
3255-            info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), keyStructure.getDERObject());
3256-        }
3257-        else
3258+        // BEGIN android-removed
3259+        // if (algorithm.equals("ECGOST3410"))
3260+        // {
3261+        //     info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), keyStructure.getDERObject());
3262+        // }
3263+        // else
3264+        // END android-removed
3265         {
3266
3267             info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, params.getDERObject()), keyStructure.getDERObject());
3268diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEECPublicKey.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEECPublicKey.java
3269--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEECPublicKey.java	2011-02-23 20:08:56.000000000 +0000
3270+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEECPublicKey.java	2011-09-08 21:28:49.000000000 +0000
3271@@ -20,8 +20,10 @@
3272 import org.bouncycastle.asn1.DERObjectIdentifier;
3273 import org.bouncycastle.asn1.DEROctetString;
3274 import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers;
3275-import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
3276-import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters;
3277+// BEGIN android-removed
3278+// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
3279+// import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters;
3280+// END android-removed
3281 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
3282 import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
3283 import org.bouncycastle.asn1.x9.X962Parameters;
3284@@ -31,11 +33,15 @@
3285 import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
3286 import org.bouncycastle.crypto.params.ECDomainParameters;
3287 import org.bouncycastle.crypto.params.ECPublicKeyParameters;
3288-import org.bouncycastle.jce.ECGOST3410NamedCurveTable;
3289+// BEGIN android-removed
3290+// import org.bouncycastle.jce.ECGOST3410NamedCurveTable;
3291+// END android-removed
3292 import org.bouncycastle.jce.interfaces.ECPointEncoder;
3293 import org.bouncycastle.jce.provider.asymmetric.ec.EC5Util;
3294 import org.bouncycastle.jce.provider.asymmetric.ec.ECUtil;
3295-import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
3296+// BEGIN android-removed
3297+// import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec;
3298+// END android-removed
3299 import org.bouncycastle.jce.spec.ECNamedCurveSpec;
3300 import org.bouncycastle.math.ec.ECCurve;
3301
3302@@ -46,7 +52,9 @@
3303     private org.bouncycastle.math.ec.ECPoint q;
3304     private ECParameterSpec         ecSpec;
3305     private boolean                 withCompression;
3306-    private GOST3410PublicKeyAlgParameters       gostParams;
3307+    // BEGIN android-removed
3308+    // private GOST3410PublicKeyAlgParameters       gostParams;
3309+    // END android-removed
3310
3311     public JCEECPublicKey(
3312         String              algorithm,
3313@@ -56,7 +64,9 @@
3314         this.q = key.q;
3315         this.ecSpec = key.ecSpec;
3316         this.withCompression = key.withCompression;
3317-        this.gostParams = key.gostParams;
3318+        // BEGIN android-removed
3319+        // this.gostParams = key.gostParams;
3320+        // END android-removed
3321     }
3322
3323     public JCEECPublicKey(
3324@@ -179,54 +189,56 @@
3325
3326     private void populateFromPubKeyInfo(SubjectPublicKeyInfo info)
3327     {
3328-        if (info.getAlgorithmId().getObjectId().equals(CryptoProObjectIdentifiers.gostR3410_2001))
3329-        {
3330-            DERBitString bits = info.getPublicKeyData();
3331-            ASN1OctetString key;
3332-            this.algorithm = "ECGOST3410";
3333-
3334-            try
3335-            {
3336-                key = (ASN1OctetString) ASN1Object.fromByteArray(bits.getBytes());
3337-            }
3338-            catch (IOException ex)
3339-            {
3340-                throw new IllegalArgumentException("error recovering public key");
3341-            }
3342-
3343-            byte[]          keyEnc = key.getOctets();
3344-            byte[]          x = new byte[32];
3345-            byte[]          y = new byte[32];
3346-
3347-            for (int i = 0; i != x.length; i++)
3348-            {
3349-                x[i] = keyEnc[32 - 1 - i];
3350-            }
3351-
3352-            for (int i = 0; i != y.length; i++)
3353-            {
3354-                y[i] = keyEnc[64 - 1 - i];
3355-            }
3356-
3357-            gostParams = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters());
3358-
3359-            ECNamedCurveParameterSpec spec = ECGOST3410NamedCurveTable.getParameterSpec(ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()));
3360-
3361-            ECCurve curve = spec.getCurve();
3362-            EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getSeed());
3363-
3364-            this.q = curve.createPoint(new BigInteger(1, x), new BigInteger(1, y), false);
3365-
3366-            ecSpec = new ECNamedCurveSpec(
3367-                    ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()),
3368-                    ellipticCurve,
3369-                    new ECPoint(
3370-                            spec.getG().getX().toBigInteger(),
3371-                            spec.getG().getY().toBigInteger()),
3372-                            spec.getN(), spec.getH());
3373-
3374-        }
3375-        else
3376+        // BEGIN android-removed
3377+        // if (info.getAlgorithmId().getObjectId().equals(CryptoProObjectIdentifiers.gostR3410_2001))
3378+        // {
3379+        //     DERBitString bits = info.getPublicKeyData();
3380+        //     ASN1OctetString key;
3381+        //     this.algorithm = "ECGOST3410";
3382+        //
3383+        //     try
3384+        //     {
3385+        //         key = (ASN1OctetString) ASN1Object.fromByteArray(bits.getBytes());
3386+        //     }
3387+        //     catch (IOException ex)
3388+        //     {
3389+        //         throw new IllegalArgumentException("error recovering public key");
3390+        //     }
3391+        //
3392+        //     byte[]          keyEnc = key.getOctets();
3393+        //     byte[]          x = new byte[32];
3394+        //     byte[]          y = new byte[32];
3395+        //
3396+        //     for (int i = 0; i != x.length; i++)
3397+        //     {
3398+        //         x[i] = keyEnc[32 - 1 - i];
3399+        //     }
3400+        //
3401+        //     for (int i = 0; i != y.length; i++)
3402+        //     {
3403+        //         y[i] = keyEnc[64 - 1 - i];
3404+        //     }
3405+        //
3406+        //     gostParams = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters());
3407+        //
3408+        //     ECNamedCurveParameterSpec spec = ECGOST3410NamedCurveTable.getParameterSpec(ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()));
3409+        //
3410+        //     ECCurve curve = spec.getCurve();
3411+        //     EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getSeed());
3412+        //
3413+        //     this.q = curve.createPoint(new BigInteger(1, x), new BigInteger(1, y), false);
3414+        //
3415+        //     ecSpec = new ECNamedCurveSpec(
3416+        //             ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()),
3417+        //             ellipticCurve,
3418+        //             new ECPoint(
3419+        //                     spec.getG().getX().toBigInteger(),
3420+        //                     spec.getG().getY().toBigInteger()),
3421+        //                     spec.getN(), spec.getH());
3422+        //
3423+        // }
3424+        // else
3425+        // END android-removed
3426         {
3427             X962Parameters params = new X962Parameters((DERObject)info.getAlgorithmId().getParameters());
3428             ECCurve                 curve;
3429@@ -315,45 +327,47 @@
3430         ASN1Encodable        params;
3431         SubjectPublicKeyInfo info;
3432
3433-        if (algorithm.equals("ECGOST3410"))
3434-        {
3435-            if (gostParams != null)
3436-            {
3437-                params = gostParams;
3438-            }
3439-            else
3440-            {
3441-                if (ecSpec instanceof ECNamedCurveSpec)
3442-                {
3443-                    params = new GOST3410PublicKeyAlgParameters(
3444-                                   ECGOST3410NamedCurves.getOID(((ECNamedCurveSpec)ecSpec).getName()),
3445-                                   CryptoProObjectIdentifiers.gostR3411_94_CryptoProParamSet);
3446-                }
3447-                else
3448-                {   // strictly speaking this may not be applicable...
3449-                    ECCurve curve = EC5Util.convertCurve(ecSpec.getCurve());
3450-
3451-                    X9ECParameters ecP = new X9ECParameters(
3452-                        curve,
3453-                        EC5Util.convertPoint(curve, ecSpec.getGenerator(), withCompression),
3454-                        ecSpec.getOrder(),
3455-                        BigInteger.valueOf(ecSpec.getCofactor()),
3456-                        ecSpec.getCurve().getSeed());
3457-
3458-                    params = new X962Parameters(ecP);
3459-                }
3460-            }
3461-
3462-            BigInteger      bX = this.q.getX().toBigInteger();
3463-            BigInteger      bY = this.q.getY().toBigInteger();
3464-            byte[]          encKey = new byte[64];
3465-
3466-            extractBytes(encKey, 0, bX);
3467-            extractBytes(encKey, 32, bY);
3468-
3469-            info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), new DEROctetString(encKey));
3470-        }
3471-        else
3472+        // BEGIN android-removed
3473+        // if (algorithm.equals("ECGOST3410"))
3474+        // {
3475+        //     if (gostParams != null)
3476+        //     {
3477+        //         params = gostParams;
3478+        //     }
3479+        //     else
3480+        //     {
3481+        //         if (ecSpec instanceof ECNamedCurveSpec)
3482+        //         {
3483+        //             params = new GOST3410PublicKeyAlgParameters(
3484+        //                            ECGOST3410NamedCurves.getOID(((ECNamedCurveSpec)ecSpec).getName()),
3485+        //                            CryptoProObjectIdentifiers.gostR3411_94_CryptoProParamSet);
3486+        //         }
3487+        //         else
3488+        //         {   // strictly speaking this may not be applicable...
3489+        //             ECCurve curve = EC5Util.convertCurve(ecSpec.getCurve());
3490+        //
3491+        //             X9ECParameters ecP = new X9ECParameters(
3492+        //                 curve,
3493+        //                 EC5Util.convertPoint(curve, ecSpec.getGenerator(), withCompression),
3494+        //                 ecSpec.getOrder(),
3495+        //                 BigInteger.valueOf(ecSpec.getCofactor()),
3496+        //                 ecSpec.getCurve().getSeed());
3497+        //
3498+        //             params = new X962Parameters(ecP);
3499+        //         }
3500+        //     }
3501+        //
3502+        //     BigInteger      bX = this.q.getX().toBigInteger();
3503+        //     BigInteger      bY = this.q.getY().toBigInteger();
3504+        //     byte[]          encKey = new byte[64];
3505+        //
3506+        //     extractBytes(encKey, 0, bX);
3507+        //     extractBytes(encKey, 32, bY);
3508+        //
3509+        //     info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), new DEROctetString(encKey));
3510+        // }
3511+        // else
3512+        // END android-removed
3513         {
3514             if (ecSpec instanceof ECNamedCurveSpec)
3515             {
3516diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEKeyGenerator.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEKeyGenerator.java
3517--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEKeyGenerator.java	2011-02-23 20:08:56.000000000 +0000
3518+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEKeyGenerator.java	2011-09-08 21:28:49.000000000 +0000
3519@@ -57,6 +57,11 @@
3520     {
3521         try
3522         {
3523+            // BEGIN android-added
3524+            if (random == null) {
3525+                random = new SecureRandom();
3526+            }
3527+            // END android-added
3528             engine.init(new KeyGenerationParameters(random, keySize));
3529             uninitialised = false;
3530         }
3531@@ -93,56 +98,60 @@
3532         }
3533     }
3534
3535-    /**
3536-     * RC2
3537-     */
3538-    public static class RC2
3539-        extends JCEKeyGenerator
3540-    {
3541-        public RC2()
3542-        {
3543-            super("RC2", 128, new CipherKeyGenerator());
3544-        }
3545-    }
3546-
3547-    /**
3548-     * GOST28147
3549-     */
3550-    public static class GOST28147
3551-        extends JCEKeyGenerator
3552-    {
3553-        public GOST28147()
3554-        {
3555-            super("GOST28147", 256, new CipherKeyGenerator());
3556-        }
3557-    }
3558+    // BEGIN android-removed
3559+    // /**
3560+    //  * RC2
3561+    //  */
3562+    // public static class RC2
3563+    //     extends JCEKeyGenerator
3564+    // {
3565+    //     public RC2()
3566+    //     {
3567+    //         super("RC2", 128, new CipherKeyGenerator());
3568+    //     }
3569+    // }
3570+    //
3571+    // /**
3572+    //  * GOST28147
3573+    //  */
3574+    // public static class GOST28147
3575+    //     extends JCEKeyGenerator
3576+    // {
3577+    //     public GOST28147()
3578+    //     {
3579+    //         super("GOST28147", 256, new CipherKeyGenerator());
3580+    //     }
3581+    // }
3582+    // END android-removed
3583
3584     // HMAC Related secret keys..
3585
3586-    /**
3587-     * MD2HMAC
3588-     */
3589-    public static class MD2HMAC
3590-        extends JCEKeyGenerator
3591-    {
3592-        public MD2HMAC()
3593-        {
3594-            super("HMACMD2", 128, new CipherKeyGenerator());
3595-        }
3596-    }
3597-
3598-
3599-    /**
3600-     * MD4HMAC
3601-     */
3602-    public static class MD4HMAC
3603-        extends JCEKeyGenerator
3604-    {
3605-        public MD4HMAC()
3606-        {
3607-            super("HMACMD4", 128, new CipherKeyGenerator());
3608-        }
3609-    }
3610+    // BEGIN android-removed
3611+    // /**
3612+    //  * MD2HMAC
3613+    //  */
3614+    // public static class MD2HMAC
3615+    //     extends JCEKeyGenerator
3616+    // {
3617+    //     public MD2HMAC()
3618+    //     {
3619+    //         super("HMACMD2", 128, new CipherKeyGenerator());
3620+    //     }
3621+    // }
3622+    //
3623+    //
3624+    // /**
3625+    //  * MD4HMAC
3626+    //  */
3627+    // public static class MD4HMAC
3628+    //     extends JCEKeyGenerator
3629+    // {
3630+    //     public MD4HMAC()
3631+    //     {
3632+    //         super("HMACMD4", 128, new CipherKeyGenerator());
3633+    //     }
3634+    // }
3635+    // END android-removed
3636
3637     /**
3638      * MD5HMAC
3639@@ -157,29 +166,29 @@
3640     }
3641
3642
3643-    /**
3644-     * RIPE128HMAC
3645-     */
3646-    public static class RIPEMD128HMAC
3647-        extends JCEKeyGenerator
3648-    {
3649-        public RIPEMD128HMAC()
3650-        {
3651-            super("HMACRIPEMD128", 128, new CipherKeyGenerator());
3652-        }
3653-    }
3654-
3655-    /**
3656-     * RIPE160HMAC
3657-     */
3658-    public static class RIPEMD160HMAC
3659-        extends JCEKeyGenerator
3660-    {
3661-        public RIPEMD160HMAC()
3662-        {
3663-            super("HMACRIPEMD160", 160, new CipherKeyGenerator());
3664-        }
3665-    }
3666+    // /**
3667+    //  * RIPE128HMAC
3668+    //  */
3669+    // public static class RIPEMD128HMAC
3670+    //     extends JCEKeyGenerator
3671+    // {
3672+    //     public RIPEMD128HMAC()
3673+    //     {
3674+    //         super("HMACRIPEMD128", 128, new CipherKeyGenerator());
3675+    //     }
3676+    // }
3677+
3678+    // /**
3679+    //  * RIPE160HMAC
3680+    //  */
3681+    // public static class RIPEMD160HMAC
3682+    //     extends JCEKeyGenerator
3683+    // {
3684+    //     public RIPEMD160HMAC()
3685+    //     {
3686+    //         super("HMACRIPEMD160", 160, new CipherKeyGenerator());
3687+    //     }
3688+    // }
3689
3690
3691     /**
3692@@ -194,17 +203,19 @@
3693         }
3694     }
3695
3696-    /**
3697-     * HMACSHA224
3698-     */
3699-    public static class HMACSHA224
3700-        extends JCEKeyGenerator
3701-    {
3702-        public HMACSHA224()
3703-        {
3704-            super("HMACSHA224", 224, new CipherKeyGenerator());
3705-        }
3706-    }
3707+    // BEGIN android-removed
3708+    // /**
3709+    //  * HMACSHA224
3710+    //  */
3711+    // public static class HMACSHA224
3712+    //     extends JCEKeyGenerator
3713+    // {
3714+    //     public HMACSHA224()
3715+    //     {
3716+    //         super("HMACSHA224", 224, new CipherKeyGenerator());
3717+    //     }
3718+    // }
3719+    // END android-removed
3720
3721     /**
3722      * HMACSHA256
3723@@ -242,15 +253,17 @@
3724         }
3725     }
3726
3727-    /**
3728-     * HMACTIGER
3729-     */
3730-    public static class HMACTIGER
3731-        extends JCEKeyGenerator
3732-    {
3733-        public HMACTIGER()
3734-        {
3735-            super("HMACTIGER", 192, new CipherKeyGenerator());
3736-        }
3737-    }
3738+    // BEGIN android-removed
3739+    // /**
3740+    //  * HMACTIGER
3741+    //  */
3742+    // public static class HMACTIGER
3743+    //     extends JCEKeyGenerator
3744+    // {
3745+    //     public HMACTIGER()
3746+    //     {
3747+    //         super("HMACTIGER", 192, new CipherKeyGenerator());
3748+    //     }
3749+    // }
3750+    // END android-removed
3751 }
3752diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEMac.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEMac.java
3753--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEMac.java	2011-02-23 20:08:56.000000000 +0000
3754+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEMac.java	2011-09-08 21:28:49.000000000 +0000
3755@@ -11,25 +11,39 @@
3756
3757 import org.bouncycastle.crypto.CipherParameters;
3758 import org.bouncycastle.crypto.Mac;
3759-import org.bouncycastle.crypto.digests.MD2Digest;
3760-import org.bouncycastle.crypto.digests.MD4Digest;
3761+// BEGIN android-removed
3762+// import org.bouncycastle.crypto.digests.MD2Digest;
3763+// import org.bouncycastle.crypto.digests.MD4Digest;
3764+// END android-removed
3765 import org.bouncycastle.crypto.digests.MD5Digest;
3766-import org.bouncycastle.crypto.digests.RIPEMD128Digest;
3767-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
3768+// BEGIN android-removed
3769+// import org.bouncycastle.crypto.digests.RIPEMD128Digest;
3770+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
3771+// END android-removed
3772 import org.bouncycastle.crypto.digests.SHA1Digest;
3773-import org.bouncycastle.crypto.digests.SHA224Digest;
3774+// BEGIN android-removed
3775+// import org.bouncycastle.crypto.digests.SHA224Digest;
3776+// END android-removed
3777 import org.bouncycastle.crypto.digests.SHA256Digest;
3778 import org.bouncycastle.crypto.digests.SHA384Digest;
3779 import org.bouncycastle.crypto.digests.SHA512Digest;
3780-import org.bouncycastle.crypto.digests.TigerDigest;
3781+// BEGIN android-removed
3782+// import org.bouncycastle.crypto.digests.TigerDigest;
3783+// END android-removed
3784 import org.bouncycastle.crypto.engines.DESEngine;
3785-import org.bouncycastle.crypto.engines.RC2Engine;
3786+// BEGIN android-removed
3787+// import org.bouncycastle.crypto.engines.RC2Engine;
3788+// END android-removed
3789 import org.bouncycastle.crypto.macs.CBCBlockCipherMac;
3790-import org.bouncycastle.crypto.macs.CFBBlockCipherMac;
3791-import org.bouncycastle.crypto.macs.GOST28147Mac;
3792+// BEGIN android-removed
3793+// import org.bouncycastle.crypto.macs.CFBBlockCipherMac;
3794+// import org.bouncycastle.crypto.macs.GOST28147Mac;
3795+// END android-removed
3796 import org.bouncycastle.crypto.macs.HMac;
3797-import org.bouncycastle.crypto.macs.ISO9797Alg3Mac;
3798-import org.bouncycastle.crypto.macs.OldHMac;
3799+// BEGIN android-removed
3800+// import org.bouncycastle.crypto.macs.ISO9797Alg3Mac;
3801+// import org.bouncycastle.crypto.macs.OldHMac;
3802+// END android-removed
3803 import org.bouncycastle.crypto.paddings.ISO7816d4Padding;
3804 import org.bouncycastle.crypto.params.KeyParameter;
3805 import org.bouncycastle.crypto.params.ParametersWithIV;
3806@@ -143,115 +157,117 @@
3807      * the classes that extend directly off us.
3808      */
3809
3810-    /**
3811-     * DES
3812-     */
3813-    public static class DES
3814-        extends JCEMac
3815-    {
3816-        public DES()
3817-        {
3818-            super(new CBCBlockCipherMac(new DESEngine()));
3819-        }
3820-    }
3821-
3822-    /**
3823-     * RC2
3824-     */
3825-    public static class RC2
3826-        extends JCEMac
3827-    {
3828-        public RC2()
3829-        {
3830-            super(new CBCBlockCipherMac(new RC2Engine()));
3831-        }
3832-    }
3833-
3834-    /**
3835-     * GOST28147
3836-     */
3837-    public static class GOST28147
3838-        extends JCEMac
3839-    {
3840-        public GOST28147()
3841-        {
3842-            super(new GOST28147Mac());
3843-        }
3844-    }
3845-
3846-
3847-
3848-    /**
3849-     * DES
3850-     */
3851-    public static class DESCFB8
3852-        extends JCEMac
3853-    {
3854-        public DESCFB8()
3855-        {
3856-            super(new CFBBlockCipherMac(new DESEngine()));
3857-        }
3858-    }
3859-
3860-    /**
3861-     * RC2CFB8
3862-     */
3863-    public static class RC2CFB8
3864-        extends JCEMac
3865-    {
3866-        public RC2CFB8()
3867-        {
3868-            super(new CFBBlockCipherMac(new RC2Engine()));
3869-        }
3870-    }
3871-
3872-    /**
3873-     * DES9797Alg3with7816-4Padding
3874-     */
3875-    public static class DES9797Alg3with7816d4
3876-        extends JCEMac
3877-    {
3878-        public DES9797Alg3with7816d4()
3879-        {
3880-            super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
3881-        }
3882-    }
3883-
3884-    /**
3885-     * DES9797Alg3
3886-     */
3887-    public static class DES9797Alg3
3888-        extends JCEMac
3889-    {
3890-        public DES9797Alg3()
3891-        {
3892-            super(new ISO9797Alg3Mac(new DESEngine()));
3893-        }
3894-    }
3895-
3896-    /**
3897-     * MD2 HMac
3898-     */
3899-    public static class MD2
3900-        extends JCEMac
3901-    {
3902-        public MD2()
3903-        {
3904-            super(new HMac(new MD2Digest()));
3905-        }
3906-    }
3907-
3908-    /**
3909-     * MD4 HMac
3910-     */
3911-    public static class MD4
3912-        extends JCEMac
3913-    {
3914-        public MD4()
3915-        {
3916-            super(new HMac(new MD4Digest()));
3917-        }
3918-    }
3919+    // BEGIN android-removed
3920+    // /**
3921+    //  * DES
3922+    //  */
3923+    // public static class DES
3924+    //     extends JCEMac
3925+    // {
3926+    //     public DES()
3927+    //     {
3928+    //         super(new CBCBlockCipherMac(new DESEngine()));
3929+    //     }
3930+    // }
3931+    //
3932+    // /**
3933+    //  * RC2
3934+    //  */
3935+    // public static class RC2
3936+    //     extends JCEMac
3937+    // {
3938+    //     public RC2()
3939+    //     {
3940+    //         super(new CBCBlockCipherMac(new RC2Engine()));
3941+    //     }
3942+    // }
3943+    //
3944+    // /**
3945+    //  * GOST28147
3946+    //  */
3947+    // public static class GOST28147
3948+    //     extends JCEMac
3949+    // {
3950+    //     public GOST28147()
3951+    //     {
3952+    //         super(new GOST28147Mac());
3953+    //     }
3954+    // }
3955+    //
3956+    //
3957+    //
3958+    // /**
3959+    //  * DES
3960+    //  */
3961+    // public static class DESCFB8
3962+    //     extends JCEMac
3963+    // {
3964+    //     public DESCFB8()
3965+    //     {
3966+    //         super(new CFBBlockCipherMac(new DESEngine()));
3967+    //     }
3968+    // }
3969+    //
3970+    // /**
3971+    //  * RC2CFB8
3972+    //  */
3973+    // public static class RC2CFB8
3974+    //     extends JCEMac
3975+    // {
3976+    //     public RC2CFB8()
3977+    //     {
3978+    //         super(new CFBBlockCipherMac(new RC2Engine()));
3979+    //     }
3980+    // }
3981+    //
3982+    // /**
3983+    //  * DES9797Alg3with7816-4Padding
3984+    //  */
3985+    // public static class DES9797Alg3with7816d4
3986+    //     extends JCEMac
3987+    // {
3988+    //     public DES9797Alg3with7816d4()
3989+    //     {
3990+    //         super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
3991+    //     }
3992+    // }
3993+    //
3994+    // /**
3995+    //  * DES9797Alg3
3996+    //  */
3997+    // public static class DES9797Alg3
3998+    //     extends JCEMac
3999+    // {
4000+    //     public DES9797Alg3()
4001+    //     {
4002+    //         super(new ISO9797Alg3Mac(new DESEngine()));
4003+    //     }
4004+    // }
4005+    //
4006+    // /**
4007+    //  * MD2 HMac
4008+    //  */
4009+    // public static class MD2
4010+    //     extends JCEMac
4011+    // {
4012+    //     public MD2()
4013+    //     {
4014+    //         super(new HMac(new MD2Digest()));
4015+    //     }
4016+    // }
4017+    //
4018+    // /**
4019+    //  * MD4 HMac
4020+    //  */
4021+    // public static class MD4
4022+    //     extends JCEMac
4023+    // {
4024+    //     public MD4()
4025+    //     {
4026+    //         super(new HMac(new MD4Digest()));
4027+    //     }
4028+    // }
4029+    // END android-removed
4030
4031     /**
4032      * MD5 HMac
4033@@ -264,7 +280,7 @@
4034             super(new HMac(new MD5Digest()));
4035         }
4036     }
4037-
4038+
4039     /**
4040      * SHA1 HMac
4041      */
4042@@ -276,18 +292,20 @@
4043             super(new HMac(new SHA1Digest()));
4044         }
4045     }
4046-
4047-    /**
4048-     * SHA-224 HMac
4049-     */
4050-    public static class SHA224
4051-        extends JCEMac
4052-    {
4053-        public SHA224()
4054-        {
4055-            super(new HMac(new SHA224Digest()));
4056-        }
4057-    }
4058+
4059+    // BEGIN android-removed
4060+    // /**
4061+    //  * SHA-224 HMac
4062+    //  */
4063+    // public static class SHA224
4064+    //     extends JCEMac
4065+    // {
4066+    //     public SHA224()
4067+    //     {
4068+    //         super(new HMac(new SHA224Digest()));
4069+    //     }
4070+    // }
4071+    // END android-removed
4072
4073     /**
4074      * SHA-256 HMac
4075@@ -300,7 +318,7 @@
4076             super(new HMac(new SHA256Digest()));
4077         }
4078     }
4079-
4080+
4081     /**
4082      * SHA-384 HMac
4083      */
4084@@ -312,15 +330,17 @@
4085             super(new HMac(new SHA384Digest()));
4086         }
4087     }
4088-
4089-    public static class OldSHA384
4090-        extends JCEMac
4091-    {
4092-        public OldSHA384()
4093-        {
4094-            super(new OldHMac(new SHA384Digest()));
4095-        }
4096-    }
4097+
4098+    // BEGIN android-removed
4099+    // public static class OldSHA384
4100+    //     extends JCEMac
4101+    // {
4102+    //     public OldSHA384()
4103+    //     {
4104+    //         super(new OldHMac(new SHA384Digest()));
4105+    //     }
4106+    // }
4107+    // END android-removed
4108
4109     /**
4110      * SHA-512 HMac
4111@@ -333,73 +353,75 @@
4112             super(new HMac(new SHA512Digest()));
4113         }
4114     }
4115-
4116-    /**
4117-     * SHA-512 HMac
4118-     */
4119-    public static class OldSHA512
4120-        extends JCEMac
4121-    {
4122-        public OldSHA512()
4123-        {
4124-            super(new OldHMac(new SHA512Digest()));
4125-        }
4126-    }
4127
4128-    /**
4129-     * RIPEMD128 HMac
4130-     */
4131-    public static class RIPEMD128
4132-        extends JCEMac
4133-    {
4134-        public RIPEMD128()
4135-        {
4136-            super(new HMac(new RIPEMD128Digest()));
4137-        }
4138-    }
4139-
4140-    /**
4141-     * RIPEMD160 HMac
4142-     */
4143-    public static class RIPEMD160
4144-        extends JCEMac
4145-    {
4146-        public RIPEMD160()
4147-        {
4148-            super(new HMac(new RIPEMD160Digest()));
4149-        }
4150-    }
4151-
4152-    /**
4153-     * Tiger HMac
4154-     */
4155-    public static class Tiger
4156-        extends JCEMac
4157-    {
4158-        public Tiger()
4159-        {
4160-            super(new HMac(new TigerDigest()));
4161-        }
4162-    }
4163-
4164+    // BEGIN android-removed
4165+    // /**
4166+    //  * SHA-512 HMac
4167+    //  */
4168+    // public static class OldSHA512
4169+    //     extends JCEMac
4170+    // {
4171+    //     public OldSHA512()
4172+    //     {
4173+    //         super(new OldHMac(new SHA512Digest()));
4174+    //     }
4175+    // }
4176     //
4177-    // PKCS12 states that the same algorithm should be used
4178-    // for the key generation as is used in the HMAC, so that
4179-    // is what we do here.
4180+    // /**
4181+    //  * RIPEMD128 HMac
4182+    //  */
4183+    // public static class RIPEMD128
4184+    //     extends JCEMac
4185+    // {
4186+    //     public RIPEMD128()
4187+    //     {
4188+    //        super(new HMac(new RIPEMD128Digest()));
4189+    //     }
4190+    // }
4191     //
4192-
4193-    /**
4194-     * PBEWithHmacRIPEMD160
4195-     */
4196-    public static class PBEWithRIPEMD160
4197-        extends JCEMac
4198-    {
4199-        public PBEWithRIPEMD160()
4200-        {
4201-            super(new HMac(new RIPEMD160Digest()), PKCS12, RIPEMD160, 160);
4202-        }
4203-    }
4204-
4205+    // /**
4206+    //  * RIPEMD160 HMac
4207+    //  */
4208+    // public static class RIPEMD160
4209+    //     extends JCEMac
4210+    // {
4211+    //     public RIPEMD160()
4212+    //     {
4213+    //        super(new HMac(new RIPEMD160Digest()));
4214+    //     }
4215+    // }
4216+    //
4217+    // /**
4218+    //  * Tiger HMac
4219+    //  */
4220+    // public static class Tiger
4221+    //     extends JCEMac
4222+    // {
4223+    //     public Tiger()
4224+    //     {
4225+    //         super(new HMac(new TigerDigest()));
4226+    //     }
4227+    // }
4228+    //
4229+    // //
4230+    // // PKCS12 states that the same algorithm should be used
4231+    // // for the key generation as is used in the HMAC, so that
4232+    // // is what we do here.
4233+    // //
4234+    //
4235+    // /**
4236+    //  * PBEWithHmacRIPEMD160
4237+    //  */
4238+    // public static class PBEWithRIPEMD160
4239+    //     extends JCEMac
4240+    // {
4241+    //     public PBEWithRIPEMD160()
4242+    //     {
4243+    //         super(new HMac(new RIPEMD160Digest()), PKCS12, RIPEMD160, 160);
4244+    //     }
4245+    // }
4246+    // END android-removed
4247+
4248     /**
4249      * PBEWithHmacSHA
4250      */
4251@@ -411,16 +433,18 @@
4252             super(new HMac(new SHA1Digest()), PKCS12, SHA1, 160);
4253         }
4254     }
4255-
4256-    /**
4257-     * PBEWithHmacTiger
4258-     */
4259-    public static class PBEWithTiger
4260-        extends JCEMac
4261-    {
4262-        public PBEWithTiger()
4263-        {
4264-            super(new HMac(new TigerDigest()), PKCS12, TIGER, 192);
4265-        }
4266-    }
4267+
4268+    // BEGIN android-removed
4269+    //  /**
4270+    //   * PBEWithHmacTiger
4271+    //   */
4272+    // public static class PBEWithTiger
4273+    //     extends JCEMac
4274+    // {
4275+    //     public PBEWithTiger()
4276+    //     {
4277+    //         super(new HMac(new TigerDigest()), PKCS12, TIGER, 192);
4278+    //     }
4279+    // }
4280+    // END android-removed
4281 }
4282diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSACipher.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSACipher.java
4283--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSACipher.java	2011-02-23 20:08:56.000000000 +0000
4284+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSACipher.java	2011-09-08 21:28:49.000000000 +0000
4285@@ -535,48 +535,50 @@
4286         }
4287     }
4288
4289-    static public class PKCS1v1_5Padding
4290-        extends JCERSACipher
4291-    {
4292-        public PKCS1v1_5Padding()
4293-        {
4294-            super(new PKCS1Encoding(new RSABlindedEngine()));
4295-        }
4296-    }
4297-
4298-    static public class PKCS1v1_5Padding_PrivateOnly
4299-        extends JCERSACipher
4300-    {
4301-        public PKCS1v1_5Padding_PrivateOnly()
4302-        {
4303-            super(false, true, new PKCS1Encoding(new RSABlindedEngine()));
4304-        }
4305-    }
4306-
4307-    static public class PKCS1v1_5Padding_PublicOnly
4308-        extends JCERSACipher
4309-    {
4310-        public PKCS1v1_5Padding_PublicOnly()
4311-        {
4312-            super(true, false, new PKCS1Encoding(new RSABlindedEngine()));
4313-        }
4314-    }
4315-
4316-    static public class OAEPPadding
4317-        extends JCERSACipher
4318-    {
4319-        public OAEPPadding()
4320-        {
4321-            super(OAEPParameterSpec.DEFAULT);
4322-        }
4323-    }
4324-
4325-    static public class ISO9796d1Padding
4326-        extends JCERSACipher
4327-    {
4328-        public ISO9796d1Padding()
4329-        {
4330-            super(new ISO9796d1Encoding(new RSABlindedEngine()));
4331-        }
4332-    }
4333+    // BEGIN android-removed
4334+    // static public class PKCS1v1_5Padding
4335+    //     extends JCERSACipher
4336+    // {
4337+    //     public PKCS1v1_5Padding()
4338+    //     {
4339+    //         super(new PKCS1Encoding(new RSABlindedEngine()));
4340+    //     }
4341+    // }
4342+    //
4343+    // static public class PKCS1v1_5Padding_PrivateOnly
4344+    //     extends JCERSACipher
4345+    // {
4346+    //     public PKCS1v1_5Padding_PrivateOnly()
4347+    //     {
4348+    //         super(false, true, new PKCS1Encoding(new RSABlindedEngine()));
4349+    //     }
4350+    // }
4351+    //
4352+    // static public class PKCS1v1_5Padding_PublicOnly
4353+    //     extends JCERSACipher
4354+    // {
4355+    //     public PKCS1v1_5Padding_PublicOnly()
4356+    //     {
4357+    //         super(true, false, new PKCS1Encoding(new RSABlindedEngine()));
4358+    //     }
4359+    // }
4360+    //
4361+    // static public class OAEPPadding
4362+    //     extends JCERSACipher
4363+    // {
4364+    //     public OAEPPadding()
4365+    //     {
4366+    //         super(OAEPParameterSpec.DEFAULT);
4367+    //     }
4368+    // }
4369+    //
4370+    // static public class ISO9796d1Padding
4371+    //     extends JCERSACipher
4372+    // {
4373+    //     public ISO9796d1Padding()
4374+    //     {
4375+    //         super(new ISO9796d1Encoding(new RSABlindedEngine()));
4376+    //     }
4377+    // }
4378+    // END android-removed
4379 }
4380diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java
4381--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java	2011-02-23 20:08:56.000000000 +0000
4382+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java	2011-09-08 21:28:49.000000000 +0000
4383@@ -125,7 +125,9 @@
4384      */
4385     public byte[] getEncoded()
4386     {
4387-        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPrivateKeyStructure(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()).getDERObject());
4388+        // BEGIN android-changed
4389+        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKeyStructure(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()).getDERObject());
4390+        // END android-changed
4391
4392         return info.getDEREncoded();
4393     }
4394diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSAPrivateKey.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSAPrivateKey.java
4395--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSAPrivateKey.java	2011-02-23 20:08:56.000000000 +0000
4396+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSAPrivateKey.java	2011-09-08 21:28:49.000000000 +0000
4397@@ -77,7 +77,9 @@
4398
4399     public byte[] getEncoded()
4400     {
4401-        PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPrivateKeyStructure(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO, ZERO, ZERO, ZERO).getDERObject());
4402+        // BEGIN android-changed
4403+        PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKeyStructure(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO, ZERO, ZERO, ZERO).getDERObject());
4404+        // END android-changed
4405
4406         return info.getDEREncoded();
4407     }
4408diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSAPublicKey.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSAPublicKey.java
4409--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCERSAPublicKey.java	2011-02-23 20:08:56.000000000 +0000
4410+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCERSAPublicKey.java	2011-09-08 21:28:49.000000000 +0000
4411@@ -90,7 +90,9 @@
4412
4413     public byte[] getEncoded()
4414     {
4415-        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
4416+        // BEGIN android-changed
4417+        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
4418+        // END android-changed
4419
4420         return info.getDEREncoded();
4421     }
4422diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCESecretKeyFactory.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCESecretKeyFactory.java
4423--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCESecretKeyFactory.java	2011-02-23 20:08:56.000000000 +0000
4424+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCESecretKeyFactory.java	2011-09-08 21:28:49.000000000 +0000
4425@@ -250,29 +250,31 @@
4426         }
4427     }
4428
4429-    /**
4430-     * PBEWithMD2AndDES
4431-     */
4432-    static public class PBEWithMD2AndDES
4433-        extends DESPBEKeyFactory
4434-    {
4435-        public PBEWithMD2AndDES()
4436-        {
4437-            super("PBEwithMD2andDES", PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, true, PKCS5S1, MD2, 64, 64);
4438-        }
4439-    }
4440-
4441-    /**
4442-     * PBEWithMD2AndRC2
4443-     */
4444-    static public class PBEWithMD2AndRC2
4445-        extends PBEKeyFactory
4446-    {
4447-        public PBEWithMD2AndRC2()
4448-        {
4449-            super("PBEwithMD2andRC2", PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, true, PKCS5S1, MD2, 64, 64);
4450-        }
4451-    }
4452+    // BEGIN android-removed
4453+    // /**
4454+    //  * PBEWithMD2AndDES
4455+    //  */
4456+    // static public class PBEWithMD2AndDES
4457+    //     extends DESPBEKeyFactory
4458+    // {
4459+    //     public PBEWithMD2AndDES()
4460+    //     {
4461+    //         super("PBEwithMD2andDES", PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, true, PKCS5S1, MD2, 64, 64);
4462+    //     }
4463+    // }
4464+    //
4465+    // /**
4466+    //  * PBEWithMD2AndRC2
4467+    //  */
4468+    // static public class PBEWithMD2AndRC2
4469+    //     extends PBEKeyFactory
4470+    // {
4471+    //     public PBEWithMD2AndRC2()
4472+    //     {
4473+    //         super("PBEwithMD2andRC2", PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, true, PKCS5S1, MD2, 64, 64);
4474+    //     }
4475+    // }
4476+    // END android-removed
4477
4478    /**
4479     * PBEWithMD5AndDES
4480@@ -406,17 +408,19 @@
4481        }
4482    }
4483
4484-   /**
4485-    * PBEWithHmacRIPEMD160
4486-    */
4487-   public static class PBEWithRIPEMD160
4488-       extends PBEKeyFactory
4489-   {
4490-       public PBEWithRIPEMD160()
4491-       {
4492-           super("PBEwithHmacRIPEMD160", null, false, PKCS12, RIPEMD160, 160, 0);
4493-       }
4494-   }
4495+   // BEGIN android-removed
4496+   // /**
4497+   //  * PBEWithHmacRIPEMD160
4498+   //  */
4499+   // public static class PBEWithRIPEMD160
4500+   //     extends PBEKeyFactory
4501+   // {
4502+   //     public PBEWithRIPEMD160()
4503+   //     {
4504+   //         super("PBEwithHmacRIPEMD160", null, false, PKCS12, RIPEMD160, 160, 0);
4505+   //     }
4506+   // }
4507+   // END android-removed
4508
4509    /**
4510     * PBEWithHmacSHA
4511@@ -430,17 +434,19 @@
4512        }
4513    }
4514
4515-   /**
4516-    * PBEWithHmacTiger
4517-    */
4518-   public static class PBEWithTiger
4519-       extends PBEKeyFactory
4520-   {
4521-       public PBEWithTiger()
4522-       {
4523-           super("PBEwithHmacTiger", null, false, PKCS12, TIGER, 192, 0);
4524-       }
4525-   }
4526+   // BEGIN android-removed
4527+   // /**
4528+   //  * PBEWithHmacTiger
4529+   //  */
4530+   // public static class PBEWithTiger
4531+   //     extends PBEKeyFactory
4532+   // {
4533+   //     public PBEWithTiger()
4534+   //     {
4535+   //         super("PBEwithHmacTiger", null, false, PKCS12, TIGER, 192, 0);
4536+   //     }
4537+   // }
4538+   // END android-removed
4539
4540    /**
4541     * PBEWithSHA1And128BitAES-BC
4542@@ -549,4 +555,56 @@
4543            super("PBEWithMD5And256BitAES-CBC-OpenSSL", null, true, OPENSSL, MD5, 256, 128);
4544        }
4545    }
4546+    // BEGIN android-added
4547+    static public class PBKDF2WithHmacSHA1
4548+        extends JCESecretKeyFactory
4549+    {
4550+        public PBKDF2WithHmacSHA1()
4551+        {
4552+            super("PBKDF2WithHmacSHA1", PKCSObjectIdentifiers.id_PBKDF2);
4553+        }
4554+
4555+        protected SecretKey engineGenerateSecret(
4556+            KeySpec keySpec)
4557+            throws InvalidKeySpecException
4558+        {
4559+            if (keySpec instanceof PBEKeySpec)
4560+            {
4561+                PBEKeySpec          pbeSpec = (PBEKeySpec)keySpec;
4562+
4563+                if (pbeSpec.getSalt() == null)
4564+                {
4565+                    throw new InvalidKeySpecException("missing required salt");
4566+                }
4567+
4568+                if (pbeSpec.getIterationCount() <= 0)
4569+                {
4570+                    throw new InvalidKeySpecException("positive iteration count required: "
4571+                                                      + pbeSpec.getIterationCount());
4572+                }
4573+
4574+                if (pbeSpec.getKeyLength() <= 0)
4575+                {
4576+                    throw new InvalidKeySpecException("positive key length required: "
4577+                                                      + pbeSpec.getKeyLength());
4578+                }
4579+
4580+                if (pbeSpec.getPassword().length == 0)
4581+                {
4582+                    throw new IllegalArgumentException("password empty");
4583+                }
4584+
4585+                int scheme = PKCS5S2;
4586+                int digest = SHA1;
4587+                int keySize = pbeSpec.getKeyLength();
4588+                int ivSize = -1;
4589+                CipherParameters param = Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize);
4590+
4591+                return new JCEPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param);
4592+            }
4593+
4594+            throw new InvalidKeySpecException("Invalid KeySpec");
4595+        }
4596+    }
4597+    // END android-added
4598 }
4599diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEStreamCipher.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEStreamCipher.java
4600--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JCEStreamCipher.java	2011-02-23 20:08:56.000000000 +0000
4601+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JCEStreamCipher.java	2011-09-08 21:28:49.000000000 +0000
4602@@ -13,20 +13,26 @@
4603 import javax.crypto.ShortBufferException;
4604 import javax.crypto.spec.IvParameterSpec;
4605 import javax.crypto.spec.PBEParameterSpec;
4606-import javax.crypto.spec.RC2ParameterSpec;
4607-import javax.crypto.spec.RC5ParameterSpec;
4608+// BEGIN android-removed
4609+// import javax.crypto.spec.RC2ParameterSpec;
4610+// import javax.crypto.spec.RC5ParameterSpec;
4611+// END android-removed
4612
4613 import org.bouncycastle.crypto.BlockCipher;
4614 import org.bouncycastle.crypto.CipherParameters;
4615 import org.bouncycastle.crypto.DataLengthException;
4616 import org.bouncycastle.crypto.StreamBlockCipher;
4617 import org.bouncycastle.crypto.StreamCipher;
4618-import org.bouncycastle.crypto.engines.BlowfishEngine;
4619-import org.bouncycastle.crypto.engines.DESEngine;
4620-import org.bouncycastle.crypto.engines.DESedeEngine;
4621+// BEGIN android-removed
4622+// import org.bouncycastle.crypto.engines.BlowfishEngine;
4623+// import org.bouncycastle.crypto.engines.DESEngine;
4624+// import org.bouncycastle.crypto.engines.DESedeEngine;
4625+// END android-removed
4626 import org.bouncycastle.crypto.engines.RC4Engine;
4627-import org.bouncycastle.crypto.engines.SkipjackEngine;
4628-import org.bouncycastle.crypto.engines.TwofishEngine;
4629+// BEGIN android-removed
4630+// import org.bouncycastle.crypto.engines.SkipjackEngine;
4631+// import org.bouncycastle.crypto.engines.TwofishEngine;
4632+// END android-removed
4633 import org.bouncycastle.crypto.modes.CFBBlockCipher;
4634 import org.bouncycastle.crypto.modes.OFBBlockCipher;
4635 import org.bouncycastle.crypto.params.KeyParameter;
4636@@ -40,8 +46,10 @@
4637     //
4638     private Class[]                 availableSpecs =
4639                                     {
4640-                                        RC2ParameterSpec.class,
4641-                                        RC5ParameterSpec.class,
4642+                                        // BEGIN android-removed
4643+                                        // RC2ParameterSpec.class,
4644+                                        // RC5ParameterSpec.class,
4645+                                        // END android-removed
4646                                         IvParameterSpec.class,
4647                                         PBEParameterSpec.class
4648                                     };
4649@@ -370,125 +378,127 @@
4650      * The ciphers that inherit from us.
4651      */
4652
4653-    /**
4654-     * DES
4655-     */
4656-    static public class DES_CFB8
4657-        extends JCEStreamCipher
4658-    {
4659-        public DES_CFB8()
4660-        {
4661-            super(new CFBBlockCipher(new DESEngine(), 8), 64);
4662-        }
4663-    }
4664-
4665-    /**
4666-     * DESede
4667-     */
4668-    static public class DESede_CFB8
4669-        extends JCEStreamCipher
4670-    {
4671-        public DESede_CFB8()
4672-        {
4673-            super(new CFBBlockCipher(new DESedeEngine(), 8), 64);
4674-        }
4675-    }
4676-
4677-    /**
4678-     * SKIPJACK
4679-     */
4680-    static public class Skipjack_CFB8
4681-        extends JCEStreamCipher
4682-    {
4683-        public Skipjack_CFB8()
4684-        {
4685-            super(new CFBBlockCipher(new SkipjackEngine(), 8), 64);
4686-        }
4687-    }
4688-
4689-    /**
4690-     * Blowfish
4691-     */
4692-    static public class Blowfish_CFB8
4693-        extends JCEStreamCipher
4694-    {
4695-        public Blowfish_CFB8()
4696-        {
4697-            super(new CFBBlockCipher(new BlowfishEngine(), 8), 64);
4698-        }
4699-    }
4700-
4701-    /**
4702-     * Twofish
4703-     */
4704-    static public class Twofish_CFB8
4705-        extends JCEStreamCipher
4706-    {
4707-        public Twofish_CFB8()
4708-        {
4709-            super(new CFBBlockCipher(new TwofishEngine(), 8), 128);
4710-        }
4711-    }
4712-
4713-    /**
4714-     * DES
4715-     */
4716-    static public class DES_OFB8
4717-        extends JCEStreamCipher
4718-    {
4719-        public DES_OFB8()
4720-        {
4721-            super(new OFBBlockCipher(new DESEngine(), 8), 64);
4722-        }
4723-    }
4724-
4725-    /**
4726-     * DESede
4727-     */
4728-    static public class DESede_OFB8
4729-        extends JCEStreamCipher
4730-    {
4731-        public DESede_OFB8()
4732-        {
4733-            super(new OFBBlockCipher(new DESedeEngine(), 8), 64);
4734-        }
4735-    }
4736-
4737-    /**
4738-     * SKIPJACK
4739-     */
4740-    static public class Skipjack_OFB8
4741-        extends JCEStreamCipher
4742-    {
4743-        public Skipjack_OFB8()
4744-        {
4745-            super(new OFBBlockCipher(new SkipjackEngine(), 8), 64);
4746-        }
4747-    }
4748-
4749-    /**
4750-     * Blowfish
4751-     */
4752-    static public class Blowfish_OFB8
4753-        extends JCEStreamCipher
4754-    {
4755-        public Blowfish_OFB8()
4756-        {
4757-            super(new OFBBlockCipher(new BlowfishEngine(), 8), 64);
4758-        }
4759-    }
4760-
4761-    /**
4762-     * Twofish
4763-     */
4764-    static public class Twofish_OFB8
4765-        extends JCEStreamCipher
4766-    {
4767-        public Twofish_OFB8()
4768-        {
4769-            super(new OFBBlockCipher(new TwofishEngine(), 8), 128);
4770-        }
4771-    }
4772+    // BEGIN android-removed
4773+    // /**
4774+    //  * DES
4775+    //  */
4776+    // static public class DES_CFB8
4777+    //     extends JCEStreamCipher
4778+    // {
4779+    //     public DES_CFB8()
4780+    //     {
4781+    //         super(new CFBBlockCipher(new DESEngine(), 8), 64);
4782+    //     }
4783+    // }
4784+    //
4785+    // /**
4786+    //  * DESede
4787+    //  */
4788+    // static public class DESede_CFB8
4789+    //     extends JCEStreamCipher
4790+    // {
4791+    //     public DESede_CFB8()
4792+    //     {
4793+    //         super(new CFBBlockCipher(new DESedeEngine(), 8), 64);
4794+    //     }
4795+    // }
4796+    //
4797+    // /**
4798+    //  * SKIPJACK
4799+    //  */
4800+    // static public class Skipjack_CFB8
4801+    //     extends JCEStreamCipher
4802+    // {
4803+    //     public Skipjack_CFB8()
4804+    //     {
4805+    //         super(new CFBBlockCipher(new SkipjackEngine(), 8), 64);
4806+    //     }
4807+    // }
4808+    //
4809+    // /**
4810+    //  * Blowfish
4811+    //  */
4812+    // static public class Blowfish_CFB8
4813+    //     extends JCEStreamCipher
4814+    // {
4815+    //     public Blowfish_CFB8()
4816+    //     {
4817+    //         super(new CFBBlockCipher(new BlowfishEngine(), 8), 64);
4818+    //     }
4819+    // }
4820+    //
4821+    // /**
4822+    //  * Twofish
4823+    //  */
4824+    // static public class Twofish_CFB8
4825+    //     extends JCEStreamCipher
4826+    // {
4827+    //     public Twofish_CFB8()
4828+    //     {
4829+    //         super(new CFBBlockCipher(new TwofishEngine(), 8), 128);
4830+    //     }
4831+    // }
4832+    //
4833+    // /**
4834+    //  * DES
4835+    //  */
4836+    // static public class DES_OFB8
4837+    //     extends JCEStreamCipher
4838+    // {
4839+    //     public DES_OFB8()
4840+    //     {
4841+    //         super(new OFBBlockCipher(new DESEngine(), 8), 64);
4842+    //     }
4843+    // }
4844+    //
4845+    // /**
4846+    //  * DESede
4847+    //  */
4848+    // static public class DESede_OFB8
4849+    //     extends JCEStreamCipher
4850+    // {
4851+    //     public DESede_OFB8()
4852+    //     {
4853+    //         super(new OFBBlockCipher(new DESedeEngine(), 8), 64);
4854+    //     }
4855+    // }
4856+    //
4857+    // /**
4858+    //  * SKIPJACK
4859+    //  */
4860+    // static public class Skipjack_OFB8
4861+    //     extends JCEStreamCipher
4862+    // {
4863+    //     public Skipjack_OFB8()
4864+    //     {
4865+    //         super(new OFBBlockCipher(new SkipjackEngine(), 8), 64);
4866+    //     }
4867+    // }
4868+    //
4869+    // /**
4870+    //  * Blowfish
4871+    //  */
4872+    // static public class Blowfish_OFB8
4873+    //     extends JCEStreamCipher
4874+    // {
4875+    //     public Blowfish_OFB8()
4876+    //     {
4877+    //         super(new OFBBlockCipher(new BlowfishEngine(), 8), 64);
4878+    //     }
4879+    // }
4880+    //
4881+    // /**
4882+    //  * Twofish
4883+    //  */
4884+    // static public class Twofish_OFB8
4885+    //     extends JCEStreamCipher
4886+    // {
4887+    //     public Twofish_OFB8()
4888+    //     {
4889+    //         super(new OFBBlockCipher(new TwofishEngine(), 8), 128);
4890+    //     }
4891+    // }
4892+    // END android-removed
4893
4894     /**
4895      * PBEWithSHAAnd128BitRC4
4896@@ -501,7 +511,7 @@
4897             super(new RC4Engine(), 0);
4898         }
4899     }
4900-
4901+
4902     /**
4903      * PBEWithSHAAnd40BitRC4
4904      */
4905diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java
4906--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java	2011-02-23 20:08:56.000000000 +0000
4907+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java	2011-09-08 21:28:49.000000000 +0000
4908@@ -11,18 +11,24 @@
4909 import javax.crypto.spec.DHGenParameterSpec;
4910 import javax.crypto.spec.DHParameterSpec;
4911 import javax.crypto.spec.IvParameterSpec;
4912-import javax.crypto.spec.RC2ParameterSpec;
4913+// BEGIN android-removed
4914+// import javax.crypto.spec.RC2ParameterSpec;
4915+// END android-removed
4916
4917 import org.bouncycastle.crypto.generators.DHParametersGenerator;
4918 import org.bouncycastle.crypto.generators.DSAParametersGenerator;
4919-import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
4920-import org.bouncycastle.crypto.generators.GOST3410ParametersGenerator;
4921+// BEGIN android-removed
4922+// import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
4923+// import org.bouncycastle.crypto.generators.GOST3410ParametersGenerator;
4924+// END android-removed
4925 import org.bouncycastle.crypto.params.DHParameters;
4926 import org.bouncycastle.crypto.params.DSAParameters;
4927-import org.bouncycastle.crypto.params.ElGamalParameters;
4928-import org.bouncycastle.crypto.params.GOST3410Parameters;
4929-import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
4930-import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
4931+// BEGIN android-removed
4932+// import org.bouncycastle.crypto.params.ElGamalParameters;
4933+// import org.bouncycastle.crypto.params.GOST3410Parameters;
4934+// import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
4935+// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
4936+// END android-removed
4937
4938 public abstract class JDKAlgorithmParameterGenerator
4939     extends AlgorithmParameterGeneratorSpi
4940@@ -145,196 +151,198 @@
4941         }
4942     }
4943
4944-    public static class GOST3410
4945-        extends JDKAlgorithmParameterGenerator
4946-    {
4947-        protected void engineInit(
4948-                AlgorithmParameterSpec  genParamSpec,
4949-                SecureRandom            random)
4950-        throws InvalidAlgorithmParameterException
4951-        {
4952-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for GOST3410 parameter generation.");
4953-        }
4954-
4955-        protected AlgorithmParameters engineGenerateParameters()
4956-        {
4957-            GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator();
4958-
4959-            if (random != null)
4960-            {
4961-                pGen.init(strength, 2, random);
4962-            }
4963-            else
4964-            {
4965-                pGen.init(strength, 2, new SecureRandom());
4966-            }
4967-
4968-            GOST3410Parameters p = pGen.generateParameters();
4969-
4970-            AlgorithmParameters params;
4971-
4972-            try
4973-            {
4974-                params = AlgorithmParameters.getInstance("GOST3410", BouncyCastleProvider.PROVIDER_NAME);
4975-                params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA())));
4976-            }
4977-            catch (Exception e)
4978-            {
4979-                throw new RuntimeException(e.getMessage());
4980-            }
4981-
4982-            return params;
4983-        }
4984-    }
4985-
4986-    public static class ElGamal
4987-        extends JDKAlgorithmParameterGenerator
4988-    {
4989-        private int l = 0;
4990-
4991-        protected void engineInit(
4992-            AlgorithmParameterSpec  genParamSpec,
4993-            SecureRandom            random)
4994-            throws InvalidAlgorithmParameterException
4995-        {
4996-            if (!(genParamSpec instanceof DHGenParameterSpec))
4997-            {
4998-                throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation");
4999-            }
5000-            DHGenParameterSpec  spec = (DHGenParameterSpec)genParamSpec;
5001-
5002-            this.strength = spec.getPrimeSize();
5003-            this.l = spec.getExponentSize();
5004-            this.random = random;
5005-        }
5006-
5007-        protected AlgorithmParameters engineGenerateParameters()
5008-        {
5009-            ElGamalParametersGenerator pGen = new ElGamalParametersGenerator();
5010-
5011-            if (random != null)
5012-            {
5013-                pGen.init(strength, 20, random);
5014-            }
5015-            else
5016-            {
5017-                pGen.init(strength, 20, new SecureRandom());
5018-            }
5019-
5020-            ElGamalParameters p = pGen.generateParameters();
5021-
5022-            AlgorithmParameters params;
5023-
5024-            try
5025-            {
5026-                params = AlgorithmParameters.getInstance("ElGamal", BouncyCastleProvider.PROVIDER_NAME);
5027-                params.init(new DHParameterSpec(p.getP(), p.getG(), l));
5028-            }
5029-            catch (Exception e)
5030-            {
5031-                throw new RuntimeException(e.getMessage());
5032-            }
5033-
5034-            return params;
5035-        }
5036-    }
5037-
5038-    public static class DES
5039-        extends JDKAlgorithmParameterGenerator
5040-    {
5041-        protected void engineInit(
5042-            AlgorithmParameterSpec  genParamSpec,
5043-            SecureRandom            random)
5044-            throws InvalidAlgorithmParameterException
5045-        {
5046-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for DES parameter generation.");
5047-        }
5048-
5049-        protected AlgorithmParameters engineGenerateParameters()
5050-        {
5051-            byte[]  iv = new byte[8];
5052-
5053-            if (random == null)
5054-            {
5055-                random = new SecureRandom();
5056-            }
5057-
5058-            random.nextBytes(iv);
5059-
5060-            AlgorithmParameters params;
5061-
5062-            try
5063-            {
5064-                params = AlgorithmParameters.getInstance("DES", BouncyCastleProvider.PROVIDER_NAME);
5065-                params.init(new IvParameterSpec(iv));
5066-            }
5067-            catch (Exception e)
5068-            {
5069-                throw new RuntimeException(e.getMessage());
5070-            }
5071-
5072-            return params;
5073-        }
5074-    }
5075-
5076-    public static class RC2
5077-        extends JDKAlgorithmParameterGenerator
5078-    {
5079-        RC2ParameterSpec    spec = null;
5080-
5081-        protected void engineInit(
5082-            AlgorithmParameterSpec  genParamSpec,
5083-            SecureRandom            random)
5084-            throws InvalidAlgorithmParameterException
5085-        {
5086-            if (genParamSpec instanceof RC2ParameterSpec)
5087-            {
5088-                spec = (RC2ParameterSpec)genParamSpec;
5089-                return;
5090-            }
5091-
5092-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for RC2 parameter generation.");
5093-        }
5094-
5095-        protected AlgorithmParameters engineGenerateParameters()
5096-        {
5097-            AlgorithmParameters params;
5098-
5099-            if (spec == null)
5100-            {
5101-                byte[]  iv = new byte[8];
5102-
5103-                if (random == null)
5104-                {
5105-                    random = new SecureRandom();
5106-                }
5107-
5108-                random.nextBytes(iv);
5109-
5110-                try
5111-                {
5112-                    params = AlgorithmParameters.getInstance("RC2", BouncyCastleProvider.PROVIDER_NAME);
5113-                    params.init(new IvParameterSpec(iv));
5114-                }
5115-                catch (Exception e)
5116-                {
5117-                    throw new RuntimeException(e.getMessage());
5118-                }
5119-            }
5120-            else
5121-            {
5122-                try
5123-                {
5124-                    params = AlgorithmParameters.getInstance("RC2", BouncyCastleProvider.PROVIDER_NAME);
5125-                    params.init(spec);
5126-                }
5127-                catch (Exception e)
5128-                {
5129-                    throw new RuntimeException(e.getMessage());
5130-                }
5131-            }
5132-
5133-            return params;
5134-        }
5135-    }
5136+    // BEGIN android-removed
5137+    // public static class GOST3410
5138+    //     extends JDKAlgorithmParameterGenerator
5139+    // {
5140+    //     protected void engineInit(
5141+    //             AlgorithmParameterSpec  genParamSpec,
5142+    //             SecureRandom            random)
5143+    //     throws InvalidAlgorithmParameterException
5144+    //     {
5145+    //         throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for GOST3410 parameter generation.");
5146+    //     }
5147+    //
5148+    //     protected AlgorithmParameters engineGenerateParameters()
5149+    //     {
5150+    //         GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator();
5151+    //
5152+    //         if (random != null)
5153+    //         {
5154+    //             pGen.init(strength, 2, random);
5155+    //         }
5156+    //         else
5157+    //         {
5158+    //             pGen.init(strength, 2, new SecureRandom());
5159+    //         }
5160+    //
5161+    //         GOST3410Parameters p = pGen.generateParameters();
5162+    //
5163+    //         AlgorithmParameters params;
5164+    //
5165+    //         try
5166+    //         {
5167+    //             params = AlgorithmParameters.getInstance("GOST3410", BouncyCastleProvider.PROVIDER_NAME);
5168+    //             params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA())));
5169+    //         }
5170+    //         catch (Exception e)
5171+    //         {
5172+    //             throw new RuntimeException(e.getMessage());
5173+    //         }
5174+    //
5175+    //         return params;
5176+    //     }
5177+    // }
5178+    //
5179+    // public static class ElGamal
5180+    //     extends JDKAlgorithmParameterGenerator
5181+    // {
5182+    //     private int l = 0;
5183+    //
5184+    //     protected void engineInit(
5185+    //         AlgorithmParameterSpec  genParamSpec,
5186+    //         SecureRandom            random)
5187+    //         throws InvalidAlgorithmParameterException
5188+    //     {
5189+    //         if (!(genParamSpec instanceof DHGenParameterSpec))
5190+    //         {
5191+    //             throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation");
5192+    //         }
5193+    //         DHGenParameterSpec  spec = (DHGenParameterSpec)genParamSpec;
5194+    //
5195+    //         this.strength = spec.getPrimeSize();
5196+    //         this.l = spec.getExponentSize();
5197+    //         this.random = random;
5198+    //     }
5199+    //
5200+    //     protected AlgorithmParameters engineGenerateParameters()
5201+    //     {
5202+    //         ElGamalParametersGenerator pGen = new ElGamalParametersGenerator();
5203+    //
5204+    //         if (random != null)
5205+    //         {
5206+    //             pGen.init(strength, 20, random);
5207+    //         }
5208+    //         else
5209+    //         {
5210+    //             pGen.init(strength, 20, new SecureRandom());
5211+    //         }
5212+    //
5213+    //         ElGamalParameters p = pGen.generateParameters();
5214+    //
5215+    //         AlgorithmParameters params;
5216+    //
5217+    //         try
5218+    //         {
5219+    //             params = AlgorithmParameters.getInstance("ElGamal", BouncyCastleProvider.PROVIDER_NAME);
5220+    //             params.init(new DHParameterSpec(p.getP(), p.getG(), l));
5221+    //         }
5222+    //         catch (Exception e)
5223+    //         {
5224+    //             throw new RuntimeException(e.getMessage());
5225+    //         }
5226+    //
5227+    //         return params;
5228+    //     }
5229+    // }
5230+    //
5231+    // public static class DES
5232+    //     extends JDKAlgorithmParameterGenerator
5233+    // {
5234+    //     protected void engineInit(
5235+    //         AlgorithmParameterSpec  genParamSpec,
5236+    //         SecureRandom            random)
5237+    //         throws InvalidAlgorithmParameterException
5238+    //     {
5239+    //         throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for DES parameter generation.");
5240+    //     }
5241+    //
5242+    //     protected AlgorithmParameters engineGenerateParameters()
5243+    //     {
5244+    //         byte[]  iv = new byte[8];
5245+    //
5246+    //         if (random == null)
5247+    //         {
5248+    //             random = new SecureRandom();
5249+    //         }
5250+    //
5251+    //         random.nextBytes(iv);
5252+    //
5253+    //         AlgorithmParameters params;
5254+    //
5255+    //         try
5256+    //         {
5257+    //             params = AlgorithmParameters.getInstance("DES", BouncyCastleProvider.PROVIDER_NAME);
5258+    //             params.init(new IvParameterSpec(iv));
5259+    //         }
5260+    //         catch (Exception e)
5261+    //         {
5262+    //             throw new RuntimeException(e.getMessage());
5263+    //         }
5264+    //
5265+    //         return params;
5266+    //     }
5267+    // }
5268+    //
5269+    // public static class RC2
5270+    //     extends JDKAlgorithmParameterGenerator
5271+    // {
5272+    //     RC2ParameterSpec    spec = null;
5273+    //
5274+    //     protected void engineInit(
5275+    //         AlgorithmParameterSpec  genParamSpec,
5276+    //         SecureRandom            random)
5277+    //         throws InvalidAlgorithmParameterException
5278+    //     {
5279+    //         if (genParamSpec instanceof RC2ParameterSpec)
5280+    //         {
5281+    //             spec = (RC2ParameterSpec)genParamSpec;
5282+    //             return;
5283+    //         }
5284+    //
5285+    //         throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for RC2 parameter generation.");
5286+    //     }
5287+    //
5288+    //     protected AlgorithmParameters engineGenerateParameters()
5289+    //     {
5290+    //         AlgorithmParameters params;
5291+    //
5292+    //         if (spec == null)
5293+    //         {
5294+    //             byte[]  iv = new byte[8];
5295+    //
5296+    //             if (random == null)
5297+    //             {
5298+    //                 random = new SecureRandom();
5299+    //             }
5300+    //
5301+    //             random.nextBytes(iv);
5302+    //
5303+    //             try
5304+    //             {
5305+    //                 params = AlgorithmParameters.getInstance("RC2", BouncyCastleProvider.PROVIDER_NAME);
5306+    //                 params.init(new IvParameterSpec(iv));
5307+    //             }
5308+    //             catch (Exception e)
5309+    //             {
5310+    //                 throw new RuntimeException(e.getMessage());
5311+    //             }
5312+    //         }
5313+    //         else
5314+    //         {
5315+    //             try
5316+    //             {
5317+    //                 params = AlgorithmParameters.getInstance("RC2", BouncyCastleProvider.PROVIDER_NAME);
5318+    //                 params.init(spec);
5319+    //             }
5320+    //             catch (Exception e)
5321+    //             {
5322+    //                 throw new RuntimeException(e.getMessage());
5323+    //             }
5324+    //         }
5325+    //
5326+    //         return params;
5327+    //     }
5328+    // }
5329+    // END android-removed
5330 }
5331diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java
5332--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java	2011-02-23 20:08:56.000000000 +0000
5333+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java	2011-09-08 21:28:49.000000000 +0000
5334@@ -10,21 +10,27 @@
5335 import org.bouncycastle.asn1.DERObjectIdentifier;
5336 import org.bouncycastle.asn1.DEROctetString;
5337 import org.bouncycastle.asn1.DERSequence;
5338-import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters;
5339-import org.bouncycastle.asn1.oiw.ElGamalParameter;
5340+// BEGIN android-removed
5341+// import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters;
5342+// import org.bouncycastle.asn1.oiw.ElGamalParameter;
5343+// END android-removed
5344 import org.bouncycastle.asn1.pkcs.DHParameter;
5345 import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
5346 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
5347-import org.bouncycastle.asn1.pkcs.RC2CBCParameter;
5348+// BEGIN android-removed
5349+// import org.bouncycastle.asn1.pkcs.RC2CBCParameter;
5350+// END android-removed
5351 import org.bouncycastle.asn1.pkcs.RSAESOAEPparams;
5352 import org.bouncycastle.asn1.pkcs.RSASSAPSSparams;
5353 import org.bouncycastle.asn1.pkcs.PBKDF2Params;
5354 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
5355 import org.bouncycastle.asn1.x509.DSAParameter;
5356-import org.bouncycastle.jce.spec.ElGamalParameterSpec;
5357-import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
5358-import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
5359-import org.bouncycastle.jce.spec.IESParameterSpec;
5360+// BEGIN android-removed
5361+// import org.bouncycastle.jce.spec.ElGamalParameterSpec;
5362+// import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
5363+// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
5364+// import org.bouncycastle.jce.spec.IESParameterSpec;
5365+// END android-removed
5366 import org.bouncycastle.util.Arrays;
5367
5368 import javax.crypto.spec.DHParameterSpec;
5369@@ -32,7 +38,9 @@
5370 import javax.crypto.spec.OAEPParameterSpec;
5371 import javax.crypto.spec.PBEParameterSpec;
5372 import javax.crypto.spec.PSource;
5373-import javax.crypto.spec.RC2ParameterSpec;
5374+// BEGIN android-removed
5375+// import javax.crypto.spec.RC2ParameterSpec;
5376+// END android-removed
5377 import java.io.IOException;
5378 import java.security.AlgorithmParametersSpi;
5379 import java.security.spec.AlgorithmParameterSpec;
5380@@ -68,13 +76,13 @@
5381         extends JDKAlgorithmParameters
5382     {
5383         private byte[]  iv;
5384-
5385+
5386         protected byte[] engineGetEncoded()
5387             throws IOException
5388         {
5389             return engineGetEncoded("ASN.1");
5390         }
5391-
5392+
5393         protected byte[] engineGetEncoded(
5394             String format)
5395             throws IOException
5396@@ -83,15 +91,15 @@
5397             {
5398                  return new DEROctetString(engineGetEncoded("RAW")).getEncoded();
5399             }
5400-
5401+
5402             if (format.equals("RAW"))
5403             {
5404                 return Arrays.clone(iv);
5405             }
5406-
5407+
5408             return null;
5409         }
5410-
5411+
5412         protected AlgorithmParameterSpec localEngineGetParameterSpec(
5413             Class paramSpec)
5414             throws InvalidParameterSpecException
5415@@ -100,10 +108,10 @@
5416             {
5417                 return new IvParameterSpec(iv);
5418             }
5419-
5420+
5421             throw new InvalidParameterSpecException("unknown parameter spec passed to IV parameters object.");
5422         }
5423-
5424+
5425         protected void engineInit(
5426             AlgorithmParameterSpec paramSpec)
5427             throws InvalidParameterSpecException
5428@@ -112,10 +120,10 @@
5429             {
5430                 throw new InvalidParameterSpecException("IvParameterSpec required to initialise a IV parameters algorithm parameters object");
5431             }
5432-
5433+
5434             this.iv = ((IvParameterSpec)paramSpec).getIV();
5435         }
5436-
5437+
5438         protected void engineInit(
5439             byte[] params)
5440             throws IOException
5441@@ -127,13 +135,13 @@
5442                     && params[0] == 0x04 && params[1] == params.length - 2)
5443             {
5444                 ASN1OctetString oct = (ASN1OctetString)ASN1Object.fromByteArray(params);
5445-
5446+
5447                 params = oct.getOctets();
5448             }
5449-
5450+
5451             this.iv = Arrays.clone(params);
5452         }
5453-
5454+
5455         protected void engineInit(
5456             byte[] params,
5457             String format)
5458@@ -144,204 +152,206 @@
5459                 try
5460                 {
5461                     ASN1OctetString oct = (ASN1OctetString)ASN1Object.fromByteArray(params);
5462-
5463+
5464                     engineInit(oct.getOctets());
5465                 }
5466                 catch (Exception e)
5467                 {
5468                     throw new IOException("Exception decoding: " + e);
5469                 }
5470-
5471+
5472                 return;
5473             }
5474-
5475+
5476             if (format.equals("RAW"))
5477             {
5478                 engineInit(params);
5479                 return;
5480             }
5481-
5482+
5483             throw new IOException("Unknown parameters format in IV parameters object");
5484         }
5485-
5486+
5487         protected String engineToString()
5488         {
5489             return "IV Parameters";
5490         }
5491     }
5492-
5493-    public static class RC2AlgorithmParameters
5494-        extends JDKAlgorithmParameters
5495-    {
5496-        private static final short[] table = {
5497-           0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
5498-           0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
5499-           0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
5500-           0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
5501-           0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
5502-           0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
5503-           0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
5504-           0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
5505-           0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
5506-           0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
5507-           0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
5508-           0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
5509-           0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
5510-           0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
5511-           0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
5512-           0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab
5513-        };
5514-
5515-        private static final short[] ekb = {
5516-           0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d, 0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5,
5517-           0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47, 0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5,
5518-           0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c, 0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef,
5519-           0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89, 0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d,
5520-           0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8, 0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb,
5521-           0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab, 0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d,
5522-           0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46, 0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3,
5523-           0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87, 0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61,
5524-           0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6, 0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1,
5525-           0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7, 0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21,
5526-           0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0, 0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42,
5527-           0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a, 0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f,
5528-           0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5, 0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7,
5529-           0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90, 0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15,
5530-           0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b, 0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7,
5531-           0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18, 0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd
5532-        };
5533-
5534-        private byte[]  iv;
5535-        private int     parameterVersion = 58;
5536-
5537-        protected byte[] engineGetEncoded()
5538-        {
5539-            return Arrays.clone(iv);
5540-        }
5541-
5542-        protected byte[] engineGetEncoded(
5543-            String format)
5544-            throws IOException
5545-        {
5546-            if (isASN1FormatString(format))
5547-            {
5548-                if (parameterVersion == -1)
5549-                {
5550-                    return new RC2CBCParameter(engineGetEncoded()).getEncoded();
5551-                }
5552-                else
5553-                {
5554-                    return new RC2CBCParameter(parameterVersion, engineGetEncoded()).getEncoded();
5555-                }
5556-            }
5557-
5558-            if (format.equals("RAW"))
5559-            {
5560-                return engineGetEncoded();
5561-            }
5562-
5563-            return null;
5564-        }
5565-
5566-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
5567-            Class paramSpec)
5568-            throws InvalidParameterSpecException
5569-        {
5570-            if (paramSpec == RC2ParameterSpec.class)
5571-            {
5572-                if (parameterVersion != -1)
5573-                {
5574-                    if (parameterVersion < 256)
5575-                    {
5576-                        return new RC2ParameterSpec(ekb[parameterVersion], iv);
5577-                    }
5578-                    else
5579-                    {
5580-                        return new RC2ParameterSpec(parameterVersion, iv);
5581-                    }
5582-                }
5583-            }
5584-
5585-            if (paramSpec == IvParameterSpec.class)
5586-            {
5587-                return new IvParameterSpec(iv);
5588-            }
5589-
5590-            throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
5591-        }
5592-
5593-        protected void engineInit(
5594-            AlgorithmParameterSpec paramSpec)
5595-            throws InvalidParameterSpecException
5596-        {
5597-            if (paramSpec instanceof IvParameterSpec)
5598-            {
5599-                this.iv = ((IvParameterSpec)paramSpec).getIV();
5600-            }
5601-            else if (paramSpec instanceof RC2ParameterSpec)
5602-            {
5603-                int effKeyBits = ((RC2ParameterSpec)paramSpec).getEffectiveKeyBits();
5604-                if (effKeyBits != -1)
5605-                {
5606-                    if (effKeyBits < 256)
5607-                    {
5608-                        parameterVersion = table[effKeyBits];
5609-                    }
5610-                    else
5611-                    {
5612-                        parameterVersion = effKeyBits;
5613-                    }
5614-                }
5615-
5616-                this.iv = ((RC2ParameterSpec)paramSpec).getIV();
5617-            }
5618-            else
5619-            {
5620-                throw new InvalidParameterSpecException("IvParameterSpec or RC2ParameterSpec required to initialise a RC2 parameters algorithm parameters object");
5621-            }
5622-        }
5623-
5624-        protected void engineInit(
5625-            byte[] params)
5626-            throws IOException
5627-        {
5628-            this.iv = Arrays.clone(params);
5629-        }
5630-
5631-        protected void engineInit(
5632-            byte[] params,
5633-            String format)
5634-            throws IOException
5635-        {
5636-            if (isASN1FormatString(format))
5637-            {
5638-                RC2CBCParameter p = RC2CBCParameter.getInstance(ASN1Object.fromByteArray(params));
5639-
5640-                if (p.getRC2ParameterVersion() != null)
5641-                {
5642-                    parameterVersion = p.getRC2ParameterVersion().intValue();
5643-                }
5644-
5645-                iv = p.getIV();
5646-
5647-                return;
5648-            }
5649-
5650-            if (format.equals("RAW"))
5651-            {
5652-                engineInit(params);
5653-                return;
5654-            }
5655-
5656-            throw new IOException("Unknown parameters format in IV parameters object");
5657-        }
5658-
5659-        protected String engineToString()
5660-        {
5661-            return "RC2 Parameters";
5662-        }
5663-    }
5664-
5665+
5666+    // BEGIN android-removed
5667+    // public static class RC2AlgorithmParameters
5668+    //     extends JDKAlgorithmParameters
5669+    // {
5670+    //     private static final short[] table = {
5671+    //        0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
5672+    //        0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
5673+    //        0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
5674+    //        0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
5675+    //        0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
5676+    //        0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
5677+    //        0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
5678+    //        0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
5679+    //        0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
5680+    //        0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
5681+    //        0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
5682+    //        0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
5683+    //        0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
5684+    //        0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
5685+    //        0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
5686+    //        0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab
5687+    //     };
5688+    //
5689+    //     private static final short[] ekb = {
5690+    //        0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d, 0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5,
5691+    //        0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47, 0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5,
5692+    //        0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c, 0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef,
5693+    //        0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89, 0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d,
5694+    //        0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8, 0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb,
5695+    //        0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab, 0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d,
5696+    //        0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46, 0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3,
5697+    //        0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87, 0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61,
5698+    //        0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6, 0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1,
5699+    //        0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7, 0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21,
5700+    //        0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0, 0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42,
5701+    //        0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a, 0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f,
5702+    //        0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5, 0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7,
5703+    //        0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90, 0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15,
5704+    //        0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b, 0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7,
5705+    //        0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18, 0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd
5706+    //     };
5707+    //
5708+    //     private byte[]  iv;
5709+    //     private int     parameterVersion = 58;
5710+    //
5711+    //     protected byte[] engineGetEncoded()
5712+    //     {
5713+    //         return Arrays.clone(iv);
5714+    //     }
5715+    //
5716+    //     protected byte[] engineGetEncoded(
5717+    //         String format)
5718+    //         throws IOException
5719+    //     {
5720+    //         if (isASN1FormatString(format))
5721+    //         {
5722+    //             if (parameterVersion == -1)
5723+    //             {
5724+    //                 return new RC2CBCParameter(engineGetEncoded()).getEncoded();
5725+    //             }
5726+    //             else
5727+    //             {
5728+    //                 return new RC2CBCParameter(parameterVersion, engineGetEncoded()).getEncoded();
5729+    //             }
5730+    //         }
5731+    //
5732+    //         if (format.equals("RAW"))
5733+    //         {
5734+    //             return engineGetEncoded();
5735+    //         }
5736+    //
5737+    //         return null;
5738+    //     }
5739+    //
5740+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
5741+    //         Class paramSpec)
5742+    //         throws InvalidParameterSpecException
5743+    //     {
5744+    //         if (paramSpec == RC2ParameterSpec.class)
5745+    //         {
5746+    //             if (parameterVersion != -1)
5747+    //             {
5748+    //                 if (parameterVersion < 256)
5749+    //                 {
5750+    //                     return new RC2ParameterSpec(ekb[parameterVersion], iv);
5751+    //                 }
5752+    //                 else
5753+    //                 {
5754+    //                     return new RC2ParameterSpec(parameterVersion, iv);
5755+    //                 }
5756+    //             }
5757+    //         }
5758+    //
5759+    //         if (paramSpec == IvParameterSpec.class)
5760+    //         {
5761+    //             return new IvParameterSpec(iv);
5762+    //         }
5763+    //
5764+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
5765+    //     }
5766+    //
5767+    //     protected void engineInit(
5768+    //         AlgorithmParameterSpec paramSpec)
5769+    //         throws InvalidParameterSpecException
5770+    //     {
5771+    //         if (paramSpec instanceof IvParameterSpec)
5772+    //         {
5773+    //             this.iv = ((IvParameterSpec)paramSpec).getIV();
5774+    //         }
5775+    //         else if (paramSpec instanceof RC2ParameterSpec)
5776+    //         {
5777+    //             int effKeyBits = ((RC2ParameterSpec)paramSpec).getEffectiveKeyBits();
5778+    //             if (effKeyBits != -1)
5779+    //             {
5780+    //                 if (effKeyBits < 256)
5781+    //                 {
5782+    //                     parameterVersion = table[effKeyBits];
5783+    //                 }
5784+    //                 else
5785+    //                 {
5786+    //                     parameterVersion = effKeyBits;
5787+    //                 }
5788+    //             }
5789+    //
5790+    //             this.iv = ((RC2ParameterSpec)paramSpec).getIV();
5791+    //         }
5792+    //         else
5793+    //         {
5794+    //             throw new InvalidParameterSpecException("IvParameterSpec or RC2ParameterSpec required to initialise a RC2 parameters algorithm parameters object");
5795+    //         }
5796+    //     }
5797+    //
5798+    //     protected void engineInit(
5799+    //         byte[] params)
5800+    //         throws IOException
5801+    //     {
5802+    //         this.iv = Arrays.clone(params);
5803+    //     }
5804+    //
5805+    //     protected void engineInit(
5806+    //         byte[] params,
5807+    //         String format)
5808+    //         throws IOException
5809+    //     {
5810+    //         if (isASN1FormatString(format))
5811+    //         {
5812+    //             RC2CBCParameter p = RC2CBCParameter.getInstance(ASN1Object.fromByteArray(params));
5813+    //
5814+    //             if (p.getRC2ParameterVersion() != null)
5815+    //             {
5816+    //                 parameterVersion = p.getRC2ParameterVersion().intValue();
5817+    //             }
5818+    //
5819+    //             iv = p.getIV();
5820+    //
5821+    //             return;
5822+    //         }
5823+    //
5824+    //         if (format.equals("RAW"))
5825+    //         {
5826+    //             engineInit(params);
5827+    //             return;
5828+    //         }
5829+    //
5830+    //         throw new IOException("Unknown parameters format in IV parameters object");
5831+    //     }
5832+    //
5833+    //     protected String engineToString()
5834+    //     {
5835+    //         return "RC2 Parameters";
5836+    //     }
5837+    // }
5838+    // END android-removed
5839+
5840     public static class PBKDF2
5841         extends JDKAlgorithmParameters
5842     {
5843@@ -429,7 +439,7 @@
5844         extends JDKAlgorithmParameters
5845     {
5846         PKCS12PBEParams params;
5847-
5848+
5849         protected byte[] engineGetEncoded()
5850         {
5851             try
5852@@ -441,7 +451,7 @@
5853                 throw new RuntimeException("Oooops! " + e.toString());
5854             }
5855         }
5856-
5857+
5858         protected byte[] engineGetEncoded(
5859             String format)
5860         {
5861@@ -449,10 +459,10 @@
5862             {
5863                 return engineGetEncoded();
5864             }
5865-
5866+
5867             return null;
5868         }
5869-
5870+
5871         protected AlgorithmParameterSpec localEngineGetParameterSpec(
5872             Class paramSpec)
5873             throws InvalidParameterSpecException
5874@@ -462,10 +472,10 @@
5875                 return new PBEParameterSpec(params.getIV(),
5876                                 params.getIterations().intValue());
5877             }
5878-
5879+
5880             throw new InvalidParameterSpecException("unknown parameter spec passed to PKCS12 PBE parameters object.");
5881         }
5882-
5883+
5884         protected void engineInit(
5885             AlgorithmParameterSpec paramSpec)
5886             throws InvalidParameterSpecException
5887@@ -474,20 +484,20 @@
5888             {
5889                 throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PKCS12 PBE parameters algorithm parameters object");
5890             }
5891-
5892+
5893             PBEParameterSpec    pbeSpec = (PBEParameterSpec)paramSpec;
5894-
5895+
5896             this.params = new PKCS12PBEParams(pbeSpec.getSalt(),
5897                                 pbeSpec.getIterationCount());
5898         }
5899-
5900+
5901         protected void engineInit(
5902             byte[] params)
5903             throws IOException
5904         {
5905             this.params = PKCS12PBEParams.getInstance(ASN1Object.fromByteArray(params));
5906         }
5907-
5908+
5909         protected void engineInit(
5910             byte[] params,
5911             String format)
5912@@ -498,10 +508,10 @@
5913                 engineInit(params);
5914                 return;
5915             }
5916-
5917+
5918             throw new IOException("Unknown parameters format in PKCS12 PBE parameters object");
5919         }
5920-
5921+
5922         protected String engineToString()
5923         {
5924             return "PKCS12 PBE Parameters";
5925@@ -725,334 +735,336 @@
5926         }
5927     }
5928
5929-    public static class GOST3410
5930-        extends JDKAlgorithmParameters
5931-    {
5932-        GOST3410ParameterSpec     currentSpec;
5933-
5934-        /**
5935-         * Return the X.509 ASN.1 structure GOST3410Parameter.
5936-         * <p>
5937-         * <pre>
5938-         *  GOST3410Parameter ::= SEQUENCE {
5939-         *                   prime INTEGER, -- p
5940-         *                   subprime INTEGER, -- q
5941-         *                   base INTEGER, -- a}
5942-         * </pre>
5943-         */
5944-        protected byte[] engineGetEncoded()
5945-        {
5946-            GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID()));
5947-
5948-            try
5949-            {
5950-                return gost3410P.getEncoded(ASN1Encodable.DER);
5951-            }
5952-            catch (IOException e)
5953-            {
5954-                throw new RuntimeException("Error encoding GOST3410Parameters");
5955-            }
5956-        }
5957-
5958-        protected byte[] engineGetEncoded(
5959-                String format)
5960-        {
5961-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
5962-            {
5963-                return engineGetEncoded();
5964-            }
5965-
5966-            return null;
5967-        }
5968-
5969-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
5970-                Class paramSpec)
5971-        throws InvalidParameterSpecException
5972-        {
5973-            if (paramSpec == GOST3410PublicKeyParameterSetSpec.class)
5974-            {
5975-                return currentSpec;
5976-            }
5977-
5978-            throw new InvalidParameterSpecException("unknown parameter spec passed to GOST3410 parameters object.");
5979-        }
5980-
5981-        protected void engineInit(
5982-                AlgorithmParameterSpec paramSpec)
5983-        throws InvalidParameterSpecException
5984-        {
5985-            if (!(paramSpec instanceof GOST3410ParameterSpec))
5986-            {
5987-                throw new InvalidParameterSpecException("GOST3410ParameterSpec required to initialise a GOST3410 algorithm parameters object");
5988-            }
5989-
5990-            this.currentSpec = (GOST3410ParameterSpec)paramSpec;
5991-        }
5992-
5993-        protected void engineInit(
5994-                byte[] params)
5995-        throws IOException
5996-        {
5997-            try
5998-            {
5999-                ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params);
6000-
6001-                this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg(
6002-                    new GOST3410PublicKeyAlgParameters(seq));
6003-            }
6004-            catch (ClassCastException e)
6005-            {
6006-                throw new IOException("Not a valid GOST3410 Parameter encoding.");
6007-            }
6008-            catch (ArrayIndexOutOfBoundsException e)
6009-            {
6010-                throw new IOException("Not a valid GOST3410 Parameter encoding.");
6011-            }
6012-        }
6013-
6014-        protected void engineInit(
6015-                byte[] params,
6016-                String format)
6017-        throws IOException
6018-        {
6019-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6020-            {
6021-                engineInit(params);
6022-            }
6023-            else
6024-            {
6025-                throw new IOException("Unknown parameter format " + format);
6026-            }
6027-        }
6028-
6029-        protected String engineToString()
6030-        {
6031-            return "GOST3410 Parameters";
6032-        }
6033-    }
6034-
6035-    public static class ElGamal
6036-        extends JDKAlgorithmParameters
6037-    {
6038-        ElGamalParameterSpec     currentSpec;
6039-
6040-        /**
6041-         * Return the X.509 ASN.1 structure ElGamalParameter.
6042-         * <p>
6043-         * <pre>
6044-         *  ElGamalParameter ::= SEQUENCE {
6045-         *                   prime INTEGER, -- p
6046-         *                   base INTEGER, -- g}
6047-         * </pre>
6048-         */
6049-        protected byte[] engineGetEncoded()
6050-        {
6051-            ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG());
6052-
6053-            try
6054-            {
6055-                return elP.getEncoded(ASN1Encodable.DER);
6056-            }
6057-            catch (IOException e)
6058-            {
6059-                throw new RuntimeException("Error encoding ElGamalParameters");
6060-            }
6061-        }
6062-
6063-        protected byte[] engineGetEncoded(
6064-            String format)
6065-        {
6066-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6067-            {
6068-                return engineGetEncoded();
6069-            }
6070-
6071-            return null;
6072-        }
6073-
6074-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
6075-            Class paramSpec)
6076-            throws InvalidParameterSpecException
6077-        {
6078-            if (paramSpec == ElGamalParameterSpec.class)
6079-            {
6080-                return currentSpec;
6081-            }
6082-            else if (paramSpec == DHParameterSpec.class)
6083-            {
6084-                return new DHParameterSpec(currentSpec.getP(), currentSpec.getG());
6085-            }
6086-
6087-            throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
6088-        }
6089-
6090-        protected void engineInit(
6091-            AlgorithmParameterSpec paramSpec)
6092-            throws InvalidParameterSpecException
6093-        {
6094-            if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec))
6095-            {
6096-                throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
6097-            }
6098-
6099-            if (paramSpec instanceof ElGamalParameterSpec)
6100-            {
6101-                this.currentSpec = (ElGamalParameterSpec)paramSpec;
6102-            }
6103-            else
6104-            {
6105-                DHParameterSpec s = (DHParameterSpec)paramSpec;
6106-
6107-                this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
6108-            }
6109-        }
6110-
6111-        protected void engineInit(
6112-            byte[] params)
6113-            throws IOException
6114-        {
6115-            try
6116-            {
6117-                ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params));
6118-
6119-                currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
6120-            }
6121-            catch (ClassCastException e)
6122-            {
6123-                throw new IOException("Not a valid ElGamal Parameter encoding.");
6124-            }
6125-            catch (ArrayIndexOutOfBoundsException e)
6126-            {
6127-                throw new IOException("Not a valid ElGamal Parameter encoding.");
6128-            }
6129-        }
6130-
6131-        protected void engineInit(
6132-            byte[] params,
6133-            String format)
6134-            throws IOException
6135-        {
6136-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6137-            {
6138-                engineInit(params);
6139-            }
6140-            else
6141-            {
6142-                throw new IOException("Unknown parameter format " + format);
6143-            }
6144-        }
6145-
6146-        protected String engineToString()
6147-        {
6148-            return "ElGamal Parameters";
6149-        }
6150-    }
6151-
6152-    public static class IES
6153-        extends JDKAlgorithmParameters
6154-    {
6155-        IESParameterSpec     currentSpec;
6156-
6157-        /**
6158-         * in the absence of a standard way of doing it this will do for
6159-         * now...
6160-         */
6161-        protected byte[] engineGetEncoded()
6162-        {
6163-            try
6164-            {
6165-                ASN1EncodableVector v = new ASN1EncodableVector();
6166-
6167-                v.add(new DEROctetString(currentSpec.getDerivationV()));
6168-                v.add(new DEROctetString(currentSpec.getEncodingV()));
6169-                v.add(new DERInteger(currentSpec.getMacKeySize()));
6170-
6171-                return new DERSequence(v).getEncoded(ASN1Encodable.DER);
6172-            }
6173-            catch (IOException e)
6174-            {
6175-                throw new RuntimeException("Error encoding IESParameters");
6176-            }
6177-        }
6178-
6179-        protected byte[] engineGetEncoded(
6180-            String format)
6181-        {
6182-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6183-            {
6184-                return engineGetEncoded();
6185-            }
6186-
6187-            return null;
6188-        }
6189-
6190-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
6191-            Class paramSpec)
6192-            throws InvalidParameterSpecException
6193-        {
6194-            if (paramSpec == IESParameterSpec.class)
6195-            {
6196-                return currentSpec;
6197-            }
6198-
6199-            throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
6200-        }
6201-
6202-        protected void engineInit(
6203-            AlgorithmParameterSpec paramSpec)
6204-            throws InvalidParameterSpecException
6205-        {
6206-            if (!(paramSpec instanceof IESParameterSpec))
6207-            {
6208-                throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object");
6209-            }
6210-
6211-            this.currentSpec = (IESParameterSpec)paramSpec;
6212-        }
6213-
6214-        protected void engineInit(
6215-            byte[] params)
6216-            throws IOException
6217-        {
6218-            try
6219-            {
6220-                ASN1Sequence s = (ASN1Sequence)ASN1Object.fromByteArray(params);
6221-
6222-                this.currentSpec = new IESParameterSpec(
6223-                                        ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
6224-                                        ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
6225-                                        ((DERInteger)s.getObjectAt(0)).getValue().intValue());
6226-            }
6227-            catch (ClassCastException e)
6228-            {
6229-                throw new IOException("Not a valid IES Parameter encoding.");
6230-            }
6231-            catch (ArrayIndexOutOfBoundsException e)
6232-            {
6233-                throw new IOException("Not a valid IES Parameter encoding.");
6234-            }
6235-        }
6236-
6237-        protected void engineInit(
6238-            byte[] params,
6239-            String format)
6240-            throws IOException
6241-        {
6242-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6243-            {
6244-                engineInit(params);
6245-            }
6246-            else
6247-            {
6248-                throw new IOException("Unknown parameter format " + format);
6249-            }
6250-        }
6251-
6252-        protected String engineToString()
6253-        {
6254-            return "IES Parameters";
6255-        }
6256-    }
6257+    // BEGIN android-removed
6258+    // public static class GOST3410
6259+    //     extends JDKAlgorithmParameters
6260+    // {
6261+    //     GOST3410ParameterSpec     currentSpec;
6262+    //
6263+    //     /**
6264+    //      * Return the X.509 ASN.1 structure GOST3410Parameter.
6265+    //      * <p>
6266+    //      * <pre>
6267+    //      *  GOST3410Parameter ::= SEQUENCE {
6268+    //      *                   prime INTEGER, -- p
6269+    //      *                   subprime INTEGER, -- q
6270+    //      *                   base INTEGER, -- a}
6271+    //      * </pre>
6272+    //      */
6273+    //     protected byte[] engineGetEncoded()
6274+    //     {
6275+    //         GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID()));
6276+    //
6277+    //         try
6278+    //         {
6279+    //             return gost3410P.getEncoded(ASN1Encodable.DER);
6280+    //         }
6281+    //         catch (IOException e)
6282+    //         {
6283+    //             throw new RuntimeException("Error encoding GOST3410Parameters");
6284+    //         }
6285+    //     }
6286+    //
6287+    //     protected byte[] engineGetEncoded(
6288+    //             String format)
6289+    //     {
6290+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6291+    //         {
6292+    //             return engineGetEncoded();
6293+    //         }
6294+    //
6295+    //         return null;
6296+    //     }
6297+    //
6298+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
6299+    //             Class paramSpec)
6300+    //     throws InvalidParameterSpecException
6301+    //     {
6302+    //         if (paramSpec == GOST3410PublicKeyParameterSetSpec.class)
6303+    //         {
6304+    //             return currentSpec;
6305+    //         }
6306+    //
6307+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to GOST3410 parameters object.");
6308+    //     }
6309+    //
6310+    //     protected void engineInit(
6311+    //             AlgorithmParameterSpec paramSpec)
6312+    //     throws InvalidParameterSpecException
6313+    //     {
6314+    //         if (!(paramSpec instanceof GOST3410ParameterSpec))
6315+    //         {
6316+    //             throw new InvalidParameterSpecException("GOST3410ParameterSpec required to initialise a GOST3410 algorithm parameters object");
6317+    //         }
6318+    //
6319+    //         this.currentSpec = (GOST3410ParameterSpec)paramSpec;
6320+    //     }
6321+    //
6322+    //     protected void engineInit(
6323+    //             byte[] params)
6324+    //     throws IOException
6325+    //     {
6326+    //         try
6327+    //         {
6328+    //             ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params);
6329+    //
6330+    //             this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg(
6331+    //                 new GOST3410PublicKeyAlgParameters(seq));
6332+    //         }
6333+    //         catch (ClassCastException e)
6334+    //         {
6335+    //             throw new IOException("Not a valid GOST3410 Parameter encoding.");
6336+    //         }
6337+    //         catch (ArrayIndexOutOfBoundsException e)
6338+    //         {
6339+    //             throw new IOException("Not a valid GOST3410 Parameter encoding.");
6340+    //         }
6341+    //     }
6342+    //
6343+    //     protected void engineInit(
6344+    //             byte[] params,
6345+    //             String format)
6346+    //     throws IOException
6347+    //     {
6348+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6349+    //         {
6350+    //             engineInit(params);
6351+    //         }
6352+    //         else
6353+    //         {
6354+    //             throw new IOException("Unknown parameter format " + format);
6355+    //         }
6356+    //     }
6357+    //
6358+    //     protected String engineToString()
6359+    //     {
6360+    //         return "GOST3410 Parameters";
6361+    //     }
6362+    // }
6363+
6364+    // public static class ElGamal
6365+    //     extends JDKAlgorithmParameters
6366+    // {
6367+    //     ElGamalParameterSpec     currentSpec;
6368+    //
6369+    //     /**
6370+    //      * Return the X.509 ASN.1 structure ElGamalParameter.
6371+    //      * <p>
6372+    //      * <pre>
6373+    //      *  ElGamalParameter ::= SEQUENCE {
6374+    //      *                   prime INTEGER, -- p
6375+    //      *                   base INTEGER, -- g}
6376+    //      * </pre>
6377+    //      */
6378+    //     protected byte[] engineGetEncoded()
6379+    //     {
6380+    //         ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG());
6381+    //
6382+    //         try
6383+    //         {
6384+    //             return elP.getEncoded(ASN1Encodable.DER);
6385+    //         }
6386+    //         catch (IOException e)
6387+    //         {
6388+    //             throw new RuntimeException("Error encoding ElGamalParameters");
6389+    //         }
6390+    //     }
6391+    //
6392+    //     protected byte[] engineGetEncoded(
6393+    //         String format)
6394+    //     {
6395+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6396+    //         {
6397+    //             return engineGetEncoded();
6398+    //         }
6399+    //
6400+    //         return null;
6401+    //     }
6402+    //
6403+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
6404+    //         Class paramSpec)
6405+    //         throws InvalidParameterSpecException
6406+    //     {
6407+    //         if (paramSpec == ElGamalParameterSpec.class)
6408+    //         {
6409+    //             return currentSpec;
6410+    //         }
6411+    //         else if (paramSpec == DHParameterSpec.class)
6412+    //         {
6413+    //             return new DHParameterSpec(currentSpec.getP(), currentSpec.getG());
6414+    //         }
6415+    //
6416+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
6417+    //     }
6418+    //
6419+    //     protected void engineInit(
6420+    //         AlgorithmParameterSpec paramSpec)
6421+    //         throws InvalidParameterSpecException
6422+    //     {
6423+    //         if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec))
6424+    //         {
6425+    //             throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
6426+    //         }
6427+    //
6428+    //         if (paramSpec instanceof ElGamalParameterSpec)
6429+    //         {
6430+    //             this.currentSpec = (ElGamalParameterSpec)paramSpec;
6431+    //         }
6432+    //         else
6433+    //         {
6434+    //             DHParameterSpec s = (DHParameterSpec)paramSpec;
6435+    //
6436+    //             this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
6437+    //         }
6438+    //     }
6439+    //
6440+    //     protected void engineInit(
6441+    //         byte[] params)
6442+    //         throws IOException
6443+    //     {
6444+    //         try
6445+    //         {
6446+    //             ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params));
6447+    //
6448+    //             currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
6449+    //         }
6450+    //         catch (ClassCastException e)
6451+    //         {
6452+    //             throw new IOException("Not a valid ElGamal Parameter encoding.");
6453+    //         }
6454+    //         catch (ArrayIndexOutOfBoundsException e)
6455+    //         {
6456+    //             throw new IOException("Not a valid ElGamal Parameter encoding.");
6457+    //         }
6458+    //     }
6459+    //
6460+    //     protected void engineInit(
6461+    //         byte[] params,
6462+    //         String format)
6463+    //         throws IOException
6464+    //     {
6465+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6466+    //         {
6467+    //             engineInit(params);
6468+    //         }
6469+    //         else
6470+    //         {
6471+    //             throw new IOException("Unknown parameter format " + format);
6472+    //         }
6473+    //     }
6474+    //
6475+    //     protected String engineToString()
6476+    //     {
6477+    //         return "ElGamal Parameters";
6478+    //     }
6479+    // }
6480+    //
6481+    // public static class IES
6482+    //     extends JDKAlgorithmParameters
6483+    // {
6484+    //     IESParameterSpec     currentSpec;
6485+    //
6486+    //     /**
6487+    //      * in the absence of a standard way of doing it this will do for
6488+    //      * now...
6489+    //      */
6490+    //     protected byte[] engineGetEncoded()
6491+    //     {
6492+    //         try
6493+    //         {
6494+    //             ASN1EncodableVector v = new ASN1EncodableVector();
6495+    //
6496+    //             v.add(new DEROctetString(currentSpec.getDerivationV()));
6497+    //             v.add(new DEROctetString(currentSpec.getEncodingV()));
6498+    //             v.add(new DERInteger(currentSpec.getMacKeySize()));
6499+    //
6500+    //             return new DERSequence(v).getEncoded(ASN1Encodable.DER);
6501+    //         }
6502+    //         catch (IOException e)
6503+    //         {
6504+    //             throw new RuntimeException("Error encoding IESParameters");
6505+    //         }
6506+    //     }
6507+    //
6508+    //     protected byte[] engineGetEncoded(
6509+    //         String format)
6510+    //     {
6511+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6512+    //         {
6513+    //             return engineGetEncoded();
6514+    //         }
6515+    //
6516+    //         return null;
6517+    //     }
6518+    //
6519+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
6520+    //         Class paramSpec)
6521+    //         throws InvalidParameterSpecException
6522+    //     {
6523+    //         if (paramSpec == IESParameterSpec.class)
6524+    //         {
6525+    //             return currentSpec;
6526+    //         }
6527+    //
6528+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
6529+    //     }
6530+    //
6531+    //     protected void engineInit(
6532+    //         AlgorithmParameterSpec paramSpec)
6533+    //         throws InvalidParameterSpecException
6534+    //     {
6535+    //         if (!(paramSpec instanceof IESParameterSpec))
6536+    //         {
6537+    //             throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object");
6538+    //         }
6539+    //
6540+    //         this.currentSpec = (IESParameterSpec)paramSpec;
6541+    //     }
6542+    //
6543+    //     protected void engineInit(
6544+    //         byte[] params)
6545+    //         throws IOException
6546+    //     {
6547+    //         try
6548+    //         {
6549+    //             ASN1Sequence s = (ASN1Sequence)ASN1Object.fromByteArray(params);
6550+    //
6551+    //             this.currentSpec = new IESParameterSpec(
6552+    //                                     ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
6553+    //                                     ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
6554+    //                                     ((DERInteger)s.getObjectAt(0)).getValue().intValue());
6555+    //         }
6556+    //         catch (ClassCastException e)
6557+    //         {
6558+    //             throw new IOException("Not a valid IES Parameter encoding.");
6559+    //         }
6560+    //         catch (ArrayIndexOutOfBoundsException e)
6561+    //         {
6562+    //             throw new IOException("Not a valid IES Parameter encoding.");
6563+    //         }
6564+    //     }
6565+    //
6566+    //     protected void engineInit(
6567+    //         byte[] params,
6568+    //         String format)
6569+    //         throws IOException
6570+    //     {
6571+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6572+    //         {
6573+    //             engineInit(params);
6574+    //         }
6575+    //         else
6576+    //         {
6577+    //             throw new IOException("Unknown parameter format " + format);
6578+    //         }
6579+    //     }
6580+    //
6581+    //     protected String engineToString()
6582+    //     {
6583+    //         return "IES Parameters";
6584+    //     }
6585+    // }
6586+    // END android-removed
6587
6588     public static class OAEP
6589         extends JDKAlgorithmParameters
6590@@ -1066,11 +1078,15 @@
6591         {
6592             AlgorithmIdentifier     hashAlgorithm = new AlgorithmIdentifier(
6593                                                             JCEDigestUtil.getOID(currentSpec.getDigestAlgorithm()),
6594-                                                            new DERNull());
6595+                                                            // BEGIN android-changed
6596+                                                            DERNull.INSTANCE);
6597+                                                            // END android-changed
6598             MGF1ParameterSpec       mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
6599             AlgorithmIdentifier     maskGenAlgorithm = new AlgorithmIdentifier(
6600                                                             PKCSObjectIdentifiers.id_mgf1,
6601-                                                            new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull()));
6602+                                                            // BEGIN android-changed
6603+                                                            new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
6604+                                                            // END android-changed
6605             PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
6606             AlgorithmIdentifier     pSourceAlgorithm = new AlgorithmIdentifier(
6607                                                             PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
6608@@ -1167,110 +1183,116 @@
6609         }
6610     }
6611
6612-    public static class PSS
6613-        extends JDKAlgorithmParameters
6614-    {
6615-        PSSParameterSpec     currentSpec;
6616-
6617-        /**
6618-         * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
6619-         */
6620-        protected byte[] engineGetEncoded()
6621-            throws IOException
6622-        {
6623-            PSSParameterSpec    pssSpec = currentSpec;
6624-            AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
6625-                                                JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()),
6626-                                                new DERNull());
6627-            MGF1ParameterSpec   mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
6628-            AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
6629-                                                PKCSObjectIdentifiers.id_mgf1,
6630-                                                new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull()));
6631-            RSASSAPSSparams     pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField()));
6632-
6633-            return pssP.getEncoded("DER");
6634-        }
6635-
6636-        protected byte[] engineGetEncoded(
6637-            String format)
6638-            throws IOException
6639-        {
6640-            if (format.equalsIgnoreCase("X.509")
6641-                    || format.equalsIgnoreCase("ASN.1"))
6642-            {
6643-                return engineGetEncoded();
6644-            }
6645-
6646-            return null;
6647-        }
6648-
6649-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
6650-            Class paramSpec)
6651-            throws InvalidParameterSpecException
6652-        {
6653-            if (paramSpec == PSSParameterSpec.class && currentSpec != null)
6654-            {
6655-                return currentSpec;
6656-            }
6657-
6658-            throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
6659-        }
6660-
6661-        protected void engineInit(
6662-            AlgorithmParameterSpec paramSpec)
6663-            throws InvalidParameterSpecException
6664-        {
6665-            if (!(paramSpec instanceof PSSParameterSpec))
6666-            {
6667-                throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
6668-            }
6669-
6670-            this.currentSpec = (PSSParameterSpec)paramSpec;
6671-        }
6672-
6673-        protected void engineInit(
6674-            byte[] params)
6675-            throws IOException
6676-        {
6677-            try
6678-            {
6679-                RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params));
6680-
6681-                currentSpec = new PSSParameterSpec(
6682-                                       pssP.getHashAlgorithm().getObjectId().getId(),
6683-                                       pssP.getMaskGenAlgorithm().getObjectId().getId(),
6684-                                       new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()),
6685-                                       pssP.getSaltLength().getValue().intValue(),
6686-                                       pssP.getTrailerField().getValue().intValue());
6687-            }
6688-            catch (ClassCastException e)
6689-            {
6690-                throw new IOException("Not a valid PSS Parameter encoding.");
6691-            }
6692-            catch (ArrayIndexOutOfBoundsException e)
6693-            {
6694-                throw new IOException("Not a valid PSS Parameter encoding.");
6695-            }
6696-        }
6697-
6698-        protected void engineInit(
6699-            byte[] params,
6700-            String format)
6701-            throws IOException
6702-        {
6703-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6704-            {
6705-                engineInit(params);
6706-            }
6707-            else
6708-            {
6709-                throw new IOException("Unknown parameter format " + format);
6710-            }
6711-        }
6712-
6713-        protected String engineToString()
6714-        {
6715-            return "PSS Parameters";
6716-        }
6717-    }
6718+    // BEGIN android-removed
6719+    // public static class PSS
6720+    //     extends JDKAlgorithmParameters
6721+    // {
6722+    //     PSSParameterSpec     currentSpec;
6723+    //
6724+    //     /**
6725+    //      * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
6726+    //      */
6727+    //     protected byte[] engineGetEncoded()
6728+    //         throws IOException
6729+    //     {
6730+    //         PSSParameterSpec    pssSpec = currentSpec;
6731+    //         AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
6732+    //                                             JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()),
6733+    //                                             // BEGIN android-changed
6734+    //                                             DERNull.INSTANCE);
6735+    //                                             // END android-changed
6736+    //         MGF1ParameterSpec   mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
6737+    //         AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
6738+    //                                             PKCSObjectIdentifiers.id_mgf1,
6739+    //                                             // BEGIN android-changed
6740+    //                                             new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
6741+    //                                             // END android-changed
6742+    //         RSASSAPSSparams     pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField()));
6743+    //
6744+    //         return pssP.getEncoded("DER");
6745+    //     }
6746+    //
6747+    //     protected byte[] engineGetEncoded(
6748+    //         String format)
6749+    //         throws IOException
6750+    //     {
6751+    //         if (format.equalsIgnoreCase("X.509")
6752+    //                 || format.equalsIgnoreCase("ASN.1"))
6753+    //         {
6754+    //             return engineGetEncoded();
6755+    //         }
6756+    //
6757+    //         return null;
6758+    //     }
6759+    //
6760+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
6761+    //         Class paramSpec)
6762+    //         throws InvalidParameterSpecException
6763+    //     {
6764+    //         if (paramSpec == PSSParameterSpec.class && currentSpec != null)
6765+    //         {
6766+    //             return currentSpec;
6767+    //         }
6768+    //
6769+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
6770+    //     }
6771+    //
6772+    //     protected void engineInit(
6773+    //         AlgorithmParameterSpec paramSpec)
6774+    //         throws InvalidParameterSpecException
6775+    //     {
6776+    //         if (!(paramSpec instanceof PSSParameterSpec))
6777+    //         {
6778+    //             throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
6779+    //         }
6780+    //
6781+    //         this.currentSpec = (PSSParameterSpec)paramSpec;
6782+    //     }
6783+    //
6784+    //     protected void engineInit(
6785+    //         byte[] params)
6786+    //         throws IOException
6787+    //     {
6788+    //         try
6789+    //         {
6790+    //             RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params));
6791+    //
6792+    //             currentSpec = new PSSParameterSpec(
6793+    //                                    pssP.getHashAlgorithm().getObjectId().getId(),
6794+    //                                    pssP.getMaskGenAlgorithm().getObjectId().getId(),
6795+    //                                    new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()),
6796+    //                                    pssP.getSaltLength().getValue().intValue(),
6797+    //                                    pssP.getTrailerField().getValue().intValue());
6798+    //         }
6799+    //         catch (ClassCastException e)
6800+    //         {
6801+    //             throw new IOException("Not a valid PSS Parameter encoding.");
6802+    //         }
6803+    //         catch (ArrayIndexOutOfBoundsException e)
6804+    //         {
6805+    //             throw new IOException("Not a valid PSS Parameter encoding.");
6806+    //         }
6807+    //     }
6808+    //
6809+    //     protected void engineInit(
6810+    //         byte[] params,
6811+    //         String format)
6812+    //         throws IOException
6813+    //     {
6814+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
6815+    //         {
6816+    //             engineInit(params);
6817+    //         }
6818+    //         else
6819+    //         {
6820+    //             throw new IOException("Unknown parameter format " + format);
6821+    //         }
6822+    //     }
6823+    //
6824+    //     protected String engineToString()
6825+    //     {
6826+    //         return "PSS Parameters";
6827+    //     }
6828+    // }
6829+    // END android-removed
6830 }
6831diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKDSASigner.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKDSASigner.java
6832--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKDSASigner.java	2011-02-23 20:08:56.000000000 +0000
6833+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKDSASigner.java	2011-09-08 21:28:49.000000000 +0000
6834@@ -23,13 +23,17 @@
6835 import org.bouncycastle.crypto.Digest;
6836 import org.bouncycastle.crypto.digests.NullDigest;
6837 import org.bouncycastle.crypto.digests.SHA1Digest;
6838-import org.bouncycastle.crypto.digests.SHA224Digest;
6839+// BEGIN android-removed
6840+// import org.bouncycastle.crypto.digests.SHA224Digest;
6841+// END android-removed
6842 import org.bouncycastle.crypto.digests.SHA256Digest;
6843 import org.bouncycastle.crypto.digests.SHA384Digest;
6844 import org.bouncycastle.crypto.digests.SHA512Digest;
6845 import org.bouncycastle.crypto.params.ParametersWithRandom;
6846 import org.bouncycastle.crypto.signers.DSASigner;
6847-import org.bouncycastle.jce.interfaces.GOST3410Key;
6848+// BEGIN android-removed
6849+// import org.bouncycastle.jce.interfaces.GOST3410Key;
6850+// END android-removed
6851
6852 public class JDKDSASigner
6853     extends SignatureSpi
6854@@ -53,11 +57,16 @@
6855     {
6856         CipherParameters    param;
6857
6858-        if (publicKey instanceof GOST3410Key)
6859-        {
6860-            param = GOST3410Util.generatePublicKeyParameter(publicKey);
6861-        }
6862-        else if (publicKey instanceof DSAKey)
6863+        // BEGIN android-removed
6864+        // if (publicKey instanceof GOST3410Key)
6865+        // {
6866+        //     param = GOST3410Util.generatePublicKeyParameter(publicKey);
6867+        // }
6868+        // else if (publicKey instanceof DSAKey)
6869+        // END android-removed
6870+        // BEGIN android-added
6871+        if (publicKey instanceof DSAKey)
6872+        // END android-added
6873         {
6874             param = DSAUtil.generatePublicKeyParameter(publicKey);
6875         }
6876@@ -103,14 +112,18 @@
6877     {
6878         CipherParameters    param;
6879
6880-        if (privateKey instanceof GOST3410Key)
6881-        {
6882-            param = GOST3410Util.generatePrivateKeyParameter(privateKey);
6883-        }
6884-        else
6885-        {
6886+        // BEGIN android-removed
6887+        // if (privateKey instanceof GOST3410Key)
6888+        // {
6889+        //     param = GOST3410Util.generatePrivateKeyParameter(privateKey);
6890+        // }
6891+        // else
6892+        // {
6893+        // END android-removed
6894             param = DSAUtil.generatePrivateKeyParameter(privateKey);
6895-        }
6896+        // BEGIN android-removed
6897+        // }
6898+        // END android-removed
6899
6900         if (random != null)
6901         {
6902@@ -231,42 +244,44 @@
6903             super(new SHA1Digest(), new DSASigner());
6904         }
6905     }
6906-
6907-    static public class dsa224
6908-        extends JDKDSASigner
6909-    {
6910-        public dsa224()
6911-        {
6912-            super(new SHA224Digest(), new DSASigner());
6913-        }
6914-    }
6915-
6916-    static public class dsa256
6917-        extends JDKDSASigner
6918-    {
6919-        public dsa256()
6920-        {
6921-            super(new SHA256Digest(), new DSASigner());
6922-        }
6923-    }
6924
6925-    static public class dsa384
6926-        extends JDKDSASigner
6927-    {
6928-        public dsa384()
6929-        {
6930-            super(new SHA384Digest(), new DSASigner());
6931-        }
6932-    }
6933-
6934-    static public class dsa512
6935-        extends JDKDSASigner
6936-    {
6937-        public dsa512()
6938-        {
6939-            super(new SHA512Digest(), new DSASigner());
6940-        }
6941-    }
6942+    // BEGIN android-removed
6943+    // static public class dsa224
6944+    //     extends JDKDSASigner
6945+    // {
6946+    //     public dsa224()
6947+    //     {
6948+    //         super(new SHA224Digest(), new DSASigner());
6949+    //     }
6950+    // }
6951+    //
6952+    // static public class dsa256
6953+    //     extends JDKDSASigner
6954+    // {
6955+    //     public dsa256()
6956+    //     {
6957+    //         super(new SHA256Digest(), new DSASigner());
6958+    //     }
6959+    // }
6960+    //
6961+    // static public class dsa384
6962+    //     extends JDKDSASigner
6963+    // {
6964+    //     public dsa384()
6965+    //     {
6966+    //         super(new SHA384Digest(), new DSASigner());
6967+    //     }
6968+    // }
6969+    //
6970+    // static public class dsa512
6971+    //     extends JDKDSASigner
6972+    // {
6973+    //     public dsa512()
6974+    //     {
6975+    //         super(new SHA512Digest(), new DSASigner());
6976+    //     }
6977+    // }
6978+    // END android-removed
6979
6980     static public class noneDSA
6981         extends JDKDSASigner
6982diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKDigestSignature.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKDigestSignature.java
6983--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKDigestSignature.java	2011-02-23 20:08:56.000000000 +0000
6984+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKDigestSignature.java	2011-09-08 21:28:49.000000000 +0000
6985@@ -23,15 +23,21 @@
6986 import org.bouncycastle.crypto.AsymmetricBlockCipher;
6987 import org.bouncycastle.crypto.CipherParameters;
6988 import org.bouncycastle.crypto.Digest;
6989-import org.bouncycastle.crypto.digests.MD2Digest;
6990-import org.bouncycastle.crypto.digests.MD4Digest;
6991+// BEGIN android-removed
6992+// import org.bouncycastle.crypto.digests.MD2Digest;
6993+// import org.bouncycastle.crypto.digests.MD4Digest;
6994+// END android-removed
6995 import org.bouncycastle.crypto.digests.MD5Digest;
6996 import org.bouncycastle.crypto.digests.NullDigest;
6997-import org.bouncycastle.crypto.digests.RIPEMD128Digest;
6998-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
6999-import org.bouncycastle.crypto.digests.RIPEMD256Digest;
7000+// BEGIN android-removed
7001+// import org.bouncycastle.crypto.digests.RIPEMD128Digest;
7002+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
7003+// import org.bouncycastle.crypto.digests.RIPEMD256Digest;
7004+// END android-removed
7005 import org.bouncycastle.crypto.digests.SHA1Digest;
7006-import org.bouncycastle.crypto.digests.SHA224Digest;
7007+// BEGIN android-removed
7008+// import org.bouncycastle.crypto.digests.SHA224Digest;
7009+// END android-removed
7010 import org.bouncycastle.crypto.digests.SHA256Digest;
7011 import org.bouncycastle.crypto.digests.SHA384Digest;
7012 import org.bouncycastle.crypto.digests.SHA512Digest;
7013@@ -265,14 +271,16 @@
7014         }
7015     }
7016
7017-    static public class SHA224WithRSAEncryption
7018-        extends JDKDigestSignature
7019-    {
7020-        public SHA224WithRSAEncryption()
7021-        {
7022-            super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7023-        }
7024-    }
7025+    // BEGIN android-removed
7026+    // static public class SHA224WithRSAEncryption
7027+    //     extends JDKDigestSignature
7028+    // {
7029+    //     public SHA224WithRSAEncryption()
7030+    //     {
7031+    //         super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7032+    //     }
7033+    // }
7034+    // END android-removed
7035
7036     static public class SHA256WithRSAEncryption
7037         extends JDKDigestSignature
7038@@ -301,23 +309,25 @@
7039         }
7040     }
7041
7042-    static public class MD2WithRSAEncryption
7043-        extends JDKDigestSignature
7044-    {
7045-        public MD2WithRSAEncryption()
7046-        {
7047-            super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7048-        }
7049-    }
7050-
7051-    static public class MD4WithRSAEncryption
7052-        extends JDKDigestSignature
7053-    {
7054-        public MD4WithRSAEncryption()
7055-        {
7056-            super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7057-        }
7058-    }
7059+    // BEGIN android-removed
7060+    // static public class MD2WithRSAEncryption
7061+    //     extends JDKDigestSignature
7062+    // {
7063+    //     public MD2WithRSAEncryption()
7064+    //     {
7065+    //         super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7066+    //     }
7067+    // }
7068+    //
7069+    // static public class MD4WithRSAEncryption
7070+    //     extends JDKDigestSignature
7071+    // {
7072+    //     public MD4WithRSAEncryption()
7073+    //     {
7074+    //         super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7075+    //     }
7076+    // }
7077+    // END android-removed
7078
7079     static public class MD5WithRSAEncryption
7080         extends JDKDigestSignature
7081@@ -328,39 +338,41 @@
7082         }
7083     }
7084
7085-    static public class RIPEMD160WithRSAEncryption
7086-        extends JDKDigestSignature
7087-    {
7088-        public RIPEMD160WithRSAEncryption()
7089-        {
7090-            super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7091-        }
7092-    }
7093-
7094-    static public class RIPEMD128WithRSAEncryption
7095-        extends JDKDigestSignature
7096-    {
7097-        public RIPEMD128WithRSAEncryption()
7098-        {
7099-            super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7100-        }
7101-    }
7102-
7103-    static public class RIPEMD256WithRSAEncryption
7104-        extends JDKDigestSignature
7105-    {
7106-        public RIPEMD256WithRSAEncryption()
7107-        {
7108-            super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7109-        }
7110-    }
7111-
7112-    static public class noneRSA
7113-        extends JDKDigestSignature
7114-    {
7115-        public noneRSA()
7116-        {
7117-            super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine()));
7118-        }
7119-    }
7120+    // BEGIN android-removed
7121+    // static public class RIPEMD160WithRSAEncryption
7122+    //     extends JDKDigestSignature
7123+    // {
7124+    //     public RIPEMD160WithRSAEncryption()
7125+    //     {
7126+    //         super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7127+    //     }
7128+    // }
7129+    //
7130+    // static public class RIPEMD128WithRSAEncryption
7131+    //     extends JDKDigestSignature
7132+    // {
7133+    //     public RIPEMD128WithRSAEncryption()
7134+    //     {
7135+    //         super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7136+    //     }
7137+    // }
7138+    //
7139+    // static public class RIPEMD256WithRSAEncryption
7140+    //     extends JDKDigestSignature
7141+    // {
7142+    //     public RIPEMD256WithRSAEncryption()
7143+    //     {
7144+    //         super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
7145+    //     }
7146+    // }
7147+    //
7148+    // static public class noneRSA
7149+    //     extends JDKDigestSignature
7150+    // {
7151+    //     public noneRSA()
7152+    //     {
7153+    //         super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine()));
7154+    //     }
7155+    // }
7156+    // END android-removed
7157 }
7158diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKKeyFactory.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKKeyFactory.java
7159--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKKeyFactory.java	2011-02-23 20:08:56.000000000 +0000
7160+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKKeyFactory.java	2011-09-08 21:28:49.000000000 +0000
7161@@ -36,17 +36,21 @@
7162 import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
7163 import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
7164 import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
7165-import org.bouncycastle.jce.interfaces.ElGamalPrivateKey;
7166-import org.bouncycastle.jce.interfaces.ElGamalPublicKey;
7167-import org.bouncycastle.jce.spec.ElGamalPrivateKeySpec;
7168-import org.bouncycastle.jce.spec.ElGamalPublicKeySpec;
7169-import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec;
7170-import org.bouncycastle.jce.spec.GOST3410PublicKeySpec;
7171+// BEGIN android-removed
7172+// import org.bouncycastle.jce.interfaces.ElGamalPrivateKey;
7173+// import org.bouncycastle.jce.interfaces.ElGamalPublicKey;
7174+// import org.bouncycastle.jce.spec.ElGamalPrivateKeySpec;
7175+// import org.bouncycastle.jce.spec.ElGamalPublicKeySpec;
7176+// import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec;
7177+// import org.bouncycastle.jce.spec.GOST3410PublicKeySpec;
7178+// END android-removed
7179
7180 public abstract class JDKKeyFactory
7181     extends KeyFactorySpi
7182 {
7183-    protected boolean elGamalFactory = false;
7184+    // BEGIN android-removed
7185+    // protected boolean elGamalFactory = false;
7186+    // END android-removed
7187
7188     public JDKKeyFactory()
7189     {
7190@@ -140,6 +144,20 @@
7191
7192            return new DHPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getG());
7193        }
7194+       // BEGIN android-added
7195+       else if (spec.isAssignableFrom(DSAPublicKeySpec.class) && key instanceof DSAPublicKey)
7196+       {
7197+            DSAPublicKey    k = (DSAPublicKey)key;
7198+
7199+            return new DSAPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG());
7200+       }
7201+       else if (spec.isAssignableFrom(DSAPrivateKeySpec.class) && key instanceof DSAPrivateKey)
7202+       {
7203+            DSAPrivateKey    k = (DSAPrivateKey)key;
7204+
7205+            return new DSAPrivateKeySpec(k.getX(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG());
7206+       }
7207+       // END android-added
7208
7209        throw new RuntimeException("not implemented yet " + key + " " + spec);
7210     }
7211@@ -162,25 +180,33 @@
7212         }
7213         else if (key instanceof DHPublicKey)
7214         {
7215-            if (elGamalFactory)
7216-            {
7217-                return new JCEElGamalPublicKey((DHPublicKey)key);
7218-            }
7219-            else
7220-            {
7221+            // BEGIN android-removed
7222+            // if (elGamalFactory)
7223+            // {
7224+            //     return new JCEElGamalPublicKey((DHPublicKey)key);
7225+            // }
7226+            // else
7227+            // {
7228+            // END android-removed
7229                 return new JCEDHPublicKey((DHPublicKey)key);
7230-            }
7231+            // BEGIN android-removed
7232+            // }
7233+            // END android-removed
7234         }
7235         else if (key instanceof DHPrivateKey)
7236         {
7237-            if (elGamalFactory)
7238-            {
7239-                return new JCEElGamalPrivateKey((DHPrivateKey)key);
7240-            }
7241-            else
7242-            {
7243+            // BEGIN android-removed
7244+            // if (elGamalFactory)
7245+            // {
7246+            //     return new JCEElGamalPrivateKey((DHPrivateKey)key);
7247+            // }
7248+            // else
7249+            // {
7250+            // END android-removed
7251                 return new JCEDHPrivateKey((DHPrivateKey)key);
7252-            }
7253+            // BEGIN android-removed
7254+            // }
7255+            // END android-removed
7256         }
7257         else if (key instanceof DSAPublicKey)
7258         {
7259@@ -190,14 +216,16 @@
7260         {
7261             return new JDKDSAPrivateKey((DSAPrivateKey)key);
7262         }
7263-        else if (key instanceof ElGamalPublicKey)
7264-        {
7265-            return new JCEElGamalPublicKey((ElGamalPublicKey)key);
7266-        }
7267-        else if (key instanceof ElGamalPrivateKey)
7268-        {
7269-            return new JCEElGamalPrivateKey((ElGamalPrivateKey)key);
7270-        }
7271+        // BEGIN android-removed
7272+        // else if (key instanceof ElGamalPublicKey)
7273+        // {
7274+        //     return new JCEElGamalPublicKey((ElGamalPublicKey)key);
7275+        // }
7276+        // else if (key instanceof ElGamalPrivateKey)
7277+        // {
7278+        //    return new JCEElGamalPrivateKey((ElGamalPrivateKey)key);
7279+        // }
7280+        // END android-removed
7281
7282         throw new InvalidKeyException("key type unknown");
7283     }
7284@@ -233,10 +261,12 @@
7285         {
7286             return new JCEDHPublicKey(info);
7287         }
7288-        else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
7289-        {
7290-            return new JCEElGamalPublicKey(info);
7291-        }
7292+        // BEGIN android-removed
7293+        // else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
7294+        // {
7295+        //     return new JCEElGamalPublicKey(info);
7296+        // }
7297+        // END android-removed
7298         else if (algOid.equals(X9ObjectIdentifiers.id_dsa))
7299         {
7300             return new JDKDSAPublicKey(info);
7301@@ -249,14 +279,15 @@
7302         {
7303             return new JCEECPublicKey(info);
7304         }
7305-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
7306-        {
7307-            return new JDKGOST3410PublicKey(info);
7308-        }
7309-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
7310-        {
7311-            return new JCEECPublicKey(info);
7312-        }
7313+        // BEGIN android-removed
7314+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
7315+        // {
7316+        //     return new JDKGOST3410PublicKey(info);
7317+        // }
7318+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
7319+        // {
7320+        //     return new JCEECPublicKey(info);
7321+        // }
7322         else
7323         {
7324             throw new RuntimeException("algorithm identifier " + algOid + " in key not recognised");
7325@@ -294,10 +325,12 @@
7326         {
7327               return new JCEDHPrivateKey(info);
7328         }
7329-        else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
7330-        {
7331-              return new JCEElGamalPrivateKey(info);
7332-        }
7333+        // BEGIN android-removed
7334+        // else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
7335+        // {
7336+        //       return new JCEElGamalPrivateKey(info);
7337+        // }
7338+        // END android-removed
7339         else if (algOid.equals(X9ObjectIdentifiers.id_dsa))
7340         {
7341               return new JDKDSAPrivateKey(info);
7342@@ -306,14 +339,16 @@
7343         {
7344               return new JCEECPrivateKey(info);
7345         }
7346-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
7347-        {
7348-              return new JDKGOST3410PrivateKey(info);
7349-        }
7350-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
7351-        {
7352-              return new JCEECPrivateKey(info);
7353-        }
7354+        // BEGIN android-removed
7355+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
7356+        // {
7357+        //       return new JDKGOST3410PrivateKey(info);
7358+        // }
7359+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
7360+        // {
7361+        //       return new JCEECPrivateKey(info);
7362+        // }
7363+        // END android-removed
7364         else
7365         {
7366             throw new RuntimeException("algorithm identifier " + algOid + " in key not recognised");
7367@@ -444,89 +479,92 @@
7368         }
7369     }
7370
7371-    public static class GOST3410
7372-        extends JDKKeyFactory
7373-    {
7374-        public GOST3410()
7375-        {
7376-        }
7377-
7378-        protected PrivateKey engineGeneratePrivate(
7379-                KeySpec    keySpec)
7380-        throws InvalidKeySpecException
7381-        {
7382-            if (keySpec instanceof GOST3410PrivateKeySpec)
7383-            {
7384-                return new JDKGOST3410PrivateKey((GOST3410PrivateKeySpec)keySpec);
7385-            }
7386-
7387-            return super.engineGeneratePrivate(keySpec);
7388-        }
7389-
7390-        protected PublicKey engineGeneratePublic(
7391-                KeySpec    keySpec)
7392-        throws InvalidKeySpecException
7393-        {
7394-            if (keySpec instanceof GOST3410PublicKeySpec)
7395-            {
7396-                return new JDKGOST3410PublicKey((GOST3410PublicKeySpec)keySpec);
7397-            }
7398-
7399-            return super.engineGeneratePublic(keySpec);
7400-        }
7401-    }
7402-
7403-    public static class ElGamal
7404-        extends JDKKeyFactory
7405-    {
7406-        public ElGamal()
7407-        {
7408-            elGamalFactory = true;
7409-        }
7410-
7411-        protected PrivateKey engineGeneratePrivate(
7412-            KeySpec    keySpec)
7413-            throws InvalidKeySpecException
7414-        {
7415-            if (keySpec instanceof ElGamalPrivateKeySpec)
7416-            {
7417-                return new JCEElGamalPrivateKey((ElGamalPrivateKeySpec)keySpec);
7418-            }
7419-            else if (keySpec instanceof DHPrivateKeySpec)
7420-            {
7421-                return new JCEElGamalPrivateKey((DHPrivateKeySpec)keySpec);
7422-            }
7423-
7424-            return super.engineGeneratePrivate(keySpec);
7425-        }
7426+    // BEGIN android-removed
7427+    // public static class GOST3410
7428+    //     extends JDKKeyFactory
7429+    // {
7430+    //     public GOST3410()
7431+    //     {
7432+    //     }
7433+    //
7434+    //     protected PrivateKey engineGeneratePrivate(
7435+    //             KeySpec    keySpec)
7436+    //     throws InvalidKeySpecException
7437+    //     {
7438+    //         if (keySpec instanceof GOST3410PrivateKeySpec)
7439+    //         {
7440+    //             return new JDKGOST3410PrivateKey((GOST3410PrivateKeySpec)keySpec);
7441+    //         }
7442+    //
7443+    //         return super.engineGeneratePrivate(keySpec);
7444+    //     }
7445+    //
7446+    //     protected PublicKey engineGeneratePublic(
7447+    //             KeySpec    keySpec)
7448+    //     throws InvalidKeySpecException
7449+    //     {
7450+    //         if (keySpec instanceof GOST3410PublicKeySpec)
7451+    //         {
7452+    //             return new JDKGOST3410PublicKey((GOST3410PublicKeySpec)keySpec);
7453+    //         }
7454+    //
7455+    //         return super.engineGeneratePublic(keySpec);
7456+    //     }
7457+    // }
7458
7459-        protected PublicKey engineGeneratePublic(
7460-            KeySpec    keySpec)
7461-            throws InvalidKeySpecException
7462-        {
7463-            if (keySpec instanceof ElGamalPublicKeySpec)
7464-            {
7465-                return new JCEElGamalPublicKey((ElGamalPublicKeySpec)keySpec);
7466-            }
7467-            else if (keySpec instanceof DHPublicKeySpec)
7468-            {
7469-                return new JCEElGamalPublicKey((DHPublicKeySpec)keySpec);
7470-            }
7471-
7472-            return super.engineGeneratePublic(keySpec);
7473-        }
7474-    }
7475-
7476-
7477-    /**
7478-     * This isn't really correct, however the class path project API seems to think such
7479-     * a key factory will exist.
7480-     */
7481-    public static class X509
7482-        extends JDKKeyFactory
7483-    {
7484-        public X509()
7485-        {
7486-        }
7487-    }
7488+    // public static class ElGamal
7489+    //     extends JDKKeyFactory
7490+    // {
7491+    //     public ElGamal()
7492+    //     {
7493+    //         elGamalFactory = true;
7494+    //     }
7495+    //
7496+    //     protected PrivateKey engineGeneratePrivate(
7497+    //         KeySpec    keySpec)
7498+    //         throws InvalidKeySpecException
7499+    //     {
7500+    //         if (keySpec instanceof ElGamalPrivateKeySpec)
7501+    //         {
7502+    //             return new JCEElGamalPrivateKey((ElGamalPrivateKeySpec)keySpec);
7503+    //         }
7504+    //         else if (keySpec instanceof DHPrivateKeySpec)
7505+    //         {
7506+    //             return new JCEElGamalPrivateKey((DHPrivateKeySpec)keySpec);
7507+    //         }
7508+    //
7509+    //         return super.engineGeneratePrivate(keySpec);
7510+    //     }
7511+    //
7512+    //     protected PublicKey engineGeneratePublic(
7513+    //         KeySpec    keySpec)
7514+    //         throws InvalidKeySpecException
7515+    //     {
7516+    //         if (keySpec instanceof ElGamalPublicKeySpec)
7517+    //         {
7518+    //             return new JCEElGamalPublicKey((ElGamalPublicKeySpec)keySpec);
7519+    //         }
7520+    //         else if (keySpec instanceof DHPublicKeySpec)
7521+    //         {
7522+    //             return new JCEElGamalPublicKey((DHPublicKeySpec)keySpec);
7523+    //         }
7524+    //
7525+    //         return super.engineGeneratePublic(keySpec);
7526+    //     }
7527+    // }
7528+    //
7529+    //
7530+    //
7531+    // /**
7532+    //  * This isn't really correct, however the class path project API seems to think such
7533+    //  * a key factory will exist.
7534+    //  */
7535+    // public static class X509
7536+    //     extends JDKKeyFactory
7537+    // {
7538+    //     public X509()
7539+    //     {
7540+    //     }
7541+    // }
7542+    // END android-removed
7543 }
7544diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java
7545--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java	2011-02-23 20:08:56.000000000 +0000
7546+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java	2011-09-08 21:28:49.000000000 +0000
7547@@ -6,9 +6,11 @@
7548 import org.bouncycastle.crypto.generators.DHParametersGenerator;
7549 import org.bouncycastle.crypto.generators.DSAKeyPairGenerator;
7550 import org.bouncycastle.crypto.generators.DSAParametersGenerator;
7551-import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator;
7552-import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
7553-import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator;
7554+// BEGIN android-removed
7555+// import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator;
7556+// import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
7557+// import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator;
7558+// END android-removed
7559 import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
7560 import org.bouncycastle.crypto.params.DHKeyGenerationParameters;
7561 import org.bouncycastle.crypto.params.DHParameters;
7562@@ -18,20 +20,24 @@
7563 import org.bouncycastle.crypto.params.DSAParameters;
7564 import org.bouncycastle.crypto.params.DSAPrivateKeyParameters;
7565 import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
7566-import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;
7567-import org.bouncycastle.crypto.params.ElGamalParameters;
7568-import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
7569-import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
7570-import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters;
7571-import org.bouncycastle.crypto.params.GOST3410Parameters;
7572-import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters;
7573-import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters;
7574+// BEGIN android-removed
7575+// import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;
7576+// import org.bouncycastle.crypto.params.ElGamalParameters;
7577+// import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
7578+// import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
7579+// import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters;
7580+// import org.bouncycastle.crypto.params.GOST3410Parameters;
7581+// import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters;
7582+// import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters;
7583+// END android-removed
7584 import org.bouncycastle.crypto.params.RSAKeyGenerationParameters;
7585 import org.bouncycastle.crypto.params.RSAKeyParameters;
7586 import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
7587-import org.bouncycastle.jce.spec.ElGamalParameterSpec;
7588-import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
7589-import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
7590+// BEGIN android-removed
7591+// import org.bouncycastle.jce.spec.ElGamalParameterSpec;
7592+// import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
7593+// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
7594+// END android-removed
7595
7596 import java.math.BigInteger;
7597 import java.security.InvalidAlgorithmParameterException;
7598@@ -163,7 +169,9 @@
7599         {
7600             if (!initialised)
7601             {
7602-                Integer paramStrength = new Integer(strength);
7603+                // BEGIN android-changed
7604+                Integer paramStrength = Integer.valueOf(strength);
7605+                // END android-changed
7606
7607                 if (params.containsKey(paramStrength))
7608                 {
7609@@ -260,139 +268,143 @@
7610         }
7611     }
7612
7613-    public static class ElGamal
7614-        extends JDKKeyPairGenerator
7615-    {
7616-        ElGamalKeyGenerationParameters  param;
7617-        ElGamalKeyPairGenerator         engine = new ElGamalKeyPairGenerator();
7618-        int                             strength = 1024;
7619-        int                             certainty = 20;
7620-        SecureRandom                    random = new SecureRandom();
7621-        boolean                         initialised = false;
7622-
7623-        public ElGamal()
7624-        {
7625-            super("ElGamal");
7626-        }
7627-
7628-        public void initialize(
7629-            int             strength,
7630-            SecureRandom    random)
7631-        {
7632-            this.strength = strength;
7633-            this.random = random;
7634-        }
7635-
7636-        public void initialize(
7637-            AlgorithmParameterSpec  params,
7638-            SecureRandom            random)
7639-            throws InvalidAlgorithmParameterException
7640-        {
7641-            if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec))
7642-            {
7643-                throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec");
7644-            }
7645-
7646-            if (params instanceof ElGamalParameterSpec)
7647-            {
7648-                ElGamalParameterSpec     elParams = (ElGamalParameterSpec)params;
7649-
7650-                param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG()));
7651-            }
7652-            else
7653-            {
7654-                DHParameterSpec     dhParams = (DHParameterSpec)params;
7655-
7656-                param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL()));
7657-            }
7658-
7659-            engine.init(param);
7660-            initialised = true;
7661-        }
7662-
7663-        public KeyPair generateKeyPair()
7664-        {
7665-            if (!initialised)
7666-            {
7667-                ElGamalParametersGenerator   pGen = new ElGamalParametersGenerator();
7668-
7669-                pGen.init(strength, certainty, random);
7670-                param = new ElGamalKeyGenerationParameters(random, pGen.generateParameters());
7671-                engine.init(param);
7672-                initialised = true;
7673-            }
7674-
7675-            AsymmetricCipherKeyPair         pair = engine.generateKeyPair();
7676-            ElGamalPublicKeyParameters      pub = (ElGamalPublicKeyParameters)pair.getPublic();
7677-            ElGamalPrivateKeyParameters     priv = (ElGamalPrivateKeyParameters)pair.getPrivate();
7678-
7679-            return new KeyPair(new JCEElGamalPublicKey(pub),
7680-                               new JCEElGamalPrivateKey(priv));
7681-        }
7682-    }
7683-
7684-    public static class GOST3410
7685-        extends JDKKeyPairGenerator
7686-    {
7687-        GOST3410KeyGenerationParameters param;
7688-        GOST3410KeyPairGenerator        engine = new GOST3410KeyPairGenerator();
7689-        GOST3410ParameterSpec           gost3410Params;
7690-        int                             strength = 1024;
7691-        SecureRandom                    random = null;
7692-        boolean                         initialised = false;
7693-
7694-        public GOST3410()
7695-        {
7696-            super("GOST3410");
7697-        }
7698-
7699-        public void initialize(
7700-            int             strength,
7701-            SecureRandom    random)
7702-        {
7703-            this.strength = strength;
7704-            this.random = random;
7705-        }
7706-
7707-        private void init(
7708-            GOST3410ParameterSpec gParams,
7709-            SecureRandom          random)
7710-        {
7711-            GOST3410PublicKeyParameterSetSpec spec = gParams.getPublicKeyParameters();
7712-
7713-            param = new GOST3410KeyGenerationParameters(random, new GOST3410Parameters(spec.getP(), spec.getQ(), spec.getA()));
7714-
7715-            engine.init(param);
7716-
7717-            initialised = true;
7718-            gost3410Params = gParams;
7719-        }
7720-
7721-        public void initialize(
7722-            AlgorithmParameterSpec  params,
7723-            SecureRandom            random)
7724-            throws InvalidAlgorithmParameterException
7725-        {
7726-            if (!(params instanceof GOST3410ParameterSpec))
7727-            {
7728-                throw new InvalidAlgorithmParameterException("parameter object not a GOST3410ParameterSpec");
7729-            }
7730-
7731-            init((GOST3410ParameterSpec)params, random);
7732-        }
7733-
7734-        public KeyPair generateKeyPair()
7735-        {
7736-            if (!initialised)
7737-            {
7738-                init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom());
7739-            }
7740-
7741-            AsymmetricCipherKeyPair   pair = engine.generateKeyPair();
7742-            GOST3410PublicKeyParameters  pub = (GOST3410PublicKeyParameters)pair.getPublic();
7743-            GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate();
7744-
7745-            return new KeyPair(new JDKGOST3410PublicKey(pub, gost3410Params), new JDKGOST3410PrivateKey(priv, gost3410Params));
7746-        }
7747-   }
7748+    // BEGIN android-removed
7749+    // public static class ElGamal
7750+    //     extends JDKKeyPairGenerator
7751+    // {
7752+    //     ElGamalKeyGenerationParameters  param;
7753+    //     ElGamalKeyPairGenerator         engine = new ElGamalKeyPairGenerator();
7754+    //     int                             strength = 1024;
7755+    //     int                             certainty = 20;
7756+    //     SecureRandom                    random = new SecureRandom();
7757+    //     boolean                         initialised = false;
7758+    //
7759+    //     public ElGamal()
7760+    //     {
7761+    //         super("ElGamal");
7762+    //     }
7763+    //
7764+    //     public void initialize(
7765+    //         int             strength,
7766+    //         SecureRandom    random)
7767+    //     {
7768+    //         this.strength = strength;
7769+    //         this.random = random;
7770+    //     }
7771+    //
7772+    //     public void initialize(
7773+    //         AlgorithmParameterSpec  params,
7774+    //         SecureRandom            random)
7775+    //         throws InvalidAlgorithmParameterException
7776+    //     {
7777+    //         if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec))
7778+    //         {
7779+    //             throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec");
7780+    //         }
7781+    //
7782+    //         if (params instanceof ElGamalParameterSpec)
7783+    //         {
7784+    //             ElGamalParameterSpec     elParams = (ElGamalParameterSpec)params;
7785+
7786+    //             param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG()));
7787+    //         }
7788+    //         else
7789+    //         {
7790+    //             DHParameterSpec     dhParams = (DHParameterSpec)params;
7791+    //
7792+    //             param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL()));
7793+    //         }
7794+    //
7795+    //         engine.init(param);
7796+    //         initialised = true;
7797+    //     }
7798+    //
7799+    //     public KeyPair generateKeyPair()
7800+    //     {
7801+    //         if (!initialised)
7802+    //         {
7803+    //             ElGamalParametersGenerator   pGen = new ElGamalParametersGenerator();
7804+    //
7805+    //             pGen.init(strength, certainty, random);
7806+    //             param = new ElGamalKeyGenerationParameters(random, pGen.generateParameters());
7807+    //             engine.init(param);
7808+    //             initialised = true;
7809+    //         }
7810+    //
7811+    //         AsymmetricCipherKeyPair         pair = engine.generateKeyPair();
7812+    //         ElGamalPublicKeyParameters      pub = (ElGamalPublicKeyParameters)pair.getPublic();
7813+    //         ElGamalPrivateKeyParameters     priv = (ElGamalPrivateKeyParameters)pair.getPrivate();
7814+    //
7815+    //         return new KeyPair(new JCEElGamalPublicKey(pub),
7816+    //                            new JCEElGamalPrivateKey(priv));
7817+    //     }
7818+    // }
7819+    // END android-removed
7820+
7821+   // BEGIN android-removed
7822+   //  public static class GOST3410
7823+   //      extends JDKKeyPairGenerator
7824+   //  {
7825+   //      GOST3410KeyGenerationParameters param;
7826+   //      GOST3410KeyPairGenerator        engine = new GOST3410KeyPairGenerator();
7827+   //      GOST3410ParameterSpec           gost3410Params;
7828+   //      int                             strength = 1024;
7829+   //      SecureRandom                    random = null;
7830+   //      boolean                         initialised = false;
7831+   //
7832+   //      public GOST3410()
7833+   //      {
7834+   //          super("GOST3410");
7835+   //      }
7836+   //
7837+   //      public void initialize(
7838+   //          int             strength,
7839+   //          SecureRandom    random)
7840+   //      {
7841+   //          this.strength = strength;
7842+   //          this.random = random;
7843+   //      }
7844+   //
7845+   //      private void init(
7846+   //          GOST3410ParameterSpec gParams,
7847+   //          SecureRandom          random)
7848+   //      {
7849+   //          GOST3410PublicKeyParameterSetSpec spec = gParams.getPublicKeyParameters();
7850+   //
7851+   //          param = new GOST3410KeyGenerationParameters(random, new GOST3410Parameters(spec.getP(), spec.getQ(), spec.getA()));
7852+   //
7853+   //          engine.init(param);
7854+   //
7855+   //          initialised = true;
7856+   //          gost3410Params = gParams;
7857+   //      }
7858+   //
7859+   //      public void initialize(
7860+   //          AlgorithmParameterSpec  params,
7861+   //          SecureRandom            random)
7862+   //          throws InvalidAlgorithmParameterException
7863+   //      {
7864+   //          if (!(params instanceof GOST3410ParameterSpec))
7865+   //          {
7866+   //              throw new InvalidAlgorithmParameterException("parameter object not a GOST3410ParameterSpec");
7867+   //          }
7868+   //
7869+   //          init((GOST3410ParameterSpec)params, random);
7870+   //      }
7871+   //
7872+   //      public KeyPair generateKeyPair()
7873+   //      {
7874+   //          if (!initialised)
7875+   //          {
7876+   //              init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom());
7877+   //          }
7878+   //
7879+   //          AsymmetricCipherKeyPair   pair = engine.generateKeyPair();
7880+   //          GOST3410PublicKeyParameters  pub = (GOST3410PublicKeyParameters)pair.getPublic();
7881+   //          GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate();
7882+   //
7883+   //          return new KeyPair(new JDKGOST3410PublicKey(pub, gost3410Params), new JDKGOST3410PrivateKey(priv, gost3410Params));
7884+   //      }
7885+   // }
7886+   // END android-removed
7887 }
7888diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKKeyStore.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKKeyStore.java
7889--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKKeyStore.java	2011-02-23 20:08:56.000000000 +0000
7890+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKKeyStore.java	2011-09-08 21:28:49.000000000 +0000
7891@@ -39,7 +39,12 @@
7892 import org.bouncycastle.crypto.CipherParameters;
7893 import org.bouncycastle.crypto.Digest;
7894 import org.bouncycastle.crypto.PBEParametersGenerator;
7895-import org.bouncycastle.crypto.digests.SHA1Digest;
7896+// BEGIN android-added
7897+import org.bouncycastle.crypto.digests.OpenSSLDigest;
7898+// END android-added
7899+// BEGIN android-removed
7900+// import org.bouncycastle.crypto.digests.SHA1Digest;
7901+// END android-removed
7902 import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
7903 import org.bouncycastle.crypto.io.DigestInputStream;
7904 import org.bouncycastle.crypto.io.DigestOutputStream;
7905@@ -442,6 +447,7 @@
7906         }
7907         catch (Exception e)
7908         {
7909+
7910             throw new IOException("Exception creating key: " + e.toString());
7911         }
7912     }
7913@@ -497,7 +503,13 @@
7914
7915         if (entry == null)
7916         {
7917-            throw new KeyStoreException("no such entry as " + alias);
7918+            // BEGIN android-removed
7919+            // Only throw if there is a problem removing, not if missing
7920+            // throw new KeyStoreException("no such entry as " + alias);
7921+            // END android-removed
7922+            // BEGIN android-added
7923+            return;
7924+            // END android-added
7925         }
7926
7927         table.remove(alias);
7928@@ -810,12 +822,16 @@
7929         //
7930         // we only do an integrity check if the password is provided.
7931         //
7932-        HMac hMac = new HMac(new SHA1Digest());
7933+        // BEGIN android-changed
7934+        HMac hMac = new HMac(new OpenSSLDigest.SHA1());
7935+        // END android-changed
7936         if (password != null && password.length != 0)
7937         {
7938             byte[] passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password);
7939
7940-            PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new SHA1Digest());
7941+            // BEGIN android-changed
7942+            PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new OpenSSLDigest.SHA1());
7943+            // END android-changed
7944             pbeGen.init(passKey, salt, iterationCount);
7945             CipherParameters macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize());
7946             Arrays.fill(passKey, (byte)0);
7947@@ -866,9 +882,11 @@
7948         dOut.write(salt);
7949         dOut.writeInt(iterationCount);
7950
7951-        HMac                    hMac = new HMac(new SHA1Digest());
7952+        // BEGIN android-changed
7953+        HMac                    hMac = new HMac(new OpenSSLDigest.SHA1());
7954         MacOutputStream         mOut = new MacOutputStream(dOut, hMac);
7955-        PBEParametersGenerator  pbeGen = new PKCS12ParametersGenerator(new SHA1Digest());
7956+        PBEParametersGenerator  pbeGen = new PKCS12ParametersGenerator(new OpenSSLDigest.SHA1());
7957+        // END android-changed
7958         byte[]                  passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password);
7959
7960         pbeGen.init(passKey, salt, iterationCount);
7961@@ -956,7 +974,9 @@
7962             Cipher cipher = this.makePBECipher(cipherAlg, Cipher.DECRYPT_MODE, password, salt, iterationCount);
7963             CipherInputStream cIn = new CipherInputStream(dIn, cipher);
7964
7965-            Digest dig = new SHA1Digest();
7966+            // BEGIN android-changed
7967+            Digest dig = new OpenSSLDigest.SHA1();
7968+            // END android-changed
7969             DigestInputStream  dgIn = new DigestInputStream(cIn, dig);
7970
7971             this.loadStore(dgIn);
7972@@ -996,8 +1016,9 @@
7973             cipher = this.makePBECipher(STORE_CIPHER, Cipher.ENCRYPT_MODE, password, salt, iterationCount);
7974
7975             CipherOutputStream  cOut = new CipherOutputStream(dOut, cipher);
7976-            DigestOutputStream  dgOut = new DigestOutputStream(cOut, new SHA1Digest());
7977-
7978+            // BEGIN android-changed
7979+            DigestOutputStream  dgOut = new DigestOutputStream(cOut, new OpenSSLDigest.SHA1());
7980+            // END android-changed
7981             this.saveStore(dgOut);
7982
7983             Digest  dig = dgOut.getDigest();
7984@@ -1009,5 +1030,5 @@
7985
7986             cOut.close();
7987         }
7988-    }
7989+    }
7990 }
7991diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKMessageDigest.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKMessageDigest.java
7992--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKMessageDigest.java	2011-02-23 20:08:56.000000000 +0000
7993+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKMessageDigest.java	2011-09-08 21:28:49.000000000 +0000
7994@@ -57,36 +57,38 @@
7995         {
7996             super(new SHA1Digest());
7997         }
7998-
7999+
8000         public Object clone()
8001             throws CloneNotSupportedException
8002         {
8003             SHA1 d = (SHA1)super.clone();
8004             d.digest = new SHA1Digest((SHA1Digest)digest);
8005-
8006-            return d;
8007-        }
8008-    }
8009-
8010-    static public class SHA224
8011-        extends JDKMessageDigest
8012-        implements Cloneable
8013-    {
8014-        public SHA224()
8015-        {
8016-            super(new SHA224Digest());
8017-        }
8018-
8019-        public Object clone()
8020-            throws CloneNotSupportedException
8021-        {
8022-            SHA224 d = (SHA224)super.clone();
8023-            d.digest = new SHA224Digest((SHA224Digest)digest);
8024-
8025+
8026             return d;
8027         }
8028     }
8029-
8030+
8031+    // BEGIN android-removed
8032+    // static public class SHA224
8033+    //     extends JDKMessageDigest
8034+    //     implements Cloneable
8035+    // {
8036+    //     public SHA224()
8037+    //     {
8038+    //         super(new SHA224Digest());
8039+    //     }
8040+    //
8041+    //     public Object clone()
8042+    //         throws CloneNotSupportedException
8043+    //     {
8044+    //         SHA224 d = (SHA224)super.clone();
8045+    //         d.digest = new SHA224Digest((SHA224Digest)digest);
8046+    //
8047+    //         return d;
8048+    //     }
8049+    // }
8050+    // END android-removed
8051+
8052     static public class SHA256
8053         extends JDKMessageDigest
8054         implements Cloneable
8055@@ -95,13 +97,13 @@
8056         {
8057             super(new SHA256Digest());
8058         }
8059-
8060+
8061         public Object clone()
8062             throws CloneNotSupportedException
8063         {
8064             SHA256 d = (SHA256)super.clone();
8065             d.digest = new SHA256Digest((SHA256Digest)digest);
8066-
8067+
8068             return d;
8069         }
8070     }
8071@@ -144,43 +146,45 @@
8072         }
8073     }
8074
8075-    static public class MD2
8076-        extends JDKMessageDigest
8077-        implements Cloneable
8078-    {
8079-        public MD2()
8080-        {
8081-            super(new MD2Digest());
8082-        }
8083-
8084-        public Object clone()
8085-            throws CloneNotSupportedException
8086-        {
8087-            MD2 d = (MD2)super.clone();
8088-            d.digest = new MD2Digest((MD2Digest)digest);
8089-
8090-            return d;
8091-        }
8092-    }
8093-
8094-    static public class MD4
8095-        extends JDKMessageDigest
8096-        implements Cloneable
8097-    {
8098-        public MD4()
8099-        {
8100-            super(new MD4Digest());
8101-        }
8102-
8103-        public Object clone()
8104-            throws CloneNotSupportedException
8105-        {
8106-            MD4 d = (MD4)super.clone();
8107-            d.digest = new MD4Digest((MD4Digest)digest);
8108-
8109-            return d;
8110-        }
8111-    }
8112+    // BEGIN android-removed
8113+    // static public class MD2
8114+    //     extends JDKMessageDigest
8115+    //     implements Cloneable
8116+    // {
8117+    //     public MD2()
8118+    //     {
8119+    //         super(new MD2Digest());
8120+    //     }
8121+    //
8122+    //     public Object clone()
8123+    //         throws CloneNotSupportedException
8124+    //     {
8125+    //         MD2 d = (MD2)super.clone();
8126+    //         d.digest = new MD2Digest((MD2Digest)digest);
8127+    //
8128+    //         return d;
8129+    //     }
8130+    // }
8131+    //
8132+    // static public class MD4
8133+    //     extends JDKMessageDigest
8134+    //     implements Cloneable
8135+    // {
8136+    //     public MD4()
8137+    //     {
8138+    //         super(new MD4Digest());
8139+    //     }
8140+    //
8141+    //     public Object clone()
8142+    //         throws CloneNotSupportedException
8143+    //     {
8144+    //         MD4 d = (MD4)super.clone();
8145+    //         d.digest = new MD4Digest((MD4Digest)digest);
8146+    //
8147+    //         return d;
8148+    //     }
8149+    // }
8150+    // END android-removed
8151
8152     static public class MD5
8153         extends JDKMessageDigest
8154@@ -190,147 +194,149 @@
8155         {
8156             super(new MD5Digest());
8157         }
8158-
8159+
8160         public Object clone()
8161             throws CloneNotSupportedException
8162         {
8163             MD5 d = (MD5)super.clone();
8164             d.digest = new MD5Digest((MD5Digest)digest);
8165-
8166-            return d;
8167-        }
8168-    }
8169-
8170-    static public class RIPEMD128
8171-        extends JDKMessageDigest
8172-        implements Cloneable
8173-    {
8174-        public RIPEMD128()
8175-        {
8176-            super(new RIPEMD128Digest());
8177-        }
8178-
8179-        public Object clone()
8180-            throws CloneNotSupportedException
8181-        {
8182-            RIPEMD128 d = (RIPEMD128)super.clone();
8183-            d.digest = new RIPEMD128Digest((RIPEMD128Digest)digest);
8184-
8185+
8186             return d;
8187         }
8188     }
8189
8190-    static public class RIPEMD160
8191-        extends JDKMessageDigest
8192-        implements Cloneable
8193-    {
8194-        public RIPEMD160()
8195-        {
8196-            super(new RIPEMD160Digest());
8197-        }
8198-
8199-        public Object clone()
8200-            throws CloneNotSupportedException
8201-        {
8202-            RIPEMD160 d = (RIPEMD160)super.clone();
8203-            d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);
8204-
8205-            return d;
8206-        }
8207-    }
8208-
8209-    static public class RIPEMD256
8210-        extends JDKMessageDigest
8211-        implements Cloneable
8212-    {
8213-        public RIPEMD256()
8214-        {
8215-            super(new RIPEMD256Digest());
8216-        }
8217-
8218-        public Object clone()
8219-            throws CloneNotSupportedException
8220-        {
8221-            RIPEMD256 d = (RIPEMD256)super.clone();
8222-            d.digest = new RIPEMD256Digest((RIPEMD256Digest)digest);
8223-
8224-            return d;
8225-        }
8226-    }
8227-
8228-    static public class RIPEMD320
8229-        extends JDKMessageDigest
8230-        implements Cloneable
8231-    {
8232-        public RIPEMD320()
8233-        {
8234-            super(new RIPEMD320Digest());
8235-        }
8236-
8237-        public Object clone()
8238-            throws CloneNotSupportedException
8239-        {
8240-            RIPEMD320 d = (RIPEMD320)super.clone();
8241-            d.digest = new RIPEMD320Digest((RIPEMD320Digest)digest);
8242-
8243-            return d;
8244-        }
8245-    }
8246-
8247-    static public class Tiger
8248-        extends JDKMessageDigest
8249-        implements Cloneable
8250-    {
8251-        public Tiger()
8252-        {
8253-            super(new TigerDigest());
8254-        }
8255-
8256-        public Object clone()
8257-            throws CloneNotSupportedException
8258-        {
8259-            Tiger d = (Tiger)super.clone();
8260-            d.digest = new TigerDigest((TigerDigest)digest);
8261-
8262-            return d;
8263-        }
8264-    }
8265-
8266-    static public class GOST3411
8267-        extends JDKMessageDigest
8268-        implements Cloneable
8269-    {
8270-        public GOST3411()
8271-        {
8272-            super(new GOST3411Digest());
8273-        }
8274-
8275-        public Object clone()
8276-        throws CloneNotSupportedException
8277-        {
8278-            GOST3411 d = (GOST3411)super.clone();
8279-            d.digest = new GOST3411Digest((GOST3411Digest)digest);
8280-
8281-            return d;
8282-        }
8283-    }
8284-
8285-    static public class Whirlpool
8286-       extends JDKMessageDigest
8287-       implements Cloneable
8288-    {
8289-        public Whirlpool()
8290-        {
8291-            super(new WhirlpoolDigest());
8292-        }
8293-
8294-        public Object clone()
8295-        throws CloneNotSupportedException
8296-        {
8297-            Whirlpool d = (Whirlpool)super.clone();
8298-            d.digest = new WhirlpoolDigest((WhirlpoolDigest)digest);
8299-
8300-            return d;
8301-        }
8302-    }
8303+    // BEGIN android-removed
8304+    // static public class RIPEMD128
8305+    //     extends JDKMessageDigest
8306+    //     implements Cloneable
8307+    // {
8308+    //     public RIPEMD128()
8309+    //     {
8310+    //         super(new RIPEMD128Digest());
8311+    //     }
8312+    //
8313+    //     public Object clone()
8314+    //         throws CloneNotSupportedException
8315+    //     {
8316+    //         RIPEMD128 d = (RIPEMD128)super.clone();
8317+    //         d.digest = new RIPEMD128Digest((RIPEMD128Digest)digest);
8318+    //
8319+    //         return d;
8320+    //     }
8321+    // }
8322+    //
8323+    // static public class RIPEMD160
8324+    //     extends JDKMessageDigest
8325+    //     implements Cloneable
8326+    // {
8327+    //     public RIPEMD160()
8328+    //     {
8329+    //         super(new RIPEMD160Digest());
8330+    //     }
8331+    //
8332+    //     public Object clone()
8333+    //         throws CloneNotSupportedException
8334+    //     {
8335+    //         RIPEMD160 d = (RIPEMD160)super.clone();
8336+    //         d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);
8337+    //
8338+    //         return d;
8339+    //     }
8340+    // }
8341+    //
8342+    // static public class RIPEMD256
8343+    //     extends JDKMessageDigest
8344+    //     implements Cloneable
8345+    // {
8346+    //     public RIPEMD256()
8347+    //     {
8348+    //         super(new RIPEMD256Digest());
8349+    //     }
8350+    //
8351+    //     public Object clone()
8352+    //         throws CloneNotSupportedException
8353+    //     {
8354+    //         RIPEMD256 d = (RIPEMD256)super.clone();
8355+    //         d.digest = new RIPEMD256Digest((RIPEMD256Digest)digest);
8356+    //
8357+    //         return d;
8358+    //     }
8359+    // }
8360+    //
8361+    // static public class RIPEMD320
8362+    //     extends JDKMessageDigest
8363+    //     implements Cloneable
8364+    // {
8365+    //     public RIPEMD320()
8366+    //     {
8367+    //         super(new RIPEMD320Digest());
8368+    //     }
8369+    //
8370+    //     public Object clone()
8371+    //         throws CloneNotSupportedException
8372+    //     {
8373+    //         RIPEMD320 d = (RIPEMD320)super.clone();
8374+    //         d.digest = new RIPEMD320Digest((RIPEMD320Digest)digest);
8375+    //
8376+    //         return d;
8377+    //     }
8378+    // }
8379+    //
8380+    // static public class Tiger
8381+    //     extends JDKMessageDigest
8382+    //     implements Cloneable
8383+    // {
8384+    //     public Tiger()
8385+    //     {
8386+    //         super(new TigerDigest());
8387+    //     }
8388+    //
8389+    //     public Object clone()
8390+    //         throws CloneNotSupportedException
8391+    //     {
8392+    //         Tiger d = (Tiger)super.clone();
8393+    //         d.digest = new TigerDigest((TigerDigest)digest);
8394+    //
8395+    //         return d;
8396+    //     }
8397+    // }
8398+    //
8399+    // static public class GOST3411
8400+    //     extends JDKMessageDigest
8401+    //     implements Cloneable
8402+    // {
8403+    //     public GOST3411()
8404+    //     {
8405+    //         super(new GOST3411Digest());
8406+    //     }
8407+    //
8408+    //     public Object clone()
8409+    //     throws CloneNotSupportedException
8410+    //     {
8411+    //         GOST3411 d = (GOST3411)super.clone();
8412+    //         d.digest = new GOST3411Digest((GOST3411Digest)digest);
8413+    //
8414+    //         return d;
8415+    //     }
8416+    // }
8417+    //
8418+    // static public class Whirlpool
8419+    //    extends JDKMessageDigest
8420+    //    implements Cloneable
8421+    // {
8422+    //     public Whirlpool()
8423+    //     {
8424+    //         super(new WhirlpoolDigest());
8425+    //     }
8426+    //
8427+    //     public Object clone()
8428+    //     throws CloneNotSupportedException
8429+    //     {
8430+    //         Whirlpool d = (Whirlpool)super.clone();
8431+    //         d.digest = new WhirlpoolDigest((WhirlpoolDigest)digest);
8432+    //
8433+    //         return d;
8434+    //     }
8435+    // }
8436+    // END android-removed
8437 }
8438diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java
8439--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java	2011-02-23 20:08:56.000000000 +0000
8440+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java	2011-09-08 21:28:49.000000000 +0000
8441@@ -260,10 +260,13 @@
8442             }
8443         }
8444
8445-        if (c == null && k == null)
8446-        {
8447-            throw new KeyStoreException("no such entry as " + alias);
8448-        }
8449+        // BEGIN android-removed
8450+        // Only throw if there is a problem removing, not if missing
8451+        // if (c == null && k == null)
8452+        // {
8453+        //     throw new KeyStoreException("no such entry as " + alias);
8454+        // }
8455+        // END android-removed
8456     }
8457
8458     /**
8459@@ -438,6 +441,14 @@
8460
8461     public Date engineGetCreationDate(String alias)
8462     {
8463+        // BEGIN android-added
8464+        if (alias == null) {
8465+            throw new NullPointerException("alias == null");
8466+        }
8467+        if (keys.get(alias) == null && certs.get(alias) == null) {
8468+            return null;
8469+        }
8470+        // END android-added
8471         return new Date();
8472     }
8473
8474@@ -496,6 +507,11 @@
8475         Certificate[]   chain)
8476         throws KeyStoreException
8477     {
8478+        // BEGIN android-added
8479+        if (!(key instanceof PrivateKey)) {
8480+            throw new KeyStoreException("PKCS12 does not support non-PrivateKeys");
8481+        }
8482+        // END android-added
8483         if ((key instanceof PrivateKey) && (chain == null))
8484         {
8485             throw new KeyStoreException("no certificate chain for private key");
8486@@ -507,12 +523,18 @@
8487         }
8488
8489         keys.put(alias, key);
8490+        // BEGIN android-added
8491+        if (chain != null) {
8492+        // END android-added
8493         certs.put(alias, chain[0]);
8494
8495         for (int i = 0; i != chain.length; i++)
8496         {
8497             chainCerts.put(new CertId(chain[i].getPublicKey()), chain[i]);
8498         }
8499+        // BEGIN android-added
8500+        }
8501+        // END android-added
8502     }
8503
8504     public int engineSize()
8505@@ -1488,7 +1510,9 @@
8506         {
8507             byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data);
8508
8509-            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, new DERNull());
8510+            // BEGIN android-changed
8511+            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, DERNull.INSTANCE);
8512+            // END android-changed
8513             DigestInfo              dInfo = new DigestInfo(algId, res);
8514
8515             mData = new MacData(dInfo, mSalt, itCount);
8516@@ -1545,32 +1569,34 @@
8517         }
8518     }
8519
8520-    public static class BCPKCS12KeyStore3DES
8521-        extends JDKPKCS12KeyStore
8522-    {
8523-        public BCPKCS12KeyStore3DES()
8524-        {
8525-            super(bcProvider, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
8526-        }
8527-    }
8528-
8529-    public static class DefPKCS12KeyStore
8530-        extends JDKPKCS12KeyStore
8531-    {
8532-        public DefPKCS12KeyStore()
8533-        {
8534-            super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC);
8535-        }
8536-    }
8537-
8538-    public static class DefPKCS12KeyStore3DES
8539-        extends JDKPKCS12KeyStore
8540-    {
8541-        public DefPKCS12KeyStore3DES()
8542-        {
8543-            super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
8544-        }
8545-    }
8546+    // BEGIN android-removed
8547+    // public static class BCPKCS12KeyStore3DES
8548+    //     extends JDKPKCS12KeyStore
8549+    // {
8550+    //     public BCPKCS12KeyStore3DES()
8551+    //     {
8552+    //         super(bcProvider, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
8553+    //     }
8554+    // }
8555+    //
8556+    // public static class DefPKCS12KeyStore
8557+    //     extends JDKPKCS12KeyStore
8558+    // {
8559+    //     public DefPKCS12KeyStore()
8560+    //     {
8561+    //         super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC);
8562+    //     }
8563+    // }
8564+    //
8565+    // public static class DefPKCS12KeyStore3DES
8566+    //     extends JDKPKCS12KeyStore
8567+    // {
8568+    //     public DefPKCS12KeyStore3DES()
8569+    //     {
8570+    //         super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
8571+    //     }
8572+    // }
8573+    // END android-removed
8574
8575     private static class IgnoresCaseHashtable
8576     {
8577@@ -1579,7 +1605,7 @@
8578
8579         public void put(String key, Object value)
8580         {
8581-            String lower = Strings.toLowerCase(key);
8582+            String lower = (key == null) ? null : Strings.toLowerCase(key);
8583             String k = (String)keys.get(lower);
8584             if (k != null)
8585             {
8586@@ -1597,7 +1623,9 @@
8587
8588         public Object remove(String alias)
8589         {
8590-            String k = (String)keys.remove(Strings.toLowerCase(alias));
8591+            // BEGIN android-changed
8592+            String k = (String)keys.remove(alias == null ? null : Strings.toLowerCase(alias));
8593+            // END android-changed
8594             if (k == null)
8595             {
8596                 return null;
8597@@ -1608,7 +1636,9 @@
8598
8599         public Object get(String alias)
8600         {
8601-            String k = (String)keys.get(Strings.toLowerCase(alias));
8602+            // BEGIN android-changed
8603+            String k = (String)keys.get(alias == null ? null : Strings.toLowerCase(alias));
8604+            // END android-changed
8605             if (k == null)
8606             {
8607                 return null;
8608diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PBE.java bcprov-jdk16-146/org/bouncycastle/jce/provider/PBE.java
8609--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PBE.java	2011-02-23 20:08:56.000000000 +0000
8610+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/PBE.java	2011-09-08 21:28:49.000000000 +0000
8611@@ -7,12 +7,18 @@
8612
8613 import org.bouncycastle.crypto.CipherParameters;
8614 import org.bouncycastle.crypto.PBEParametersGenerator;
8615-import org.bouncycastle.crypto.digests.MD2Digest;
8616+// BEGIN android-removed
8617+// import org.bouncycastle.crypto.digests.MD2Digest;
8618+// END android-removed
8619 import org.bouncycastle.crypto.digests.MD5Digest;
8620-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
8621+// BEGIN android-removed
8622+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
8623+// END android-removed
8624 import org.bouncycastle.crypto.digests.SHA1Digest;
8625 import org.bouncycastle.crypto.digests.SHA256Digest;
8626-import org.bouncycastle.crypto.digests.TigerDigest;
8627+// BEGIN android-removed
8628+// import org.bouncycastle.crypto.digests.TigerDigest;
8629+// END android-removed
8630 import org.bouncycastle.crypto.generators.OpenSSLPBEParametersGenerator;
8631 import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
8632 import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator;
8633@@ -53,9 +59,11 @@
8634             {
8635                 switch (hash)
8636                 {
8637-                case MD2:
8638-                    generator = new PKCS5S1ParametersGenerator(new MD2Digest());
8639-                    break;
8640+                // BEGIN android-removed
8641+                // case MD2:
8642+                //     generator = new PKCS5S1ParametersGenerator(new MD2Digest());
8643+                //     break;
8644+                // END android-removed
8645                 case MD5:
8646                     generator = new PKCS5S1ParametersGenerator(new MD5Digest());
8647                     break;
8648@@ -74,21 +82,25 @@
8649             {
8650                 switch (hash)
8651                 {
8652-                case MD2:
8653-                    generator = new PKCS12ParametersGenerator(new MD2Digest());
8654-                    break;
8655+                // BEGIN android-removed
8656+                // case MD2:
8657+                //     generator = new PKCS12ParametersGenerator(new MD2Digest());
8658+                //     break;
8659+                // END android-removed
8660                 case MD5:
8661                     generator = new PKCS12ParametersGenerator(new MD5Digest());
8662                     break;
8663                 case SHA1:
8664                     generator = new PKCS12ParametersGenerator(new SHA1Digest());
8665                     break;
8666-                case RIPEMD160:
8667-                    generator = new PKCS12ParametersGenerator(new RIPEMD160Digest());
8668-                    break;
8669-                case TIGER:
8670-                    generator = new PKCS12ParametersGenerator(new TigerDigest());
8671-                    break;
8672+                // BEGIN android-removed
8673+                // case RIPEMD160:
8674+                //     generator = new PKCS12ParametersGenerator(new RIPEMD160Digest());
8675+                //     break;
8676+                // case TIGER:
8677+                //     generator = new PKCS12ParametersGenerator(new TigerDigest());
8678+                //     break;
8679+                // END android-removed
8680                 case SHA256:
8681                     generator = new PKCS12ParametersGenerator(new SHA256Digest());
8682                     break;
8683diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PKIXCertPath.java bcprov-jdk16-146/org/bouncycastle/jce/provider/PKIXCertPath.java
8684--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PKIXCertPath.java	2011-02-23 20:08:56.000000000 +0000
8685+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/PKIXCertPath.java	2011-09-08 21:28:49.000000000 +0000
8686@@ -33,7 +33,9 @@
8687 import org.bouncycastle.asn1.pkcs.ContentInfo;
8688 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
8689 import org.bouncycastle.asn1.pkcs.SignedData;
8690-import org.bouncycastle.openssl.PEMWriter;
8691+// BEGIN android-removed
8692+// import org.bouncycastle.openssl.PEMWriter;
8693+// END android-removed
8694
8695 /**
8696  * CertPath implementation for X.509 certificates.
8697@@ -295,27 +297,29 @@
8698             return toDEREncoded(new ContentInfo(
8699                     PKCSObjectIdentifiers.signedData, sd));
8700         }
8701-        else if (encoding.equalsIgnoreCase("PEM"))
8702-        {
8703-            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
8704-            PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
8705-
8706-            try
8707-            {
8708-                for (int i = 0; i != certificates.size(); i++)
8709-                {
8710-                    pWrt.writeObject(certificates.get(i));
8711-                }
8712-
8713-                pWrt.close();
8714-            }
8715-            catch (Exception e)
8716-            {
8717-                throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
8718-            }
8719-
8720-            return bOut.toByteArray();
8721-        }
8722+        // BEGIN android-removed
8723+        // else if (encoding.equalsIgnoreCase("PEM"))
8724+        // {
8725+        //     ByteArrayOutputStream bOut = new ByteArrayOutputStream();
8726+        //     PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
8727+        //
8728+        //     try
8729+        //     {
8730+        //         for (int i = 0; i != certificates.size(); i++)
8731+        //         {
8732+        //             pWrt.writeObject(certificates.get(i));
8733+        //         }
8734+        //
8735+        //         pWrt.close();
8736+        //     }
8737+        //     catch (Exception e)
8738+        //     {
8739+        //         throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
8740+        //     }
8741+        //
8742+        //     return bOut.toByteArray();
8743+        // }
8744+        // END android-removed
8745         else
8746         {
8747             throw new CertificateEncodingException("unsupported encoding: " + encoding);
8748diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java bcprov-jdk16-146/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java
8749--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java	2011-02-23 20:08:56.000000000 +0000
8750+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java	2011-09-08 21:28:49.000000000 +0000
8751@@ -1,5 +1,8 @@
8752 package org.bouncycastle.jce.provider;
8753
8754+// BEGIN android-added
8755+import java.math.BigInteger;
8756+// END android-added
8757 import java.security.InvalidAlgorithmParameterException;
8758 import java.security.PublicKey;
8759 import java.security.cert.CertPath;
8760@@ -13,6 +16,7 @@
8761 import java.security.cert.TrustAnchor;
8762 import java.security.cert.X509Certificate;
8763 import java.util.ArrayList;
8764+import java.util.Arrays;
8765 import java.util.HashSet;
8766 import java.util.Iterator;
8767 import java.util.List;
8768@@ -23,6 +27,10 @@
8769 import org.bouncycastle.asn1.DEREncodable;
8770 import org.bouncycastle.asn1.DERObjectIdentifier;
8771 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
8772+// BEGIN android-added
8773+import org.bouncycastle.crypto.Digest;
8774+import org.bouncycastle.crypto.digests.OpenSSLDigest;
8775+// END android-added
8776 import org.bouncycastle.jce.exception.ExtCertPathValidatorException;
8777 import org.bouncycastle.x509.ExtendedPKIXParameters;
8778
8779@@ -33,6 +41,63 @@
8780 public class PKIXCertPathValidatorSpi
8781         extends CertPathValidatorSpi
8782 {
8783+    // BEGIN android-added
8784+
8785+    // From http://src.chromium.org/viewvc/chrome/trunk/src/net/base/x509_certificate.cc?revision=78748&view=markup
8786+    private static final Set<BigInteger> SERIAL_BLACKLIST = new HashSet<BigInteger>(Arrays.asList(
8787+        // Not a real certificate. For testing only.
8788+        new BigInteger(1, new byte[] {(byte)0x07,(byte)0x7a,(byte)0x59,(byte)0xbc,(byte)0xd5,(byte)0x34,(byte)0x59,(byte)0x60,(byte)0x1c,(byte)0xa6,(byte)0x90,(byte)0x72,(byte)0x67,(byte)0xa6,(byte)0xdd,(byte)0x1c}),
8789+
8790+        new BigInteger(1, new byte[] {(byte)0x04,(byte)0x7e,(byte)0xcb,(byte)0xe9,(byte)0xfc,(byte)0xa5,(byte)0x5f,(byte)0x7b,(byte)0xd0,(byte)0x9e,(byte)0xae,(byte)0x36,(byte)0xe1,(byte)0x0c,(byte)0xae,(byte)0x1e}),
8791+        new BigInteger(1, new byte[] {(byte)0xd8,(byte)0xf3,(byte)0x5f,(byte)0x4e,(byte)0xb7,(byte)0x87,(byte)0x2b,(byte)0x2d,(byte)0xab,(byte)0x06,(byte)0x92,(byte)0xe3,(byte)0x15,(byte)0x38,(byte)0x2f,(byte)0xb0}),
8792+        new BigInteger(1, new byte[] {(byte)0xb0,(byte)0xb7,(byte)0x13,(byte)0x3e,(byte)0xd0,(byte)0x96,(byte)0xf9,(byte)0xb5,(byte)0x6f,(byte)0xae,(byte)0x91,(byte)0xc8,(byte)0x74,(byte)0xbd,(byte)0x3a,(byte)0xc0}),
8793+        new BigInteger(1, new byte[] {(byte)0x92,(byte)0x39,(byte)0xd5,(byte)0x34,(byte)0x8f,(byte)0x40,(byte)0xd1,(byte)0x69,(byte)0x5a,(byte)0x74,(byte)0x54,(byte)0x70,(byte)0xe1,(byte)0xf2,(byte)0x3f,(byte)0x43}),
8794+        new BigInteger(1, new byte[] {(byte)0xe9,(byte)0x02,(byte)0x8b,(byte)0x95,(byte)0x78,(byte)0xe4,(byte)0x15,(byte)0xdc,(byte)0x1a,(byte)0x71,(byte)0x0a,(byte)0x2b,(byte)0x88,(byte)0x15,(byte)0x44,(byte)0x47}),
8795+        new BigInteger(1, new byte[] {(byte)0xd7,(byte)0x55,(byte)0x8f,(byte)0xda,(byte)0xf5,(byte)0xf1,(byte)0x10,(byte)0x5b,(byte)0xb2,(byte)0x13,(byte)0x28,(byte)0x2b,(byte)0x70,(byte)0x77,(byte)0x29,(byte)0xa3}),
8796+        new BigInteger(1, new byte[] {(byte)0xf5,(byte)0xc8,(byte)0x6a,(byte)0xf3,(byte)0x61,(byte)0x62,(byte)0xf1,(byte)0x3a,(byte)0x64,(byte)0xf5,(byte)0x4f,(byte)0x6d,(byte)0xc9,(byte)0x58,(byte)0x7c,(byte)0x06}),
8797+        new BigInteger(1, new byte[] {(byte)0x39,(byte)0x2a,(byte)0x43,(byte)0x4f,(byte)0x0e,(byte)0x07,(byte)0xdf,(byte)0x1f,(byte)0x8a,(byte)0xa3,(byte)0x05,(byte)0xde,(byte)0x34,(byte)0xe0,(byte)0xc2,(byte)0x29}),
8798+        new BigInteger(1, new byte[] {(byte)0x3e,(byte)0x75,(byte)0xce,(byte)0xd4,(byte)0x6b,(byte)0x69,(byte)0x30,(byte)0x21,(byte)0x21,(byte)0x88,(byte)0x30,(byte)0xae,(byte)0x86,(byte)0xa8,(byte)0x2a,(byte)0x71})
8799+    ));
8800+
8801+    // From http://src.chromium.org/viewvc/chrome/branches/782/src/net/base/x509_certificate.cc?r1=98750&r2=98749&pathrev=98750
8802+    private static final byte[][] PUBLIC_KEY_SHA1_BLACKLIST = {
8803+        // C=NL, O=DigiNotar, CN=DigiNotar Root CA/emailAddress=info@diginotar.nl
8804+        {(byte)0x41, (byte)0x0f, (byte)0x36, (byte)0x36, (byte)0x32, (byte)0x58, (byte)0xf3, (byte)0x0b, (byte)0x34, (byte)0x7d,
8805+         (byte)0x12, (byte)0xce, (byte)0x48, (byte)0x63, (byte)0xe4, (byte)0x33, (byte)0x43, (byte)0x78, (byte)0x06, (byte)0xa8},
8806+        // Subject: CN=DigiNotar Cyber CA
8807+        // Issuer: CN=GTE CyberTrust Global Root
8808+        {(byte)0xba, (byte)0x3e, (byte)0x7b, (byte)0xd3, (byte)0x8c, (byte)0xd7, (byte)0xe1, (byte)0xe6, (byte)0xb9, (byte)0xcd,
8809+         (byte)0x4c, (byte)0x21, (byte)0x99, (byte)0x62, (byte)0xe5, (byte)0x9d, (byte)0x7a, (byte)0x2f, (byte)0x4e, (byte)0x37},
8810+        // Subject: CN=DigiNotar Services 1024 CA
8811+        // Issuer: CN=Entrust.net
8812+        {(byte)0xe2, (byte)0x3b, (byte)0x8d, (byte)0x10, (byte)0x5f, (byte)0x87, (byte)0x71, (byte)0x0a, (byte)0x68, (byte)0xd9,
8813+         (byte)0x24, (byte)0x80, (byte)0x50, (byte)0xeb, (byte)0xef, (byte)0xc6, (byte)0x27, (byte)0xbe, (byte)0x4c, (byte)0xa6},
8814+        // Subject: CN=DigiNotar PKIoverheid CA Organisatie - G2
8815+        // Issuer: CN=Staat der Nederlanden Organisatie CA - G2
8816+        {(byte)0x7b, (byte)0x2e, (byte)0x16, (byte)0xbc, (byte)0x39, (byte)0xbc, (byte)0xd7, (byte)0x2b, (byte)0x45, (byte)0x6e,
8817+         (byte)0x9f, (byte)0x05, (byte)0x5d, (byte)0x1d, (byte)0xe6, (byte)0x15, (byte)0xb7, (byte)0x49, (byte)0x45, (byte)0xdb},
8818+        // Subject: CN=DigiNotar PKIoverheid CA Overheid en Bedrijven
8819+        // Issuer: CN=Staat der Nederlanden Overheid CA
8820+        {(byte)0xe8, (byte)0xf9, (byte)0x12, (byte)0x00, (byte)0xc6, (byte)0x5c, (byte)0xee, (byte)0x16, (byte)0xe0, (byte)0x39,
8821+         (byte)0xb9, (byte)0xf8, (byte)0x83, (byte)0x84, (byte)0x16, (byte)0x61, (byte)0x63, (byte)0x5f, (byte)0x81, (byte)0xc5},
8822+    };
8823+
8824+    private static boolean isPublicKeyBlackListed(PublicKey publicKey) {
8825+        byte[] encoded = publicKey.getEncoded();
8826+        Digest digest = new OpenSSLDigest.SHA1();
8827+        digest.update(encoded, 0, encoded.length);
8828+        byte[] out = new byte[digest.getDigestSize()];
8829+        digest.doFinal(out, 0);
8830+
8831+        for (byte[] sha1 : PUBLIC_KEY_SHA1_BLACKLIST) {
8832+            if (Arrays.equals(out, sha1)) {
8833+                return true;
8834+            }
8835+        }
8836+        return false;
8837+    }
8838+
8839+    // END android-added
8840
8841     public CertPathValidatorResult engineValidate(
8842             CertPath certPath,
8843@@ -75,6 +140,22 @@
8844         {
8845             throw new CertPathValidatorException("Certification path is empty.", null, certPath, 0);
8846         }
8847+        // BEGIN android-added
8848+        {
8849+            X509Certificate cert = (X509Certificate) certs.get(0);
8850+
8851+            if (cert != null) {
8852+                BigInteger serial = cert.getSerialNumber();
8853+                if (serial != null && SERIAL_BLACKLIST.contains(serial)) {
8854+                    // emulate CRL exception message in RFC3280CertPathUtilities.checkCRLs
8855+                    String message = "Certificate revocation of serial 0x" + serial.toString(16);
8856+                    System.out.println(message);
8857+                    AnnotatedException e = new AnnotatedException(message);
8858+                    throw new CertPathValidatorException(e.getMessage(), e, certPath, 0);
8859+                }
8860+            }
8861+        }
8862+        // END android-added
8863
8864         //
8865         // (b)
8866@@ -251,6 +332,15 @@
8867
8868         for (index = certs.size() - 1; index >= 0; index--)
8869         {
8870+            // BEGIN android-added
8871+            if (isPublicKeyBlackListed(workingPublicKey)) {
8872+                // emulate CRL exception message in RFC3280CertPathUtilities.checkCRLs
8873+                String message = "Certificate revocation of public key " + workingPublicKey;
8874+                System.out.println(message);
8875+                AnnotatedException e = new AnnotatedException(message);
8876+                throw new CertPathValidatorException(e.getMessage(), e, certPath, index);
8877+            }
8878+            // END android-added
8879             // try
8880             // {
8881             //
8882diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java bcprov-jdk16-146/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java
8883--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java	2011-02-23 20:08:56.000000000 +0000
8884+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java	2011-09-08 21:28:49.000000000 +0000
8885@@ -1533,7 +1533,9 @@
8886         for (Enumeration e = permitted.getObjects(); e.hasMoreElements();)
8887         {
8888             GeneralSubtree subtree = GeneralSubtree.getInstance(e.nextElement());
8889-            Integer tagNo = new Integer(subtree.getBase().getTagNo());
8890+            // BEGIN android-changed
8891+            Integer tagNo = Integer.valueOf(subtree.getBase().getTagNo());
8892+            // END android-changed
8893             if (subtreesMap.get(tagNo) == null)
8894             {
8895                 subtreesMap.put(tagNo, new HashSet());
8896diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/WrapCipherSpi.java bcprov-jdk16-146/org/bouncycastle/jce/provider/WrapCipherSpi.java
8897--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/WrapCipherSpi.java	2011-02-23 20:08:56.000000000 +0000
8898+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/WrapCipherSpi.java	2011-09-08 21:28:49.000000000 +0000
8899@@ -22,8 +22,10 @@
8900 import javax.crypto.ShortBufferException;
8901 import javax.crypto.spec.IvParameterSpec;
8902 import javax.crypto.spec.PBEParameterSpec;
8903-import javax.crypto.spec.RC2ParameterSpec;
8904-import javax.crypto.spec.RC5ParameterSpec;
8905+// BEGIN android-removed
8906+// import javax.crypto.spec.RC2ParameterSpec;
8907+// import javax.crypto.spec.RC5ParameterSpec;
8908+// END android-removed
8909 import javax.crypto.spec.SecretKeySpec;
8910
8911 import org.bouncycastle.asn1.ASN1InputStream;
8912@@ -36,7 +38,9 @@
8913 import org.bouncycastle.crypto.CipherParameters;
8914 import org.bouncycastle.crypto.InvalidCipherTextException;
8915 import org.bouncycastle.crypto.Wrapper;
8916-import org.bouncycastle.crypto.engines.RC2WrapEngine;
8917+// BEGIN android-removed
8918+// import org.bouncycastle.crypto.engines.RC2WrapEngine;
8919+// END android-removed
8920 import org.bouncycastle.crypto.params.KeyParameter;
8921 import org.bouncycastle.crypto.params.ParametersWithIV;
8922
8923@@ -50,8 +54,10 @@
8924                                     {
8925                                         IvParameterSpec.class,
8926                                         PBEParameterSpec.class,
8927-                                        RC2ParameterSpec.class,
8928-                                        RC5ParameterSpec.class
8929+                                        // BEGIN android-removed
8930+                                        // RC2ParameterSpec.class,
8931+                                        // RC5ParameterSpec.class
8932+                                        // END android-removed
8933                                     };
8934
8935     protected int                     pbeType = PKCS12;
8936@@ -263,16 +269,19 @@
8937         return null;
8938     }
8939
8940+    // BEGIN android-changed
8941+    // added ShortBufferException to throws statement
8942     protected int engineDoFinal(
8943         byte[]  input,
8944         int     inputOffset,
8945         int     inputLen,
8946         byte[]  output,
8947         int     outputOffset)
8948-        throws IllegalBlockSizeException, BadPaddingException
8949+        throws IllegalBlockSizeException, BadPaddingException, ShortBufferException
8950     {
8951         return 0;
8952     }
8953+    // END android-changed
8954
8955     protected byte[] engineWrap(
8956         Key     key)
8957@@ -305,7 +314,12 @@
8958         byte[]  wrappedKey,
8959         String  wrappedKeyAlgorithm,
8960         int     wrappedKeyType)
8961-    throws InvalidKeyException
8962+    // BEGIN android-removed
8963+    // throws InvalidKeyException
8964+    // END android-removed
8965+    // BEGIN android-added
8966+    throws InvalidKeyException, NoSuchAlgorithmException
8967+    // END android-added
8968     {
8969         byte[] encoded;
8970         try
8971@@ -356,10 +370,12 @@
8972                 {
8973                     privKey = new JCEECPrivateKey(in);
8974                 }
8975-                else if (oid.equals(CryptoProObjectIdentifiers.gostR3410_94))
8976-                {
8977-                    privKey = new JDKGOST3410PrivateKey(in);
8978-                }
8979+                // BEGIN android-removed
8980+                // else if (oid.equals(CryptoProObjectIdentifiers.gostR3410_94))
8981+                // {
8982+                //     privKey = new JDKGOST3410PrivateKey(in);
8983+                // }
8984+                // END android-removed
8985                 else if (oid.equals(X9ObjectIdentifiers.id_dsa))
8986                 {
8987                     privKey = new JDKDSAPrivateKey(in);
8988@@ -403,10 +419,12 @@
8989             {
8990                 throw new InvalidKeyException("Unknown key type " + e.getMessage());
8991             }
8992-            catch (NoSuchAlgorithmException e)
8993-            {
8994-                throw new InvalidKeyException("Unknown key type " + e.getMessage());
8995-            }
8996+            // BEGIN android-removed
8997+            // catch (NoSuchAlgorithmException e)
8998+            // {
8999+            //     throw new InvalidKeyException("Unknown key type " + e.getMessage());
9000+            // }
9001+            // END android-removed
9002             catch (InvalidKeySpecException e2)
9003             {
9004                 throw new InvalidKeyException("Unknown key type " + e2.getMessage());
9005@@ -420,12 +438,14 @@
9006     // classes that inherit directly from us
9007     //
9008
9009-    public static class RC2Wrap
9010-        extends WrapCipherSpi
9011-    {
9012-        public RC2Wrap()
9013-        {
9014-            super(new RC2WrapEngine());
9015-        }
9016-    }
9017+    // BEGIN android-removed
9018+    // public static class RC2Wrap
9019+    //     extends WrapCipherSpi
9020+    // {
9021+    //     public RC2Wrap()
9022+    //     {
9023+    //         super(new RC2WrapEngine());
9024+    //     }
9025+    // }
9026+    // END android-removed
9027 }
9028diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/X509CertificateObject.java bcprov-jdk16-146/org/bouncycastle/jce/provider/X509CertificateObject.java
9029--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/X509CertificateObject.java	2011-02-23 20:08:56.000000000 +0000
9030+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/X509CertificateObject.java	2011-09-08 21:28:49.000000000 +0000
9031@@ -520,12 +520,20 @@
9032         return JDKKeyFactory.createPublicKeyFromPublicKeyInfo(c.getSubjectPublicKeyInfo());
9033     }
9034
9035+    // BEGIN android-changed
9036+    private byte[] encoded;
9037+    // END android-changed
9038     public byte[] getEncoded()
9039         throws CertificateEncodingException
9040     {
9041         try
9042         {
9043-            return c.getEncoded(ASN1Encodable.DER);
9044+            // BEGIN android-changed
9045+            if (encoded == null) {
9046+                encoded = c.getEncoded(ASN1Encodable.DER);
9047+            }
9048+            return encoded;
9049+            // END android-changed
9050         }
9051         catch (IOException e)
9052         {
9053@@ -711,7 +719,7 @@
9054     {
9055         Signature   signature;
9056         String      sigName = X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
9057-
9058+
9059         try
9060         {
9061             signature = Signature.getInstance(sigName, BouncyCastleProvider.PROVIDER_NAME);
9062diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/X509SignatureUtil.java bcprov-jdk16-146/org/bouncycastle/jce/provider/X509SignatureUtil.java
9063--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/X509SignatureUtil.java	2011-02-23 20:08:56.000000000 +0000
9064+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/X509SignatureUtil.java	2011-09-08 21:28:49.000000000 +0000
9065@@ -25,7 +25,9 @@
9066
9067 class X509SignatureUtil
9068 {
9069-    private static final ASN1Null       derNull = new DERNull();
9070+    // BEGIN android-changed
9071+    private static final ASN1Null       derNull = DERNull.INSTANCE;
9072+    // END android-changed
9073
9074     static void setSignatureParameters(
9075         Signature signature,
9076@@ -66,12 +68,14 @@
9077
9078         if (params != null && !derNull.equals(params))
9079         {
9080-            if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
9081-            {
9082-                RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
9083-
9084-                return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
9085-            }
9086+            // BEGIN android-removed
9087+            // if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
9088+            // {
9089+            //     RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
9090+            //
9091+            //     return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
9092+            // }
9093+            // END android-removed
9094             if (sigAlgId.getObjectId().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
9095             {
9096                 ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
9097@@ -98,10 +102,12 @@
9098         {
9099             return "SHA1";
9100         }
9101-        else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
9102-        {
9103-            return "SHA224";
9104-        }
9105+        // BEGIN android-removed
9106+        // else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
9107+        // {
9108+        //     return "SHA224";
9109+        // }
9110+        // END android-removed
9111         else if (NISTObjectIdentifiers.id_sha256.equals(digestAlgOID))
9112         {
9113             return "SHA256";
9114@@ -114,22 +120,24 @@
9115         {
9116             return "SHA512";
9117         }
9118-        else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
9119-        {
9120-            return "RIPEMD128";
9121-        }
9122-        else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
9123-        {
9124-            return "RIPEMD160";
9125-        }
9126-        else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
9127-        {
9128-            return "RIPEMD256";
9129-        }
9130-        else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
9131-        {
9132-            return "GOST3411";
9133-        }
9134+        // BEGIN android-removed
9135+        // else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
9136+        // {
9137+        //     return "RIPEMD128";
9138+        // }
9139+        // else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
9140+        // {
9141+        //     return "RIPEMD160";
9142+        // }
9143+        // else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
9144+        // {
9145+        //     return "RIPEMD256";
9146+        // }
9147+        // else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
9148+        // {
9149+        //     return "GOST3411";
9150+        // }
9151+        // END android-removed
9152         else
9153         {
9154             return digestAlgOID.getId();
9155diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/EC.java bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/EC.java
9156--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/EC.java	2011-02-23 20:08:56.000000000 +0000
9157+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/EC.java	2011-09-08 21:28:49.000000000 +0000
9158@@ -4,8 +4,10 @@
9159
9160 import org.bouncycastle.asn1.DERObjectIdentifier;
9161 import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers;
9162-import org.bouncycastle.asn1.eac.EACObjectIdentifiers;
9163-import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
9164+// BEGIN android-removed
9165+// import org.bouncycastle.asn1.eac.EACObjectIdentifiers;
9166+// import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers;
9167+// END android-removed
9168 import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
9169
9170 public class EC
9171@@ -16,39 +18,49 @@
9172         public Mappings()
9173         {
9174             put("KeyAgreement.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DH");
9175-            put("KeyAgreement.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHC");
9176-            put("KeyAgreement.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQV");
9177-            put("KeyAgreement." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHwithSHA1KDF");
9178-            put("KeyAgreement." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQVwithSHA1KDF");
9179+            // BEGIN android-removed
9180+            // put("KeyAgreement.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHC");
9181+            // put("KeyAgreement.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQV");
9182+            // put("KeyAgreement." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHwithSHA1KDF");
9183+            // put("KeyAgreement." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQVwithSHA1KDF");
9184+            // END android-removed
9185
9186             put("KeyFactory.EC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$EC");
9187-            put("KeyFactory.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDSA");
9188-            put("KeyFactory.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDH");
9189-            put("KeyFactory.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDHC");
9190-            put("KeyFactory.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECMQV");
9191+            // BEGIN android-removed
9192+            // put("KeyFactory.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDSA");
9193+            // put("KeyFactory.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDH");
9194+            // put("KeyFactory.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDHC");
9195+            // put("KeyFactory.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECMQV");
9196+            // END android-removed
9197             put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.id_ecPublicKey, "EC");
9198             // TODO Should this be an alias for ECDH?
9199             put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "EC");
9200-            put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV");
9201-
9202-            put("KeyFactory.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECGOST3410");
9203-            put("Alg.Alias.KeyFactory.GOST-3410-2001", "ECGOST3410");
9204-            put("Alg.Alias.KeyFactory.ECGOST-3410", "ECGOST3410");
9205-            put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_2001, "ECGOST3410");
9206+            // BEGIN android-removed
9207+            // put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV");
9208+            //
9209+            // put("KeyFactory.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECGOST3410");
9210+            // put("Alg.Alias.KeyFactory.GOST-3410-2001", "ECGOST3410");
9211+            // put("Alg.Alias.KeyFactory.ECGOST-3410", "ECGOST3410");
9212+            // put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_2001, "ECGOST3410");
9213+            // END android-removed
9214
9215             put("KeyPairGenerator.EC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$EC");
9216-            put("KeyPairGenerator.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDSA");
9217-            put("KeyPairGenerator.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH");
9218-            put("KeyPairGenerator.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDHC");
9219-            put("KeyPairGenerator.ECIES", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH");
9220-            put("KeyPairGenerator.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECMQV");
9221+            // BEGIN android-removed
9222+            // put("KeyPairGenerator.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDSA");
9223+            // put("KeyPairGenerator.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH");
9224+            // put("KeyPairGenerator.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDHC");
9225+            // put("KeyPairGenerator.ECIES", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH");
9226+            // put("KeyPairGenerator.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECMQV");
9227+            // END android-removed
9228             // TODO Should this be an alias for ECDH?
9229             put("Alg.Alias.KeyPairGenerator." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "EC");
9230-            put("Alg.Alias.KeyPairGenerator." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV");
9231-
9232-            put("KeyPairGenerator.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECGOST3410");
9233-            put("Alg.Alias.KeyPairGenerator.ECGOST-3410", "ECGOST3410");
9234-            put("Alg.Alias.KeyPairGenerator.GOST-3410-2001", "ECGOST3410");
9235+            // BEGIN android-removed
9236+            // put("Alg.Alias.KeyPairGenerator." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV");
9237+            //
9238+            // put("KeyPairGenerator.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECGOST3410");
9239+            // put("Alg.Alias.KeyPairGenerator.ECGOST-3410", "ECGOST3410");
9240+            // put("Alg.Alias.KeyPairGenerator.GOST-3410-2001", "ECGOST3410");
9241+            // END android-removed
9242
9243             put("Signature.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA");
9244             put("Signature.NONEwithECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSAnone");
9245@@ -60,23 +72,27 @@
9246             put("Alg.Alias.Signature.SHA1WithECDSA", "ECDSA");
9247             put("Alg.Alias.Signature.ECDSAWithSHA1", "ECDSA");
9248             put("Alg.Alias.Signature.1.2.840.10045.4.1", "ECDSA");
9249-            put("Alg.Alias.Signature." + TeleTrusTObjectIdentifiers.ecSignWithSha1, "ECDSA");
9250-
9251-            addSignatureAlgorithm("SHA224", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA224", X9ObjectIdentifiers.ecdsa_with_SHA224);
9252+            // BEGIN android-removed
9253+            // put("Alg.Alias.Signature." + TeleTrusTObjectIdentifiers.ecSignWithSha1, "ECDSA");
9254+            //
9255+            // addSignatureAlgorithm("SHA224", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA224", X9ObjectIdentifiers.ecdsa_with_SHA224);
9256+            // END android-removed
9257             addSignatureAlgorithm("SHA256", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA256", X9ObjectIdentifiers.ecdsa_with_SHA256);
9258             addSignatureAlgorithm("SHA384", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA384", X9ObjectIdentifiers.ecdsa_with_SHA384);
9259             addSignatureAlgorithm("SHA512", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA512", X9ObjectIdentifiers.ecdsa_with_SHA512);
9260-            addSignatureAlgorithm("RIPEMD160", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSARipeMD160",TeleTrusTObjectIdentifiers.ecSignWithRipemd160);
9261-
9262-            put("Signature.SHA1WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR");
9263-            put("Signature.SHA224WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR224");
9264-            put("Signature.SHA256WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR256");
9265-            put("Signature.SHA384WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR384");
9266-            put("Signature.SHA512WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR512");
9267-
9268-            addSignatureAlgorithm("SHA1", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_1);
9269-            addSignatureAlgorithm("SHA224", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA224", EACObjectIdentifiers.id_TA_ECDSA_SHA_224);
9270-            addSignatureAlgorithm("SHA256", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA256", EACObjectIdentifiers.id_TA_ECDSA_SHA_256);
9271+            // BEGIN android-removed
9272+            // addSignatureAlgorithm("RIPEMD160", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSARipeMD160",TeleTrusTObjectIdentifiers.ecSignWithRipemd160);
9273+            //
9274+            // put("Signature.SHA1WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR");
9275+            // put("Signature.SHA224WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR224");
9276+            // put("Signature.SHA256WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR256");
9277+            // put("Signature.SHA384WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR384");
9278+            // put("Signature.SHA512WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR512");
9279+            //
9280+            // addSignatureAlgorithm("SHA1", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_1);
9281+            // addSignatureAlgorithm("SHA224", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA224", EACObjectIdentifiers.id_TA_ECDSA_SHA_224);
9282+            // addSignatureAlgorithm("SHA256", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA256", EACObjectIdentifiers.id_TA_ECDSA_SHA_256);
9283+            // END android-removed
9284         }
9285
9286         private void addSignatureAlgorithm(
9287diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java
9288--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java	2011-02-23 20:08:56.000000000 +0000
9289+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java	2011-09-08 21:28:49.000000000 +0000
9290@@ -1,10 +1,14 @@
9291 package org.bouncycastle.jce.provider.asymmetric.ec;
9292
9293 import org.bouncycastle.asn1.DERObjectIdentifier;
9294-import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
9295+// BEGIN android-removed
9296+// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
9297+// END android-removed
9298 import org.bouncycastle.asn1.nist.NISTNamedCurves;
9299 import org.bouncycastle.asn1.sec.SECNamedCurves;
9300-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
9301+// BEGIN android-removed
9302+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
9303+// END android-removed
9304 import org.bouncycastle.asn1.x9.X962NamedCurves;
9305 import org.bouncycastle.asn1.x9.X9ECParameters;
9306 import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
9307@@ -167,14 +171,16 @@
9308             {
9309                 oid = NISTNamedCurves.getOID(name);
9310             }
9311-            if (oid == null)
9312-            {
9313-                oid = TeleTrusTNamedCurves.getOID(name);
9314-            }
9315-            if (oid == null)
9316-            {
9317-                oid = ECGOST3410NamedCurves.getOID(name);
9318-            }
9319+            // BEGIN android-removed
9320+            // if (oid == null)
9321+            // {
9322+            //     oid = TeleTrusTNamedCurves.getOID(name);
9323+            // }
9324+            // if (oid == null)
9325+            // {
9326+            //     oid = ECGOST3410NamedCurves.getOID(name);
9327+            // }
9328+            // END android-removed
9329         }
9330
9331         return oid;
9332@@ -192,10 +198,12 @@
9333             {
9334                 params = NISTNamedCurves.getByOID(oid);
9335             }
9336-            if (params == null)
9337-            {
9338-                params = TeleTrusTNamedCurves.getByOID(oid);
9339-            }
9340+            // BEGIN android-removed
9341+            // if (params == null)
9342+            // {
9343+            //     params = TeleTrusTNamedCurves.getByOID(oid);
9344+            // }
9345+            // END android-removed
9346         }
9347
9348         return params;
9349@@ -213,14 +221,16 @@
9350             {
9351                 name = NISTNamedCurves.getName(oid);
9352             }
9353-            if (name == null)
9354-            {
9355-                name = TeleTrusTNamedCurves.getName(oid);
9356-            }
9357-            if (name == null)
9358-            {
9359-                name = ECGOST3410NamedCurves.getName(oid);
9360-            }
9361+            // BEGIN android-removed
9362+            // if (name == null)
9363+            // {
9364+            //     name = TeleTrusTNamedCurves.getName(oid);
9365+            // }
9366+            // if (name == null)
9367+            // {
9368+            //     name = ECGOST3410NamedCurves.getName(oid);
9369+            // }
9370+            // END android-removed
9371         }
9372
9373         return name;
9374diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java
9375--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java	2011-02-23 20:08:56.000000000 +0000
9376+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java	2011-09-08 21:28:49.000000000 +0000
9377@@ -24,20 +24,26 @@
9378 import org.bouncycastle.crypto.CipherParameters;
9379 import org.bouncycastle.crypto.DerivationFunction;
9380 import org.bouncycastle.crypto.agreement.ECDHBasicAgreement;
9381-import org.bouncycastle.crypto.agreement.ECDHCBasicAgreement;
9382-import org.bouncycastle.crypto.agreement.ECMQVBasicAgreement;
9383-import org.bouncycastle.crypto.agreement.kdf.DHKDFParameters;
9384-import org.bouncycastle.crypto.agreement.kdf.ECDHKEKGenerator;
9385+// BEGIN android-removed
9386+// import org.bouncycastle.crypto.agreement.ECDHCBasicAgreement;
9387+// import org.bouncycastle.crypto.agreement.ECMQVBasicAgreement;
9388+// import org.bouncycastle.crypto.agreement.kdf.DHKDFParameters;
9389+// import org.bouncycastle.crypto.agreement.kdf.ECDHKEKGenerator;
9390+// END android-removed
9391 import org.bouncycastle.crypto.digests.SHA1Digest;
9392 import org.bouncycastle.crypto.params.ECDomainParameters;
9393 import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
9394 import org.bouncycastle.crypto.params.ECPublicKeyParameters;
9395-import org.bouncycastle.crypto.params.MQVPrivateParameters;
9396-import org.bouncycastle.crypto.params.MQVPublicParameters;
9397+// BEGIN android-removed
9398+// import org.bouncycastle.crypto.params.MQVPrivateParameters;
9399+// import org.bouncycastle.crypto.params.MQVPublicParameters;
9400+// END android-removed
9401 import org.bouncycastle.jce.interfaces.ECPrivateKey;
9402 import org.bouncycastle.jce.interfaces.ECPublicKey;
9403-import org.bouncycastle.jce.interfaces.MQVPrivateKey;
9404-import org.bouncycastle.jce.interfaces.MQVPublicKey;
9405+// BEGIN android-removed
9406+// import org.bouncycastle.jce.interfaces.MQVPrivateKey;
9407+// import org.bouncycastle.jce.interfaces.MQVPublicKey;
9408+// END android-removed
9409
9410 /**
9411  * Diffie-Hellman key agreement using elliptic curve keys, ala IEEE P1363
9412@@ -53,9 +59,11 @@
9413
9414     static
9415     {
9416-        Integer i128 = new Integer(128);
9417-        Integer i192 = new Integer(192);
9418-        Integer i256 = new Integer(256);
9419+        // BEGIN android-changed
9420+        Integer i128 = Integer.valueOf(128);
9421+        Integer i192 = Integer.valueOf(192);
9422+        Integer i256 = Integer.valueOf(256);
9423+        // END android-changed
9424
9425         algorithms.put(NISTObjectIdentifiers.id_aes128_CBC.getId(), i128);
9426         algorithms.put(NISTObjectIdentifiers.id_aes192_CBC.getId(), i192);
9427@@ -70,7 +78,9 @@
9428     private BigInteger             result;
9429     private ECDomainParameters     parameters;
9430     private BasicAgreement         agreement;
9431-    private DerivationFunction     kdf;
9432+    // BEGIN android-removed
9433+    // private DerivationFunction     kdf;
9434+    // END android-removed
9435
9436     private byte[] bigIntToBytes(
9437         BigInteger    r)
9438@@ -85,7 +95,9 @@
9439     {
9440         this.kaAlgorithm = kaAlgorithm;
9441         this.agreement = agreement;
9442-        this.kdf = kdf;
9443+        // BEGIN android-removed
9444+        // this.kdf = kdf;
9445+        // END android-removed
9446     }
9447
9448     protected Key engineDoPhase(
9449@@ -104,25 +116,27 @@
9450         }
9451
9452         CipherParameters pubKey;
9453-        if (agreement instanceof ECMQVBasicAgreement)
9454-        {
9455-            if (!(key instanceof MQVPublicKey))
9456-            {
9457-                throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
9458-                    + getSimpleName(MQVPublicKey.class) + " for doPhase");
9459-            }
9460-
9461-            MQVPublicKey mqvPubKey = (MQVPublicKey)key;
9462-            ECPublicKeyParameters staticKey = (ECPublicKeyParameters)
9463-                ECUtil.generatePublicKeyParameter(mqvPubKey.getStaticKey());
9464-            ECPublicKeyParameters ephemKey = (ECPublicKeyParameters)
9465-                ECUtil.generatePublicKeyParameter(mqvPubKey.getEphemeralKey());
9466-
9467-            pubKey = new MQVPublicParameters(staticKey, ephemKey);
9468-
9469-            // TODO Validate that all the keys are using the same parameters?
9470-        }
9471-        else
9472+        // BEGIN android-removed
9473+        // if (agreement instanceof ECMQVBasicAgreement)
9474+        // {
9475+        //     if (!(key instanceof MQVPublicKey))
9476+        //     {
9477+        //         throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
9478+        //             + getSimpleName(MQVPublicKey.class) + " for doPhase");
9479+        //     }
9480+        //
9481+        //     MQVPublicKey mqvPubKey = (MQVPublicKey)key;
9482+        //     ECPublicKeyParameters staticKey = (ECPublicKeyParameters)
9483+        //         ECUtil.generatePublicKeyParameter(mqvPubKey.getStaticKey());
9484+        //     ECPublicKeyParameters ephemKey = (ECPublicKeyParameters)
9485+        //         ECUtil.generatePublicKeyParameter(mqvPubKey.getEphemeralKey());
9486+        //
9487+        //     pubKey = new MQVPublicParameters(staticKey, ephemKey);
9488+        //
9489+        //     // TODO Validate that all the keys are using the same parameters?
9490+        // }
9491+        // else
9492+        // END android-removed
9493         {
9494             if (!(key instanceof ECPublicKey))
9495             {
9496@@ -143,11 +157,13 @@
9497     protected byte[] engineGenerateSecret()
9498         throws IllegalStateException
9499     {
9500-        if (kdf != null)
9501-        {
9502-            throw new UnsupportedOperationException(
9503-                "KDF can only be used when algorithm is known");
9504-        }
9505+        // BEGIN android-removed
9506+        // if (kdf != null)
9507+        // {
9508+        //     throw new UnsupportedOperationException(
9509+        //         "KDF can only be used when algorithm is known");
9510+        // }
9511+        // END android-removed
9512
9513         return bigIntToBytes(result);
9514     }
9515@@ -175,23 +191,25 @@
9516     {
9517         byte[] secret = bigIntToBytes(result);
9518
9519-        if (kdf != null)
9520-        {
9521-            if (!algorithms.containsKey(algorithm))
9522-            {
9523-                throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
9524-            }
9525-
9526-            int    keySize = ((Integer)algorithms.get(algorithm)).intValue();
9527-
9528-            DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);
9529-
9530-            byte[] keyBytes = new byte[keySize / 8];
9531-            kdf.init(params);
9532-            kdf.generateBytes(keyBytes, 0, keyBytes.length);
9533-            secret = keyBytes;
9534-        }
9535-        else
9536+        // BEGIN android-removed
9537+        // if (kdf != null)
9538+        // {
9539+        //     if (!algorithms.containsKey(algorithm))
9540+        //     {
9541+        //         throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm);
9542+        //     }
9543+        //
9544+        //     int    keySize = ((Integer)algorithms.get(algorithm)).intValue();
9545+        //
9546+        //     DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret);
9547+        //
9548+        //     byte[] keyBytes = new byte[keySize / 8];
9549+        //     kdf.init(params);
9550+        //     kdf.generateBytes(keyBytes, 0, keyBytes.length);
9551+        //     secret = keyBytes;
9552+        // }
9553+        // else
9554+        // END android-removed
9555         {
9556             // TODO Should we be ensuring the key is the right length?
9557         }
9558@@ -219,35 +237,37 @@
9559     private void initFromKey(Key key)
9560         throws InvalidKeyException
9561     {
9562-        if (agreement instanceof ECMQVBasicAgreement)
9563-        {
9564-            if (!(key instanceof MQVPrivateKey))
9565-            {
9566-                throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
9567-                    + getSimpleName(MQVPrivateKey.class) + " for initialisation");
9568-            }
9569-
9570-            MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
9571-            ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
9572-                ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
9573-            ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
9574-                ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());
9575-
9576-            ECPublicKeyParameters ephemPubKey = null;
9577-            if (mqvPrivKey.getEphemeralPublicKey() != null)
9578-            {
9579-                ephemPubKey = (ECPublicKeyParameters)
9580-                    ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
9581-            }
9582-
9583-            MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
9584-            this.parameters = staticPrivKey.getParameters();
9585-
9586-            // TODO Validate that all the keys are using the same parameters?
9587-
9588-            agreement.init(localParams);
9589-        }
9590-        else
9591+        // BEGIN android-removed
9592+        // if (agreement instanceof ECMQVBasicAgreement)
9593+        // {
9594+        //     if (!(key instanceof MQVPrivateKey))
9595+        //     {
9596+        //         throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
9597+        //             + getSimpleName(MQVPrivateKey.class) + " for initialisation");
9598+        //     }
9599+        //
9600+        //     MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
9601+        //     ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
9602+        //         ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
9603+        //     ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
9604+        //         ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());
9605+        //
9606+        //     ECPublicKeyParameters ephemPubKey = null;
9607+        //     if (mqvPrivKey.getEphemeralPublicKey() != null)
9608+        //     {
9609+        //         ephemPubKey = (ECPublicKeyParameters)
9610+        //             ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
9611+        //     }
9612+        //
9613+        //     MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
9614+        //     this.parameters = staticPrivKey.getParameters();
9615+        //
9616+        //     // TODO Validate that all the keys are using the same parameters?
9617+        //
9618+        //     agreement.init(localParams);
9619+        // }
9620+        // else
9621+        // END android-removed
9622         {
9623             if (!(key instanceof ECPrivateKey))
9624             {
9625@@ -278,39 +298,41 @@
9626         }
9627     }
9628
9629-    public static class DHC
9630-        extends KeyAgreement
9631-    {
9632-        public DHC()
9633-        {
9634-            super("ECDHC", new ECDHCBasicAgreement(), null);
9635-        }
9636-    }
9637-
9638-    public static class MQV
9639-        extends KeyAgreement
9640-    {
9641-        public MQV()
9642-        {
9643-            super("ECMQV", new ECMQVBasicAgreement(), null);
9644-        }
9645-    }
9646-
9647-    public static class DHwithSHA1KDF
9648-        extends KeyAgreement
9649-    {
9650-        public DHwithSHA1KDF()
9651-        {
9652-            super("ECDHwithSHA1KDF", new ECDHBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
9653-        }
9654-    }
9655-
9656-    public static class MQVwithSHA1KDF
9657-        extends KeyAgreement
9658-    {
9659-        public MQVwithSHA1KDF()
9660-        {
9661-            super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
9662-        }
9663-    }
9664+    // BEGIN android-removed
9665+    // public static class DHC
9666+    //     extends KeyAgreement
9667+    // {
9668+    //     public DHC()
9669+    //     {
9670+    //         super("ECDHC", new ECDHCBasicAgreement(), null);
9671+    //     }
9672+    // }
9673+    //
9674+    // public static class MQV
9675+    //     extends KeyAgreement
9676+    // {
9677+    //     public MQV()
9678+    //     {
9679+    //         super("ECMQV", new ECMQVBasicAgreement(), null);
9680+    //     }
9681+    // }
9682+    //
9683+    // public static class DHwithSHA1KDF
9684+    //     extends KeyAgreement
9685+    // {
9686+    //     public DHwithSHA1KDF()
9687+    //     {
9688+    //         super("ECDHwithSHA1KDF", new ECDHBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
9689+    //     }
9690+    // }
9691+    //
9692+    // public static class MQVwithSHA1KDF
9693+    //     extends KeyAgreement
9694+    // {
9695+    //     public MQVwithSHA1KDF()
9696+    //     {
9697+    //         super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
9698+    //     }
9699+    // }
9700+    // END android-removed
9701 }
9702diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java
9703--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java	2011-02-23 20:08:56.000000000 +0000
9704+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java	2011-09-08 21:28:49.000000000 +0000
9705@@ -10,10 +10,14 @@
9706 import java.util.Hashtable;
9707
9708 import org.bouncycastle.asn1.DERObjectIdentifier;
9709-import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
9710+// BEGIN android-removed
9711+// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves;
9712+// END android-removed
9713 import org.bouncycastle.asn1.nist.NISTNamedCurves;
9714 import org.bouncycastle.asn1.sec.SECNamedCurves;
9715-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
9716+// BEGIN android-removed
9717+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
9718+// END android-removed
9719 import org.bouncycastle.asn1.x9.X962NamedCurves;
9720 import org.bouncycastle.asn1.x9.X9ECParameters;
9721 import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
9722@@ -56,13 +60,15 @@
9723         static {
9724             ecParameters = new Hashtable();
9725
9726-            ecParameters.put(new Integer(192), new ECGenParameterSpec("prime192v1")); // a.k.a P-192
9727-            ecParameters.put(new Integer(239), new ECGenParameterSpec("prime239v1"));
9728-            ecParameters.put(new Integer(256), new ECGenParameterSpec("prime256v1")); // a.k.a P-256
9729-
9730-            ecParameters.put(new Integer(224), new ECGenParameterSpec("P-224"));
9731-            ecParameters.put(new Integer(384), new ECGenParameterSpec("P-384"));
9732-            ecParameters.put(new Integer(521), new ECGenParameterSpec("P-521"));
9733+            // BEGIN android-changed
9734+            ecParameters.put(Integer.valueOf(192), new ECGenParameterSpec("prime192v1")); // a.k.a P-192
9735+            ecParameters.put(Integer.valueOf(239), new ECGenParameterSpec("prime239v1"));
9736+            ecParameters.put(Integer.valueOf(256), new ECGenParameterSpec("prime256v1")); // a.k.a P-256
9737+
9738+            ecParameters.put(Integer.valueOf(224), new ECGenParameterSpec("P-224"));
9739+            ecParameters.put(Integer.valueOf(384), new ECGenParameterSpec("P-384"));
9740+            ecParameters.put(Integer.valueOf(521), new ECGenParameterSpec("P-521"));
9741+            // END android-changed
9742         }
9743
9744         public EC()
9745@@ -83,8 +89,16 @@
9746             SecureRandom    random)
9747         {
9748             this.strength = strength;
9749+            // BEGIN android-added
9750+            if (random != null) {
9751+            // END android-added
9752             this.random = random;
9753-            this.ecParams = ecParameters.get(new Integer(strength));
9754+            // BEGIN android-added
9755+            }
9756+            // END android-added
9757+            // BEGIN android-changed
9758+            this.ecParams = ecParameters.get(Integer.valueOf(strength));
9759+            // END android-changed
9760
9761             if (ecParams != null)
9762             {
9763@@ -108,6 +122,11 @@
9764             SecureRandom            random)
9765             throws InvalidAlgorithmParameterException
9766         {
9767+            // BEGIN android-added
9768+            if (random == null) {
9769+                random = this.random;
9770+            }
9771+            // END android-added
9772             if (params instanceof ECParameterSpec)
9773             {
9774                 ECParameterSpec p = (ECParameterSpec)params;
9775@@ -135,23 +154,25 @@
9776             {
9777                 final String curveName = ((ECGenParameterSpec)params).getName();
9778
9779-                if (this.algorithm.equals("ECGOST3410"))
9780-                {
9781-                    ECDomainParameters  ecP = ECGOST3410NamedCurves.getByName(curveName);
9782-                    if (ecP == null)
9783-                    {
9784-                        throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
9785-                    }
9786-
9787-                    this.ecParams = new ECNamedCurveSpec(
9788-                                                    curveName,
9789-                                                    ecP.getCurve(),
9790-                                                    ecP.getG(),
9791-                                                    ecP.getN(),
9792-                                                    ecP.getH(),
9793-                                                    ecP.getSeed());
9794-                }
9795-                else
9796+                // BEGIN android-removed
9797+                // if (this.algorithm.equals("ECGOST3410"))
9798+                // {
9799+                //     ECDomainParameters  ecP = ECGOST3410NamedCurves.getByName(curveName);
9800+                //     if (ecP == null)
9801+                //     {
9802+                //         throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName);
9803+                //     }
9804+                //
9805+                //     this.ecParams = new ECNamedCurveSpec(
9806+                //                                     curveName,
9807+                //                                     ecP.getCurve(),
9808+                //                                     ecP.getG(),
9809+                //                                     ecP.getN(),
9810+                //                                     ecP.getH(),
9811+                //                                     ecP.getSeed());
9812+                // }
9813+                // else
9814+                // END android-removed
9815                 {
9816                     X9ECParameters  ecP = X962NamedCurves.getByName(curveName);
9817                     if (ecP == null)
9818@@ -161,10 +182,12 @@
9819                         {
9820                             ecP = NISTNamedCurves.getByName(curveName);
9821                         }
9822-                        if (ecP == null)
9823-                        {
9824-                            ecP = TeleTrusTNamedCurves.getByName(curveName);
9825-                        }
9826+                        // BEGIN android-removed
9827+                        // if (ecP == null)
9828+                        // {
9829+                        //     ecP = TeleTrusTNamedCurves.getByName(curveName);
9830+                        // }
9831+                        // END android-removed
9832                         if (ecP == null)
9833                         {
9834                             // See if it's actually an OID string (SunJSSE ServerHandshaker setupEphemeralECDHKeys bug)
9835@@ -180,10 +203,12 @@
9836                                 {
9837                                     ecP = NISTNamedCurves.getByOID(oid);
9838                                 }
9839-                                if (ecP == null)
9840-                                {
9841-                                    ecP = TeleTrusTNamedCurves.getByOID(oid);
9842-                                }
9843+                                // BEGIN android-removed
9844+                                // if (ecP == null)
9845+                                // {
9846+                                //     ecP = TeleTrusTNamedCurves.getByOID(oid);
9847+                                // }
9848+                                // END android-removed
9849                                 if (ecP == null)
9850                                 {
9851                                     throw new InvalidAlgorithmParameterException("unknown curve OID: " + curveName);
9852@@ -239,7 +264,15 @@
9853         {
9854             if (!initialised)
9855             {
9856-                throw new IllegalStateException("EC Key Pair Generator not initialised");
9857+                // BEGIN android-removed
9858+                // throw new IllegalStateException("EC Key Pair Generator not initialised");
9859+                // END android-removed
9860+                // BEGIN android-added
9861+                /*
9862+                 * KeyPairGenerator documentation says that a default initialization must be provided
9863+                 */
9864+                initialize(192, random);
9865+                // END android-added
9866             }
9867
9868             AsymmetricCipherKeyPair     pair = engine.generateKeyPair();
9869@@ -279,14 +312,16 @@
9870         }
9871     }
9872
9873-    public static class ECGOST3410
9874-        extends EC
9875-    {
9876-        public ECGOST3410()
9877-        {
9878-            super("ECGOST3410");
9879-        }
9880-    }
9881+    // BEGIN android-removed
9882+    // public static class ECGOST3410
9883+    //     extends EC
9884+    // {
9885+    //     public ECGOST3410()
9886+    //     {
9887+    //         super("ECGOST3410");
9888+    //     }
9889+    // }
9890+    // END android-removed
9891
9892     public static class ECDH
9893         extends EC
9894@@ -314,4 +349,4 @@
9895             super("ECMQV");
9896         }
9897     }
9898-}
9899\ No newline at end of file
9900+}
9901diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java
9902--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java	2011-02-23 20:08:56.000000000 +0000
9903+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java	2011-09-08 21:28:49.000000000 +0000
9904@@ -18,15 +18,21 @@
9905 import org.bouncycastle.crypto.DSA;
9906 import org.bouncycastle.crypto.Digest;
9907 import org.bouncycastle.crypto.digests.NullDigest;
9908-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
9909+// BEGIN android-removed
9910+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
9911+// END android-removed
9912 import org.bouncycastle.crypto.digests.SHA1Digest;
9913-import org.bouncycastle.crypto.digests.SHA224Digest;
9914+// BEGIN android-removed
9915+// import org.bouncycastle.crypto.digests.SHA224Digest;
9916+// END android-removed
9917 import org.bouncycastle.crypto.digests.SHA256Digest;
9918 import org.bouncycastle.crypto.digests.SHA384Digest;
9919 import org.bouncycastle.crypto.digests.SHA512Digest;
9920 import org.bouncycastle.crypto.params.ParametersWithRandom;
9921 import org.bouncycastle.crypto.signers.ECDSASigner;
9922-import org.bouncycastle.crypto.signers.ECNRSigner;
9923+// BEGIN android-removed
9924+// import org.bouncycastle.crypto.signers.ECNRSigner;
9925+// END android-removed
9926 import org.bouncycastle.jce.interfaces.ECKey;
9927 import org.bouncycastle.jce.provider.DSABase;
9928 import org.bouncycastle.jce.provider.DSAEncoder;
9929@@ -122,14 +128,16 @@
9930         }
9931     }
9932
9933-    static public class ecDSA224
9934-        extends Signature
9935-    {
9936-        public ecDSA224()
9937-        {
9938-            super(new SHA224Digest(), new ECDSASigner(), new StdDSAEncoder());
9939-        }
9940-    }
9941+    // BEGIN android-removed
9942+    // static public class ecDSA224
9943+    //     extends Signature
9944+    // {
9945+    //     public ecDSA224()
9946+    //     {
9947+    //         super(new SHA224Digest(), new ECDSASigner(), new StdDSAEncoder());
9948+    //     }
9949+    // }
9950+    // END android-removed
9951
9952     static public class ecDSA256
9953         extends Signature
9954@@ -158,86 +166,88 @@
9955         }
9956     }
9957
9958-    static public class ecDSARipeMD160
9959-        extends Signature
9960-    {
9961-        public ecDSARipeMD160()
9962-        {
9963-            super(new RIPEMD160Digest(), new ECDSASigner(), new StdDSAEncoder());
9964-        }
9965-    }
9966-
9967-    static public class ecNR
9968-        extends Signature
9969-    {
9970-        public ecNR()
9971-        {
9972-            super(new SHA1Digest(), new ECNRSigner(), new StdDSAEncoder());
9973-        }
9974-    }
9975-
9976-    static public class ecNR224
9977-        extends Signature
9978-    {
9979-        public ecNR224()
9980-        {
9981-            super(new SHA224Digest(), new ECNRSigner(), new StdDSAEncoder());
9982-        }
9983-    }
9984-
9985-    static public class ecNR256
9986-        extends Signature
9987-    {
9988-        public ecNR256()
9989-        {
9990-            super(new SHA256Digest(), new ECNRSigner(), new StdDSAEncoder());
9991-        }
9992-    }
9993-
9994-    static public class ecNR384
9995-        extends Signature
9996-    {
9997-        public ecNR384()
9998-        {
9999-            super(new SHA384Digest(), new ECNRSigner(), new StdDSAEncoder());
10000-        }
10001-    }
10002-
10003-    static public class ecNR512
10004-        extends Signature
10005-    {
10006-        public ecNR512()
10007-        {
10008-            super(new SHA512Digest(), new ECNRSigner(), new StdDSAEncoder());
10009-        }
10010-    }
10011-
10012-    static public class ecCVCDSA
10013-        extends Signature
10014-    {
10015-        public ecCVCDSA()
10016-        {
10017-            super(new SHA1Digest(), new ECDSASigner(), new CVCDSAEncoder());
10018-        }
10019-    }
10020-
10021-    static public class ecCVCDSA224
10022-        extends Signature
10023-    {
10024-        public ecCVCDSA224()
10025-        {
10026-            super(new SHA224Digest(), new ECDSASigner(), new CVCDSAEncoder());
10027-        }
10028-    }
10029-
10030-    static public class ecCVCDSA256
10031-        extends Signature
10032-    {
10033-        public ecCVCDSA256()
10034-        {
10035-            super(new SHA256Digest(), new ECDSASigner(), new CVCDSAEncoder());
10036-        }
10037-    }
10038+    // BEGIN android-removed
10039+    // static public class ecDSARipeMD160
10040+    //     extends Signature
10041+    // {
10042+    //     public ecDSARipeMD160()
10043+    //     {
10044+    //         super(new RIPEMD160Digest(), new ECDSASigner(), new StdDSAEncoder());
10045+    //     }
10046+    // }
10047+    //
10048+    // static public class ecNR
10049+    //     extends Signature
10050+    // {
10051+    //     public ecNR()
10052+    //     {
10053+    //         super(new SHA1Digest(), new ECNRSigner(), new StdDSAEncoder());
10054+    //     }
10055+    // }
10056+    //
10057+    // static public class ecNR224
10058+    //     extends Signature
10059+    // {
10060+    //     public ecNR224()
10061+    //     {
10062+    //         super(new SHA224Digest(), new ECNRSigner(), new StdDSAEncoder());
10063+    //     }
10064+    // }
10065+    //
10066+    // static public class ecNR256
10067+    //     extends Signature
10068+    // {
10069+    //     public ecNR256()
10070+    //     {
10071+    //         super(new SHA256Digest(), new ECNRSigner(), new StdDSAEncoder());
10072+    //     }
10073+    // }
10074+    //
10075+    // static public class ecNR384
10076+    //     extends Signature
10077+    // {
10078+    //     public ecNR384()
10079+    //     {
10080+    //         super(new SHA384Digest(), new ECNRSigner(), new StdDSAEncoder());
10081+    //     }
10082+    // }
10083+    //
10084+    // static public class ecNR512
10085+    //     extends Signature
10086+    // {
10087+    //     public ecNR512()
10088+    //     {
10089+    //         super(new SHA512Digest(), new ECNRSigner(), new StdDSAEncoder());
10090+    //     }
10091+    // }
10092+    //
10093+    // static public class ecCVCDSA
10094+    //     extends Signature
10095+    // {
10096+    //     public ecCVCDSA()
10097+    //     {
10098+    //         super(new SHA1Digest(), new ECDSASigner(), new CVCDSAEncoder());
10099+    //     }
10100+    // }
10101+    //
10102+    // static public class ecCVCDSA224
10103+    //     extends Signature
10104+    // {
10105+    //     public ecCVCDSA224()
10106+    //     {
10107+    //         super(new SHA224Digest(), new ECDSASigner(), new CVCDSAEncoder());
10108+    //     }
10109+    // }
10110+    //
10111+    // static public class ecCVCDSA256
10112+    //     extends Signature
10113+    // {
10114+    //     public ecCVCDSA256()
10115+    //     {
10116+    //         super(new SHA256Digest(), new ECDSASigner(), new CVCDSAEncoder());
10117+    //     }
10118+    // }
10119+    // END android-removed
10120
10121     private static class StdDSAEncoder
10122         implements DSAEncoder
10123@@ -331,4 +341,4 @@
10124             return sig;
10125         }
10126     }
10127-}
10128\ No newline at end of file
10129+}
10130diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/AES.java bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/AES.java
10131--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/AES.java	2011-02-23 20:08:56.000000000 +0000
10132+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/AES.java	2011-09-08 21:28:49.000000000 +0000
10133@@ -13,8 +13,10 @@
10134 import org.bouncycastle.crypto.CipherKeyGenerator;
10135 import org.bouncycastle.crypto.engines.AESFastEngine;
10136 import org.bouncycastle.crypto.engines.AESWrapEngine;
10137-import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
10138-import org.bouncycastle.crypto.macs.CMac;
10139+// BEGIN android-removed
10140+// import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
10141+// import org.bouncycastle.crypto.macs.CMac;
10142+// END android-removed
10143 import org.bouncycastle.crypto.modes.CBCBlockCipher;
10144 import org.bouncycastle.crypto.modes.CFBBlockCipher;
10145 import org.bouncycastle.crypto.modes.OFBBlockCipher;
10146@@ -41,41 +43,43 @@
10147         }
10148     }
10149
10150-    public static class CBC
10151-       extends JCEBlockCipher
10152-    {
10153-        public CBC()
10154-        {
10155-            super(new CBCBlockCipher(new AESFastEngine()), 128);
10156-        }
10157-    }
10158-
10159-    static public class CFB
10160-        extends JCEBlockCipher
10161-    {
10162-        public CFB()
10163-        {
10164-            super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128);
10165-        }
10166-    }
10167-
10168-    static public class OFB
10169-        extends JCEBlockCipher
10170-    {
10171-        public OFB()
10172-        {
10173-            super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128);
10174-        }
10175-    }
10176-
10177-    public static class AESCMAC
10178-        extends JCEMac
10179-    {
10180-        public AESCMAC()
10181-        {
10182-            super(new CMac(new AESFastEngine()));
10183-        }
10184-    }
10185+    // BEGIN android-removed
10186+    // public static class CBC
10187+    //    extends JCEBlockCipher
10188+    // {
10189+    //     public CBC()
10190+    //     {
10191+    //         super(new CBCBlockCipher(new AESFastEngine()), 128);
10192+    //     }
10193+    // }
10194+    //
10195+    // static public class CFB
10196+    //     extends JCEBlockCipher
10197+    // {
10198+    //     public CFB()
10199+    //     {
10200+    //         super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128);
10201+    //     }
10202+    // }
10203+    //
10204+    // static public class OFB
10205+    //     extends JCEBlockCipher
10206+    // {
10207+    //     public OFB()
10208+    //     {
10209+    //         super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128);
10210+    //     }
10211+    // }
10212+    //
10213+    // public static class AESCMAC
10214+    //     extends JCEMac
10215+    // {
10216+    //     public AESCMAC()
10217+    //     {
10218+    //         super(new CMac(new AESFastEngine()));
10219+    //     }
10220+    // }
10221+    // END android-removed
10222
10223     static public class Wrap
10224         extends WrapCipherSpi
10225@@ -86,14 +90,16 @@
10226         }
10227     }
10228
10229-    public static class RFC3211Wrap
10230-        extends WrapCipherSpi
10231-    {
10232-        public RFC3211Wrap()
10233-        {
10234-            super(new RFC3211WrapEngine(new AESFastEngine()), 16);
10235-        }
10236-    }
10237+    // BEGIN android-removed
10238+    // public static class RFC3211Wrap
10239+    //     extends WrapCipherSpi
10240+    // {
10241+    //     public RFC3211Wrap()
10242+    //     {
10243+    //         super(new RFC3211WrapEngine(new AESFastEngine()), 16);
10244+    //     }
10245+    // }
10246+    // END android-removed
10247
10248     public static class KeyGen
10249         extends JCEKeyGenerator
10250@@ -109,70 +115,72 @@
10251         }
10252     }
10253
10254-    public static class KeyGen128
10255-        extends KeyGen
10256-    {
10257-        public KeyGen128()
10258-        {
10259-            super(128);
10260-        }
10261-    }
10262-
10263-    public static class KeyGen192
10264-        extends KeyGen
10265-    {
10266-        public KeyGen192()
10267-        {
10268-            super(192);
10269-        }
10270-    }
10271-
10272-    public static class KeyGen256
10273-        extends KeyGen
10274-    {
10275-        public KeyGen256()
10276-        {
10277-            super(256);
10278-        }
10279-    }
10280-
10281-    public static class AlgParamGen
10282-        extends JDKAlgorithmParameterGenerator
10283-    {
10284-        protected void engineInit(
10285-            AlgorithmParameterSpec genParamSpec,
10286-            SecureRandom random)
10287-            throws InvalidAlgorithmParameterException
10288-        {
10289-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation.");
10290-        }
10291-
10292-        protected AlgorithmParameters engineGenerateParameters()
10293-        {
10294-            byte[]  iv = new byte[16];
10295-
10296-            if (random == null)
10297-            {
10298-                random = new SecureRandom();
10299-            }
10300-
10301-            random.nextBytes(iv);
10302-
10303-            AlgorithmParameters params;
10304-
10305-            try
10306-            {
10307-                params = AlgorithmParameters.getInstance("AES", BouncyCastleProvider.PROVIDER_NAME);
10308-                params.init(new IvParameterSpec(iv));
10309-            }
10310-            catch (Exception e)
10311-            {
10312-                throw new RuntimeException(e.getMessage());
10313-            }
10314-
10315-            return params;
10316-        }
10317-    }
10318+    // BEGIN android-removed
10319+    // public static class KeyGen128
10320+    //     extends KeyGen
10321+    // {
10322+    //     public KeyGen128()
10323+    //     {
10324+    //         super(128);
10325+    //     }
10326+    // }
10327+    //
10328+    // public static class KeyGen192
10329+    //     extends KeyGen
10330+    // {
10331+    //     public KeyGen192()
10332+    //     {
10333+    //         super(192);
10334+    //     }
10335+    // }
10336+    //
10337+    // public static class KeyGen256
10338+    //     extends KeyGen
10339+    // {
10340+    //     public KeyGen256()
10341+    //     {
10342+    //         super(256);
10343+    //     }
10344+    // }
10345+    //
10346+    // public static class AlgParamGen
10347+    //     extends JDKAlgorithmParameterGenerator
10348+    // {
10349+    //     protected void engineInit(
10350+    //         AlgorithmParameterSpec genParamSpec,
10351+    //         SecureRandom random)
10352+    //         throws InvalidAlgorithmParameterException
10353+    //     {
10354+    //         throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation.");
10355+    //     }
10356+    //
10357+    //     protected AlgorithmParameters engineGenerateParameters()
10358+    //     {
10359+    //         byte[]  iv = new byte[16];
10360+    //
10361+    //         if (random == null)
10362+    //         {
10363+    //             random = new SecureRandom();
10364+    //         }
10365+    //
10366+    //         random.nextBytes(iv);
10367+    //
10368+    //         AlgorithmParameters params;
10369+    //
10370+    //         try
10371+    //         {
10372+    //             params = AlgorithmParameters.getInstance("AES", BouncyCastleProvider.PROVIDER_NAME);
10373+    //             params.init(new IvParameterSpec(iv));
10374+    //         }
10375+    //         catch (Exception e)
10376+    //         {
10377+    //             throw new RuntimeException(e.getMessage());
10378+    //         }
10379+    //
10380+    //         return params;
10381+    //     }
10382+    // }
10383+    // END android-removed
10384
10385     public static class AlgParams
10386         extends JDKAlgorithmParameters.IVAlgorithmParameters
10387@@ -205,58 +213,66 @@
10388             put("Alg.Alias.AlgorithmParameters." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
10389             put("Alg.Alias.AlgorithmParameters." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
10390
10391-            put("AlgorithmParameterGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$AlgParamGen");
10392-            put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES128, "AES");
10393-            put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES192, "AES");
10394-            put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES256, "AES");
10395-            put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "AES");
10396-            put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
10397-            put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
10398+            // BEGIN android-removed
10399+            // put("AlgorithmParameterGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$AlgParamGen");
10400+            // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES128, "AES");
10401+            // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES192, "AES");
10402+            // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES256, "AES");
10403+            // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "AES");
10404+            // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
10405+            // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
10406+            // END android-removed
10407
10408             put("Cipher.AES", "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10409             put("Alg.Alias.Cipher." + wrongAES128, "AES");
10410             put("Alg.Alias.Cipher." + wrongAES192, "AES");
10411             put("Alg.Alias.Cipher." + wrongAES256, "AES");
10412-            put("Cipher." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10413-            put("Cipher." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10414-            put("Cipher." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10415-            put("Cipher." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
10416-            put("Cipher." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
10417-            put("Cipher." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
10418-            put("Cipher." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
10419-            put("Cipher." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
10420-            put("Cipher." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
10421-            put("Cipher." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
10422-            put("Cipher." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
10423-            put("Cipher." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
10424+            // BEGIN android-removed
10425+            // put("Cipher." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10426+            // put("Cipher." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10427+            // put("Cipher." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
10428+            // put("Cipher." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
10429+            // put("Cipher." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
10430+            // put("Cipher." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
10431+            // put("Cipher." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
10432+            // put("Cipher." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
10433+            // put("Cipher." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
10434+            // put("Cipher." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
10435+            // put("Cipher." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
10436+            // put("Cipher." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
10437+            // END android-removed
10438             put("Cipher.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$Wrap");
10439             put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_wrap, "AESWRAP");
10440             put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_wrap, "AESWRAP");
10441             put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_wrap, "AESWRAP");
10442-            put("Cipher.AESRFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.AES$RFC3211Wrap");
10443+            // BEGIN android-removed
10444+            // put("Cipher.AESRFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.AES$RFC3211Wrap");
10445+            // END android-removed
10446
10447             put("KeyGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen");
10448-            put("KeyGenerator.2.16.840.1.101.3.4.2", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10449-            put("KeyGenerator.2.16.840.1.101.3.4.22", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10450-            put("KeyGenerator.2.16.840.1.101.3.4.42", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10451-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10452-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10453-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10454-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10455-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10456-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10457-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10458-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10459-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10460-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10461-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10462-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10463-            put("KeyGenerator.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen");
10464-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10465-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10466-            put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10467-
10468-            put("Mac.AESCMAC", "org.bouncycastle.jce.provider.symmetric.AES$AESCMAC");
10469+            // BEGIN android-removed
10470+            // put("KeyGenerator.2.16.840.1.101.3.4.2", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10471+            // put("KeyGenerator.2.16.840.1.101.3.4.22", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10472+            // put("KeyGenerator.2.16.840.1.101.3.4.42", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10473+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10474+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10475+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10476+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10477+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10478+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10479+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10480+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10481+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10482+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10483+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10484+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10485+            // put("KeyGenerator.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen");
10486+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
10487+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
10488+            // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
10489+            //
10490+            // put("Mac.AESCMAC", "org.bouncycastle.jce.provider.symmetric.AES$AESCMAC");
10491+            // END android-removed
10492         }
10493     }
10494 }
10495diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/ARC4.java bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/ARC4.java
10496--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/ARC4.java	2011-02-23 20:08:56.000000000 +0000
10497+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/ARC4.java	2011-09-08 21:28:49.000000000 +0000
10498@@ -27,7 +27,9 @@
10499     {
10500         public KeyGen()
10501         {
10502-            super("RC4", 128, new CipherKeyGenerator());
10503+            // BEGIN android-changed
10504+            super("ARC4", 128, new CipherKeyGenerator());
10505+            // END android-changed
10506         }
10507     }
10508
10509diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/Blowfish.java bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/Blowfish.java
10510--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/Blowfish.java	2011-02-23 20:08:56.000000000 +0000
10511+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/Blowfish.java	2011-09-08 21:28:49.000000000 +0000
10512@@ -57,7 +57,9 @@
10513         public Mappings()
10514         {
10515             put("Cipher.BLOWFISH", "org.bouncycastle.jce.provider.symmetric.Blowfish$ECB");
10516-            put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.symmetric.Blowfish$CBC");
10517+            // BEGIN android-removed
10518+            // put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.symmetric.Blowfish$CBC");
10519+            // END android-removed
10520             put("KeyGenerator.BLOWFISH", "org.bouncycastle.jce.provider.symmetric.Blowfish$KeyGen");
10521             put("Alg.Alias.KeyGenerator.1.3.6.1.4.1.3029.1.2", "BLOWFISH");
10522             put("AlgorithmParameters.BLOWFISH", "org.bouncycastle.jce.provider.symmetric.Blowfish$AlgParams");
10523diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/DESede.java bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/DESede.java
10524--- bcprov-jdk16-146.orig/org/bouncycastle/jce/provider/symmetric/DESede.java	2011-02-23 20:08:56.000000000 +0000
10525+++ bcprov-jdk16-146/org/bouncycastle/jce/provider/symmetric/DESede.java	2011-09-08 21:28:49.000000000 +0000
10526@@ -14,11 +14,15 @@
10527 import org.bouncycastle.crypto.KeyGenerationParameters;
10528 import org.bouncycastle.crypto.engines.DESedeEngine;
10529 import org.bouncycastle.crypto.engines.DESedeWrapEngine;
10530-import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
10531+// BEGIN android-removed
10532+// import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
10533+// END android-removed
10534 import org.bouncycastle.crypto.generators.DESedeKeyGenerator;
10535 import org.bouncycastle.crypto.macs.CBCBlockCipherMac;
10536-import org.bouncycastle.crypto.macs.CFBBlockCipherMac;
10537-import org.bouncycastle.crypto.macs.CMac;
10538+// BEGIN android-removed
10539+// import org.bouncycastle.crypto.macs.CFBBlockCipherMac;
10540+// import org.bouncycastle.crypto.macs.CMac;
10541+// END android-removed
10542 import org.bouncycastle.crypto.modes.CBCBlockCipher;
10543 import org.bouncycastle.crypto.paddings.ISO7816d4Padding;
10544 import org.bouncycastle.jce.provider.JCEBlockCipher;
10545@@ -51,17 +55,19 @@
10546         }
10547     }
10548
10549-    /**
10550-     * DESede   CFB8
10551-     */
10552-    public static class DESedeCFB8
10553-        extends JCEMac
10554-    {
10555-        public DESedeCFB8()
10556-        {
10557-            super(new CFBBlockCipherMac(new DESedeEngine()));
10558-        }
10559-    }
10560+    // BEGIN android-removed
10561+    // /**
10562+    //  * DESede   CFB8
10563+    //  */
10564+    // public static class DESedeCFB8
10565+    //     extends JCEMac
10566+    // {
10567+    //     public DESedeCFB8()
10568+    //     {
10569+    //         super(new CFBBlockCipherMac(new DESedeEngine()));
10570+    //     }
10571+    // }
10572+    // END android-removed
10573
10574     /**
10575      * DESede64
10576@@ -96,14 +102,16 @@
10577         }
10578     }
10579
10580-    static public class CMAC
10581-        extends JCEMac
10582-    {
10583-        public CMAC()
10584-        {
10585-            super(new CMac(new DESedeEngine()));
10586-        }
10587-    }
10588+    // BEGIN android-removed
10589+    // static public class CMAC
10590+    //     extends JCEMac
10591+    // {
10592+    //     public CMAC()
10593+    //     {
10594+    //         super(new CMac(new DESedeEngine()));
10595+    //     }
10596+    // }
10597+    // END android-removed
10598
10599     public static class Wrap
10600         extends WrapCipherSpi
10601@@ -114,14 +122,16 @@
10602         }
10603     }
10604
10605-    public static class RFC3211
10606-        extends WrapCipherSpi
10607-    {
10608-        public RFC3211()
10609-        {
10610-            super(new RFC3211WrapEngine(new DESedeEngine()), 8);
10611-        }
10612-    }
10613+    // BEGIN android-removed
10614+    // public static class RFC3211
10615+    //     extends WrapCipherSpi
10616+    // {
10617+    //     public RFC3211()
10618+    //     {
10619+    //         super(new RFC3211WrapEngine(new DESedeEngine()), 8);
10620+    //     }
10621+    // }
10622+    // END android-removed
10623
10624   /**
10625      * DESede - the default for this is to generate a key in
10626@@ -262,32 +272,42 @@
10627         public Mappings()
10628         {
10629             put("Cipher.DESEDE", "org.bouncycastle.jce.provider.symmetric.DESede$ECB");
10630-            put("Cipher." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.symmetric.DESede$CBC");
10631-            put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.symmetric.DESede$CBC");
10632+            // BEGIN android-removed
10633+            // put("Cipher." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.symmetric.DESede$CBC");
10634+            // put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.symmetric.DESede$CBC");
10635+            // END android-removed
10636             put("Cipher.DESEDEWRAP", "org.bouncycastle.jce.provider.symmetric.DESede$Wrap");
10637-            put("Cipher." + PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "org.bouncycastle.jce.provider.symmetric.DESede$Wrap");
10638-            put("Cipher.DESEDERFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.DESede$RFC3211");
10639+            // BEGIN android-changed
10640+            put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "DESEDEWRAP");
10641+            // END android-changed
10642+            // BEGIN android-removed
10643+            // put("Cipher.DESEDERFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.DESede$RFC3211");
10644+            // END android-removed
10645
10646             put("KeyGenerator.DESEDE", "org.bouncycastle.jce.provider.symmetric.DESede$KeyGenerator");
10647-            put("KeyGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.symmetric.DESede$KeyGenerator3");
10648-            put("KeyGenerator.DESEDEWRAP", "org.bouncycastle.jce.provider.symmetric.DESede$KeyGenerator");
10649+            // BEGIN android-removed
10650+            // put("KeyGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.symmetric.DESede$KeyGenerator3");
10651+            // put("KeyGenerator.DESEDEWRAP", "org.bouncycastle.jce.provider.symmetric.DESede$KeyGenerator");
10652+            // END android-removed
10653
10654             put("SecretKeyFactory.DESEDE", "org.bouncycastle.jce.provider.symmetric.DESede$KeyFactory");
10655
10656-            put("Mac.DESEDECMAC", "org.bouncycastle.jce.provider.symmetric.DESede$CMAC");
10657-            put("Mac.DESEDEMAC", "org.bouncycastle.jce.provider.symmetric.DESede$CBCMAC");
10658-            put("Alg.Alias.Mac.DESEDE", "DESEDEMAC");
10659-
10660-            put("Mac.DESEDEMAC/CFB8", "org.bouncycastle.jce.provider.symmetric.DESede$DESedeCFB8");
10661-            put("Alg.Alias.Mac.DESEDE/CFB8", "DESEDEMAC/CFB8");
10662-
10663-            put("Mac.DESEDEMAC64", "org.bouncycastle.jce.provider.symmetric.DESede$DESede64");
10664-            put("Alg.Alias.Mac.DESEDE64", "DESEDEMAC64");
10665-
10666-            put("Mac.DESEDEMAC64WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.symmetric.DESede$DESede64with7816d4");
10667-            put("Alg.Alias.Mac.DESEDE64WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
10668-            put("Alg.Alias.Mac.DESEDEISO9797ALG1MACWITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
10669-            put("Alg.Alias.Mac.DESEDEISO9797ALG1WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
10670+            // BEGIN android-removed
10671+            // put("Mac.DESEDECMAC", "org.bouncycastle.jce.provider.symmetric.DESede$CMAC");
10672+            // put("Mac.DESEDEMAC", "org.bouncycastle.jce.provider.symmetric.DESede$CBCMAC");
10673+            // put("Alg.Alias.Mac.DESEDE", "DESEDEMAC");
10674+            //
10675+            // put("Mac.DESEDEMAC/CFB8", "org.bouncycastle.jce.provider.symmetric.DESede$DESedeCFB8");
10676+            // put("Alg.Alias.Mac.DESEDE/CFB8", "DESEDEMAC/CFB8");
10677+            //
10678+            // put("Mac.DESEDEMAC64", "org.bouncycastle.jce.provider.symmetric.DESede$DESede64");
10679+            // put("Alg.Alias.Mac.DESEDE64", "DESEDEMAC64");
10680+            //
10681+            // put("Mac.DESEDEMAC64WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.symmetric.DESede$DESede64with7816d4");
10682+            // put("Alg.Alias.Mac.DESEDE64WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
10683+            // put("Alg.Alias.Mac.DESEDEISO9797ALG1MACWITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
10684+            // put("Alg.Alias.Mac.DESEDEISO9797ALG1WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
10685+            // END android-removed
10686         }
10687     }
10688 }
10689diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/openssl/PEMUtilities.java bcprov-jdk16-146/org/bouncycastle/openssl/PEMUtilities.java
10690--- bcprov-jdk16-146.orig/org/bouncycastle/openssl/PEMUtilities.java	2011-02-23 20:08:56.000000000 +0000
10691+++ bcprov-jdk16-146/org/bouncycastle/openssl/PEMUtilities.java	2011-09-08 21:28:50.000000000 +0000
10692@@ -45,10 +45,12 @@
10693         PKCS5_SCHEME_2.add(NISTObjectIdentifiers.id_aes192_CBC);
10694         PKCS5_SCHEME_2.add(NISTObjectIdentifiers.id_aes256_CBC);
10695
10696-        KEYSIZES.put(PKCSObjectIdentifiers.des_EDE3_CBC.getId(), new Integer(192));
10697-        KEYSIZES.put(NISTObjectIdentifiers.id_aes128_CBC.getId(), new Integer(128));
10698-        KEYSIZES.put(NISTObjectIdentifiers.id_aes192_CBC.getId(), new Integer(192));
10699-        KEYSIZES.put(NISTObjectIdentifiers.id_aes256_CBC.getId(), new Integer(256));
10700+        // BEGIN android-changed
10701+        KEYSIZES.put(PKCSObjectIdentifiers.des_EDE3_CBC.getId(), Integer.valueOf(192));
10702+        KEYSIZES.put(NISTObjectIdentifiers.id_aes128_CBC.getId(), Integer.valueOf(128));
10703+        KEYSIZES.put(NISTObjectIdentifiers.id_aes192_CBC.getId(), Integer.valueOf(192));
10704+        KEYSIZES.put(NISTObjectIdentifiers.id_aes256_CBC.getId(), Integer.valueOf(256));
10705+        // END android-changed
10706     }
10707
10708     static int getKeySize(String algorithm)
10709diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/x509/X509Util.java bcprov-jdk16-146/org/bouncycastle/x509/X509Util.java
10710--- bcprov-jdk16-146.orig/org/bouncycastle/x509/X509Util.java	2011-02-23 20:08:56.000000000 +0000
10711+++ bcprov-jdk16-146/org/bouncycastle/x509/X509Util.java	2011-09-08 21:28:50.000000000 +0000
10712@@ -44,14 +44,18 @@
10713
10714     static
10715     {
10716-        algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption);
10717-        algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption);
10718+        // BEGIN android-removed
10719+        // algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption);
10720+        // algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption);
10721+        // END android-removed
10722         algorithms.put("MD5WITHRSAENCRYPTION", PKCSObjectIdentifiers.md5WithRSAEncryption);
10723         algorithms.put("MD5WITHRSA", PKCSObjectIdentifiers.md5WithRSAEncryption);
10724         algorithms.put("SHA1WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha1WithRSAEncryption);
10725         algorithms.put("SHA1WITHRSA", PKCSObjectIdentifiers.sha1WithRSAEncryption);
10726-        algorithms.put("SHA224WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha224WithRSAEncryption);
10727-        algorithms.put("SHA224WITHRSA", PKCSObjectIdentifiers.sha224WithRSAEncryption);
10728+        // BEGIN android-removed
10729+        // algorithms.put("SHA224WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha224WithRSAEncryption);
10730+        // algorithms.put("SHA224WITHRSA", PKCSObjectIdentifiers.sha224WithRSAEncryption);
10731+        // END android-removed
10732         algorithms.put("SHA256WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha256WithRSAEncryption);
10733         algorithms.put("SHA256WITHRSA", PKCSObjectIdentifiers.sha256WithRSAEncryption);
10734         algorithms.put("SHA384WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha384WithRSAEncryption);
10735@@ -59,45 +63,59 @@
10736         algorithms.put("SHA512WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha512WithRSAEncryption);
10737         algorithms.put("SHA512WITHRSA", PKCSObjectIdentifiers.sha512WithRSAEncryption);
10738         algorithms.put("SHA1WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
10739-        algorithms.put("SHA224WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
10740+        // BEGIN android-removed
10741+        // algorithms.put("SHA224WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
10742+        // END android-removed
10743         algorithms.put("SHA256WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
10744         algorithms.put("SHA384WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
10745         algorithms.put("SHA512WITHRSAANDMGF1", PKCSObjectIdentifiers.id_RSASSA_PSS);
10746-        algorithms.put("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
10747-        algorithms.put("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
10748-        algorithms.put("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
10749-        algorithms.put("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
10750-        algorithms.put("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
10751-        algorithms.put("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
10752+        // BEGIN android-removed
10753+        // algorithms.put("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
10754+        // algorithms.put("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160);
10755+        // algorithms.put("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
10756+        // algorithms.put("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128);
10757+        // algorithms.put("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
10758+        // algorithms.put("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256);
10759+        // END android-removed
10760         algorithms.put("SHA1WITHDSA", X9ObjectIdentifiers.id_dsa_with_sha1);
10761         algorithms.put("DSAWITHSHA1", X9ObjectIdentifiers.id_dsa_with_sha1);
10762-        algorithms.put("SHA224WITHDSA", NISTObjectIdentifiers.dsa_with_sha224);
10763+        // BEGIN android-removed
10764+        // algorithms.put("SHA224WITHDSA", NISTObjectIdentifiers.dsa_with_sha224);
10765+        // END android-removed
10766         algorithms.put("SHA256WITHDSA", NISTObjectIdentifiers.dsa_with_sha256);
10767         algorithms.put("SHA384WITHDSA", NISTObjectIdentifiers.dsa_with_sha384);
10768         algorithms.put("SHA512WITHDSA", NISTObjectIdentifiers.dsa_with_sha512);
10769         algorithms.put("SHA1WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA1);
10770         algorithms.put("ECDSAWITHSHA1", X9ObjectIdentifiers.ecdsa_with_SHA1);
10771-        algorithms.put("SHA224WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA224);
10772+        // BEGIN android-removed
10773+        // algorithms.put("SHA224WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA224);
10774+        // END android-removed
10775         algorithms.put("SHA256WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA256);
10776         algorithms.put("SHA384WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA384);
10777         algorithms.put("SHA512WITHECDSA", X9ObjectIdentifiers.ecdsa_with_SHA512);
10778-        algorithms.put("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
10779-        algorithms.put("GOST3411WITHGOST3410-94", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
10780-        algorithms.put("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10781-        algorithms.put("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10782-        algorithms.put("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10783+        // BEGIN android-removed
10784+        // algorithms.put("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
10785+        // algorithms.put("GOST3411WITHGOST3410-94", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
10786+        // algorithms.put("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10787+        // algorithms.put("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10788+        // algorithms.put("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10789+        // END android-removed
10790
10791         //
10792         // According to RFC 3279, the ASN.1 encoding SHALL (id-dsa-with-sha1) or MUST (ecdsa-with-SHA*) omit the parameters field.
10793         // The parameters field SHALL be NULL for RSA based signature algorithms.
10794         //
10795         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA1);
10796-        noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA224);
10797+        // BEGIN android-removed
10798+        // noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA224);
10799+        // END android-removed
10800         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA256);
10801         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA384);
10802         noParams.add(X9ObjectIdentifiers.ecdsa_with_SHA512);
10803         noParams.add(X9ObjectIdentifiers.id_dsa_with_sha1);
10804-        noParams.add(NISTObjectIdentifiers.dsa_with_sha224);
10805+        // BEGIN android-removed
10806+        // noParams.add(NISTObjectIdentifiers.dsa_with_sha224);
10807+        // END android-removed
10808         noParams.add(NISTObjectIdentifiers.dsa_with_sha256);
10809         noParams.add(NISTObjectIdentifiers.dsa_with_sha384);
10810         noParams.add(NISTObjectIdentifiers.dsa_with_sha512);
10811@@ -105,25 +123,39 @@
10812         //
10813         // RFC 4491
10814         //
10815-        noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
10816-        noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10817+        // BEGIN android-removed
10818+        // noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94);
10819+        // noParams.add(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001);
10820+        // END android-removed
10821
10822         //
10823         // explicit params
10824         //
10825-        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
10826+        // BEGIN android-changed
10827+        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
10828+        // END android-changed
10829         params.put("SHA1WITHRSAANDMGF1", creatPSSParams(sha1AlgId, 20));
10830
10831-        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, new DERNull());
10832-        params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28));
10833-
10834-        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, new DERNull());
10835+        // BEGIN android-removed
10836+        // // BEGIN android-changed
10837+        // AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE);
10838+        // // END android-changed
10839+        // params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28));
10840+        // END android-removed
10841+
10842+        // BEGIN android-changed
10843+        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE);
10844+        // END android-changed
10845         params.put("SHA256WITHRSAANDMGF1", creatPSSParams(sha256AlgId, 32));
10846
10847-        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, new DERNull());
10848+        // BEGIN android-changed
10849+        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE);
10850+        // END android-changed
10851         params.put("SHA384WITHRSAANDMGF1", creatPSSParams(sha384AlgId, 48));
10852
10853-        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, new DERNull());
10854+        // BEGIN android-changed
10855+        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE);
10856+        // END android-changed
10857         params.put("SHA512WITHRSAANDMGF1", creatPSSParams(sha512AlgId, 64));
10858     }
10859
10860@@ -166,7 +198,9 @@
10861         }
10862         else
10863         {
10864-            return new AlgorithmIdentifier(sigOid, new DERNull());
10865+            // BEGIN android-changed
10866+            return new AlgorithmIdentifier(sigOid, DERNull.INSTANCE);
10867+            // END android-changed
10868         }
10869     }
10870
10871diff -Naur bcprov-jdk16-146.orig/org/bouncycastle/x509/extension/X509ExtensionUtil.java bcprov-jdk16-146/org/bouncycastle/x509/extension/X509ExtensionUtil.java
10872--- bcprov-jdk16-146.orig/org/bouncycastle/x509/extension/X509ExtensionUtil.java	2011-02-23 20:08:56.000000000 +0000
10873+++ bcprov-jdk16-146/org/bouncycastle/x509/extension/X509ExtensionUtil.java	2011-09-08 21:28:50.000000000 +0000
10874@@ -62,7 +62,9 @@
10875             {
10876                 GeneralName genName = GeneralName.getInstance(it.nextElement());
10877                 List list = new ArrayList();
10878-                list.add(new Integer(genName.getTagNo()));
10879+                // BEGIN android-changed
10880+                list.add(Integer.valueOf(genName.getTagNo()));
10881+                // END android-changed
10882                 switch (genName.getTagNo())
10883                 {
10884                 case GeneralName.ediPartyName:
10885