• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Collection.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Collection.java
2--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Collection.java	1970-01-01 00:00:00.000000000 +0000
3+++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Collection.java	2011-09-03 18:19:15.000000000 +0000
4@@ -0,0 +1,298 @@
5+package org.bouncycastle.asn1;
6+
7+import java.io.ByteArrayOutputStream;
8+import java.io.IOException;
9+import java.util.Enumeration;
10+import java.util.ConcurrentModificationException;
11+
12+// BEGIN android-note
13+/*
14+ * This is a new class that was synthesized from ASN1Sequence and
15+ * ASN1Set, but with extra smarts about efficiently storing its
16+ * elements.
17+ */
18+// END android-note
19+
20+/**
21+ * Base class for collection-like <code>DERObject</code>s. Instances
22+ * of this class will keep up to four elements directly, resorting to
23+ * an external collection only if more elements than that need to be
24+ * stored.
25+ */
26+public abstract class ASN1Collection
27+    extends ASN1Object
28+{
29+    /** &gt;= 0; size of the collection */
30+    private int size;
31+
32+    /** null-ok; element #0 */
33+    private DEREncodable obj0;
34+
35+    /** null-ok; element #1 */
36+    private DEREncodable obj1;
37+
38+    /** null-ok; element #2 */
39+    private DEREncodable obj2;
40+
41+    /** null-ok; element #3 */
42+    private DEREncodable obj3;
43+
44+    /** null-ok; elements #4 and higher */
45+    private DEREncodable[] rest;
46+
47+    /**
48+     * Returns the object at the postion indicated by index.
49+     *
50+     * @param index the index (starting at zero) of the object
51+     * @return the object at the postion indicated by index
52+     */
53+    public DEREncodable getObjectAt(int index) {
54+        if ((index < 0) || (index >= size)) {
55+            throw new IndexOutOfBoundsException(Integer.toString(index));
56+        }
57+
58+        switch (index) {
59+            case 0: return obj0;
60+            case 1: return obj1;
61+            case 2: return obj2;
62+            case 3: return obj3;
63+            default: return rest[index - 4];
64+        }
65+    }
66+
67+    /**
68+     * Returns the number of objects in this instance.
69+     *
70+     * @return the number of objects in this instance
71+     */
72+    public int size() {
73+        return size;
74+    }
75+
76+    /** {@inheritDoc} */
77+    public final int hashCode() {
78+        Enumeration e = this.getObjects();
79+        int hashCode = 0;
80+
81+        while (e.hasMoreElements()) {
82+            Object o = e.nextElement();
83+
84+            if (o != null) {
85+                hashCode ^= o.hashCode();
86+            }
87+        }
88+
89+        return hashCode;
90+    }
91+
92+    /**
93+     * Adds a new element to this instance.
94+     *
95+     * @param obj non-null; the instance to add
96+     */
97+    protected void addObject(DEREncodable obj) {
98+        if (obj == null) {
99+            throw new NullPointerException("obj == null");
100+        }
101+
102+        int sz = size;
103+
104+        switch (sz) {
105+            case 0: obj0 = obj; break;
106+            case 1: obj1 = obj; break;
107+            case 2: obj2 = obj; break;
108+            case 3: obj3 = obj; break;
109+            case 4: {
110+                // Initial allocation of rest.
111+                rest = new DEREncodable[5];
112+                rest[0] = obj;
113+                break;
114+            }
115+            default: {
116+                int index = sz - 4;
117+                if (index >= rest.length) {
118+                    // Grow rest.
119+                    DEREncodable[] newRest = new DEREncodable[index * 2 + 10];
120+                    System.arraycopy(rest, 0, newRest, 0, rest.length);
121+                    rest = newRest;
122+                }
123+                rest[index] = obj;
124+                break;
125+            }
126+        }
127+
128+        size++;
129+    }
130+
131+    /**
132+     * Sets the element at a given index (used by {@link #sort}).
133+     *
134+     * @param obj non-null; the object to set
135+     * @param index &gt;= 0; the index
136+     */
137+    private void setObjectAt(DEREncodable obj, int index) {
138+        switch (index) {
139+            case 0: obj0 = obj; break;
140+            case 1: obj1 = obj; break;
141+            case 2: obj2 = obj; break;
142+            case 3: obj3 = obj; break;
143+            default: {
144+                rest[index - 4] = obj;
145+                break;
146+            }
147+        }
148+    }
149+
150+    /**
151+     * Encodes this instance to the given stream.
152+     *
153+     * @param out non-null; stream to encode to
154+     */
155+    /*package*/ abstract void encode(DEROutputStream out) throws IOException;
156+
157+    /**
158+     * Gets an enumeration of all the objects in this collection.
159+     *
160+     * @return non-null; the enumeration
161+     */
162+    public Enumeration getObjects() {
163+        return new ASN1CollectionEnumeration();
164+    }
165+
166+    /**
167+     * Associated enumeration class.
168+     */
169+    private class ASN1CollectionEnumeration implements Enumeration {
170+        /** original size; used for modification detection */
171+        private final int origSize = size;
172+
173+        /** &gt;= 0; current cursor */
174+        private int at = 0;
175+
176+        /** {@inheritDoc} */
177+        public boolean hasMoreElements() {
178+            if (size != origSize) {
179+                throw new ConcurrentModificationException();
180+            }
181+
182+            return at < origSize;
183+        }
184+
185+        /** {@inheritDoc} */
186+        public Object nextElement() {
187+            if (size != origSize) {
188+                throw new ConcurrentModificationException();
189+            }
190+
191+            switch (at++) {
192+                case 0: return obj0;
193+                case 1: return obj1;
194+                case 2: return obj2;
195+                case 3: return obj3;
196+                default: return rest[at - 5];
197+            }
198+        }
199+    }
200+
201+    /**
202+     * Sorts the elements in this instance.
203+     */
204+    protected void sort() {
205+        if (size <= 1) {
206+            return;
207+        }
208+
209+        boolean swapped = true;
210+
211+        // TODO: This is bubble sort. Probably not the best choice.
212+        while (swapped) {
213+            int index = 0;
214+            byte[] a = getEncoded(getObjectAt(0));
215+
216+            swapped = false;
217+
218+            while (index != size - 1) {
219+                int nextIndex = index + 1;
220+                byte[] b = getEncoded(getObjectAt(nextIndex));
221+
222+                if (lessThanOrEqual(a, b)) {
223+                    a = b;
224+                } else {
225+                    DEREncodable o = getObjectAt(index);
226+
227+                    setObjectAt(getObjectAt(nextIndex), index);
228+                    setObjectAt(o, nextIndex);
229+
230+                    swapped = true;
231+                }
232+
233+                index++;
234+            }
235+        }
236+    }
237+
238+    /**
239+     * Returns true if a <= b (arrays are assumed padded with zeros).
240+     */
241+    private static boolean lessThanOrEqual(byte[] a, byte[] b) {
242+        if (a.length <= b.length) {
243+            for (int i = 0; i != a.length; i++) {
244+                int l = a[i] & 0xff;
245+                int r = b[i] & 0xff;
246+
247+                if (r > l) {
248+                    return true;
249+                } else if (l > r) {
250+                    return false;
251+                }
252+            }
253+
254+            return true;
255+        } else {
256+            for (int i = 0; i != b.length; i++) {
257+                 int l = a[i] & 0xff;
258+                 int r = b[i] & 0xff;
259+
260+                 if (r > l) {
261+                     return true;
262+                 } else if (l > r) {
263+                     return false;
264+                 }
265+             }
266+
267+             return false;
268+         }
269+    }
270+
271+    /**
272+     * Gets the encoded form of an object.
273+     *
274+     * @param obj non-null; object to encode
275+     * @return non-null; the encoded form
276+     */
277+    private static byte[] getEncoded(DEREncodable obj) {
278+        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
279+        ASN1OutputStream aOut = new ASN1OutputStream(bOut);
280+
281+        try {
282+            aOut.writeObject(obj);
283+        } catch (IOException e) {
284+            throw new IllegalArgumentException(
285+                    "cannot encode object added to collection");
286+        }
287+
288+        return bOut.toByteArray();
289+    }
290+
291+    /** {@inheritDoc} */
292+    public final String toString() {
293+        StringBuilder sb = new StringBuilder();
294+        sb.append('[');
295+        for (int i = 0; i < size; i++) {
296+            if (i != 0) sb.append(", ");
297+            sb.append(getObjectAt(i));
298+        }
299+        sb.append(']');
300+        return sb.toString();
301+    }
302+}
303diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1InputStream.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1InputStream.java
304--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1InputStream.java	2010-01-11 21:46:14.000000000 +0000
305+++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1InputStream.java	2011-09-03 18:19:15.000000000 +0000
306@@ -348,7 +348,9 @@
307             case BMP_STRING:
308                 return new DERBMPString(bytes);
309             case BOOLEAN:
310-                return new DERBoolean(bytes);
311+                // BEGIN android-changed
312+                return DERBoolean.getInstance(bytes);
313+                // END android-changed
314             case ENUMERATED:
315                 return new DEREnumerated(bytes);
316             case GENERALIZED_TIME:
317diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Null.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Null.java
318--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Null.java	2010-01-11 21:46:14.000000000 +0000
319+++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Null.java	2011-09-03 18:19:15.000000000 +0000
320@@ -8,9 +8,11 @@
321 public abstract class ASN1Null
322     extends ASN1Object
323 {
324-    public ASN1Null()
325+    // BEGIN android-changed
326+    /*package*/ ASN1Null()
327     {
328     }
329+    // END android-changed
330
331     public int hashCode()
332     {
333diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Sequence.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Sequence.java
334--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Sequence.java	2010-01-11 21:46:14.000000000 +0000
335+++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Sequence.java	2011-09-03 18:19:15.000000000 +0000
336@@ -2,12 +2,20 @@
337
338 import java.io.IOException;
339 import java.util.Enumeration;
340-import java.util.Vector;
341+// BEGIN android-removed
342+// import java.util.Vector;
343+// END android-removed
344+
345+// BEGIN android-note
346+// Changed inheritence of class.
347+// END android-note
348
349 public abstract class ASN1Sequence
350-    extends ASN1Object
351+    extends ASN1Collection
352 {
353-    private Vector seq = new Vector();
354+    // BEGIN android-removed
355+    // private Vector seq = new Vector();
356+    // END android-removed
357
358     /**
359      * return an ASN1Sequence from the given object.
360@@ -85,10 +93,12 @@
361         throw new IllegalArgumentException("unknown object in getInstance: " + obj.getClass().getName());
362     }
363
364-    public Enumeration getObjects()
365-    {
366-        return seq.elements();
367-    }
368+    // BEGIN android-removed
369+    // public Enumeration getObjects()
370+    // {
371+    //     return seq.elements();
372+    // }
373+    // END android-removed
374
375     public ASN1SequenceParser parser()
376     {
377@@ -127,45 +137,47 @@
378         };
379     }
380
381-    /**
382-     * return the object at the sequence position indicated by index.
383-     *
384-     * @param index the sequence number (starting at zero) of the object
385-     * @return the object at the sequence position indicated by index.
386-     */
387-    public DEREncodable getObjectAt(
388-        int index)
389-    {
390-        return (DEREncodable)seq.elementAt(index);
391-    }
392-
393-    /**
394-     * return the number of objects in this sequence.
395-     *
396-     * @return the number of objects in this sequence.
397-     */
398-    public int size()
399-    {
400-        return seq.size();
401-    }
402-
403-    public int hashCode()
404-    {
405-        Enumeration             e = this.getObjects();
406-        int                     hashCode = size();
407-
408-        while (e.hasMoreElements())
409-        {
410-            Object o = e.nextElement();
411-            hashCode *= 17;
412-            if (o != null)
413-            {
414-                hashCode ^= o.hashCode();
415-            }
416-        }
417-
418-        return hashCode;
419-    }
420+    // BEGIN android-removed
421+    // /**
422+    //  * return the object at the sequence position indicated by index.
423+    //  *
424+    //  * @param index the sequence number (starting at zero) of the object
425+    //  * @return the object at the sequence position indicated by index.
426+    //  */
427+    // public DEREncodable getObjectAt(
428+    //     int index)
429+    // {
430+    //     return (DEREncodable)seq.elementAt(index);
431+    // }
432+    //
433+    // /**
434+    //  * return the number of objects in this sequence.
435+    //  *
436+    //  * @return the number of objects in this sequence.
437+    //  */
438+    // public int size()
439+    // {
440+    //     return seq.size();
441+    // }
442+    //
443+    // public int hashCode()
444+    // {
445+    //     Enumeration             e = this.getObjects();
446+    //     int                     hashCode = size();
447+    //
448+    //     while (e.hasMoreElements())
449+    //     {
450+    //         Object o = e.nextElement();
451+    //         hashCode *= 17;
452+    //         if (o != null)
453+    //         {
454+    //             hashCode ^= o.hashCode();
455+    //         }
456+    //     }
457+    //
458+    //     return hashCode;
459+    // }
460+    // END android-removed
461
462     boolean asn1Equals(
463         DERObject  o)
464@@ -201,17 +213,19 @@
465         return true;
466     }
467
468-    protected void addObject(
469-        DEREncodable obj)
470-    {
471-        seq.addElement(obj);
472-    }
473-
474-    abstract void encode(DEROutputStream out)
475-        throws IOException;
476-
477-    public String toString()
478-    {
479-      return seq.toString();
480-    }
481+    // BEGIN android-removed
482+    //protected void addObject(
483+    //    DEREncodable obj)
484+    //{
485+    //    seq.addElement(obj);
486+    //}
487+
488+    //abstract void encode(DEROutputStream out)
489+    //    throws IOException;
490+
491+    //public String toString()
492+    //{
493+    //  return seq.toString();
494+    //}
495+    // END android-removed
496 }
497diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Set.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Set.java
498--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Set.java	2010-01-11 21:46:14.000000000 +0000
499+++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Set.java	2011-09-03 18:19:15.000000000 +0000
500@@ -3,12 +3,20 @@
501 import java.io.ByteArrayOutputStream;
502 import java.io.IOException;
503 import java.util.Enumeration;
504-import java.util.Vector;
505+// BEGIN android-removed
506+// import java.util.Vector;
507+// END android-removed
508+
509+// BEGIN android-note
510+// Changed inheritence of class.
511+// END android-note
512
513 abstract public class ASN1Set
514-    extends ASN1Object
515+    extends ASN1Collection
516 {
517-    protected Vector set = new Vector();
518+    // BEGIN android-removed
519+    // protected Vector set = new Vector();
520+    // END android-removed
521
522     /**
523      * return an ASN1Set from the given object.
524@@ -104,32 +112,34 @@
525     {
526     }
527
528-    public Enumeration getObjects()
529-    {
530-        return set.elements();
531-    }
532-
533-    /**
534-     * return the object at the set position indicated by index.
535-     *
536-     * @param index the set number (starting at zero) of the object
537-     * @return the object at the set position indicated by index.
538-     */
539-    public DEREncodable getObjectAt(
540-        int index)
541-    {
542-        return (DEREncodable)set.elementAt(index);
543-    }
544-
545-    /**
546-     * return the number of objects in this set.
547-     *
548-     * @return the number of objects in this set.
549-     */
550-    public int size()
551-    {
552-        return set.size();
553-    }
554+    // BEGIN android-removed
555+    // public Enumeration getObjects()
556+    // {
557+    //     return set.elements();
558+    // }
559+    //
560+    // /**
561+    //  * return the object at the set position indicated by index.
562+    //  *
563+    //  * @param index the set number (starting at zero) of the object
564+    //  * @return the object at the set position indicated by index.
565+    //  */
566+    // public DEREncodable getObjectAt(
567+    //     int index)
568+    // {
569+    //     return (DEREncodable)set.elementAt(index);
570+    // }
571+    //
572+    // /**
573+    //  * return the number of objects in this set.
574+    //  *
575+    //  * @return the number of objects in this set.
576+    //  */
577+    // public int size()
578+    // {
579+    //     return set.size();
580+    // }
581+    // END android-removed
582
583     public ASN1SetParser parser()
584     {
585@@ -168,23 +178,25 @@
586         };
587     }
588
589-    public int hashCode()
590-    {
591-        Enumeration             e = this.getObjects();
592-        int                     hashCode = size();
593-
594-        while (e.hasMoreElements())
595-        {
596-            Object o = e.nextElement();
597-            hashCode *= 17;
598-            if (o != null)
599-            {
600-                hashCode ^= o.hashCode();
601-            }
602-        }
603-
604-        return hashCode;
605-    }
606+    // BEGIN android-removed
607+    // public int hashCode()
608+    // {
609+    //     Enumeration             e = this.getObjects();
610+    //     int                     hashCode = size();
611+    //
612+    //     while (e.hasMoreElements())
613+    //     {
614+    //         Object o = e.nextElement();
615+    //         hashCode *= 17;
616+    //         if (o != null)
617+    //         {
618+    //             hashCode ^= o.hashCode();
619+    //         }
620+    //     }
621+    //
622+    //     return hashCode;
623+    // }
624+    // END android-removed
625
626     boolean asn1Equals(
627         DERObject  o)
628@@ -220,52 +232,54 @@
629         return true;
630     }
631
632-    /**
633-     * return true if a <= b (arrays are assumed padded with zeros).
634-     */
635-    private boolean lessThanOrEqual(
636-         byte[] a,
637-         byte[] b)
638-    {
639-         if (a.length <= b.length)
640-         {
641-             for (int i = 0; i != a.length; i++)
642-             {
643-                 int    l = a[i] & 0xff;
644-                 int    r = b[i] & 0xff;
645-
646-                 if (r > l)
647-                 {
648-                     return true;
649-                 }
650-                 else if (l > r)
651-                 {
652-                     return false;
653-                 }
654-             }
655-
656-             return true;
657-         }
658-         else
659-         {
660-             for (int i = 0; i != b.length; i++)
661-             {
662-                 int    l = a[i] & 0xff;
663-                 int    r = b[i] & 0xff;
664-
665-                 if (r > l)
666-                 {
667-                     return true;
668-                 }
669-                 else if (l > r)
670-                 {
671-                     return false;
672-                 }
673-             }
674-
675-             return false;
676-         }
677-    }
678+    // BEGIN android-removed
679+    // /**
680+    //  * return true if a <= b (arrays are assumed padded with zeros).
681+    //  */
682+    // private boolean lessThanOrEqual(
683+    //      byte[] a,
684+    //      byte[] b)
685+    // {
686+    //      if (a.length <= b.length)
687+    //      {
688+    //          for (int i = 0; i != a.length; i++)
689+    //          {
690+    //              int    l = a[i] & 0xff;
691+    //              int    r = b[i] & 0xff;
692+    //
693+    //              if (r > l)
694+    //              {
695+    //                  return true;
696+    //              }
697+    //              else if (l > r)
698+    //              {
699+    //                  return false;
700+    //              }
701+    //          }
702+    //
703+    //          return true;
704+    //      }
705+    //      else
706+    //      {
707+    //          for (int i = 0; i != b.length; i++)
708+    //          {
709+    //              int    l = a[i] & 0xff;
710+    //              int    r = b[i] & 0xff;
711+    //
712+    //              if (r > l)
713+    //              {
714+    //                  return true;
715+    //              }
716+    //              else if (l > r)
717+    //              {
718+    //                  return false;
719+    //              }
720+    //          }
721+    //
722+    //          return false;
723+    //      }
724+    // }
725+    // END android-removed
726
727     private byte[] getEncoded(
728         DEREncodable obj)
729@@ -285,59 +299,61 @@
730         return bOut.toByteArray();
731     }
732
733-    protected void sort()
734-    {
735-        if (set.size() > 1)
736-        {
737-            boolean    swapped = true;
738-            int        lastSwap = set.size() - 1;
739-
740-            while (swapped)
741-            {
742-                int    index = 0;
743-                int    swapIndex = 0;
744-                byte[] a = getEncoded((DEREncodable)set.elementAt(0));
745-
746-                swapped = false;
747-
748-                while (index != lastSwap)
749-                {
750-                    byte[] b = getEncoded((DEREncodable)set.elementAt(index + 1));
751-
752-                    if (lessThanOrEqual(a, b))
753-                    {
754-                        a = b;
755-                    }
756-                    else
757-                    {
758-                        Object  o = set.elementAt(index);
759-
760-                        set.setElementAt(set.elementAt(index + 1), index);
761-                        set.setElementAt(o, index + 1);
762-
763-                        swapped = true;
764-                        swapIndex = index;
765-                    }
766-
767-                    index++;
768-                }
769-
770-                lastSwap = swapIndex;
771-            }
772-        }
773-    }
774-
775-    protected void addObject(
776-        DEREncodable obj)
777-    {
778-        set.addElement(obj);
779-    }
780-
781-    abstract void encode(DEROutputStream out)
782-            throws IOException;
783-
784-    public String toString()
785-    {
786-      return set.toString();
787-    }
788+    // BEGIN android-removed
789+    // protected void sort()
790+    // {
791+    //     if (set.size() > 1)
792+    //     {
793+    //         boolean    swapped = true;
794+    //         int        lastSwap = set.size() - 1;
795+    //
796+    //         while (swapped)
797+    //         {
798+    //             int    index = 0;
799+    //             int    swapIndex = 0;
800+    //             byte[] a = getEncoded((DEREncodable)set.elementAt(0));
801+    //
802+    //             swapped = false;
803+    //
804+    //             while (index != lastSwap)
805+    //             {
806+    //                 byte[] b = getEncoded((DEREncodable)set.elementAt(index + 1));
807+    //
808+    //                 if (lessThanOrEqual(a, b))
809+    //                 {
810+    //                     a = b;
811+    //                 }
812+    //                 else
813+    //                 {
814+    //                     Object  o = set.elementAt(index);
815+    //
816+    //                     set.setElementAt(set.elementAt(index + 1), index);
817+    //                     set.setElementAt(o, index + 1);
818+    //
819+    //                     swapped = true;
820+    //                     swapIndex = index;
821+    //                 }
822+    //
823+    //                 index++;
824+    //             }
825+    //
826+    //             lastSwap = swapIndex;
827+    //         }
828+    //     }
829+    // }
830+    //
831+    // protected void addObject(
832+    //     DEREncodable obj)
833+    // {
834+    //     set.addElement(obj);
835+    // }
836+    //
837+    // abstract void encode(DEROutputStream out)
838+    //         throws IOException;
839+    //
840+    // public String toString()
841+    // {
842+    //   return set.toString();
843+    // }
844+    // END android-removed
845 }
846diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERBoolean.java bcprov-jdk16-145/org/bouncycastle/asn1/DERBoolean.java
847--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERBoolean.java	2010-01-11 21:46:14.000000000 +0000
848+++ bcprov-jdk16-145/org/bouncycastle/asn1/DERBoolean.java	2011-09-03 18:19:15.000000000 +0000
849@@ -5,7 +5,9 @@
850 public class DERBoolean
851     extends ASN1Object
852 {
853-    byte         value;
854+    // BEGIN android-changed
855+    private final byte  value;
856+    // END android-changed
857
858     public static final DERBoolean FALSE = new DERBoolean(false);
859     public static final DERBoolean TRUE  = new DERBoolean(true);
860@@ -25,7 +27,9 @@
861
862         if (obj instanceof ASN1OctetString)
863         {
864-            return new DERBoolean(((ASN1OctetString)obj).getOctets());
865+            // BEGIN android-changed
866+            return getInstance(((ASN1OctetString)obj).getOctets());
867+            // END android-changed
868         }
869
870         if (obj instanceof ASN1TaggedObject)
871@@ -45,6 +49,17 @@
872         return (value ? TRUE : FALSE);
873     }
874
875+    // BEGIN android-added
876+    /**
877+     * return a DERBoolean from the passed in array.
878+     */
879+    public static DERBoolean getInstance(
880+        byte[] octets)
881+    {
882+        return (octets[0] != 0) ? TRUE : FALSE;
883+    }
884+    // END android-added
885+
886     /**
887      * return a Boolean from a tagged object.
888      *
889@@ -60,18 +75,22 @@
890     {
891         return getInstance(obj.getObject());
892     }
893-
894-    public DERBoolean(
895-        byte[]       value)
896-    {
897-        this.value = value[0];
898-    }
899
900-    public DERBoolean(
901+    // BEGIN android-removed
902+    //private DERBoolean(
903+    //    byte[]       value)
904+    //{
905+    //    this.value = value[0];
906+    //}
907+    // END android-removed
908+
909+    // BEGIN android-changed
910+    private DERBoolean(
911         boolean     value)
912     {
913         this.value = (value) ? (byte)0xff : (byte)0;
914     }
915+    // END android-changed
916
917     public boolean isTrue()
918     {
919diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERInputStream.java bcprov-jdk16-145/org/bouncycastle/asn1/DERInputStream.java
920--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERInputStream.java	2010-01-11 21:46:14.000000000 +0000
921+++ bcprov-jdk16-145/org/bouncycastle/asn1/DERInputStream.java	2011-09-03 18:19:15.000000000 +0000
922@@ -144,7 +144,9 @@
923                 return new DERConstructedSet(v);
924             }
925         case BOOLEAN:
926-            return new DERBoolean(bytes);
927+            // BEGIN android-changed
928+            return DERBoolean.getInstance(bytes);
929+            // BEGIN android-changed
930         case INTEGER:
931             return new DERInteger(bytes);
932         case ENUMERATED:
933@@ -195,7 +197,9 @@
934                 {
935                     if ((tag & CONSTRUCTED) == 0)
936                     {
937-                        return new DERTaggedObject(false, tag & 0x1f, new DERNull());
938+                        // BEGIN android-changed
939+                        return new DERTaggedObject(false, tag & 0x1f, DERNull.INSTANCE);
940+                        // END android-changed
941                     }
942                     else
943                     {
944diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERNull.java bcprov-jdk16-145/org/bouncycastle/asn1/DERNull.java
945--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERNull.java	2010-01-11 21:46:14.000000000 +0000
946+++ bcprov-jdk16-145/org/bouncycastle/asn1/DERNull.java	2011-09-03 18:19:15.000000000 +0000
947@@ -10,9 +10,13 @@
948 {
949     public static final DERNull INSTANCE = new DERNull();
950
951-    byte[]  zeroBytes = new byte[0];
952+    // BEGIN android-changed
953+    private static final byte[]  zeroBytes = new byte[0];
954+    // END android-changed
955
956-    public DERNull()
957+    // BEGIN android-changed
958+    protected DERNull()
959+    // END android-changed
960     {
961     }
962
963diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERObjectIdentifier.java bcprov-jdk16-145/org/bouncycastle/asn1/DERObjectIdentifier.java
964--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERObjectIdentifier.java	2010-01-11 21:46:14.000000000 +0000
965+++ bcprov-jdk16-145/org/bouncycastle/asn1/DERObjectIdentifier.java	2011-09-03 18:19:15.000000000 +0000
966@@ -111,7 +111,13 @@
967             }
968         }
969
970-        this.identifier = objId.toString();
971+        // BEGIN android-changed
972+        /*
973+         * Intern the identifier so there aren't hundreds of duplicates
974+         * (in practice).
975+         */
976+        this.identifier = objId.toString().intern();
977+        // END android-changed
978     }
979
980     public DERObjectIdentifier(
981@@ -122,7 +128,13 @@
982             throw new IllegalArgumentException("string " + identifier + " not an OID");
983         }
984
985-        this.identifier = identifier;
986+        // BEGIN android-changed
987+        /*
988+         * Intern the identifier so there aren't hundreds of duplicates
989+         * (in practice).
990+         */
991+        this.identifier = identifier.intern();
992+        // END android-changed
993     }
994
995     public String getId()
996diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERPrintableString.java bcprov-jdk16-145/org/bouncycastle/asn1/DERPrintableString.java
997--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERPrintableString.java	2010-01-11 21:46:14.000000000 +0000
998+++ bcprov-jdk16-145/org/bouncycastle/asn1/DERPrintableString.java	2011-09-03 18:19:15.000000000 +0000
999@@ -9,7 +9,9 @@
1000     extends ASN1Object
1001     implements DERString
1002 {
1003-    String  string;
1004+    // BEGIN android-changed
1005+    private final String string;
1006+    // END android-changed
1007
1008     /**
1009      * return a printable string from the passed in object.
1010@@ -66,7 +68,9 @@
1011             cs[i] = (char)(string[i] & 0xff);
1012         }
1013
1014-        this.string = new String(cs);
1015+        // BEGIN android-changed
1016+        this.string = new String(cs).intern();
1017+        // END android-changed
1018     }
1019
1020     /**
1021@@ -95,7 +99,9 @@
1022             throw new IllegalArgumentException("string contains illegal characters");
1023         }
1024
1025-        this.string = string;
1026+        // BEGIN android-changed
1027+        this.string = string.intern();
1028+        // END android-changed
1029     }
1030
1031     public String getString()
1032diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/OrderedTable.java bcprov-jdk16-145/org/bouncycastle/asn1/OrderedTable.java
1033--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/OrderedTable.java	1970-01-01 00:00:00.000000000 +0000
1034+++ bcprov-jdk16-145/org/bouncycastle/asn1/OrderedTable.java	2011-09-03 18:19:15.000000000 +0000
1035@@ -0,0 +1,281 @@
1036+package org.bouncycastle.asn1;
1037+
1038+import java.util.Enumeration;
1039+import java.util.ConcurrentModificationException;
1040+
1041+// BEGIN android-note
1042+/*
1043+ * This is a new class that was synthesized from the observed
1044+ * requirement for a lookup table that preserves order. Since in
1045+ * practice the element count is typically very low, we just use a
1046+ * flat list rather than doing any hashing / bucketing.
1047+ */
1048+// END android-note
1049+
1050+/**
1051+ * Ordered lookup table. Instances of this class will keep up to four
1052+ * key-value pairs directly, resorting to an external collection only
1053+ * if more elements than that need to be stored.
1054+ */
1055+public final class OrderedTable {
1056+    /** null-ok; key #0 */
1057+    private DERObjectIdentifier key0;
1058+
1059+    /** null-ok; key #1 */
1060+    private DERObjectIdentifier key1;
1061+
1062+    /** null-ok; key #2 */
1063+    private DERObjectIdentifier key2;
1064+
1065+    /** null-ok; key #3 */
1066+    private DERObjectIdentifier key3;
1067+
1068+    /** null-ok; value #0 */
1069+    private Object value0;
1070+
1071+    /** null-ok; value #1 */
1072+    private Object value1;
1073+
1074+    /** null-ok; value #2 */
1075+    private Object value2;
1076+
1077+    /** null-ok; value #3 */
1078+    private Object value3;
1079+
1080+    /**
1081+     * null-ok; array of additional keys and values, alternating
1082+     * key then value, etc.
1083+     */
1084+    private Object[] rest;
1085+
1086+    /** &gt;= 0; number of elements in the list */
1087+    private int size;
1088+
1089+    // Note: Default public constructor.
1090+
1091+    /**
1092+     * Adds an element assuming no duplicate key.
1093+     *
1094+     * @see #put
1095+     *
1096+     * @param key non-null; the key
1097+     * @param value non-null; the value
1098+     */
1099+    public void add(DERObjectIdentifier key, Object value) {
1100+        if (key == null) {
1101+            throw new NullPointerException("key == null");
1102+        }
1103+
1104+        if (value == null) {
1105+            throw new NullPointerException("value == null");
1106+        }
1107+
1108+        int sz = size;
1109+
1110+        switch (sz) {
1111+            case 0: {
1112+                key0 = key;
1113+                value0 = value;
1114+                break;
1115+            }
1116+            case 1: {
1117+                key1 = key;
1118+                value1 = value;
1119+                break;
1120+            }
1121+            case 2: {
1122+                key2 = key;
1123+                value2 = value;
1124+                break;
1125+            }
1126+            case 3: {
1127+                key3 = key;
1128+                value3 = value;
1129+                break;
1130+            }
1131+            case 4: {
1132+                // Do initial allocation of rest.
1133+                rest = new Object[10];
1134+                rest[0] = key;
1135+                rest[1] = value;
1136+                break;
1137+            }
1138+            default: {
1139+                int index = (sz - 4) * 2;
1140+                int index1 = index + 1;
1141+                if (index1 >= rest.length) {
1142+                    // Grow rest.
1143+                    Object[] newRest = new Object[index1 * 2 + 10];
1144+                    System.arraycopy(rest, 0, newRest, 0, rest.length);
1145+                    rest = newRest;
1146+                }
1147+                rest[index] = key;
1148+                rest[index1] = value;
1149+                break;
1150+            }
1151+        }
1152+
1153+        size = sz + 1;
1154+    }
1155+
1156+    /**
1157+     * Gets the number of elements in this instance.
1158+     */
1159+    public int size() {
1160+        return size;
1161+    }
1162+
1163+    /**
1164+     * Look up the given key, returning the associated value if found.
1165+     *
1166+     * @param key non-null; the key to look up
1167+     * @return null-ok; the associated value
1168+     */
1169+    public Object get(DERObjectIdentifier key) {
1170+        int keyHash = key.hashCode();
1171+        int sz = size;
1172+
1173+        for (int i = 0; i < size; i++) {
1174+            DERObjectIdentifier probe = getKey(i);
1175+            if ((probe.hashCode() == keyHash) &&
1176+                    probe.equals(key)) {
1177+                return getValue(i);
1178+            }
1179+        }
1180+
1181+        return null;
1182+    }
1183+
1184+    /**
1185+     * Replace a key if present, otherwise add
1186+     *
1187+     * @see #add
1188+     *
1189+     * @param key non-null; the key
1190+     * @param value non-null; the value
1191+     */
1192+    public void put(DERObjectIdentifier key, Object value) {
1193+        if (key == null) {
1194+            throw new NullPointerException("key == null");
1195+        }
1196+
1197+        if (value == null) {
1198+            throw new NullPointerException("value == null");
1199+        }
1200+
1201+        int keyHash = key.hashCode();
1202+        int sz = size;
1203+
1204+        for (int i = 0; i < size; i++) {
1205+            DERObjectIdentifier probe = getKey(i);
1206+            if ((probe.hashCode() == keyHash) &&
1207+                    probe.equals(key)) {
1208+                setValue(i, value);
1209+                return;
1210+            }
1211+        }
1212+
1213+        add(key, value);
1214+    }
1215+
1216+    /**
1217+     * Gets the nth key.
1218+     *
1219+     * @param n index
1220+     * @return non-null; the nth key
1221+     */
1222+    public DERObjectIdentifier getKey(int n) {
1223+        if ((n < 0) || (n >= size)) {
1224+            throw new IndexOutOfBoundsException(Integer.toString(n));
1225+        }
1226+
1227+        switch (n) {
1228+            case 0: return key0;
1229+            case 1: return key1;
1230+            case 2: return key2;
1231+            case 3: return key3;
1232+            default: return (DERObjectIdentifier) rest[(n - 4) * 2];
1233+        }
1234+    }
1235+
1236+    /**
1237+     * Gets the nth value.
1238+     *
1239+     * @param n index
1240+     * @return non-null; the nth value
1241+     */
1242+    public Object getValue(int n) {
1243+        if ((n < 0) || (n >= size)) {
1244+            throw new IndexOutOfBoundsException(Integer.toString(n));
1245+        }
1246+
1247+        switch (n) {
1248+            case 0: return value0;
1249+            case 1: return value1;
1250+            case 2: return value2;
1251+            case 3: return value3;
1252+            default: return rest[((n - 4) * 2) + 1];
1253+        }
1254+    }
1255+
1256+    /**
1257+     * Sets the nth value.
1258+     *
1259+     * @param n index
1260+     * @param value non-null object
1261+     */
1262+    public void setValue(int n, Object value) {
1263+        if ((n < 0) || (n >= size)) {
1264+            throw new IndexOutOfBoundsException(Integer.toString(n));
1265+        }
1266+        if (value == null) {
1267+            throw new NullPointerException("value == null");
1268+        }
1269+
1270+        switch (n) {
1271+            case 0: value0 = value; return;
1272+            case 1: value1 = value; return;
1273+            case 2: value2 = value; return;
1274+            case 3: value3 = value; return;
1275+            default: rest[((n - 4) * 2) + 1] = value; return;
1276+        }
1277+    }
1278+
1279+    /**
1280+     * Gets an enumeration of the keys, in order.
1281+     *
1282+     * @return non-null; an enumeration of the keys
1283+     */
1284+    public Enumeration getKeys() {
1285+        return new KeyEnumeration();
1286+    }
1287+
1288+    /**
1289+     * Associated enumeration class.
1290+     */
1291+    private class KeyEnumeration implements Enumeration {
1292+        /** original size; used for modification detection */
1293+        private final int origSize = size;
1294+
1295+        /** &gt;= 0; current cursor */
1296+        private int at = 0;
1297+
1298+        /** {@inheritDoc} */
1299+        public boolean hasMoreElements() {
1300+            if (size != origSize) {
1301+                throw new ConcurrentModificationException();
1302+            }
1303+
1304+            return at < origSize;
1305+        }
1306+
1307+        /** {@inheritDoc} */
1308+        public Object nextElement() {
1309+            if (size != origSize) {
1310+                throw new ConcurrentModificationException();
1311+            }
1312+
1313+            return getKey(at++);
1314+        }
1315+    }
1316+}
1317diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java
1318--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java	2010-01-11 21:46:14.000000000 +0000
1319+++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java	2011-09-03 18:19:15.000000000 +0000
1320@@ -10,7 +10,10 @@
1321     //
1322     static final String                 pkcs_1                    = "1.2.840.113549.1.1";
1323     static final DERObjectIdentifier    rsaEncryption             = new DERObjectIdentifier(pkcs_1 + ".1");
1324-    static final DERObjectIdentifier    md2WithRSAEncryption      = new DERObjectIdentifier(pkcs_1 + ".2");
1325+    // BEGIN android-removed
1326+    // Dropping MD2
1327+    // static final DERObjectIdentifier    md2WithRSAEncryption      = new DERObjectIdentifier(pkcs_1 + ".2");
1328+    // END android-removed
1329     static final DERObjectIdentifier    md4WithRSAEncryption      = new DERObjectIdentifier(pkcs_1 + ".3");
1330     static final DERObjectIdentifier    md5WithRSAEncryption      = new DERObjectIdentifier(pkcs_1 + ".4");
1331     static final DERObjectIdentifier    sha1WithRSAEncryption     = new DERObjectIdentifier(pkcs_1 + ".5");
1332@@ -65,7 +68,10 @@
1333     // md2 OBJECT IDENTIFIER ::=
1334     //      {iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 2}
1335     //
1336-    static final DERObjectIdentifier    md2                     = new DERObjectIdentifier(digestAlgorithm + ".2");
1337+    // BEGIN android-removed
1338+    // Dropping MD2
1339+    // static final DERObjectIdentifier    md2                     = new DERObjectIdentifier(digestAlgorithm + ".2");
1340+    // END android-removed
1341
1342     //
1343     // md4 OBJECT IDENTIFIER ::=
1344diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java
1345--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java	2010-01-11 21:46:14.000000000 +0000
1346+++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java	2011-09-03 18:19:15.000000000 +0000
1347@@ -19,7 +19,9 @@
1348     private AlgorithmIdentifier maskGenAlgorithm;
1349     private AlgorithmIdentifier pSourceAlgorithm;
1350
1351-    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
1352+    // BEGIN android-changed
1353+    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
1354+    // END android-changed
1355     public final static AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, DEFAULT_HASH_ALGORITHM);
1356     public final static AlgorithmIdentifier DEFAULT_P_SOURCE_ALGORITHM = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(new byte[0]));
1357
1358diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java
1359--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java	2010-01-11 21:46:14.000000000 +0000
1360+++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java	2011-09-03 18:19:15.000000000 +0000
1361@@ -20,7 +20,9 @@
1362     private DERInteger          saltLength;
1363     private DERInteger          trailerField;
1364
1365-    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
1366+    // BEGIN android-changed
1367+    public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
1368+    // END android-changed
1369     public final static AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, DEFAULT_HASH_ALGORITHM);
1370     public final static DERInteger          DEFAULT_SALT_LENGTH = new DERInteger(20);
1371     public final static DERInteger          DEFAULT_TRAILER_FIELD = new DERInteger(1);
1372diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/util/ASN1Dump.java bcprov-jdk16-145/org/bouncycastle/asn1/util/ASN1Dump.java
1373--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/util/ASN1Dump.java	2010-01-11 21:46:14.000000000 +0000
1374+++ bcprov-jdk16-145/org/bouncycastle/asn1/util/ASN1Dump.java	2011-09-03 18:19:15.000000000 +0000
1375@@ -90,7 +90,9 @@
1376             {
1377                 Object  o = e.nextElement();
1378
1379-                if (o == null || o.equals(new DERNull()))
1380+                // BEGIN android-changed
1381+                if (o == null || o.equals(DERNull.INSTANCE))
1382+                // END android-changed
1383                 {
1384                     buf.append(tab);
1385                     buf.append("NULL");
1386diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/AttCertIssuer.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/AttCertIssuer.java
1387--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/AttCertIssuer.java	2010-01-11 21:46:14.000000000 +0000
1388+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/AttCertIssuer.java	2011-09-03 18:19:15.000000000 +0000
1389@@ -45,7 +45,7 @@
1390         ASN1TaggedObject obj,
1391         boolean          explicit)
1392     {
1393-        return getInstance(obj.getObject()); // must be explictly tagged
1394+        return getInstance(obj.getObject()); // must be explicitly tagged
1395     }
1396
1397     /**
1398diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/BasicConstraints.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/BasicConstraints.java
1399--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/BasicConstraints.java	2010-01-11 21:46:14.000000000 +0000
1400+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/BasicConstraints.java	2011-09-03 18:19:15.000000000 +0000
1401@@ -14,7 +14,9 @@
1402 public class BasicConstraints
1403     extends ASN1Encodable
1404 {
1405-    DERBoolean  cA = new DERBoolean(false);
1406+    // BEGIN android-changed
1407+    DERBoolean  cA = DERBoolean.FALSE;
1408+    // END android-changed
1409     DERInteger  pathLenConstraint = null;
1410
1411     public static BasicConstraints getInstance(
1412@@ -89,7 +91,9 @@
1413     {
1414         if (cA)
1415         {
1416-            this.cA = new DERBoolean(cA);
1417+            // BEGIN android-changed
1418+            this.cA = DERBoolean.getInstance(cA);
1419+            // END android-changed
1420             this.pathLenConstraint = new DERInteger(pathLenConstraint);
1421         }
1422         else
1423@@ -104,7 +108,9 @@
1424     {
1425         if (cA)
1426         {
1427-            this.cA = new DERBoolean(true);
1428+            // BEGIN android-changed
1429+            this.cA = DERBoolean.TRUE;
1430+            // END android-changed
1431         }
1432         else
1433         {
1434@@ -121,7 +127,9 @@
1435     public BasicConstraints(
1436         int     pathLenConstraint)
1437     {
1438-        this.cA = new DERBoolean(true);
1439+        // BEGIN android-changed
1440+        this.cA = DERBoolean.TRUE;
1441+        // END android-changed
1442         this.pathLenConstraint = new DERInteger(pathLenConstraint);
1443     }
1444
1445diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java
1446--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java	2010-01-11 21:46:14.000000000 +0000
1447+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java	2011-09-03 18:19:15.000000000 +0000
1448@@ -96,11 +96,15 @@
1449         }
1450         if (onlyContainsUserCerts)
1451         {
1452-            vec.add(new DERTaggedObject(false, 1, new DERBoolean(true)));
1453+            // BEGIN android-changed
1454+            vec.add(new DERTaggedObject(false, 1, DERBoolean.TRUE));
1455+            // END android-changed
1456         }
1457         if (onlyContainsCACerts)
1458         {
1459-            vec.add(new DERTaggedObject(false, 2, new DERBoolean(true)));
1460+            // BEGIN android-changed
1461+            vec.add(new DERTaggedObject(false, 2, DERBoolean.TRUE));
1462+            // END android-changed
1463         }
1464         if (onlySomeReasons != null)
1465         {
1466@@ -108,11 +112,15 @@
1467         }
1468         if (indirectCRL)
1469         {
1470-            vec.add(new DERTaggedObject(false, 4, new DERBoolean(true)));
1471+            // BEGIN android-changed
1472+            vec.add(new DERTaggedObject(false, 4, DERBoolean.TRUE));
1473+            // END android-changed
1474         }
1475         if (onlyContainsAttributeCerts)
1476         {
1477-            vec.add(new DERTaggedObject(false, 5, new DERBoolean(true)));
1478+            // BEGIN android-changed
1479+            vec.add(new DERTaggedObject(false, 5, DERBoolean.TRUE));
1480+            // END android-changed
1481         }
1482
1483         seq = new DERSequence(vec);
1484diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Extensions.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Extensions.java
1485--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Extensions.java	2010-01-11 21:46:14.000000000 +0000
1486+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Extensions.java	2011-09-03 18:19:15.000000000 +0000
1487@@ -9,6 +9,9 @@
1488 import org.bouncycastle.asn1.DERObject;
1489 import org.bouncycastle.asn1.DERObjectIdentifier;
1490 import org.bouncycastle.asn1.DERSequence;
1491+// BEGIN android-added
1492+import org.bouncycastle.asn1.OrderedTable;
1493+// END android-added
1494
1495 import java.util.Enumeration;
1496 import java.util.Hashtable;
1497@@ -172,8 +175,9 @@
1498      */
1499     public static final DERObjectIdentifier TargetInformation = new DERObjectIdentifier("2.5.29.55");
1500
1501-    private Hashtable               extensions = new Hashtable();
1502-    private Vector                  ordering = new Vector();
1503+    // BEGIN android-changed
1504+    private OrderedTable table = new OrderedTable();
1505+    // END android-changed
1506
1507     public static X509Extensions getInstance(
1508         ASN1TaggedObject obj,
1509@@ -217,20 +221,26 @@
1510         {
1511             ASN1Sequence            s = ASN1Sequence.getInstance(e.nextElement());
1512
1513-            if (s.size() == 3)
1514+            // BEGIN android-changed
1515+            int sSize = s.size();
1516+            DERObjectIdentifier key = (DERObjectIdentifier) s.getObjectAt(0);
1517+            Object value;
1518+
1519+            if (sSize == 3)
1520             {
1521-                extensions.put(s.getObjectAt(0), new X509Extension(DERBoolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))));
1522+                value = new X509Extension(DERBoolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2)));
1523             }
1524-            else if (s.size() == 2)
1525+            else if (sSize == 2)
1526             {
1527-                extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
1528+                value = new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1)));
1529             }
1530             else
1531             {
1532-                throw new IllegalArgumentException("Bad sequence size: " + s.size());
1533+                throw new IllegalArgumentException("Bad sequence size: " + sSize);
1534             }
1535
1536-            ordering.addElement(s.getObjectAt(0));
1537+            table.add(key, value);
1538+            // END android-changed
1539         }
1540     }
1541
1542@@ -265,20 +275,14 @@
1543             e = ordering.elements();
1544         }
1545
1546-        while (e.hasMoreElements())
1547-        {
1548-            this.ordering.addElement(e.nextElement());
1549-        }
1550-
1551-        e = this.ordering.elements();
1552-
1553+        // BEGIN android-changed
1554         while (e.hasMoreElements())
1555         {
1556             DERObjectIdentifier     oid = (DERObjectIdentifier)e.nextElement();
1557             X509Extension           ext = (X509Extension)extensions.get(oid);
1558-
1559-            this.extensions.put(oid, ext);
1560+            table.add(oid, ext);
1561         }
1562+        // END android-changed
1563     }
1564
1565     /**
1566@@ -293,23 +297,18 @@
1567     {
1568         Enumeration e = objectIDs.elements();
1569
1570-        while (e.hasMoreElements())
1571-        {
1572-            this.ordering.addElement(e.nextElement());
1573-        }
1574-
1575+        // BEGIN android-changed
1576         int count = 0;
1577
1578-        e = this.ordering.elements();
1579-
1580         while (e.hasMoreElements())
1581         {
1582             DERObjectIdentifier     oid = (DERObjectIdentifier)e.nextElement();
1583             X509Extension           ext = (X509Extension)values.elementAt(count);
1584
1585-            this.extensions.put(oid, ext);
1586+            table.add(oid, ext);
1587             count++;
1588         }
1589+        // END android-changed
1590     }
1591
1592     /**
1593@@ -317,7 +316,9 @@
1594      */
1595     public Enumeration oids()
1596     {
1597-        return ordering.elements();
1598+        // BEGIN android-changed
1599+        return table.getKeys();
1600+        // END android-changed
1601     }
1602
1603     /**
1604@@ -329,7 +330,9 @@
1605     public X509Extension getExtension(
1606         DERObjectIdentifier oid)
1607     {
1608-        return (X509Extension)extensions.get(oid);
1609+        // BEGIN android-changed
1610+        return (X509Extension)table.get(oid);
1611+        // END android-changed
1612     }
1613
1614     /**
1615@@ -345,19 +348,23 @@
1616     public DERObject toASN1Object()
1617     {
1618         ASN1EncodableVector     vec = new ASN1EncodableVector();
1619-        Enumeration             e = ordering.elements();
1620+        // BEGIN android-changed
1621+        int                     size = table.size();
1622
1623-        while (e.hasMoreElements())
1624+        for (int i = 0; i < size; i++)
1625         {
1626-            DERObjectIdentifier     oid = (DERObjectIdentifier)e.nextElement();
1627-            X509Extension           ext = (X509Extension)extensions.get(oid);
1628+            DERObjectIdentifier     oid = table.getKey(i);
1629+            X509Extension           ext = (X509Extension)table.getValue(i);
1630+            // END android-changed
1631             ASN1EncodableVector     v = new ASN1EncodableVector();
1632
1633             v.add(oid);
1634
1635             if (ext.isCritical())
1636             {
1637-                v.add(new DERBoolean(true));
1638+                // BEGIN android-changed
1639+                v.add(DERBoolean.TRUE);
1640+                // END android-changed
1641             }
1642
1643             v.add(ext.getValue());
1644@@ -371,18 +378,24 @@
1645     public boolean equivalent(
1646         X509Extensions other)
1647     {
1648-        if (extensions.size() != other.extensions.size())
1649+        // BEGIN android-changed
1650+        if (table.size() != other.table.size())
1651+        // END android-changed
1652         {
1653             return false;
1654         }
1655
1656-        Enumeration     e1 = extensions.keys();
1657+        // BEGIN android-changed
1658+        Enumeration     e1 = table.getKeys();
1659+        // END android-changed
1660
1661         while (e1.hasMoreElements())
1662         {
1663-            Object  key = e1.nextElement();
1664+            // BEGIN android-changed
1665+            DERObjectIdentifier  key = (DERObjectIdentifier)e1.nextElement();
1666
1667-            if (!extensions.get(key).equals(other.extensions.get(key)))
1668+            if (!table.get(key).equals(other.table.get(key)))
1669+            // END android-changed
1670             {
1671                 return false;
1672             }
1673diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Name.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Name.java
1674--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Name.java	2010-01-11 21:46:14.000000000 +0000
1675+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Name.java	2011-09-03 18:19:15.000000000 +0000
1676@@ -247,8 +247,10 @@
1677      */
1678     public static final Hashtable SymbolLookUp = DefaultLookUp;
1679
1680-    private static final Boolean TRUE = new Boolean(true); // for J2ME compatibility
1681-    private static final Boolean FALSE = new Boolean(false);
1682+    // BEGIN android-removed
1683+    //private static final Boolean TRUE = new Boolean(true); // for J2ME compatibility
1684+    //private static final Boolean FALSE = new Boolean(false);
1685+    // END android-removed
1686
1687     static
1688     {
1689@@ -340,9 +342,9 @@
1690     }
1691
1692     private X509NameEntryConverter  converter = null;
1693-    private Vector                  ordering = new Vector();
1694-    private Vector                  values = new Vector();
1695-    private Vector                  added = new Vector();
1696+    // BEGIN android-changed
1697+    private X509NameElementList     elems = new X509NameElementList();
1698+    // END android-changed
1699
1700     private ASN1Sequence            seq;
1701
1702@@ -403,26 +405,30 @@
1703                        throw new IllegalArgumentException("badly sized pair");
1704                    }
1705
1706-                   ordering.addElement(DERObjectIdentifier.getInstance(s.getObjectAt(0)));
1707+                   // BEGIN android-changed
1708+                   DERObjectIdentifier key = DERObjectIdentifier.getInstance(s.getObjectAt(0));
1709
1710                    DEREncodable value = s.getObjectAt(1);
1711+                   String valueStr;
1712                    if (value instanceof DERString && !(value instanceof DERUniversalString))
1713                    {
1714                        String v = ((DERString)value).getString();
1715                        if (v.length() > 0 && v.charAt(0) == '#')
1716                        {
1717-                           values.addElement("\\" + v);
1718+                           valueStr = "\\" + v;
1719                        }
1720                        else
1721                        {
1722-                           values.addElement(v);
1723+                           valueStr = v;
1724                        }
1725                    }
1726                    else
1727                    {
1728-                       values.addElement("#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded())));
1729+                       valueStr = "#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded()));
1730                    }
1731-                   added.addElement((i != 0) ? TRUE : FALSE);  // to allow earlier JDK compatibility
1732+                   boolean added = (i != 0);  // to allow earlier JDK compatibility
1733+                   elems.add(key, valueStr, added);
1734+                   // END android-changed
1735             }
1736         }
1737     }
1738@@ -476,14 +482,23 @@
1739         Hashtable                attributes,
1740         X509NameEntryConverter   converter)
1741     {
1742+        // BEGIN android-changed
1743+        DERObjectIdentifier problem = null;
1744         this.converter = converter;
1745
1746         if (ordering != null)
1747         {
1748             for (int i = 0; i != ordering.size(); i++)
1749             {
1750-                this.ordering.addElement(ordering.elementAt(i));
1751-                this.added.addElement(FALSE);
1752+                DERObjectIdentifier key =
1753+                    (DERObjectIdentifier) ordering.elementAt(i);
1754+                String value = (String) attributes.get(key);
1755+                if (value == null)
1756+                {
1757+                    problem = key;
1758+                    break;
1759+                }
1760+                elems.add(key, value);
1761             }
1762         }
1763         else
1764@@ -492,22 +507,23 @@
1765
1766             while (e.hasMoreElements())
1767             {
1768-                this.ordering.addElement(e.nextElement());
1769-                this.added.addElement(FALSE);
1770+                DERObjectIdentifier key =
1771+                    (DERObjectIdentifier) e.nextElement();
1772+                String value = (String) attributes.get(key);
1773+                if (value == null)
1774+                {
1775+                    problem = key;
1776+                    break;
1777+                }
1778+                elems.add(key, value);
1779             }
1780         }
1781
1782-        for (int i = 0; i != this.ordering.size(); i++)
1783+        if (problem != null)
1784         {
1785-            DERObjectIdentifier     oid = (DERObjectIdentifier)this.ordering.elementAt(i);
1786-
1787-            if (attributes.get(oid) == null)
1788-            {
1789-                throw new IllegalArgumentException("No attribute for object id - " + oid.getId() + " - passed to distinguished name");
1790-            }
1791-
1792-            this.values.addElement(attributes.get(oid)); // copy the hash table
1793+            throw new IllegalArgumentException("No attribute for object id - " + problem.getId() + " - passed to distinguished name");
1794         }
1795+        // END android-changed
1796     }
1797
1798     /**
1799@@ -540,9 +556,10 @@
1800
1801         for (int i = 0; i < oids.size(); i++)
1802         {
1803-            this.ordering.addElement(oids.elementAt(i));
1804-            this.values.addElement(values.elementAt(i));
1805-            this.added.addElement(FALSE);
1806+            // BEGIN android-changed
1807+            elems.add((DERObjectIdentifier) oids.elementAt(i),
1808+                    (String) values.elementAt(i));
1809+            // END android-changed
1810         }
1811     }
1812
1813@@ -679,7 +696,7 @@
1814
1815             if (index == -1)
1816             {
1817-                throw new IllegalArgumentException("badly formated directory string");
1818+                throw new IllegalArgumentException("badly formatted directory string");
1819             }
1820
1821             String              name = token.substring(0, index);
1822@@ -691,9 +708,9 @@
1823                 X509NameTokenizer   vTok = new X509NameTokenizer(value, '+');
1824                 String  v = vTok.nextToken();
1825
1826-                this.ordering.addElement(oid);
1827-                this.values.addElement(v);
1828-                this.added.addElement(FALSE);
1829+                // BEGIN android-changed
1830+                this.elems.add(oid, v);
1831+                // END android-changed
1832
1833                 while (vTok.hasMoreTokens())
1834                 {
1835@@ -702,48 +719,24 @@
1836
1837                     String  nm = sv.substring(0, ndx);
1838                     String  vl = sv.substring(ndx + 1);
1839-                    this.ordering.addElement(decodeOID(nm, lookUp));
1840-                    this.values.addElement(vl);
1841-                    this.added.addElement(TRUE);
1842+                    // BEGIN android-changed
1843+                    this.elems.add(decodeOID(nm, lookUp), vl, true);
1844+                    // END android-changed
1845                 }
1846             }
1847             else
1848             {
1849-                this.ordering.addElement(oid);
1850-                this.values.addElement(value);
1851-                this.added.addElement(FALSE);
1852+                // BEGIN android-changed
1853+                this.elems.add(oid, value);
1854+                // END android-changed
1855             }
1856         }
1857
1858         if (reverse)
1859         {
1860-            Vector  o = new Vector();
1861-            Vector  v = new Vector();
1862-            Vector  a = new Vector();
1863-
1864-            int count = 1;
1865-
1866-            for (int i = 0; i < this.ordering.size(); i++)
1867-            {
1868-                if (((Boolean)this.added.elementAt(i)).booleanValue())
1869-                {
1870-                    o.insertElementAt(this.ordering.elementAt(i), count);
1871-                    v.insertElementAt(this.values.elementAt(i), count);
1872-                    a.insertElementAt(this.added.elementAt(i), count);
1873-                    count++;
1874-                }
1875-                else
1876-                {
1877-                    o.insertElementAt(this.ordering.elementAt(i), 0);
1878-                    v.insertElementAt(this.values.elementAt(i), 0);
1879-                    a.insertElementAt(this.added.elementAt(i), 0);
1880-                    count = 1;
1881-                }
1882-            }
1883-
1884-            this.ordering = o;
1885-            this.values = v;
1886-            this.added = a;
1887+            // BEGIN android-changed
1888+            this.elems = this.elems.reverse();
1889+            // END android-changed
1890         }
1891     }
1892
1893@@ -752,14 +745,17 @@
1894      */
1895     public Vector getOIDs()
1896     {
1897+        // BEGIN android-changed
1898         Vector  v = new Vector();
1899+        int     size = elems.size();
1900
1901-        for (int i = 0; i != ordering.size(); i++)
1902+        for (int i = 0; i < size; i++)
1903         {
1904-            v.addElement(ordering.elementAt(i));
1905+            v.addElement(elems.getKey(i));
1906         }
1907
1908         return v;
1909+        // END android-changed
1910     }
1911
1912     /**
1913@@ -769,11 +765,14 @@
1914     public Vector getValues()
1915     {
1916         Vector  v = new Vector();
1917+        // BEGIN android-changed
1918+        int     size = elems.size();
1919
1920-        for (int i = 0; i != values.size(); i++)
1921+        for (int i = 0; i != size; i++)
1922         {
1923-            v.addElement(values.elementAt(i));
1924+            v.addElement(elems.getValue(i));
1925         }
1926+        // END android-changed
1927
1928         return v;
1929     }
1930@@ -786,12 +785,14 @@
1931         DERObjectIdentifier oid)
1932     {
1933         Vector  v = new Vector();
1934+        int     size = elems.size();
1935+        // BEGIN android-changed
1936
1937-        for (int i = 0; i != values.size(); i++)
1938+        for (int i = 0; i != size; i++)
1939         {
1940-            if (ordering.elementAt(i).equals(oid))
1941+            if (elems.getKey(i).equals(oid))
1942             {
1943-                String val = (String)values.elementAt(i);
1944+                String val = elems.getValue(i);
1945
1946                 if (val.length() > 2 && val.charAt(0) == '\\' && val.charAt(1) == '#')
1947                 {
1948@@ -803,6 +804,7 @@
1949                 }
1950             }
1951         }
1952+        // END android-changed
1953
1954         return v;
1955     }
1956@@ -814,20 +816,23 @@
1957             ASN1EncodableVector  vec = new ASN1EncodableVector();
1958             ASN1EncodableVector  sVec = new ASN1EncodableVector();
1959             DERObjectIdentifier  lstOid = null;
1960+            // BEGIN android-changed
1961+            int                  size = elems.size();
1962
1963-            for (int i = 0; i != ordering.size(); i++)
1964+            for (int i = 0; i != size; i++)
1965             {
1966                 ASN1EncodableVector     v = new ASN1EncodableVector();
1967-                DERObjectIdentifier     oid = (DERObjectIdentifier)ordering.elementAt(i);
1968+                DERObjectIdentifier     oid = elems.getKey(i);
1969
1970                 v.add(oid);
1971
1972-                String  str = (String)values.elementAt(i);
1973+                String  str = elems.getValue(i);
1974
1975                 v.add(converter.getConvertedValue(oid, str));
1976
1977                 if (lstOid == null
1978-                    || ((Boolean)this.added.elementAt(i)).booleanValue())
1979+                    || this.elems.getAdded(i))
1980+                // END android-changed
1981                 {
1982                     sVec.add(new DERSequence(v));
1983                 }
1984@@ -845,6 +850,7 @@
1985             vec.add(new DERSet(sVec));
1986
1987             seq = new DERSequence(vec);
1988+            // END android-changed
1989         }
1990
1991         return seq;
1992@@ -889,22 +895,28 @@
1993             return false;
1994         }
1995
1996-        int      orderingSize = ordering.size();
1997+        // BEGIN android-changed
1998+        int      orderingSize = elems.size();
1999
2000-        if (orderingSize != other.ordering.size())
2001+        if (orderingSize != other.elems.size())
2002+        // END android-changed
2003         {
2004             return false;
2005         }
2006
2007         for (int i = 0; i < orderingSize; i++)
2008         {
2009-            DERObjectIdentifier  oid = (DERObjectIdentifier)ordering.elementAt(i);
2010-            DERObjectIdentifier  oOid = (DERObjectIdentifier)other.ordering.elementAt(i);
2011+            // BEGIN android-changed
2012+            DERObjectIdentifier  oid = elems.getKey(i);
2013+            DERObjectIdentifier  oOid = other.elems.getKey(i);
2014+            // END android-changed
2015
2016             if (oid.equals(oOid))
2017             {
2018-                String value = (String)values.elementAt(i);
2019-                String oValue = (String)other.values.elementAt(i);
2020+                // BEGIN android-changed
2021+                String value = elems.getValue(i);
2022+                String oValue = other.elems.getValue(i);
2023+                // END android-changed
2024
2025                 if (!equivalentStrings(value, oValue))
2026                 {
2027@@ -930,9 +942,9 @@
2028         isHashCodeCalculated = true;
2029
2030         // this needs to be order independent, like equals
2031-        for (int i = 0; i != ordering.size(); i += 1)
2032+        for (int i = 0; i != elems.size(); i += 1)
2033         {
2034-            String value = (String)values.elementAt(i);
2035+            String value = (String)elems.getValue(i);
2036
2037             value = canonicalize(value);
2038             value = stripInternalSpaces(value);
2039@@ -976,9 +988,11 @@
2040             return false;
2041         }
2042
2043-        int      orderingSize = ordering.size();
2044+        // BEGIN android-changed
2045+        int      orderingSize = elems.size();
2046
2047-        if (orderingSize != other.ordering.size())
2048+        if (orderingSize != other.elems.size())
2049+            // END android-changed
2050         {
2051             return false;
2052         }
2053@@ -986,7 +1000,9 @@
2054         boolean[] indexes = new boolean[orderingSize];
2055         int       start, end, delta;
2056
2057-        if (ordering.elementAt(0).equals(other.ordering.elementAt(0)))   // guess forward
2058+        // BEGIN android-changed
2059+        if (elems.getKey(0).equals(other.elems.getKey(0)))   // guess forward
2060+        // END android-changed
2061         {
2062             start = 0;
2063             end = orderingSize;
2064@@ -1002,8 +1018,10 @@
2065         for (int i = start; i != end; i += delta)
2066         {
2067             boolean              found = false;
2068-            DERObjectIdentifier  oid = (DERObjectIdentifier)ordering.elementAt(i);
2069-            String               value = (String)values.elementAt(i);
2070+            // BEGIN android-changed
2071+            DERObjectIdentifier  oid = elems.getKey(i);
2072+            String               value = elems.getValue(i);
2073+            // END android-changed
2074
2075             for (int j = 0; j < orderingSize; j++)
2076             {
2077@@ -1012,11 +1030,15 @@
2078                     continue;
2079                 }
2080
2081-                DERObjectIdentifier oOid = (DERObjectIdentifier)other.ordering.elementAt(j);
2082+                // BEGIN android-changed
2083+                DERObjectIdentifier oOid = other.elems.getKey(j);
2084+                // END android-changed
2085
2086                 if (oid.equals(oOid))
2087                 {
2088-                    String oValue = (String)other.values.elementAt(j);
2089+                    // BEGIN android-changed
2090+                    String oValue = other.elems.getValue(j);
2091+                    // END android-changed
2092
2093                     if (equivalentStrings(value, oValue))
2094                     {
2095@@ -1181,28 +1203,36 @@
2096
2097         StringBuffer ava = null;
2098
2099-        for (int i = 0; i < ordering.size(); i++)
2100+        // BEGIN android-changed
2101+        for (int i = 0; i < elems.size(); i++)
2102+        // END android-changed
2103         {
2104-            if (((Boolean)added.elementAt(i)).booleanValue())
2105+            if (elems.getAdded(i))
2106             {
2107                 ava.append('+');
2108                 appendValue(ava, oidSymbols,
2109-                    (DERObjectIdentifier)ordering.elementAt(i),
2110-                    (String)values.elementAt(i));
2111+                    // BEGIN android-changed
2112+                    elems.getKey(i),
2113+                    elems.getValue(i));
2114+                    // END android-changed
2115             }
2116             else
2117             {
2118                 ava = new StringBuffer();
2119                 appendValue(ava, oidSymbols,
2120-                    (DERObjectIdentifier)ordering.elementAt(i),
2121-                    (String)values.elementAt(i));
2122+                    // BEGIN android-changed
2123+                    elems.getKey(i),
2124+                    elems.getValue(i));
2125+                    // END android-changed
2126                 components.addElement(ava);
2127             }
2128         }
2129
2130         if (reverse)
2131         {
2132-            for (int i = components.size() - 1; i >= 0; i--)
2133+            // BEGIN android-changed
2134+            for (int i = elems.size() - 1; i >= 0; i--)
2135+            // END android-changed
2136             {
2137                 if (first)
2138                 {
2139diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameElementList.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameElementList.java
2140--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameElementList.java	1970-01-01 00:00:00.000000000 +0000
2141+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameElementList.java	2011-09-03 18:19:15.000000000 +0000
2142@@ -0,0 +1,206 @@
2143+package org.bouncycastle.asn1.x509;
2144+
2145+import java.util.ArrayList;
2146+import java.util.BitSet;
2147+import org.bouncycastle.asn1.DERObjectIdentifier;
2148+
2149+// BEGIN android-note
2150+// This class was extracted from X509Name as a way to keep the element
2151+// list in a more controlled fashion.
2152+// END android-note
2153+
2154+/**
2155+ * List of elements of an X509 name. Each element has a key, a value, and
2156+ * an "added" flag.
2157+ */
2158+public class X509NameElementList {
2159+    /** null-ok; key #0 */
2160+    private DERObjectIdentifier key0;
2161+
2162+    /** null-ok; key #1 */
2163+    private DERObjectIdentifier key1;
2164+
2165+    /** null-ok; key #2 */
2166+    private DERObjectIdentifier key2;
2167+
2168+    /** null-ok; key #3 */
2169+    private DERObjectIdentifier key3;
2170+
2171+    /** null-ok; value #0 */
2172+    private String value0;
2173+
2174+    /** null-ok; value #1 */
2175+    private String value1;
2176+
2177+    /** null-ok; value #2 */
2178+    private String value2;
2179+
2180+    /** null-ok; value #3 */
2181+    private String value3;
2182+
2183+    /**
2184+     * null-ok; array of additional keys and values, alternating
2185+     * key then value, etc.
2186+     */
2187+    private ArrayList<Object> rest;
2188+
2189+    /** bit vector for all the "added" bits */
2190+    private BitSet added = new BitSet();
2191+
2192+    /** &gt;= 0; number of elements in the list */
2193+    private int size;
2194+
2195+    // Note: Default public constructor.
2196+
2197+    /**
2198+     * Adds an element. The "added" flag is set to false for the element.
2199+     *
2200+     * @param key non-null; the key
2201+     * @param value non-null; the value
2202+     */
2203+    public void add(DERObjectIdentifier key, String value) {
2204+        add(key, value, false);
2205+    }
2206+
2207+    /**
2208+     * Adds an element.
2209+     *
2210+     * @param key non-null; the key
2211+     * @param value non-null; the value
2212+     * @param added the added bit
2213+     */
2214+    public void add(DERObjectIdentifier key, String value, boolean added) {
2215+        if (key == null) {
2216+            throw new NullPointerException("key == null");
2217+        }
2218+
2219+        if (value == null) {
2220+            throw new NullPointerException("value == null");
2221+        }
2222+
2223+        int sz = size;
2224+
2225+        switch (sz) {
2226+            case 0: {
2227+                key0 = key;
2228+                value0 = value;
2229+                break;
2230+            }
2231+            case 1: {
2232+                key1 = key;
2233+                value1 = value;
2234+                break;
2235+            }
2236+            case 2: {
2237+                key2 = key;
2238+                value2 = value;
2239+                break;
2240+            }
2241+            case 3: {
2242+                key3 = key;
2243+                value3 = value;
2244+                break;
2245+            }
2246+            case 4: {
2247+                // Do initial allocation of rest.
2248+                rest = new ArrayList<Object>();
2249+                // Fall through...
2250+            }
2251+            default: {
2252+                rest.add(key);
2253+                rest.add(value);
2254+                break;
2255+            }
2256+        }
2257+
2258+        if (added) {
2259+            this.added.set(sz);
2260+        }
2261+
2262+        size = sz + 1;
2263+    }
2264+
2265+    /**
2266+     * Sets the "added" flag on the most recently added element.
2267+     */
2268+    public void setLastAddedFlag() {
2269+        added.set(size - 1);
2270+    }
2271+
2272+    /**
2273+     * Gets the number of elements in this instance.
2274+     */
2275+    public int size() {
2276+        return size;
2277+    }
2278+
2279+    /**
2280+     * Gets the nth key.
2281+     *
2282+     * @param n index
2283+     * @return non-null; the nth key
2284+     */
2285+    public DERObjectIdentifier getKey(int n) {
2286+        if ((n < 0) || (n >= size)) {
2287+            throw new IndexOutOfBoundsException(Integer.toString(n));
2288+        }
2289+
2290+        switch (n) {
2291+            case 0: return key0;
2292+            case 1: return key1;
2293+            case 2: return key2;
2294+            case 3: return key3;
2295+            default: return (DERObjectIdentifier) rest.get((n - 4) * 2);
2296+        }
2297+    }
2298+
2299+    /**
2300+     * Gets the nth value.
2301+     *
2302+     * @param n index
2303+     * @return non-null; the nth value
2304+     */
2305+    public String getValue(int n) {
2306+        if ((n < 0) || (n >= size)) {
2307+            throw new IndexOutOfBoundsException(Integer.toString(n));
2308+        }
2309+
2310+        switch (n) {
2311+            case 0: return value0;
2312+            case 1: return value1;
2313+            case 2: return value2;
2314+            case 3: return value3;
2315+            default: return (String) rest.get(((n - 4) * 2) + 1);
2316+        }
2317+    }
2318+
2319+    /**
2320+     * Gets the nth added flag bit.
2321+     *
2322+     * @param n index
2323+     * @return the nth added flag bit
2324+     */
2325+    public boolean getAdded(int n) {
2326+        if ((n < 0) || (n >= size)) {
2327+            throw new IndexOutOfBoundsException(Integer.toString(n));
2328+        }
2329+
2330+        return added.get(n);
2331+    }
2332+
2333+    /**
2334+     * Constructs and returns a new instance which consists of the
2335+     * elements of this one in reverse order
2336+     *
2337+     * @return non-null; the reversed instance
2338+     */
2339+    public X509NameElementList reverse() {
2340+        X509NameElementList result = new X509NameElementList();
2341+
2342+        for (int i = size - 1; i >= 0; i--) {
2343+            result.add(getKey(i), getValue(i), getAdded(i));
2344+        }
2345+
2346+        return result;
2347+    }
2348+}
2349diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameTokenizer.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameTokenizer.java
2350--- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameTokenizer.java	2010-01-11 21:46:14.000000000 +0000
2351+++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameTokenizer.java	2011-09-03 18:19:15.000000000 +0000
2352@@ -58,6 +58,17 @@
2353                 }
2354                 else
2355                 {
2356+                    // BEGIN android-added
2357+                    // copied from a newer version of BouncyCastle
2358+                    if (c == '#' && buf.charAt(buf.length() - 1) == '=')
2359+                    {
2360+                        buf.append('\\');
2361+                    }
2362+                    else if (c == '+' && seperator != '+')
2363+                    {
2364+                        buf.append('\\');
2365+                    }
2366+                    // END android-added
2367                     buf.append(c);
2368                 }
2369                 escaped = false;
2370@@ -96,4 +107,4 @@
2371         index = end;
2372         return buf.toString().trim();
2373     }
2374-}
2375+}
2376\ No newline at end of file
2377diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/PBEParametersGenerator.java bcprov-jdk16-145/org/bouncycastle/crypto/PBEParametersGenerator.java
2378--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/PBEParametersGenerator.java	2010-01-11 21:46:14.000000000 +0000
2379+++ bcprov-jdk16-145/org/bouncycastle/crypto/PBEParametersGenerator.java	2011-09-03 18:19:15.000000000 +0000
2380@@ -136,7 +136,8 @@
2381     public static byte[] PKCS12PasswordToBytes(
2382         char[]  password)
2383     {
2384-        if (password.length > 0)
2385+        // BEGIN android-changed
2386+        if (password != null && password.length > 0)
2387         {
2388                                        // +1 for extra 2 pad bytes.
2389             byte[]  bytes = new byte[(password.length + 1) * 2];
2390@@ -153,5 +154,6 @@
2391         {
2392             return new byte[0];
2393         }
2394+        // END android-changed
2395     }
2396 }
2397diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/digests/OpenSSLDigest.java bcprov-jdk16-145/org/bouncycastle/crypto/digests/OpenSSLDigest.java
2398--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/digests/OpenSSLDigest.java	1970-01-01 00:00:00.000000000 +0000
2399+++ bcprov-jdk16-145/org/bouncycastle/crypto/digests/OpenSSLDigest.java	2011-09-03 18:19:15.000000000 +0000
2400@@ -0,0 +1,122 @@
2401+/*
2402+ * Copyright (C) 2008 The Android Open Source Project
2403+ *
2404+ * Licensed under the Apache License, Version 2.0 (the "License");
2405+ * you may not use this file except in compliance with the License.
2406+ * You may obtain a copy of the License at
2407+ *
2408+ *      http://www.apache.org/licenses/LICENSE-2.0
2409+ *
2410+ * Unless required by applicable law or agreed to in writing, software
2411+ * distributed under the License is distributed on an "AS IS" BASIS,
2412+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2413+ * See the License for the specific language governing permissions and
2414+ * limitations under the License.
2415+ */
2416+
2417+package org.bouncycastle.crypto.digests;
2418+
2419+import org.apache.harmony.xnet.provider.jsse.NativeCrypto;
2420+import org.bouncycastle.crypto.ExtendedDigest;
2421+
2422+/**
2423+ * Implements the BouncyCastle Digest interface using OpenSSL's EVP API.
2424+ */
2425+public class OpenSSLDigest implements ExtendedDigest {
2426+
2427+    /**
2428+     * Holds the standard name of the hashing algorithm, e.g. "SHA-1";
2429+     */
2430+    private final String algorithm;
2431+
2432+    /**
2433+     * Holds the OpenSSL name of the hashing algorithm, e.g. "sha1";
2434+     */
2435+    private final String openssl;
2436+
2437+    /**
2438+     * Holds a pointer to the native message digest context.
2439+     */
2440+    private int ctx;
2441+
2442+    /**
2443+     * Holds a dummy buffer for writing single bytes to the digest.
2444+     */
2445+    private final byte[] singleByte = new byte[1];
2446+
2447+    /**
2448+     * Creates a new OpenSSLMessageDigest instance for the given algorithm
2449+     * name.
2450+     *
2451+     * @param algorithm The standard name of the algorithm, e.g. "SHA-1".
2452+     * @param algorithm The name of the openssl algorithm, e.g. "sha1".
2453+     */
2454+    private OpenSSLDigest(String algorithm, String openssl) {
2455+        this.algorithm = algorithm;
2456+        this.openssl = openssl;
2457+        ctx = NativeCrypto.EVP_MD_CTX_create();
2458+        try {
2459+            NativeCrypto.EVP_DigestInit(ctx, openssl);
2460+        } catch (Exception ex) {
2461+            throw new RuntimeException(ex.getMessage() + " (" + algorithm + ")");
2462+        }
2463+    }
2464+
2465+    public int doFinal(byte[] out, int outOff) {
2466+        int i = NativeCrypto.EVP_DigestFinal(ctx, out, outOff);
2467+        reset();
2468+        return i;
2469+    }
2470+
2471+    public String getAlgorithmName() {
2472+        return algorithm;
2473+    }
2474+
2475+    public int getDigestSize() {
2476+        return NativeCrypto.EVP_MD_CTX_size(ctx);
2477+    }
2478+
2479+    public int getByteLength() {
2480+        return NativeCrypto.EVP_MD_CTX_block_size(ctx);
2481+    }
2482+
2483+    public void reset() {
2484+        NativeCrypto.EVP_DigestInit(ctx, openssl);
2485+    }
2486+
2487+    public void update(byte in) {
2488+        singleByte[0] = in;
2489+        NativeCrypto.EVP_DigestUpdate(ctx, singleByte, 0, 1);
2490+    }
2491+
2492+    public void update(byte[] in, int inOff, int len) {
2493+        NativeCrypto.EVP_DigestUpdate(ctx, in, inOff, len);
2494+    }
2495+
2496+    @Override
2497+    protected void finalize() throws Throwable {
2498+        super.finalize();
2499+        NativeCrypto.EVP_MD_CTX_destroy(ctx);
2500+        ctx = 0;
2501+    }
2502+
2503+    public static class MD5 extends OpenSSLDigest {
2504+        public MD5() { super("MD5", "md5"); }
2505+    }
2506+
2507+    public static class SHA1 extends OpenSSLDigest {
2508+        public SHA1() { super("SHA-1", "sha1"); }
2509+    }
2510+
2511+    public static class SHA256 extends OpenSSLDigest {
2512+        public SHA256() { super("SHA-256", "sha256"); }
2513+    }
2514+
2515+    public static class SHA384 extends OpenSSLDigest {
2516+        public SHA384() { super("SHA-384", "sha384"); }
2517+    }
2518+
2519+    public static class SHA512 extends OpenSSLDigest {
2520+        public SHA512() { super("SHA-512", "sha512"); }
2521+    }
2522+}
2523diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/engines/RC2Engine.java bcprov-jdk16-145/org/bouncycastle/crypto/engines/RC2Engine.java
2524--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/engines/RC2Engine.java	2010-01-11 21:46:14.000000000 +0000
2525+++ bcprov-jdk16-145/org/bouncycastle/crypto/engines/RC2Engine.java	2011-09-03 18:19:15.000000000 +0000
2526@@ -313,4 +313,4 @@
2527         out[outOff + 6] = (byte)x76;
2528         out[outOff + 7] = (byte)(x76 >> 8);
2529     }
2530-}
2531+}
2532\ No newline at end of file
2533diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/macs/HMac.java bcprov-jdk16-145/org/bouncycastle/crypto/macs/HMac.java
2534--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/macs/HMac.java	2010-01-11 21:46:14.000000000 +0000
2535+++ bcprov-jdk16-145/org/bouncycastle/crypto/macs/HMac.java	2011-09-03 18:19:15.000000000 +0000
2536@@ -32,23 +32,23 @@
2537     {
2538         blockLengths = new Hashtable();
2539
2540-        blockLengths.put("GOST3411", new Integer(32));
2541+        blockLengths.put("GOST3411", Integer.valueOf(32));
2542
2543-        blockLengths.put("MD2", new Integer(16));
2544-        blockLengths.put("MD4", new Integer(64));
2545-        blockLengths.put("MD5", new Integer(64));
2546-
2547-        blockLengths.put("RIPEMD128", new Integer(64));
2548-        blockLengths.put("RIPEMD160", new Integer(64));
2549-
2550-        blockLengths.put("SHA-1", new Integer(64));
2551-        blockLengths.put("SHA-224", new Integer(64));
2552-        blockLengths.put("SHA-256", new Integer(64));
2553-        blockLengths.put("SHA-384", new Integer(128));
2554-        blockLengths.put("SHA-512", new Integer(128));
2555+        blockLengths.put("MD2", Integer.valueOf(16));
2556+        blockLengths.put("MD4", Integer.valueOf(64));
2557+        blockLengths.put("MD5", Integer.valueOf(64));
2558+
2559+        blockLengths.put("RIPEMD128", Integer.valueOf(64));
2560+        blockLengths.put("RIPEMD160", Integer.valueOf(64));
2561+
2562+        blockLengths.put("SHA-1", Integer.valueOf(64));
2563+        blockLengths.put("SHA-224", Integer.valueOf(64));
2564+        blockLengths.put("SHA-256", Integer.valueOf(64));
2565+        blockLengths.put("SHA-384", Integer.valueOf(128));
2566+        blockLengths.put("SHA-512", Integer.valueOf(128));
2567
2568-        blockLengths.put("Tiger", new Integer(64));
2569-        blockLengths.put("Whirlpool", new Integer(64));
2570+        blockLengths.put("Tiger", Integer.valueOf(64));
2571+        blockLengths.put("Whirlpool", Integer.valueOf(64));
2572     }
2573
2574     private static int getByteLength(
2575diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/signers/RSADigestSigner.java bcprov-jdk16-145/org/bouncycastle/crypto/signers/RSADigestSigner.java
2576--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/signers/RSADigestSigner.java	2010-01-11 21:46:14.000000000 +0000
2577+++ bcprov-jdk16-145/org/bouncycastle/crypto/signers/RSADigestSigner.java	2011-09-03 18:19:15.000000000 +0000
2578@@ -46,8 +46,10 @@
2579         oidMap.put("SHA-384", NISTObjectIdentifiers.id_sha384);
2580         oidMap.put("SHA-512", NISTObjectIdentifiers.id_sha512);
2581
2582-        oidMap.put("MD2", PKCSObjectIdentifiers.md2);
2583-        oidMap.put("MD4", PKCSObjectIdentifiers.md4);
2584+        // BEGIN android-removed
2585+        // oidMap.put("MD2", PKCSObjectIdentifiers.md2);
2586+        // oidMap.put("MD4", PKCSObjectIdentifiers.md4);
2587+        // END android-removed
2588         oidMap.put("MD5", PKCSObjectIdentifiers.md5);
2589     }
2590
2591diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PrivateKeyFactory.java bcprov-jdk16-145/org/bouncycastle/crypto/util/PrivateKeyFactory.java
2592--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PrivateKeyFactory.java	2010-01-11 21:46:14.000000000 +0000
2593+++ bcprov-jdk16-145/org/bouncycastle/crypto/util/PrivateKeyFactory.java	2011-09-03 18:19:15.000000000 +0000
2594@@ -7,31 +7,39 @@
2595 import org.bouncycastle.asn1.DERInteger;
2596 import org.bouncycastle.asn1.DERObject;
2597 import org.bouncycastle.asn1.DERObjectIdentifier;
2598-import org.bouncycastle.asn1.nist.NISTNamedCurves;
2599-import org.bouncycastle.asn1.oiw.ElGamalParameter;
2600+// BEGIN android-removed
2601+// import org.bouncycastle.asn1.nist.NISTNamedCurves;
2602+// import org.bouncycastle.asn1.oiw.ElGamalParameter;
2603+// END android-removed
2604 import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
2605 import org.bouncycastle.asn1.pkcs.DHParameter;
2606 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
2607 import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
2608 import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
2609-import org.bouncycastle.asn1.sec.ECPrivateKeyStructure;
2610-import org.bouncycastle.asn1.sec.SECNamedCurves;
2611-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
2612+// BEGIN android-removed
2613+// import org.bouncycastle.asn1.sec.ECPrivateKeyStructure;
2614+// import org.bouncycastle.asn1.sec.SECNamedCurves;
2615+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
2616+// END android-removed
2617 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
2618 import org.bouncycastle.asn1.x509.DSAParameter;
2619-import org.bouncycastle.asn1.x9.X962NamedCurves;
2620-import org.bouncycastle.asn1.x9.X962Parameters;
2621-import org.bouncycastle.asn1.x9.X9ECParameters;
2622-import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
2623+// BEGIN android-removed
2624+// import org.bouncycastle.asn1.x9.X962NamedCurves;
2625+// import org.bouncycastle.asn1.x9.X962Parameters;
2626+// import org.bouncycastle.asn1.x9.X9ECParameters;
2627+// import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
2628+// END android-removed
2629 import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
2630 import org.bouncycastle.crypto.params.DHParameters;
2631 import org.bouncycastle.crypto.params.DHPrivateKeyParameters;
2632 import org.bouncycastle.crypto.params.DSAParameters;
2633 import org.bouncycastle.crypto.params.DSAPrivateKeyParameters;
2634-import org.bouncycastle.crypto.params.ECDomainParameters;
2635-import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
2636-import org.bouncycastle.crypto.params.ElGamalParameters;
2637-import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
2638+// BEGIN android-removed
2639+// import org.bouncycastle.crypto.params.ECDomainParameters;
2640+// import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
2641+// import org.bouncycastle.crypto.params.ElGamalParameters;
2642+// import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
2643+// END android-removed
2644 import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
2645
2646 import java.io.IOException;
2647@@ -113,75 +121,77 @@
2648
2649             return new DHPrivateKeyParameters(derX.getValue(), dhParams);
2650         }
2651-        else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
2652-        {
2653-            ElGamalParameter    params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
2654-            DERInteger          derX = (DERInteger)keyInfo.getPrivateKey();
2655-
2656-            return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(params.getP(), params.getG()));
2657-        }
2658-        else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa))
2659-        {
2660-            DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
2661-            DEREncodable de = keyInfo.getAlgorithmId().getParameters();
2662-
2663-            DSAParameters parameters = null;
2664-            if (de != null)
2665-            {
2666-                DSAParameter params = DSAParameter.getInstance(de.getDERObject());
2667-                parameters = new DSAParameters(params.getP(), params.getQ(), params.getG());
2668-            }
2669-
2670-            return new DSAPrivateKeyParameters(derX.getValue(), parameters);
2671-        }
2672-        else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
2673-        {
2674-            X962Parameters      params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters());
2675-            ECDomainParameters  dParams = null;
2676-
2677-            if (params.isNamedCurve())
2678-            {
2679-                DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
2680-                X9ECParameters      ecP = X962NamedCurves.getByOID(oid);
2681-
2682-                if (ecP == null)
2683-                {
2684-                    ecP = SECNamedCurves.getByOID(oid);
2685-
2686-                    if (ecP == null)
2687-                    {
2688-                        ecP = NISTNamedCurves.getByOID(oid);
2689-
2690-                        if (ecP == null)
2691-                        {
2692-                            ecP = TeleTrusTNamedCurves.getByOID(oid);
2693-                        }
2694-                    }
2695-                }
2696-
2697-                dParams = new ECDomainParameters(
2698-                                            ecP.getCurve(),
2699-                                            ecP.getG(),
2700-                                            ecP.getN(),
2701-                                            ecP.getH(),
2702-                                            ecP.getSeed());
2703-            }
2704-            else
2705-            {
2706-                X9ECParameters ecP = new X9ECParameters(
2707-                            (ASN1Sequence)params.getParameters());
2708-                dParams = new ECDomainParameters(
2709-                                            ecP.getCurve(),
2710-                                            ecP.getG(),
2711-                                            ecP.getN(),
2712-                                            ecP.getH(),
2713-                                            ecP.getSeed());
2714-            }
2715-
2716-            ECPrivateKeyStructure   ec = new ECPrivateKeyStructure((ASN1Sequence)keyInfo.getPrivateKey());
2717-
2718-            return new ECPrivateKeyParameters(ec.getKey(), dParams);
2719-        }
2720+        // BEGIN android-removed
2721+        // else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
2722+        // {
2723+        //     ElGamalParameter    params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
2724+        //     DERInteger          derX = (DERInteger)keyInfo.getPrivateKey();
2725+        //
2726+        //     return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(params.getP(), params.getG()));
2727+        // }
2728+        // else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa))
2729+        // {
2730+        //     DERInteger derX = (DERInteger)keyInfo.getPrivateKey();
2731+        //     DEREncodable de = keyInfo.getAlgorithmId().getParameters();
2732+        //
2733+        //     DSAParameters parameters = null;
2734+        //     if (de != null)
2735+        //     {
2736+        //         DSAParameter params = DSAParameter.getInstance(de.getDERObject());
2737+        //         parameters = new DSAParameters(params.getP(), params.getQ(), params.getG());
2738+        //     }
2739+        //
2740+        //     return new DSAPrivateKeyParameters(derX.getValue(), parameters);
2741+        // }
2742+        // else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
2743+        // {
2744+        //     X962Parameters      params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters());
2745+        //     ECDomainParameters  dParams = null;
2746+        //
2747+        //     if (params.isNamedCurve())
2748+        //     {
2749+        //         DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
2750+        //         X9ECParameters      ecP = X962NamedCurves.getByOID(oid);
2751+        //
2752+        //         if (ecP == null)
2753+        //         {
2754+        //             ecP = SECNamedCurves.getByOID(oid);
2755+        //
2756+        //             if (ecP == null)
2757+        //             {
2758+        //                 ecP = NISTNamedCurves.getByOID(oid);
2759+        //
2760+        //                 if (ecP == null)
2761+        //                 {
2762+        //                     ecP = TeleTrusTNamedCurves.getByOID(oid);
2763+        //                 }
2764+        //             }
2765+        //         }
2766+        //
2767+        //         dParams = new ECDomainParameters(
2768+        //                                     ecP.getCurve(),
2769+        //                                     ecP.getG(),
2770+        //                                     ecP.getN(),
2771+        //                                     ecP.getH(),
2772+        //                                     ecP.getSeed());
2773+        //     }
2774+        //     else
2775+        //     {
2776+        //         X9ECParameters ecP = new X9ECParameters(
2777+        //                     (ASN1Sequence)params.getParameters());
2778+        //         dParams = new ECDomainParameters(
2779+        //                                     ecP.getCurve(),
2780+        //                                     ecP.getG(),
2781+        //                                     ecP.getN(),
2782+        //                                     ecP.getH(),
2783+        //                                     ecP.getSeed());
2784+        //     }
2785+        //
2786+        //     ECPrivateKeyStructure   ec = new ECPrivateKeyStructure((ASN1Sequence)keyInfo.getPrivateKey());
2787+        //
2788+        //     return new ECPrivateKeyParameters(ec.getKey(), dParams);
2789+        // }
2790+        // END android-removed
2791         else
2792         {
2793             throw new RuntimeException("algorithm identifier in key not recognised");
2794diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PublicKeyFactory.java bcprov-jdk16-145/org/bouncycastle/crypto/util/PublicKeyFactory.java
2795--- bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PublicKeyFactory.java	2010-01-11 21:46:14.000000000 +0000
2796+++ bcprov-jdk16-145/org/bouncycastle/crypto/util/PublicKeyFactory.java	2011-09-03 18:19:15.000000000 +0000
2797@@ -10,32 +10,40 @@
2798 import org.bouncycastle.asn1.DERObject;
2799 import org.bouncycastle.asn1.DERObjectIdentifier;
2800 import org.bouncycastle.asn1.DEROctetString;
2801-import org.bouncycastle.asn1.nist.NISTNamedCurves;
2802-import org.bouncycastle.asn1.oiw.ElGamalParameter;
2803+// BEGIN android-removed
2804+// import org.bouncycastle.asn1.nist.NISTNamedCurves;
2805+// import org.bouncycastle.asn1.oiw.ElGamalParameter;
2806+// END android-removed
2807 import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
2808 import org.bouncycastle.asn1.pkcs.DHParameter;
2809 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
2810-import org.bouncycastle.asn1.sec.SECNamedCurves;
2811-import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
2812+// BEGIN android-removed
2813+// import org.bouncycastle.asn1.sec.SECNamedCurves;
2814+// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves;
2815+// END android-removed
2816 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
2817 import org.bouncycastle.asn1.x509.DSAParameter;
2818 import org.bouncycastle.asn1.x509.RSAPublicKeyStructure;
2819 import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
2820 import org.bouncycastle.asn1.x509.X509ObjectIdentifiers;
2821-import org.bouncycastle.asn1.x9.X962NamedCurves;
2822-import org.bouncycastle.asn1.x9.X962Parameters;
2823-import org.bouncycastle.asn1.x9.X9ECParameters;
2824-import org.bouncycastle.asn1.x9.X9ECPoint;
2825+// BEGIN android-removed
2826+// import org.bouncycastle.asn1.x9.X962NamedCurves;
2827+// import org.bouncycastle.asn1.x9.X962Parameters;
2828+// import org.bouncycastle.asn1.x9.X9ECParameters;
2829+// import org.bouncycastle.asn1.x9.X9ECPoint;
2830+// END android-removed
2831 import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
2832 import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
2833 import org.bouncycastle.crypto.params.DHParameters;
2834 import org.bouncycastle.crypto.params.DHPublicKeyParameters;
2835 import org.bouncycastle.crypto.params.DSAParameters;
2836 import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
2837-import org.bouncycastle.crypto.params.ECDomainParameters;
2838-import org.bouncycastle.crypto.params.ECPublicKeyParameters;
2839-import org.bouncycastle.crypto.params.ElGamalParameters;
2840-import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
2841+// BEGIN android-removed
2842+// import org.bouncycastle.crypto.params.ECDomainParameters;
2843+// import org.bouncycastle.crypto.params.ECPublicKeyParameters;
2844+// import org.bouncycastle.crypto.params.ElGamalParameters;
2845+// import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
2846+// END android-removed
2847 import org.bouncycastle.crypto.params.RSAKeyParameters;
2848
2849 import java.io.IOException;
2850@@ -112,13 +120,15 @@
2851
2852             return new DHPublicKeyParameters(derY.getValue(), dhParams);
2853         }
2854-        else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
2855-        {
2856-            ElGamalParameter    params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
2857-            DERInteger          derY = (DERInteger)keyInfo.getPublicKey();
2858-
2859-            return new ElGamalPublicKeyParameters(derY.getValue(), new ElGamalParameters(params.getP(), params.getG()));
2860-        }
2861+        // BEGIN android-removed
2862+        // else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm))
2863+        // {
2864+        //     ElGamalParameter    params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters());
2865+        //     DERInteger          derY = (DERInteger)keyInfo.getPublicKey();
2866+        //
2867+        //     return new ElGamalPublicKeyParameters(derY.getValue(), new ElGamalParameters(params.getP(), params.getG()));
2868+        // }
2869+        // END android-removed
2870         else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa)
2871                  || algId.getObjectId().equals(OIWObjectIdentifiers.dsaWithSHA1))
2872         {
2873@@ -134,58 +144,60 @@
2874
2875             return new DSAPublicKeyParameters(derY.getValue(), parameters);
2876         }
2877-        else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
2878-        {
2879-            X962Parameters      params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters());
2880-            ECDomainParameters  dParams = null;
2881-
2882-            if (params.isNamedCurve())
2883-            {
2884-                DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
2885-                X9ECParameters      ecP = X962NamedCurves.getByOID(oid);
2886-
2887-                if (ecP == null)
2888-                {
2889-                    ecP = SECNamedCurves.getByOID(oid);
2890-
2891-                    if (ecP == null)
2892-                    {
2893-                        ecP = NISTNamedCurves.getByOID(oid);
2894-
2895-                        if (ecP == null)
2896-                        {
2897-                            ecP = TeleTrusTNamedCurves.getByOID(oid);
2898-                        }
2899-                    }
2900-                }
2901-
2902-                dParams = new ECDomainParameters(
2903-                                            ecP.getCurve(),
2904-                                            ecP.getG(),
2905-                                            ecP.getN(),
2906-                                            ecP.getH(),
2907-                                            ecP.getSeed());
2908-            }
2909-            else
2910-            {
2911-                X9ECParameters ecP = new X9ECParameters(
2912-                            (ASN1Sequence)params.getParameters());
2913-                dParams = new ECDomainParameters(
2914-                                            ecP.getCurve(),
2915-                                            ecP.getG(),
2916-                                            ecP.getN(),
2917-                                            ecP.getH(),
2918-                                            ecP.getSeed());
2919-            }
2920-
2921-            DERBitString    bits = keyInfo.getPublicKeyData();
2922-            byte[]          data = bits.getBytes();
2923-            ASN1OctetString key = new DEROctetString(data);
2924-
2925-            X9ECPoint       derQ = new X9ECPoint(dParams.getCurve(), key);
2926-
2927-            return new ECPublicKeyParameters(derQ.getPoint(), dParams);
2928-        }
2929+        // BEGIN android-removed
2930+        // else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey))
2931+        // {
2932+        //     X962Parameters      params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters());
2933+        //     ECDomainParameters  dParams = null;
2934+        //
2935+        //     if (params.isNamedCurve())
2936+        //     {
2937+        //         DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters();
2938+        //         X9ECParameters      ecP = X962NamedCurves.getByOID(oid);
2939+        //
2940+        //         if (ecP == null)
2941+        //         {
2942+        //             ecP = SECNamedCurves.getByOID(oid);
2943+        //
2944+        //             if (ecP == null)
2945+        //             {
2946+        //                 ecP = NISTNamedCurves.getByOID(oid);
2947+        //
2948+        //                 if (ecP == null)
2949+        //                 {
2950+        //                     ecP = TeleTrusTNamedCurves.getByOID(oid);
2951+        //                 }
2952+        //             }
2953+        //         }
2954+        //
2955+        //         dParams = new ECDomainParameters(
2956+        //                                     ecP.getCurve(),
2957+        //                                     ecP.getG(),
2958+        //                                     ecP.getN(),
2959+        //                                     ecP.getH(),
2960+        //                                     ecP.getSeed());
2961+        //     }
2962+        //     else
2963+        //     {
2964+        //         X9ECParameters ecP = new X9ECParameters(
2965+        //                     (ASN1Sequence)params.getParameters());
2966+        //         dParams = new ECDomainParameters(
2967+        //                                     ecP.getCurve(),
2968+        //                                     ecP.getG(),
2969+        //                                     ecP.getN(),
2970+        //                                     ecP.getH(),
2971+        //                                     ecP.getSeed());
2972+        //     }
2973+        //
2974+        //     DERBitString    bits = keyInfo.getPublicKeyData();
2975+        //     byte[]          data = bits.getBytes();
2976+        //     ASN1OctetString key = new DEROctetString(data);
2977+        //
2978+        //     X9ECPoint       derQ = new X9ECPoint(dParams.getCurve(), key);
2979+        //
2980+        //     return new ECPublicKeyParameters(derQ.getPoint(), dParams);
2981+        // }
2982+        // END android-removed
2983         else
2984         {
2985             throw new RuntimeException("algorithm identifier in key not recognised");
2986diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/PKCS10CertificationRequest.java bcprov-jdk16-145/org/bouncycastle/jce/PKCS10CertificationRequest.java
2987--- bcprov-jdk16-145.orig/org/bouncycastle/jce/PKCS10CertificationRequest.java	2010-01-11 21:46:14.000000000 +0000
2988+++ bcprov-jdk16-145/org/bouncycastle/jce/PKCS10CertificationRequest.java	2011-09-03 18:19:15.000000000 +0000
2989@@ -78,8 +78,11 @@
2990
2991     static
2992     {
2993-        algorithms.put("MD2WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
2994-        algorithms.put("MD2WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
2995+        // BEGIN android-removed
2996+        // Dropping MD2
2997+        // algorithms.put("MD2WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
2998+        // algorithms.put("MD2WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.2"));
2999+        // END android-removed
3000         algorithms.put("MD5WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.4"));
3001         algorithms.put("MD5WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.4"));
3002         algorithms.put("RSAWITHMD5", new DERObjectIdentifier("1.2.840.113549.1.1.4"));
3003@@ -129,7 +132,10 @@
3004         oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "GOST3411WITHECGOST3410");
3005
3006         oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.4"), "MD5WITHRSA");
3007-        oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA");
3008+        // BEGIN android-removed
3009+        // Dropping MD2
3010+        // oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA");
3011+        // END android-removed
3012         oids.put(new DERObjectIdentifier("1.2.840.10040.4.3"), "SHA1WITHDSA");
3013         oids.put(X9ObjectIdentifiers.ecdsa_with_SHA1, "SHA1WITHECDSA");
3014         oids.put(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224WITHECDSA");
3015@@ -168,19 +174,29 @@
3016         //
3017         // explicit params
3018         //
3019-        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
3020+        // BEGIN android-changed
3021+        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
3022+        // END android-changed
3023         params.put("SHA1WITHRSAANDMGF1", creatPSSParams(sha1AlgId, 20));
3024
3025-        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, new DERNull());
3026+        // BEGIN android-changed
3027+        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE);
3028+        // END android-changed
3029         params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28));
3030
3031-        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, new DERNull());
3032+        // BEGIN android-changed
3033+        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE);
3034+        // END android-changed
3035         params.put("SHA256WITHRSAANDMGF1", creatPSSParams(sha256AlgId, 32));
3036
3037-        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, new DERNull());
3038+        // BEGIN android-changed
3039+        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE);
3040+        // END android-changed
3041         params.put("SHA384WITHRSAANDMGF1", creatPSSParams(sha384AlgId, 48));
3042
3043-        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, new DERNull());
3044+        // BEGIN android-changed
3045+        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE);
3046+        // END android-changed
3047         params.put("SHA512WITHRSAANDMGF1", creatPSSParams(sha512AlgId, 64));
3048     }
3049
3050diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/BouncyCastleProvider.java bcprov-jdk16-145/org/bouncycastle/jce/provider/BouncyCastleProvider.java
3051--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/BouncyCastleProvider.java	2010-01-11 21:46:14.000000000 +0000
3052+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/BouncyCastleProvider.java	2011-09-03 18:19:15.000000000 +0000
3053@@ -53,7 +53,12 @@
3054     private static final String SYMMETRIC_CIPHER_PACKAGE = "org.bouncycastle.jce.provider.symmetric.";
3055     private static final String[] SYMMETRIC_CIPHERS =
3056     {
3057-        "AES", "Camellia", "CAST5", "Grainv1", "Grain128", "IDEA", "Noekeon", "SEED"
3058+        // BEGIN android-removed
3059+        // "AES", "Camellia", "CAST5", "Grainv1", "Grain128", "IDEA", "Noekeon", "SEED"
3060+        // END android-removed
3061+        // BEGIN android-added
3062+        "AES",
3063+        // END android-added
3064     };
3065
3066     /*
3067@@ -62,7 +67,9 @@
3068     private static final String ASYMMETRIC_CIPHER_PACKAGE = "org.bouncycastle.jce.provider.asymmetric.";
3069     private static final String[] ASYMMETRIC_CIPHERS =
3070     {
3071-        "EC"
3072+        // BEGIN android-removed
3073+        // "EC"
3074+        // END android-removed
3075     };
3076
3077     /**
3078@@ -89,26 +96,28 @@
3079         loadAlgorithms(SYMMETRIC_CIPHER_PACKAGE, SYMMETRIC_CIPHERS);
3080         loadAlgorithms(ASYMMETRIC_CIPHER_PACKAGE, ASYMMETRIC_CIPHERS);
3081
3082-        //
3083-        // X509Store
3084-        //
3085-        put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection");
3086-        put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection");
3087-        put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection");
3088-        put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection");
3089-
3090-        put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts");
3091-        put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs");
3092-        put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts");
3093-        put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs");
3094-
3095-        //
3096-        // X509StreamParser
3097-        //
3098-        put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser");
3099-        put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser");
3100-        put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser");
3101-        put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser");
3102+        // BEGIN android-removed
3103+        // //
3104+        // // X509Store
3105+        // //
3106+        // put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection");
3107+        // put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection");
3108+        // put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection");
3109+        // put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection");
3110+        //
3111+        // put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts");
3112+        // put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs");
3113+        // put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts");
3114+        // put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs");
3115+        //
3116+        // //
3117+        // // X509StreamParser
3118+        // //
3119+        // put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser");
3120+        // put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser");
3121+        // put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser");
3122+        // put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser");
3123+        // END android-removed
3124
3125
3126         //
3127@@ -117,14 +126,24 @@
3128         put("KeyStore.BKS", "org.bouncycastle.jce.provider.JDKKeyStore");
3129         put("KeyStore.BouncyCastle", "org.bouncycastle.jce.provider.JDKKeyStore$BouncyCastleStore");
3130         put("KeyStore.PKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
3131-        put("KeyStore.BCPKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
3132-        put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
3133-
3134-        put("KeyStore.PKCS12-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore");
3135-        put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES");
3136-
3137-        put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
3138-        put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES");
3139+        // BEGIN android-changed
3140+        put("Alg.Alias.KeyStore.BCPKCS12", "PKCS12");
3141+        // END android-changed
3142+        // BEGIN android-removed
3143+        // put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
3144+        // END android-removed
3145+
3146+        // BEGIN android-changed
3147+        put("Alg.Alias.KeyStore.PKCS12-3DES-40RC2", "PKCS12");
3148+        // END android-changed
3149+        // BEGIN android-removed
3150+        // put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES");
3151+        // END android-removed
3152+
3153+        // BEGIN android-removed
3154+        // put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore");
3155+        // put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES");
3156+        // END android-removed
3157
3158         put("Alg.Alias.KeyStore.UBER", "BouncyCastle");
3159         put("Alg.Alias.KeyStore.BOUNCYCASTLE", "BouncyCastle");
3160@@ -141,44 +160,63 @@
3161         //
3162         put("AlgorithmParameterGenerator.DH", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DH");
3163         put("AlgorithmParameterGenerator.DSA", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DSA");
3164-        put("AlgorithmParameterGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$GOST3410");
3165-        put("AlgorithmParameterGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$ElGamal");
3166-        put("AlgorithmParameterGenerator.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3167-        put("AlgorithmParameterGenerator.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3168-        put("AlgorithmParameterGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3169-        put("AlgorithmParameterGenerator." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3170-        put("AlgorithmParameterGenerator.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
3171-        put("AlgorithmParameterGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
3172+        // BEGIN android-removed
3173+        // put("AlgorithmParameterGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$GOST3410");
3174+        // put("AlgorithmParameterGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$ElGamal");
3175+        // put("AlgorithmParameterGenerator.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3176+        // put("AlgorithmParameterGenerator.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3177+        // put("AlgorithmParameterGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3178+        // put("AlgorithmParameterGenerator." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES");
3179+        // put("AlgorithmParameterGenerator.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
3180+        // put("AlgorithmParameterGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2");
3181+        // END android-removed
3182
3183         put("Alg.Alias.AlgorithmParameterGenerator.DIFFIEHELLMAN", "DH");
3184-        put("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410");
3185+        // BEGIN android-removed
3186+        // put("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410");
3187+        // END android-removed
3188         //
3189         // algorithm parameters
3190         //
3191         put("AlgorithmParameters.OAEP", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$OAEP");
3192-        put("AlgorithmParameters.PSS", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PSS");
3193+        // BEGIN android-removed
3194+        // put("AlgorithmParameters.PSS", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PSS");
3195+        // END android-removed
3196         put("AlgorithmParameters.DH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$DH");
3197         put("Alg.Alias.AlgorithmParameters.DIFFIEHELLMAN", "DH");
3198         put("AlgorithmParameters.DSA", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$DSA");
3199-        put("AlgorithmParameters.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$ElGamal");
3200-        put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES");
3201+        // BEGIN android-removed
3202+        // put("AlgorithmParameters.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$ElGamal");
3203+        // put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES");
3204+        // END android-removed
3205         put("AlgorithmParameters.PKCS12PBE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PKCS12PBE");
3206-        put("AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3207-        put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2");
3208-
3209-        put("AlgorithmParameters.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$GOST3410");
3210-        put("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410");
3211+        // BEGIN android-changed
3212+        // redundant with below
3213+        // put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "DESede");
3214+        // END android-changed
3215+        // BEGIN android-removed
3216+        // put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2");
3217+        //
3218+        // put("AlgorithmParameters.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$GOST3410");
3219+        // put("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410");
3220+        // END android-removed
3221         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2", "PKCS12PBE");
3222-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE");
3223-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE");
3224-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE");
3225-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE");
3226+        // BEGIN android-removed
3227+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE");
3228+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE");
3229+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE");
3230+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE");
3231+        // END android-removed
3232         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH", "PKCS12PBE");
3233-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE");
3234+        // BEGIN android-removed
3235+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE");
3236+        // END android-removed
3237         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PKCS12PBE");
3238         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PKCS12PBE");
3239-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE");
3240-        put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE");
3241+        // BEGIN android-removed
3242+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE");
3243+        // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE");
3244+        // END android-removed
3245         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC2-CBC", "PKCS12PBE");
3246         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC4", "PKCS12PBE");
3247         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC2-CBC", "PKCS12PBE");
3248@@ -192,7 +230,7 @@
3249         put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.5", "PKCS12PBE");
3250         put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.6", "PKCS12PBE");
3251         put("Alg.Alias.AlgorithmParameters.PBEWithSHAAnd3KeyTripleDES", "PKCS12PBE");
3252-
3253+
3254         put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PKCS12PBE");
3255         put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PKCS12PBE");
3256         put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.getId(), "PKCS12PBE");
3257@@ -202,22 +240,24 @@
3258
3259         put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSAES_OAEP, "OAEP");
3260
3261-        put("Alg.Alias.AlgorithmParameters.RSAPSS", "PSS");
3262-        put("Alg.Alias.AlgorithmParameters.RSASSA-PSS", "PSS");
3263-        put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSASSA_PSS, "PSS");
3264-        put("Alg.Alias.AlgorithmParameters.SHA1withRSA/PSS", "PSS");
3265-        put("Alg.Alias.AlgorithmParameters.SHA224withRSA/PSS", "PSS");
3266-        put("Alg.Alias.AlgorithmParameters.SHA256withRSA/PSS", "PSS");
3267-        put("Alg.Alias.AlgorithmParameters.SHA384withRSA/PSS", "PSS");
3268-        put("Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS", "PSS");
3269-        put("Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1", "PSS");
3270-        put("Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1", "PSS");
3271-        put("Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1", "PSS");
3272-        put("Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1", "PSS");
3273-        put("Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1", "PSS");
3274-        put("Alg.Alias.AlgorithmParameters.RAWRSAPSS", "PSS");
3275-        put("Alg.Alias.AlgorithmParameters.NONEWITHRSAPSS", "PSS");
3276-        put("Alg.Alias.AlgorithmParameters.NONEWITHRSASSA-PSS", "PSS");
3277+        // BEGIN android-removed
3278+        // put("Alg.Alias.AlgorithmParameters.RSAPSS", "PSS");
3279+        // put("Alg.Alias.AlgorithmParameters.RSASSA-PSS", "PSS");
3280+        // put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSASSA_PSS, "PSS");
3281+        // put("Alg.Alias.AlgorithmParameters.SHA1withRSA/PSS", "PSS");
3282+        // put("Alg.Alias.AlgorithmParameters.SHA224withRSA/PSS", "PSS");
3283+        // put("Alg.Alias.AlgorithmParameters.SHA256withRSA/PSS", "PSS");
3284+        // put("Alg.Alias.AlgorithmParameters.SHA384withRSA/PSS", "PSS");
3285+        // put("Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS", "PSS");
3286+        // put("Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1", "PSS");
3287+        // put("Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1", "PSS");
3288+        // put("Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1", "PSS");
3289+        // put("Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1", "PSS");
3290+        // put("Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1", "PSS");
3291+        // put("Alg.Alias.AlgorithmParameters.RAWRSAPSS", "PSS");
3292+        // put("Alg.Alias.AlgorithmParameters.NONEWITHRSAPSS", "PSS");
3293+        // put("Alg.Alias.AlgorithmParameters.NONEWITHRSASSA-PSS", "PSS");
3294+        // END android-removed
3295
3296         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITAES-CBC-BC", "PKCS12PBE");
3297         put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND192BITAES-CBC-BC", "PKCS12PBE");
3298@@ -234,12 +274,14 @@
3299         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND128BITAES-CBC-BC","PKCS12PBE");
3300         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND192BITAES-CBC-BC","PKCS12PBE");
3301         put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND256BITAES-CBC-BC","PKCS12PBE");
3302-
3303-        put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3304-        put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3305-        put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3306-        put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3307-        put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3308+
3309+        // BEGIN android-removed
3310+        // put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3311+        // put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3312+        // put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3313+        // put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3314+        // put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters");
3315+        // END android-removed
3316
3317         //
3318         // key agreement
3319@@ -252,97 +294,129 @@
3320         //
3321         put("Cipher.DES", "org.bouncycastle.jce.provider.JCEBlockCipher$DES");
3322         put("Cipher.DESEDE", "org.bouncycastle.jce.provider.JCEBlockCipher$DESede");
3323-        put("Cipher." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESedeCBC");
3324-        put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESCBC");
3325+        // BEGIN android-removed
3326+        // put("Cipher." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESedeCBC");
3327+        // put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESCBC");
3328+        // END android-removed
3329         put("Cipher.DESEDEWRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$DESEDEWrap");
3330-        put("Cipher." + PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "org.bouncycastle.jce.provider.WrapCipherSpi$DESEDEWrap");
3331-        put("Cipher.SKIPJACK", "org.bouncycastle.jce.provider.JCEBlockCipher$Skipjack");
3332+        // BEGIN android-changed
3333+        put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "DESEDEWRAP");
3334+        // END android-changed
3335+        // BEGIN android-removed
3336+        // put("Cipher.SKIPJACK", "org.bouncycastle.jce.provider.JCEBlockCipher$Skipjack");
3337+        // END android-removed
3338         put("Cipher.BLOWFISH", "org.bouncycastle.jce.provider.JCEBlockCipher$Blowfish");
3339-        put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.JCEBlockCipher$BlowfishCBC");
3340-        put("Cipher.TWOFISH", "org.bouncycastle.jce.provider.JCEBlockCipher$Twofish");
3341-        put("Cipher.RC2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2");
3342-        put("Cipher.RC2WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
3343-        put("Cipher.1.2.840.113549.1.9.16.3.7", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
3344+        // BEGIN android-removed
3345+        // put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.JCEBlockCipher$BlowfishCBC");
3346+        // put("Cipher.TWOFISH", "org.bouncycastle.jce.provider.JCEBlockCipher$Twofish");
3347+        // put("Cipher.RC2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2");
3348+        // put("Cipher.RC2WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
3349+        // put("Cipher.1.2.840.113549.1.9.16.3.7", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap");
3350+        // END android-removed
3351         put("Cipher.ARC4", "org.bouncycastle.jce.provider.JCEStreamCipher$RC4");
3352         put("Alg.Alias.Cipher.1.2.840.113549.3.4", "ARC4");
3353         put("Alg.Alias.Cipher.ARCFOUR", "ARC4");
3354         put("Alg.Alias.Cipher.RC4", "ARC4");
3355-        put("Cipher.SALSA20", "org.bouncycastle.jce.provider.JCEStreamCipher$Salsa20");
3356-        put("Cipher.HC128", "org.bouncycastle.jce.provider.JCEStreamCipher$HC128");
3357-        put("Cipher.HC256", "org.bouncycastle.jce.provider.JCEStreamCipher$HC256");
3358-        put("Cipher.VMPC", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPC");
3359-        put("Cipher.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPCKSA3");
3360-        put("Cipher.RC5", "org.bouncycastle.jce.provider.JCEBlockCipher$RC5");
3361-        put("Cipher.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2CBC");
3362-        put("Alg.Alias.Cipher.RC5-32", "RC5");
3363-        put("Cipher.RC5-64", "org.bouncycastle.jce.provider.JCEBlockCipher$RC564");
3364-        put("Cipher.RC6", "org.bouncycastle.jce.provider.JCEBlockCipher$RC6");
3365-        put("Cipher.RIJNDAEL", "org.bouncycastle.jce.provider.JCEBlockCipher$Rijndael");
3366-        put("Cipher.DESEDERFC3211WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RFC3211DESedeWrap");
3367-        put("Cipher.SERPENT", "org.bouncycastle.jce.provider.JCEBlockCipher$Serpent");
3368-
3369-
3370-        put("Cipher.CAST6", "org.bouncycastle.jce.provider.JCEBlockCipher$CAST6");
3371+        // BEGIN android-removed
3372+        // put("Cipher.SALSA20", "org.bouncycastle.jce.provider.JCEStreamCipher$Salsa20");
3373+        // put("Cipher.HC128", "org.bouncycastle.jce.provider.JCEStreamCipher$HC128");
3374+        // put("Cipher.HC256", "org.bouncycastle.jce.provider.JCEStreamCipher$HC256");
3375+        // put("Cipher.VMPC", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPC");
3376+        // put("Cipher.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPCKSA3");
3377+        // put("Cipher.RC5", "org.bouncycastle.jce.provider.JCEBlockCipher$RC5");
3378+        // put("Cipher.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2CBC");
3379+        // put("Alg.Alias.Cipher.RC5-32", "RC5");
3380+        // put("Cipher.RC5-64", "org.bouncycastle.jce.provider.JCEBlockCipher$RC564");
3381+        // put("Cipher.RC6", "org.bouncycastle.jce.provider.JCEBlockCipher$RC6");
3382+        // put("Cipher.RIJNDAEL", "org.bouncycastle.jce.provider.JCEBlockCipher$Rijndael");
3383+        // put("Cipher.DESEDERFC3211WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RFC3211DESedeWrap");
3384+        // put("Cipher.SERPENT", "org.bouncycastle.jce.provider.JCEBlockCipher$Serpent");
3385+        // END android-removed
3386+
3387+
3388+        // BEGIN android-removed
3389+        // put("Cipher.CAST6", "org.bouncycastle.jce.provider.JCEBlockCipher$CAST6");
3390+        // END android-removed
3391         put("Alg.Alias.Cipher.PBEWithSHAAnd3KeyTripleDES",  "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
3392
3393-        put("Cipher.GOST28147", "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147");
3394-        put("Alg.Alias.Cipher.GOST", "GOST28147");
3395-        put("Alg.Alias.Cipher.GOST-28147", "GOST28147");
3396-        put("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147cbc");
3397-
3398-        put("Cipher.TEA", "org.bouncycastle.jce.provider.JCEBlockCipher$TEA");
3399-        put("Cipher.XTEA", "org.bouncycastle.jce.provider.JCEBlockCipher$XTEA");
3400+        // BEGIN android-removed
3401+        // put("Cipher.GOST28147", "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147");
3402+        // put("Alg.Alias.Cipher.GOST", "GOST28147");
3403+        // put("Alg.Alias.Cipher.GOST-28147", "GOST28147");
3404+        // put("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147cbc");
3405+        //
3406+        // put("Cipher.TEA", "org.bouncycastle.jce.provider.JCEBlockCipher$TEA");
3407+        // put("Cipher.XTEA", "org.bouncycastle.jce.provider.JCEBlockCipher$XTEA");
3408+        // END android-removed
3409
3410         put("Cipher.RSA", "org.bouncycastle.jce.provider.JCERSACipher$NoPadding");
3411-        put("Cipher.RSA/RAW", "org.bouncycastle.jce.provider.JCERSACipher$NoPadding");
3412-        put("Cipher.RSA/PKCS1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
3413-        put("Cipher.1.2.840.113549.1.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
3414-        put("Cipher.2.5.8.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
3415-        put("Cipher.RSA/1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PrivateOnly");
3416-        put("Cipher.RSA/2", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PublicOnly");
3417-        put("Cipher.RSA/OAEP", "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
3418-        put("Cipher." + PKCSObjectIdentifiers.id_RSAES_OAEP, "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
3419-        put("Cipher.RSA/ISO9796-1", "org.bouncycastle.jce.provider.JCERSACipher$ISO9796d1Padding");
3420-
3421-        put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES");
3422-        put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES");
3423-        put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES");
3424-        put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES");
3425-        put("Cipher.ELGAMAL", "org.bouncycastle.jce.provider.JCEElGamalCipher$NoPadding");
3426-        put("Cipher.ELGAMAL/PKCS1", "org.bouncycastle.jce.provider.JCEElGamalCipher$PKCS1v1_5Padding");
3427+        // BEGIN android-changed
3428+        put("Alg.Alias.Cipher.RSA/RAW", "RSA");
3429+        // END android-changed
3430+        // BEGIN android-removed
3431+        // put("Cipher.RSA/PKCS1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
3432+        // put("Cipher.1.2.840.113549.1.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
3433+        // put("Cipher.2.5.8.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding");
3434+        // put("Cipher.RSA/1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PrivateOnly");
3435+        // put("Cipher.RSA/2", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PublicOnly");
3436+        // put("Cipher.RSA/OAEP", "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
3437+        // put("Cipher." + PKCSObjectIdentifiers.id_RSAES_OAEP, "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding");
3438+        // put("Cipher.RSA/ISO9796-1", "org.bouncycastle.jce.provider.JCERSACipher$ISO9796d1Padding");
3439+        // END android-removed
3440+
3441+        // BEGIN android-removed
3442+        // put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES");
3443+        // put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES");
3444+        // put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES");
3445+        // put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES");
3446+        // put("Cipher.ELGAMAL", "org.bouncycastle.jce.provider.JCEElGamalCipher$NoPadding");
3447+        // put("Cipher.ELGAMAL/PKCS1", "org.bouncycastle.jce.provider.JCEElGamalCipher$PKCS1v1_5Padding");
3448+        // END android-removed
3449
3450         put("Alg.Alias.Cipher.RSA//RAW", "RSA");
3451         put("Alg.Alias.Cipher.RSA//NOPADDING", "RSA");
3452-        put("Alg.Alias.Cipher.RSA//PKCS1PADDING", "RSA/PKCS1");
3453-        put("Alg.Alias.Cipher.RSA//OAEPPADDING", "RSA/OAEP");
3454-        put("Alg.Alias.Cipher.RSA//ISO9796-1PADDING", "RSA/ISO9796-1");
3455-
3456-        put("Alg.Alias.Cipher.ELGAMAL/ECB/PKCS1PADDING", "ELGAMAL/PKCS1");
3457-        put("Alg.Alias.Cipher.ELGAMAL/NONE/PKCS1PADDING", "ELGAMAL/PKCS1");
3458-        put("Alg.Alias.Cipher.ELGAMAL/NONE/NOPADDING", "ELGAMAL");
3459+        // BEGIN android-removed
3460+        // put("Alg.Alias.Cipher.RSA//PKCS1PADDING", "RSA/PKCS1");
3461+        // put("Alg.Alias.Cipher.RSA//OAEPPADDING", "RSA/OAEP");
3462+        // put("Alg.Alias.Cipher.RSA//ISO9796-1PADDING", "RSA/ISO9796-1");
3463+        // END android-removed
3464+
3465+        // BEGIN android-removed
3466+        // put("Alg.Alias.Cipher.ELGAMAL/ECB/PKCS1PADDING", "ELGAMAL/PKCS1");
3467+        // put("Alg.Alias.Cipher.ELGAMAL/NONE/PKCS1PADDING", "ELGAMAL/PKCS1");
3468+        // put("Alg.Alias.Cipher.ELGAMAL/NONE/NOPADDING", "ELGAMAL");
3469+        // END android-removed
3470
3471         put("Cipher.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndDES");
3472-        put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES");
3473+        // BEGIN android-removed
3474+        // put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES");
3475+        // END android-removed
3476         put("Cipher.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndRC2");
3477         put("Cipher.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndDES");
3478-        put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES");
3479+        // BEGIN android-removed
3480+        // put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES");
3481+        // END android-removed
3482         put("Cipher.PBEWITHSHA1ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndRC2");
3483         put("Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndDES3Key");
3484-        put("Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES3Key");
3485-        put("Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndDES3Key");
3486+        // BEGIN android-removed
3487+        // put("Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES3Key");
3488+        // put("Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndDES3Key");
3489+        // END android-removed
3490         put("Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndDES2Key");
3491-        put("Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES2Key");
3492+        // BEGIN android-removed
3493+        // put("Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES2Key");
3494+        // END android-removed
3495         put("Cipher.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd128BitRC2");
3496         put("Cipher.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd40BitRC2");
3497         put("Cipher.PBEWITHSHAAND128BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd128BitRC4");
3498         put("Cipher.PBEWITHSHAAND40BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd40BitRC4");
3499
3500-        put("Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC", "Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
3501-        put("Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC", "Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC");
3502-        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "Cipher.PBEWITHSHAAND128BITRC2-CBC");
3503-        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "Cipher.PBEWITHSHAAND40BITRC2-CBC");
3504-        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "Cipher.PBEWITHSHAAND128BITRC4");
3505-        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "Cipher.PBEWITHSHAAND40BITRC4");
3506+        put("Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC");
3507+        put("Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC", "PBEWITHSHAAND2-KEYTRIPLEDES-CBC");
3508+        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "PBEWITHSHAAND128BITRC2-CBC");
3509+        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "PBEWITHSHAAND40BITRC2-CBC");
3510+        put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "PBEWITHSHAAND128BITRC4");
3511+        put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "PBEWITHSHAAND40BITRC4");
3512
3513         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PBEWITHSHAAND128BITAES-CBC-BC");
3514         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PBEWITHSHAAND192BITAES-CBC-BC");
3515@@ -350,7 +424,7 @@
3516         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC");
3517         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC");
3518         put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC");
3519-
3520+
3521         put("Cipher.PBEWITHSHAAND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
3522         put("Cipher.PBEWITHSHAAND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
3523         put("Cipher.PBEWITHSHAAND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
3524@@ -372,7 +446,9 @@
3525         put("Cipher.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC");
3526
3527         put("Cipher.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndTwofish");
3528-        put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish");
3529+        // BEGIN android-removed
3530+        // put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish");
3531+        // END android-removed
3532
3533         put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.1", "PBEWITHSHAAND128BITRC4");
3534         put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.2", "PBEWITHSHAAND40BITRC4");
3535@@ -387,38 +463,49 @@
3536         put("KeyGenerator.DES", "org.bouncycastle.jce.provider.JCEKeyGenerator$DES");
3537         put("Alg.Alias.KeyGenerator." + OIWObjectIdentifiers.desCBC, "DES");
3538         put("KeyGenerator.DESEDE", "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede");
3539-        put("KeyGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede3");
3540-        put("KeyGenerator.DESEDEWRAP", "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede");
3541-        put("KeyGenerator.SKIPJACK", "org.bouncycastle.jce.provider.JCEKeyGenerator$Skipjack");
3542+        // BEGIN android-removed
3543+        // put("KeyGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede3");
3544+        // put("KeyGenerator.DESEDEWRAP", "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede");
3545+        // put("KeyGenerator.SKIPJACK", "org.bouncycastle.jce.provider.JCEKeyGenerator$Skipjack");
3546+        // END android-removed
3547         put("KeyGenerator.BLOWFISH", "org.bouncycastle.jce.provider.JCEKeyGenerator$Blowfish");
3548         put("Alg.Alias.KeyGenerator.1.3.6.1.4.1.3029.1.2", "BLOWFISH");
3549-        put("KeyGenerator.TWOFISH", "org.bouncycastle.jce.provider.JCEKeyGenerator$Twofish");
3550-        put("KeyGenerator.RC2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
3551-        put("KeyGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
3552+        // BEGIN android-removed
3553+        // put("KeyGenerator.TWOFISH", "org.bouncycastle.jce.provider.JCEKeyGenerator$Twofish");
3554+        // put("KeyGenerator.RC2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
3555+        // put("KeyGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2");
3556+        // END android-removed
3557         put("KeyGenerator.RC4", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC4");
3558         put("Alg.Alias.KeyGenerator.ARC4", "RC4");
3559-        put("Alg.Alias.KeyGenerator.1.2.840.113549.3.4", "RC4");
3560-        put("KeyGenerator.RC5", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC5");
3561-        put("Alg.Alias.KeyGenerator.RC5-32", "RC5");
3562-        put("KeyGenerator.RC5-64", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC564");
3563-        put("KeyGenerator.RC6", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC6");
3564-        put("KeyGenerator.RIJNDAEL", "org.bouncycastle.jce.provider.JCEKeyGenerator$Rijndael");
3565-
3566-        put("KeyGenerator.SERPENT", "org.bouncycastle.jce.provider.JCEKeyGenerator$Serpent");
3567-        put("KeyGenerator.SALSA20", "org.bouncycastle.jce.provider.JCEKeyGenerator$Salsa20");
3568-        put("KeyGenerator.HC128", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC128");
3569-        put("KeyGenerator.HC256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC256");
3570-        put("KeyGenerator.VMPC", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPC");
3571-        put("KeyGenerator.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPCKSA3");
3572-
3573-        put("KeyGenerator.CAST6", "org.bouncycastle.jce.provider.JCEKeyGenerator$CAST6");
3574-        put("KeyGenerator.TEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$TEA");
3575-        put("KeyGenerator.XTEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$XTEA");
3576-
3577-        put("KeyGenerator.GOST28147", "org.bouncycastle.jce.provider.JCEKeyGenerator$GOST28147");
3578-        put("Alg.Alias.KeyGenerator.GOST", "GOST28147");
3579-        put("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147");
3580-        put("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147");
3581+        // BEGIN android-added
3582+        put("Alg.Alias.KeyGenerator.ARCFOUR", "RC4");
3583+        // END android-added
3584+        // BEGIN android-removed
3585+        // put("Alg.Alias.KeyGenerator.1.2.840.113549.3.4", "RC4");
3586+        // put("KeyGenerator.RC5", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC5");
3587+        // put("Alg.Alias.KeyGenerator.RC5-32", "RC5");
3588+        // put("KeyGenerator.RC5-64", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC564");
3589+        // put("KeyGenerator.RC6", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC6");
3590+        // put("KeyGenerator.RIJNDAEL", "org.bouncycastle.jce.provider.JCEKeyGenerator$Rijndael");
3591+        //
3592+        // put("KeyGenerator.SERPENT", "org.bouncycastle.jce.provider.JCEKeyGenerator$Serpent");
3593+        // put("KeyGenerator.SALSA20", "org.bouncycastle.jce.provider.JCEKeyGenerator$Salsa20");
3594+        // put("KeyGenerator.HC128", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC128");
3595+        // put("KeyGenerator.HC256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC256");
3596+        // put("KeyGenerator.VMPC", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPC");
3597+        // put("KeyGenerator.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPCKSA3");
3598+        // END android-removed
3599+
3600+        // BEGIN android-removed
3601+        // put("KeyGenerator.CAST6", "org.bouncycastle.jce.provider.JCEKeyGenerator$CAST6");
3602+        // put("KeyGenerator.TEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$TEA");
3603+        // put("KeyGenerator.XTEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$XTEA");
3604+        //
3605+        // put("KeyGenerator.GOST28147", "org.bouncycastle.jce.provider.JCEKeyGenerator$GOST28147");
3606+        // put("Alg.Alias.KeyGenerator.GOST", "GOST28147");
3607+        // put("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147");
3608+        // put("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147");
3609+        // END android-removed
3610
3611         //
3612         // key pair generators.
3613@@ -426,14 +513,18 @@
3614         put("KeyPairGenerator.RSA", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$RSA");
3615         put("KeyPairGenerator.DH", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$DH");
3616         put("KeyPairGenerator.DSA", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$DSA");
3617-        put("KeyPairGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$ElGamal");
3618+        // BEGIN android-removed
3619+        // put("KeyPairGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$ElGamal");
3620+        // END android-removed
3621
3622         put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.1", "RSA");
3623         put("Alg.Alias.KeyPairGenerator.DIFFIEHELLMAN", "DH");
3624
3625-        put("KeyPairGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$GOST3410");
3626-        put("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410");
3627-        put("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410");
3628+        // BEGIN android-removed
3629+        // put("KeyPairGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$GOST3410");
3630+        // put("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410");
3631+        // put("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410");
3632+        // END android-removed
3633
3634         //
3635         // key factories
3636@@ -441,20 +532,24 @@
3637         put("KeyFactory.RSA", "org.bouncycastle.jce.provider.JDKKeyFactory$RSA");
3638         put("KeyFactory.DH", "org.bouncycastle.jce.provider.JDKKeyFactory$DH");
3639         put("KeyFactory.DSA", "org.bouncycastle.jce.provider.JDKKeyFactory$DSA");
3640-        put("KeyFactory.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
3641-        put("KeyFactory.ElGamal", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
3642-
3643-        put("KeyFactory.X.509", "org.bouncycastle.jce.provider.JDKKeyFactory$X509");
3644+        // BEGIN android-removed
3645+        // put("KeyFactory.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
3646+        // put("KeyFactory.ElGamal", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal");
3647+        //
3648+        // put("KeyFactory.X.509", "org.bouncycastle.jce.provider.JDKKeyFactory$X509");
3649+        // END android-removed
3650
3651         put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.1", "RSA");
3652         put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA");
3653
3654         put("Alg.Alias.KeyFactory.DIFFIEHELLMAN", "DH");
3655
3656-        put("KeyFactory.GOST3410", "org.bouncycastle.jce.provider.JDKKeyFactory$GOST3410");
3657-        put("Alg.Alias.KeyFactory.GOST-3410", "GOST3410");
3658-        put("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410");
3659-        put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_94, "GOST3410");
3660+        // BEGIN android-removed
3661+        // put("KeyFactory.GOST3410", "org.bouncycastle.jce.provider.JDKKeyFactory$GOST3410");
3662+        // put("Alg.Alias.KeyFactory.GOST-3410", "GOST3410");
3663+        // put("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410");
3664+        // put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_94, "GOST3410");
3665+        // END android-removed
3666
3667         //
3668         // Algorithm parameters
3669@@ -462,16 +557,22 @@
3670         put("AlgorithmParameters.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3671         put("Alg.Alias.AlgorithmParameters." + OIWObjectIdentifiers.desCBC, "DES");
3672         put("AlgorithmParameters.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3673-        put("AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3674-        put("AlgorithmParameters.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
3675-        put("AlgorithmParameters.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
3676-        put("AlgorithmParameters.RC5", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3677-        put("AlgorithmParameters.RC6", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3678+        // BEGIN android-changed
3679+        put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "DESEDE");
3680+        // END android-changed
3681+        // BEGIN android-removed
3682+        // put("AlgorithmParameters.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
3683+        // put("AlgorithmParameters.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters");
3684+        // put("AlgorithmParameters.RC5", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3685+        // put("AlgorithmParameters.RC6", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3686+        // END android-removed
3687         put("AlgorithmParameters.BLOWFISH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3688         put("Alg.Alias.AlgorithmParameters.1.3.6.1.4.1.3029.1.2", "BLOWFISH");
3689-        put("AlgorithmParameters.TWOFISH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3690-        put("AlgorithmParameters.SKIPJACK", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3691-        put("AlgorithmParameters.RIJNDAEL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3692+        // BEGIN android-removed
3693+        // put("AlgorithmParameters.TWOFISH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3694+        // put("AlgorithmParameters.SKIPJACK", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3695+        // put("AlgorithmParameters.RIJNDAEL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters");
3696+        // END android-removed
3697
3698
3699         //
3700@@ -479,8 +580,10 @@
3701         //
3702         put("SecretKeyFactory.DES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$DES");
3703         put("SecretKeyFactory.DESEDE", "org.bouncycastle.jce.provider.JCESecretKeyFactory$DESede");
3704-        put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES");
3705-        put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2");
3706+        // BEGIN android-removed
3707+        // put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES");
3708+        // put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2");
3709+        // END android-removed
3710         put("SecretKeyFactory.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndDES");
3711         put("SecretKeyFactory.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndRC2");
3712         put("SecretKeyFactory.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA1AndDES");
3713@@ -492,31 +595,41 @@
3714         put("SecretKeyFactory.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd128BitRC2");
3715         put("SecretKeyFactory.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd40BitRC2");
3716         put("SecretKeyFactory.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndTwofish");
3717-        put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160");
3718+        // BEGIN android-removed
3719+        // put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160");
3720+        // END android-removed
3721         put("SecretKeyFactory.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA");
3722-        put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger");
3723+        // BEGIN android-removed
3724+        // put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger");
3725+        // END android-removed
3726
3727         put("SecretKeyFactory.PBEWITHMD5AND128BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And128BitAESCBCOpenSSL");
3728         put("SecretKeyFactory.PBEWITHMD5AND192BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And192BitAESCBCOpenSSL");
3729         put("SecretKeyFactory.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And256BitAESCBCOpenSSL");
3730
3731-        put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5");
3732-
3733-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5");
3734-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5");
3735-        put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
3736-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
3737-        put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12");
3738-        put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12");
3739-
3740-        put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES");
3741-        put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2");
3742+        // BEGIN android-removed
3743+        // put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5");
3744+        //
3745+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5");
3746+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5");
3747+        // put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
3748+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12");
3749+        // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12");
3750+        // put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12");
3751+        // END android-removed
3752+
3753+        // BEGIN android-removed
3754+        // put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES");
3755+        // put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2");
3756+        // END android-removed
3757         put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDDES-CBC", "PBEWITHMD5ANDDES");
3758         put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDRC2-CBC", "PBEWITHMD5ANDRC2");
3759         put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDDES-CBC", "PBEWITHSHA1ANDDES");
3760         put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDRC2-CBC", "PBEWITHSHA1ANDRC2");
3761-        put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
3762-        put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
3763+        // BEGIN android-removed
3764+        // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES");
3765+        // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2");
3766+        // END android-removed
3767         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES");
3768         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDRC2");
3769         put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES");
3770@@ -553,6 +666,10 @@
3771         put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC");
3772         put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC");
3773         put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC");
3774+        // BEGIN android-added
3775+
3776+        put("SecretKeyFactory.PBKDF2WithHmacSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBKDF2WithHmacSHA1");
3777+        // END android-added
3778
3779         addMacAlgorithms();
3780
3781@@ -561,16 +678,23 @@
3782         addSignatureAlgorithms();
3783
3784     // Certification Path API
3785-        put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi");
3786-        put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi");
3787-        put("CertPathValidator.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi");
3788-        put("CertPathBuilder.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi");
3789+        // BEGIN android-removed
3790+        // put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi");
3791+        // put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi");
3792+        // END android-removed
3793+        // BEGIN android-changed
3794+        // Use Alg.Alias so RFC3280 doesn't show up when iterating provider services, only PKIX
3795+        put("Alg.Alias.CertPathValidator.RFC3280", "PKIX");
3796+        put("Alg.Alias.CertPathBuilder.RFC3280", "PKIX");
3797+        // END android-changed
3798         put("CertPathValidator.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi");
3799         put("CertPathBuilder.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi");
3800         put("CertStore.Collection", "org.bouncycastle.jce.provider.CertStoreCollectionSpi");
3801-        put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi");
3802-        put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi");
3803-        put("Alg.Alias.CertStore.X509LDAP", "LDAP");
3804+        // BEGIN android-removed
3805+        // put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi");
3806+        // put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi");
3807+        // put("Alg.Alias.CertStore.X509LDAP", "LDAP");
3808+        // END android-removed
3809     }
3810
3811     private void loadAlgorithms(String packageName, String[] names)
3812@@ -631,68 +755,72 @@
3813     //
3814     private void addMacAlgorithms()
3815     {
3816-        put("Mac.DESMAC", "org.bouncycastle.jce.provider.JCEMac$DES");
3817-        put("Alg.Alias.Mac.DES", "DESMAC");
3818-        put("Mac.DESMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESCFB8");
3819-        put("Alg.Alias.Mac.DES/CFB8", "DESMAC/CFB8");
3820-
3821-        put("Mac.DESEDEMAC", "org.bouncycastle.jce.provider.JCEMac$DESede");
3822-        put("Alg.Alias.Mac.DESEDE", "DESEDEMAC");
3823-        put("Mac.DESEDEMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESedeCFB8");
3824-        put("Alg.Alias.Mac.DESEDE/CFB8", "DESEDEMAC/CFB8");
3825-
3826-        put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
3827-        put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797");
3828-
3829-        put("Mac.DESEDEMAC64", "org.bouncycastle.jce.provider.JCEMac$DESede64");
3830-        put("Alg.Alias.Mac.DESEDE64", "DESEDEMAC64");
3831-
3832-        put("Mac.DESEDEMAC64WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DESede64with7816d4");
3833-        put("Alg.Alias.Mac.DESEDE64WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
3834-        put("Alg.Alias.Mac.DESEDEISO9797ALG1MACWITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
3835-        put("Alg.Alias.Mac.DESEDEISO9797ALG1WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
3836-
3837-        put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
3838-        put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC");
3839-        put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4");
3840-        put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING");
3841-
3842-        put("Mac.SKIPJACKMAC", "org.bouncycastle.jce.provider.JCEMac$Skipjack");
3843-        put("Alg.Alias.Mac.SKIPJACK", "SKIPJACKMAC");
3844-        put("Mac.SKIPJACKMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$SkipjackCFB8");
3845-        put("Alg.Alias.Mac.SKIPJACK/CFB8", "SKIPJACKMAC/CFB8");
3846-
3847-        put("Mac.RC2MAC", "org.bouncycastle.jce.provider.JCEMac$RC2");
3848-        put("Alg.Alias.Mac.RC2", "RC2MAC");
3849-        put("Mac.RC2MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC2CFB8");
3850-        put("Alg.Alias.Mac.RC2/CFB8", "RC2MAC/CFB8");
3851-
3852-        put("Mac.RC5MAC", "org.bouncycastle.jce.provider.JCEMac$RC5");
3853-        put("Alg.Alias.Mac.RC5", "RC5MAC");
3854-        put("Mac.RC5MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC5CFB8");
3855-        put("Alg.Alias.Mac.RC5/CFB8", "RC5MAC/CFB8");
3856-
3857-        put("Mac.GOST28147MAC", "org.bouncycastle.jce.provider.JCEMac$GOST28147");
3858-        put("Alg.Alias.Mac.GOST28147", "GOST28147MAC");
3859-
3860-        put("Mac.VMPCMAC", "org.bouncycastle.jce.provider.JCEMac$VMPC");
3861-        put("Alg.Alias.Mac.VMPC", "VMPCMAC");
3862-        put("Alg.Alias.Mac.VMPC-MAC", "VMPCMAC");
3863-
3864-        put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384");
3865-
3866-        put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512");
3867-
3868-        addHMACAlgorithm("MD2", "org.bouncycastle.jce.provider.JCEMac$MD2", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD2HMAC");
3869-        addHMACAlgorithm("MD4", "org.bouncycastle.jce.provider.JCEMac$MD4", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD4HMAC");
3870+        // BEGIN android-removed
3871+        // put("Mac.DESMAC", "org.bouncycastle.jce.provider.JCEMac$DES");
3872+        // put("Alg.Alias.Mac.DES", "DESMAC");
3873+        // put("Mac.DESMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESCFB8");
3874+        // put("Alg.Alias.Mac.DES/CFB8", "DESMAC/CFB8");
3875+        //
3876+        // put("Mac.DESEDEMAC", "org.bouncycastle.jce.provider.JCEMac$DESede");
3877+        // put("Alg.Alias.Mac.DESEDE", "DESEDEMAC");
3878+        // put("Mac.DESEDEMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESedeCFB8");
3879+        // put("Alg.Alias.Mac.DESEDE/CFB8", "DESEDEMAC/CFB8");
3880+        //
3881+        // put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
3882+        // put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797");
3883+        //
3884+        // put("Mac.DESEDEMAC64", "org.bouncycastle.jce.provider.JCEMac$DESede64");
3885+        // put("Alg.Alias.Mac.DESEDE64", "DESEDEMAC64");
3886+        //
3887+        // put("Mac.DESEDEMAC64WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DESede64with7816d4");
3888+        // put("Alg.Alias.Mac.DESEDE64WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
3889+        // put("Alg.Alias.Mac.DESEDEISO9797ALG1MACWITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
3890+        // put("Alg.Alias.Mac.DESEDEISO9797ALG1WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING");
3891+        //
3892+        // put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3");
3893+        // put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC");
3894+        // put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4");
3895+        // put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING");
3896+        //
3897+        // put("Mac.SKIPJACKMAC", "org.bouncycastle.jce.provider.JCEMac$Skipjack");
3898+        // put("Alg.Alias.Mac.SKIPJACK", "SKIPJACKMAC");
3899+        // put("Mac.SKIPJACKMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$SkipjackCFB8");
3900+        // put("Alg.Alias.Mac.SKIPJACK/CFB8", "SKIPJACKMAC/CFB8");
3901+        //
3902+        // put("Mac.RC2MAC", "org.bouncycastle.jce.provider.JCEMac$RC2");
3903+        // put("Alg.Alias.Mac.RC2", "RC2MAC");
3904+        // put("Mac.RC2MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC2CFB8");
3905+        // put("Alg.Alias.Mac.RC2/CFB8", "RC2MAC/CFB8");
3906+        //
3907+        // put("Mac.RC5MAC", "org.bouncycastle.jce.provider.JCEMac$RC5");
3908+        // put("Alg.Alias.Mac.RC5", "RC5MAC");
3909+        // put("Mac.RC5MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC5CFB8");
3910+        // put("Alg.Alias.Mac.RC5/CFB8", "RC5MAC/CFB8");
3911+        //
3912+        // put("Mac.GOST28147MAC", "org.bouncycastle.jce.provider.JCEMac$GOST28147");
3913+        // put("Alg.Alias.Mac.GOST28147", "GOST28147MAC");
3914+        //
3915+        // put("Mac.VMPCMAC", "org.bouncycastle.jce.provider.JCEMac$VMPC");
3916+        // put("Alg.Alias.Mac.VMPC", "VMPCMAC");
3917+        // put("Alg.Alias.Mac.VMPC-MAC", "VMPCMAC");
3918+        //
3919+        // put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384");
3920+        //
3921+        // put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512");
3922+        //
3923+        // addHMACAlgorithm("MD2", "org.bouncycastle.jce.provider.JCEMac$MD2", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD2HMAC");
3924+        // addHMACAlgorithm("MD4", "org.bouncycastle.jce.provider.JCEMac$MD4", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD4HMAC");
3925+        // END android-removed
3926         addHMACAlgorithm("MD5", "org.bouncycastle.jce.provider.JCEMac$MD5", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD5HMAC");
3927         addHMACAlias("MD5", IANAObjectIdentifiers.hmacMD5);
3928
3929         addHMACAlgorithm("SHA1", "org.bouncycastle.jce.provider.JCEMac$SHA1", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA1");
3930         addHMACAlias("SHA1", PKCSObjectIdentifiers.id_hmacWithSHA1);
3931         addHMACAlias("SHA1", IANAObjectIdentifiers.hmacSHA1);
3932-        addHMACAlgorithm("SHA224", "org.bouncycastle.jce.provider.JCEMac$SHA224", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA224");
3933-        addHMACAlias("SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224);
3934+        // BEGIN android-removed
3935+        // addHMACAlgorithm("SHA224", "org.bouncycastle.jce.provider.JCEMac$SHA224", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA224");
3936+        // addHMACAlias("SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224);
3937+        // END android-removed
3938         addHMACAlgorithm("SHA256", "org.bouncycastle.jce.provider.JCEMac$SHA256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA256");
3939         addHMACAlias("SHA256", PKCSObjectIdentifiers.id_hmacWithSHA256);
3940         addHMACAlgorithm("SHA384", "org.bouncycastle.jce.provider.JCEMac$SHA384", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA384");
3941@@ -700,16 +828,20 @@
3942         addHMACAlgorithm("SHA512", "org.bouncycastle.jce.provider.JCEMac$SHA512", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA512");
3943         addHMACAlias("SHA512", PKCSObjectIdentifiers.id_hmacWithSHA512);
3944
3945-        addHMACAlgorithm("RIPEMD128", "org.bouncycastle.jce.provider.JCEMac$RIPEMD128", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD128HMAC");
3946-        addHMACAlgorithm("RIPEMD160", "org.bouncycastle.jce.provider.JCEMac$RIPEMD160", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD160HMAC");
3947-        addHMACAlias("RIPEMD160", IANAObjectIdentifiers.hmacRIPEMD160);
3948-
3949-        addHMACAlgorithm("TIGER", "org.bouncycastle.jce.provider.JCEMac$Tiger", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACTIGER");
3950-        addHMACAlias("TIGER", IANAObjectIdentifiers.hmacTIGER);
3951+        // BEGIN android-removed
3952+        // addHMACAlgorithm("RIPEMD128", "org.bouncycastle.jce.provider.JCEMac$RIPEMD128", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD128HMAC");
3953+        // addHMACAlgorithm("RIPEMD160", "org.bouncycastle.jce.provider.JCEMac$RIPEMD160", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD160HMAC");
3954+        // addHMACAlias("RIPEMD160", IANAObjectIdentifiers.hmacRIPEMD160);
3955+        //
3956+        // addHMACAlgorithm("TIGER", "org.bouncycastle.jce.provider.JCEMac$Tiger", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACTIGER");
3957+        // addHMACAlias("TIGER", IANAObjectIdentifiers.hmacTIGER);
3958+        // END android-removed
3959
3960         put("Mac.PBEWITHHMACSHA", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA");
3961         put("Mac.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA");
3962-        put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160");
3963+        // BEGIN android-removed
3964+        // put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160");
3965+        // END android-removed
3966         put("Alg.Alias.Mac.1.3.14.3.2.26", "PBEWITHHMACSHA");
3967     }
3968
3969@@ -747,9 +879,11 @@
3970         put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
3971         put("Alg.Alias.MessageDigest.SHA", "SHA-1");
3972         put("Alg.Alias.MessageDigest." + OIWObjectIdentifiers.idSHA1, "SHA-1");
3973-        put("MessageDigest.SHA-224", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA224");
3974-        put("Alg.Alias.MessageDigest.SHA224", "SHA-224");
3975-        put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224");
3976+        // BEGIN android-removed
3977+        // put("MessageDigest.SHA-224", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA224");
3978+        // put("Alg.Alias.MessageDigest.SHA224", "SHA-224");
3979+        // put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224");
3980+        // END android-removed
3981         put("MessageDigest.SHA-256", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA256");
3982         put("Alg.Alias.MessageDigest.SHA256", "SHA-256");
3983         put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha256, "SHA-256");
3984@@ -760,27 +894,31 @@
3985         put("Alg.Alias.MessageDigest.SHA512", "SHA-512");
3986         put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha512, "SHA-512");
3987
3988-        put("MessageDigest.MD2", "org.bouncycastle.jce.provider.JDKMessageDigest$MD2");
3989-        put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md2, "MD2");
3990-        put("MessageDigest.MD4", "org.bouncycastle.jce.provider.JDKMessageDigest$MD4");
3991-        put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md4, "MD4");
3992+        // BEGIN android-removed
3993+        // put("MessageDigest.MD2", "org.bouncycastle.jce.provider.JDKMessageDigest$MD2");
3994+        // put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md2, "MD2");
3995+        // put("MessageDigest.MD4", "org.bouncycastle.jce.provider.JDKMessageDigest$MD4");
3996+        // put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md4, "MD4");
3997+        // END android-removed
3998         put("MessageDigest.MD5", "org.bouncycastle.jce.provider.JDKMessageDigest$MD5");
3999         put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md5, "MD5");
4000-        put("MessageDigest.RIPEMD128", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD128");
4001-        put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd128, "RIPEMD128");
4002-        put("MessageDigest.RIPEMD160", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD160");
4003-        put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd160, "RIPEMD160");
4004-        put("MessageDigest.RIPEMD256", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD256");
4005-        put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd256, "RIPEMD256");
4006-        put("MessageDigest.RIPEMD320", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD320");
4007-        put("MessageDigest.Tiger", "org.bouncycastle.jce.provider.JDKMessageDigest$Tiger");
4008-
4009-        put("MessageDigest.WHIRLPOOL", "org.bouncycastle.jce.provider.JDKMessageDigest$Whirlpool");
4010-
4011-        put("MessageDigest.GOST3411", "org.bouncycastle.jce.provider.JDKMessageDigest$GOST3411");
4012-        put("Alg.Alias.MessageDigest.GOST", "GOST3411");
4013-        put("Alg.Alias.MessageDigest.GOST-3411", "GOST3411");
4014-        put("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411");
4015+        // BEGIN android-removed
4016+        // put("MessageDigest.RIPEMD128", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD128");
4017+        // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd128, "RIPEMD128");
4018+        // put("MessageDigest.RIPEMD160", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD160");
4019+        // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd160, "RIPEMD160");
4020+        // put("MessageDigest.RIPEMD256", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD256");
4021+        // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd256, "RIPEMD256");
4022+        // put("MessageDigest.RIPEMD320", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD320");
4023+        // put("MessageDigest.Tiger", "org.bouncycastle.jce.provider.JDKMessageDigest$Tiger");
4024+
4025+        // put("MessageDigest.WHIRLPOOL", "org.bouncycastle.jce.provider.JDKMessageDigest$Whirlpool");
4026+
4027+        // put("MessageDigest.GOST3411", "org.bouncycastle.jce.provider.JDKMessageDigest$GOST3411");
4028+        // put("Alg.Alias.MessageDigest.GOST", "GOST3411");
4029+        // put("Alg.Alias.MessageDigest.GOST-3411", "GOST3411");
4030+        // put("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411");
4031+        // END android-removed
4032     }
4033
4034     //
4035@@ -788,55 +926,70 @@
4036     //
4037     private void addSignatureAlgorithms()
4038     {
4039-        put("Signature.MD2WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD2WithRSAEncryption");
4040-        put("Signature.MD4WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD4WithRSAEncryption");
4041+        // BEGIN android-removed
4042+        // Dropping MD2
4043+        // put("Signature.MD2WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD2WithRSAEncryption");
4044+        // put("Signature.MD4WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD4WithRSAEncryption");
4045+        // END android-removed
4046         put("Signature.MD5WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD5WithRSAEncryption");
4047         put("Signature.SHA1WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA1WithRSAEncryption");
4048-        put("Signature.SHA224WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA224WithRSAEncryption");
4049+        // BEGIN android-removed
4050+        // put("Signature.SHA224WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA224WithRSAEncryption");
4051+        // END android-removed
4052         put("Signature.SHA256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA256WithRSAEncryption");
4053         put("Signature.SHA384WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA384WithRSAEncryption");
4054         put("Signature.SHA512WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA512WithRSAEncryption");
4055-        put("Signature.RIPEMD160WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD160WithRSAEncryption");
4056-        put("Signature.RIPEMD128WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD128WithRSAEncryption");
4057-        put("Signature.RIPEMD256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD256WithRSAEncryption");
4058-        put("Signature.DSA", "org.bouncycastle.jce.provider.JDKDSASigner$stdDSA");
4059+        // BEGIN android-removed
4060+        // put("Signature.RIPEMD160WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD160WithRSAEncryption");
4061+        // put("Signature.RIPEMD128WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD128WithRSAEncryption");
4062+        // put("Signature.RIPEMD256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD256WithRSAEncryption");
4063+        // END android-removed
4064+        // BEGIN android-changed
4065+        put("Signature.SHA1withDSA", "org.bouncycastle.jce.provider.JDKDSASigner$stdDSA");
4066+        // END android-changed
4067         put("Signature.NONEWITHDSA", "org.bouncycastle.jce.provider.JDKDSASigner$noneDSA");
4068-        put("Signature.SHA1withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$SHA1WithRSAEncryption");
4069-        put("Signature.MD5withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$MD5WithRSAEncryption");
4070-        put("Signature.RIPEMD160withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$RIPEMD160WithRSAEncryption");
4071-
4072-        put("Signature.RSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
4073-        put("Signature." + PKCSObjectIdentifiers.id_RSASSA_PSS, "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
4074-        put("Signature.SHA1withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA1withRSA");
4075-        put("Signature.SHA224withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA224withRSA");
4076-        put("Signature.SHA256withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA256withRSA");
4077-        put("Signature.SHA384withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA384withRSA");
4078-        put("Signature.SHA512withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA512withRSA");
4079-
4080-        put("Signature.RSA", "org.bouncycastle.jce.provider.JDKDigestSignature$noneRSA");
4081-        put("Signature.RAWRSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$nonePSS");
4082+        // BEGIN android-removed
4083+        // put("Signature.SHA1withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$SHA1WithRSAEncryption");
4084+        // put("Signature.MD5withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$MD5WithRSAEncryption");
4085+        // put("Signature.RIPEMD160withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$RIPEMD160WithRSAEncryption");
4086+        //
4087+        // put("Signature.RSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
4088+        // put("Signature." + PKCSObjectIdentifiers.id_RSASSA_PSS, "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA");
4089+        // put("Signature.SHA1withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA1withRSA");
4090+        // put("Signature.SHA224withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA224withRSA");
4091+        // put("Signature.SHA256withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA256withRSA");
4092+        // put("Signature.SHA384withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA384withRSA");
4093+        // put("Signature.SHA512withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA512withRSA");
4094+        //
4095+        // put("Signature.RSA", "org.bouncycastle.jce.provider.JDKDigestSignature$noneRSA");
4096+        // put("Signature.RAWRSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$nonePSS");
4097+        // END android-removed
4098
4099         put("Alg.Alias.Signature.RAWDSA", "NONEWITHDSA");
4100
4101-        put("Alg.Alias.Signature.RAWRSA", "RSA");
4102-        put("Alg.Alias.Signature.NONEWITHRSA", "RSA");
4103-        put("Alg.Alias.Signature.RAWRSAPSS", "RAWRSASSA-PSS");
4104-        put("Alg.Alias.Signature.NONEWITHRSAPSS", "RAWRSASSA-PSS");
4105-        put("Alg.Alias.Signature.NONEWITHRSASSA-PSS", "RAWRSASSA-PSS");
4106-
4107-        put("Alg.Alias.Signature.RSAPSS", "RSASSA-PSS");
4108-
4109-        put("Alg.Alias.Signature.SHA1withRSAandMGF1", "SHA1withRSA/PSS");
4110-        put("Alg.Alias.Signature.SHA224withRSAandMGF1", "SHA224withRSA/PSS");
4111-        put("Alg.Alias.Signature.SHA256withRSAandMGF1", "SHA256withRSA/PSS");
4112-        put("Alg.Alias.Signature.SHA384withRSAandMGF1", "SHA384withRSA/PSS");
4113-        put("Alg.Alias.Signature.SHA512withRSAandMGF1", "SHA512withRSA/PSS");
4114-
4115-        put("Alg.Alias.Signature.MD2withRSAEncryption", "MD2WithRSAEncryption");
4116-        put("Alg.Alias.Signature.MD4withRSAEncryption", "MD4WithRSAEncryption");
4117+        // BEGIN android-removed
4118+        // put("Alg.Alias.Signature.RAWRSA", "RSA");
4119+        // put("Alg.Alias.Signature.NONEWITHRSA", "RSA");
4120+        // put("Alg.Alias.Signature.RAWRSAPSS", "RAWRSASSA-PSS");
4121+        // put("Alg.Alias.Signature.NONEWITHRSAPSS", "RAWRSASSA-PSS");
4122+        // put("Alg.Alias.Signature.NONEWITHRSASSA-PSS", "RAWRSASSA-PSS");
4123+        //
4124+        // put("Alg.Alias.Signature.RSAPSS", "RSASSA-PSS");
4125+        //
4126+        // put("Alg.Alias.Signature.SHA1withRSAandMGF1", "SHA1withRSA/PSS");
4127+        // put("Alg.Alias.Signature.SHA224withRSAandMGF1", "SHA224withRSA/PSS");
4128+        // put("Alg.Alias.Signature.SHA256withRSAandMGF1", "SHA256withRSA/PSS");
4129+        // put("Alg.Alias.Signature.SHA384withRSAandMGF1", "SHA384withRSA/PSS");
4130+        // put("Alg.Alias.Signature.SHA512withRSAandMGF1", "SHA512withRSA/PSS");
4131+        //
4132+        // put("Alg.Alias.Signature.MD2withRSAEncryption", "MD2WithRSAEncryption");
4133+        // put("Alg.Alias.Signature.MD4withRSAEncryption", "MD4WithRSAEncryption");
4134+        // END android-removed
4135         put("Alg.Alias.Signature.MD5withRSAEncryption", "MD5WithRSAEncryption");
4136         put("Alg.Alias.Signature.SHA1withRSAEncryption", "SHA1WithRSAEncryption");
4137-        put("Alg.Alias.Signature.SHA224withRSAEncryption", "SHA224WithRSAEncryption");
4138+        // BEGIN android-removed
4139+        // put("Alg.Alias.Signature.SHA224withRSAEncryption", "SHA224WithRSAEncryption");
4140+        // END android-removed
4141
4142         put("Alg.Alias.Signature.SHA256withRSAEncryption", "SHA256WithRSAEncryption");
4143         put("Alg.Alias.Signature.SHA384withRSAEncryption", "SHA384WithRSAEncryption");
4144@@ -850,24 +1003,30 @@
4145         put("Alg.Alias.Signature.SHA384WITHRSAENCRYPTION", "SHA384WithRSAEncryption");
4146         put("Alg.Alias.Signature.SHA512WITHRSAENCRYPTION", "SHA512WithRSAEncryption");
4147
4148-        put("Alg.Alias.Signature.RIPEMD160withRSAEncryption", "RIPEMD160WithRSAEncryption");
4149-
4150-        put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md2WithRSAEncryption, "MD2WithRSAEncryption");
4151-        put("Alg.Alias.Signature.MD2WithRSA", "MD2WithRSAEncryption");
4152-        put("Alg.Alias.Signature.MD2withRSA", "MD2WithRSAEncryption");
4153-        put("Alg.Alias.Signature.MD2/RSA", "MD2WithRSAEncryption");
4154+        // BEGIN android-removed
4155+        // Dropping MD2
4156+        // put("Alg.Alias.Signature.RIPEMD160withRSAEncryption", "RIPEMD160WithRSAEncryption");
4157+        // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md2WithRSAEncryption, "MD2WithRSAEncryption");
4158+        // put("Alg.Alias.Signature.MD2WithRSA", "MD2WithRSAEncryption");
4159+        // put("Alg.Alias.Signature.MD2withRSA", "MD2WithRSAEncryption");
4160+        // put("Alg.Alias.Signature.MD2/RSA", "MD2WithRSAEncryption");
4161+        // END android-removed
4162         put("Alg.Alias.Signature.MD5WithRSA", "MD5WithRSAEncryption");
4163         put("Alg.Alias.Signature.MD5withRSA", "MD5WithRSAEncryption");
4164         put("Alg.Alias.Signature.MD5/RSA", "MD5WithRSAEncryption");
4165         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md5WithRSAEncryption, "MD5WithRSAEncryption");
4166-        put("Alg.Alias.Signature.MD4WithRSA", "MD4WithRSAEncryption");
4167-        put("Alg.Alias.Signature.MD4withRSA", "MD4WithRSAEncryption");
4168-        put("Alg.Alias.Signature.MD4/RSA", "MD4WithRSAEncryption");
4169-        put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md4WithRSAEncryption, "MD4WithRSAEncryption");
4170+        // BEGIN android-removed
4171+        // put("Alg.Alias.Signature.MD4WithRSA", "MD4WithRSAEncryption");
4172+        // put("Alg.Alias.Signature.MD4withRSA", "MD4WithRSAEncryption");
4173+        // put("Alg.Alias.Signature.MD4/RSA", "MD4WithRSAEncryption");
4174+        // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md4WithRSAEncryption, "MD4WithRSAEncryption");
4175+        // END android-removed
4176         put("Alg.Alias.Signature.SHA1WithRSA", "SHA1WithRSAEncryption");
4177         put("Alg.Alias.Signature.SHA1withRSA", "SHA1WithRSAEncryption");
4178-        put("Alg.Alias.Signature.SHA224WithRSA", "SHA224WithRSAEncryption");
4179-        put("Alg.Alias.Signature.SHA224withRSA", "SHA224WithRSAEncryption");
4180+        // BEGIN android-removed
4181+        // put("Alg.Alias.Signature.SHA224WithRSA", "SHA224WithRSAEncryption");
4182+        // put("Alg.Alias.Signature.SHA224withRSA", "SHA224WithRSAEncryption");
4183+        // END android-removed
4184         put("Alg.Alias.Signature.SHA256WithRSA", "SHA256WithRSAEncryption");
4185         put("Alg.Alias.Signature.SHA256withRSA", "SHA256WithRSAEncryption");
4186         put("Alg.Alias.Signature.SHA384WithRSA", "SHA384WithRSAEncryption");
4187@@ -877,92 +1036,110 @@
4188         put("Alg.Alias.Signature.SHA1/RSA", "SHA1WithRSAEncryption");
4189         put("Alg.Alias.Signature.SHA-1/RSA", "SHA1WithRSAEncryption");
4190         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha1WithRSAEncryption, "SHA1WithRSAEncryption");
4191-        put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WithRSAEncryption");
4192+        // BEGIN android-removed
4193+        // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WithRSAEncryption");
4194+        // END android-removed
4195         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha256WithRSAEncryption, "SHA256WithRSAEncryption");
4196         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha384WithRSAEncryption, "SHA384WithRSAEncryption");
4197         put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha512WithRSAEncryption, "SHA512WithRSAEncryption");
4198         put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.1", "SHA1WithRSAEncryption");
4199         put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.5", "SHA1WithRSAEncryption");
4200         put("Alg.Alias.Signature.1.2.840.113549.2.5with1.2.840.113549.1.1.1", "MD5WithRSAEncryption");
4201-        put("Alg.Alias.Signature.RIPEMD160WithRSA", "RIPEMD160WithRSAEncryption");
4202-        put("Alg.Alias.Signature.RIPEMD160withRSA", "RIPEMD160WithRSAEncryption");
4203-        put("Alg.Alias.Signature.RIPEMD128WithRSA", "RIPEMD128WithRSAEncryption");
4204-        put("Alg.Alias.Signature.RIPEMD128withRSA", "RIPEMD128WithRSAEncryption");
4205-        put("Alg.Alias.Signature.RIPEMD256WithRSA", "RIPEMD256WithRSAEncryption");
4206-        put("Alg.Alias.Signature.RIPEMD256withRSA", "RIPEMD256WithRSAEncryption");
4207-        put("Alg.Alias.Signature.RIPEMD-160/RSA", "RIPEMD160WithRSAEncryption");
4208-        put("Alg.Alias.Signature.RMD160withRSA", "RIPEMD160WithRSAEncryption");
4209-        put("Alg.Alias.Signature.RMD160/RSA", "RIPEMD160WithRSAEncryption");
4210-        put("Alg.Alias.Signature.1.3.36.3.3.1.2", "RIPEMD160WithRSAEncryption");
4211-        put("Alg.Alias.Signature.1.3.36.3.3.1.3", "RIPEMD128WithRSAEncryption");
4212-        put("Alg.Alias.Signature.1.3.36.3.3.1.4", "RIPEMD256WithRSAEncryption");
4213+        // BEGIN android-removed
4214+        // put("Alg.Alias.Signature.RIPEMD160WithRSA", "RIPEMD160WithRSAEncryption");
4215+        // put("Alg.Alias.Signature.RIPEMD160withRSA", "RIPEMD160WithRSAEncryption");
4216+        // put("Alg.Alias.Signature.RIPEMD128WithRSA", "RIPEMD128WithRSAEncryption");
4217+        // put("Alg.Alias.Signature.RIPEMD128withRSA", "RIPEMD128WithRSAEncryption");
4218+        // put("Alg.Alias.Signature.RIPEMD256WithRSA", "RIPEMD256WithRSAEncryption");
4219+        // put("Alg.Alias.Signature.RIPEMD256withRSA", "RIPEMD256WithRSAEncryption");
4220+        // put("Alg.Alias.Signature.RIPEMD-160/RSA", "RIPEMD160WithRSAEncryption");
4221+        // put("Alg.Alias.Signature.RMD160withRSA", "RIPEMD160WithRSAEncryption");
4222+        // put("Alg.Alias.Signature.RMD160/RSA", "RIPEMD160WithRSAEncryption");
4223+        // put("Alg.Alias.Signature.1.3.36.3.3.1.2", "RIPEMD160WithRSAEncryption");
4224+        // put("Alg.Alias.Signature.1.3.36.3.3.1.3", "RIPEMD128WithRSAEncryption");
4225+        // put("Alg.Alias.Signature.1.3.36.3.3.1.4", "RIPEMD256WithRSAEncryption");
4226+        // END android-removed
4227         put("Alg.Alias.Signature." + OIWObjectIdentifiers.sha1WithRSA, "SHA1WithRSAEncryption");
4228
4229-        put("Alg.Alias.Signature.MD2WITHRSAENCRYPTION", "MD2WithRSAEncryption");
4230+        // BEGIN android-removed
4231+        // put("Alg.Alias.Signature.MD2WITHRSAENCRYPTION", "MD2WithRSAEncryption");
4232+        // END android-removed
4233         put("Alg.Alias.Signature.MD5WITHRSAENCRYPTION", "MD5WithRSAEncryption");
4234         put("Alg.Alias.Signature.SHA1WITHRSAENCRYPTION", "SHA1WithRSAEncryption");
4235-        put("Alg.Alias.Signature.RIPEMD160WITHRSAENCRYPTION", "RIPEMD160WithRSAEncryption");
4236+        // BEGIN android-removed
4237+        // put("Alg.Alias.Signature.RIPEMD160WITHRSAENCRYPTION", "RIPEMD160WithRSAEncryption");
4238+        // END android-removed
4239
4240         put("Alg.Alias.Signature.MD5WITHRSA", "MD5WithRSAEncryption");
4241         put("Alg.Alias.Signature.SHA1WITHRSA", "SHA1WithRSAEncryption");
4242-        put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
4243-        put("Alg.Alias.Signature.RMD160WITHRSA", "RIPEMD160WithRSAEncryption");
4244-        put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
4245-
4246-        addSignatureAlgorithm("SHA224", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa224", NISTObjectIdentifiers.dsa_with_sha224);
4247-        addSignatureAlgorithm("SHA256", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa256", NISTObjectIdentifiers.dsa_with_sha256);
4248-        addSignatureAlgorithm("SHA384", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa384", NISTObjectIdentifiers.dsa_with_sha384);
4249-        addSignatureAlgorithm("SHA512", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa512", NISTObjectIdentifiers.dsa_with_sha512);
4250-
4251-        put("Alg.Alias.Signature.SHA/DSA", "DSA");
4252-        put("Alg.Alias.Signature.SHA1withDSA", "DSA");
4253-        put("Alg.Alias.Signature.SHA1WITHDSA", "DSA");
4254-        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "DSA");
4255-        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3", "DSA");
4256-        put("Alg.Alias.Signature.DSAwithSHA1", "DSA");
4257-        put("Alg.Alias.Signature.DSAWITHSHA1", "DSA");
4258-        put("Alg.Alias.Signature.SHA1WithDSA", "DSA");
4259-        put("Alg.Alias.Signature.DSAWithSHA1", "DSA");
4260-        put("Alg.Alias.Signature.1.2.840.10040.4.3", "DSA");
4261-        put("Alg.Alias.Signature.MD5WithRSA/ISO9796-2", "MD5withRSA/ISO9796-2");
4262-        put("Alg.Alias.Signature.SHA1WithRSA/ISO9796-2", "SHA1withRSA/ISO9796-2");
4263-        put("Alg.Alias.Signature.RIPEMD160WithRSA/ISO9796-2", "RIPEMD160withRSA/ISO9796-2");
4264-
4265-        put("Signature.ECGOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$ecgost3410");
4266-        put("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410");
4267-        put("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410");
4268-        put("Alg.Alias.Signature.GOST3411withECGOST3410", "ECGOST3410");
4269-        put("Alg.Alias.Signature.GOST3411WITHECGOST3410", "ECGOST3410");
4270-        put("Alg.Alias.Signature.GOST3411WithECGOST3410", "ECGOST3410");
4271-        put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "ECGOST3410");
4272-
4273-        put("Signature.GOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$gost3410");
4274-        put("Alg.Alias.Signature.GOST-3410", "GOST3410");
4275-        put("Alg.Alias.Signature.GOST-3410-94", "GOST3410");
4276-        put("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410");
4277-        put("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410");
4278-        put("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410");
4279-        put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410");
4280+        // BEGIN android-removed
4281+        // put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
4282+        // put("Alg.Alias.Signature.RMD160WITHRSA", "RIPEMD160WithRSAEncryption");
4283+        // put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption");
4284+        // END android-removed
4285+
4286+        // BEGIN android-removed
4287+        // addSignatureAlgorithm("SHA224", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa224", NISTObjectIdentifiers.dsa_with_sha224);
4288+        // addSignatureAlgorithm("SHA256", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa256", NISTObjectIdentifiers.dsa_with_sha256);
4289+        // addSignatureAlgorithm("SHA384", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa384", NISTObjectIdentifiers.dsa_with_sha384);
4290+        // addSignatureAlgorithm("SHA512", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa512", NISTObjectIdentifiers.dsa_with_sha512);
4291+        // END android-removed
4292+
4293+        // BEGIN android-changed
4294+        put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA");
4295+        put("Alg.Alias.Signature.DSA", "SHA1withDSA");
4296+        put("Alg.Alias.Signature.SHA1WITHDSA", "SHA1withDSA");
4297+        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "SHA1withDSA");
4298+        put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3", "SHA1withDSA");
4299+        put("Alg.Alias.Signature.DSAwithSHA1", "SHA1withDSA");
4300+        put("Alg.Alias.Signature.DSAWITHSHA1", "SHA1withDSA");
4301+        put("Alg.Alias.Signature.SHA1WithDSA", "SHA1withDSA");
4302+        put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA");
4303+        put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA");
4304+        // END android-changed
4305+        // BEGIN android-removed
4306+        // put("Alg.Alias.Signature.MD5WithRSA/ISO9796-2", "MD5withRSA/ISO9796-2");
4307+        // put("Alg.Alias.Signature.SHA1WithRSA/ISO9796-2", "SHA1withRSA/ISO9796-2");
4308+        // put("Alg.Alias.Signature.RIPEMD160WithRSA/ISO9796-2", "RIPEMD160withRSA/ISO9796-2");
4309+        //
4310+        // put("Signature.ECGOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$ecgost3410");
4311+        // put("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410");
4312+        // put("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410");
4313+        // put("Alg.Alias.Signature.GOST3411withECGOST3410", "ECGOST3410");
4314+        // put("Alg.Alias.Signature.GOST3411WITHECGOST3410", "ECGOST3410");
4315+        // put("Alg.Alias.Signature.GOST3411WithECGOST3410", "ECGOST3410");
4316+        // put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "ECGOST3410");
4317+        //
4318+        // put("Signature.GOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$gost3410");
4319+        // put("Alg.Alias.Signature.GOST-3410", "GOST3410");
4320+        // put("Alg.Alias.Signature.GOST-3410-94", "GOST3410");
4321+        // put("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410");
4322+        // put("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410");
4323+        // put("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410");
4324+        // put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410");
4325+        // END android-removed
4326     }
4327
4328-    private void addSignatureAlgorithm(
4329-        String digest,
4330-        String algorithm,
4331-        String className,
4332-        DERObjectIdentifier oid)
4333-    {
4334-        String mainName = digest + "WITH" + algorithm;
4335-        String jdk11Variation1 = digest + "with" + algorithm;
4336-        String jdk11Variation2 = digest + "With" + algorithm;
4337-        String alias = digest + "/" + algorithm;
4338-
4339-        put("Signature." + mainName, className);
4340-        put("Alg.Alias.Signature." + jdk11Variation1, mainName);
4341-        put("Alg.Alias.Signature." + jdk11Variation2, mainName);
4342-        put("Alg.Alias.Signature." + alias, mainName);
4343-        put("Alg.Alias.Signature." + oid, mainName);
4344-        put("Alg.Alias.Signature.OID." + oid, mainName);
4345-    }
4346+    // BEGIN android-removed
4347+    // private void addSignatureAlgorithm(
4348+    //     String digest,
4349+    //     String algorithm,
4350+    //     String className,
4351+    //     DERObjectIdentifier oid)
4352+    // {
4353+    //     String mainName = digest + "WITH" + algorithm;
4354+    //     String jdk11Variation1 = digest + "with" + algorithm;
4355+    //     String jdk11Variation2 = digest + "With" + algorithm;
4356+    //     String alias = digest + "/" + algorithm;
4357+    //
4358+    //     put("Signature." + mainName, className);
4359+    //     put("Alg.Alias.Signature." + jdk11Variation1, mainName);
4360+    //     put("Alg.Alias.Signature." + jdk11Variation2, mainName);
4361+    //     put("Alg.Alias.Signature." + alias, mainName);
4362+    //     put("Alg.Alias.Signature." + oid, mainName);
4363+    //     put("Alg.Alias.Signature.OID." + oid, mainName);
4364+    // }
4365+    // END android-removed
4366
4367     public void setParameter(String parameterName, Object parameter)
4368     {
4369diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java bcprov-jdk16-145/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java
4370--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java	2010-01-11 21:46:14.000000000 +0000
4371+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java	2011-09-03 18:19:15.000000000 +0000
4372@@ -24,6 +24,7 @@
4373 import java.security.spec.DSAPublicKeySpec;
4374 import java.text.ParseException;
4375 import java.util.ArrayList;
4376+import java.util.Arrays;
4377 import java.util.Collection;
4378 import java.util.Date;
4379 import java.util.Enumeration;
4380@@ -35,6 +36,10 @@
4381
4382 import javax.security.auth.x500.X500Principal;
4383
4384+// BEGIN android-added
4385+import org.apache.harmony.xnet.provider.jsse.IndexedPKIXParameters;
4386+
4387+// END android-added
4388 import org.bouncycastle.asn1.ASN1InputStream;
4389 import org.bouncycastle.asn1.ASN1Object;
4390 import org.bouncycastle.asn1.ASN1OctetString;
4391@@ -59,13 +64,17 @@
4392 import org.bouncycastle.asn1.x509.PolicyInformation;
4393 import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
4394 import org.bouncycastle.asn1.x509.X509Extensions;
4395-import org.bouncycastle.jce.X509LDAPCertStoreParameters;
4396+// BEGIN android-removed
4397+// import org.bouncycastle.jce.X509LDAPCertStoreParameters;
4398+// END android-removed
4399 import org.bouncycastle.jce.exception.ExtCertPathValidatorException;
4400 import org.bouncycastle.util.Selector;
4401 import org.bouncycastle.util.StoreException;
4402 import org.bouncycastle.x509.ExtendedPKIXBuilderParameters;
4403 import org.bouncycastle.x509.ExtendedPKIXParameters;
4404-import org.bouncycastle.x509.X509AttributeCertStoreSelector;
4405+// BEGIN android-removed
4406+// import org.bouncycastle.x509.X509AttributeCertStoreSelector;
4407+// END android-removed
4408 import org.bouncycastle.x509.X509AttributeCertificate;
4409 import org.bouncycastle.x509.X509CRLStoreSelector;
4410 import org.bouncycastle.x509.X509CertStoreSelector;
4411@@ -110,29 +119,32 @@
4412         "privilegeWithdrawn",
4413         "aACompromise" };
4414
4415-    /**
4416-     * Search the given Set of TrustAnchor's for one that is the
4417-     * issuer of the given X509 certificate. Uses the default provider
4418-     * for signature verification.
4419-     *
4420-     * @param cert the X509 certificate
4421-     * @param trustAnchors a Set of TrustAnchor's
4422-     *
4423-     * @return the <code>TrustAnchor</code> object if found or
4424-     * <code>null</code> if not.
4425-     *
4426-     * @exception AnnotatedException
4427-     *                if a TrustAnchor was found but the signature verification
4428-     *                on the given certificate has thrown an exception.
4429-     */
4430-    protected static TrustAnchor findTrustAnchor(
4431-        X509Certificate cert,
4432-        Set             trustAnchors)
4433-            throws AnnotatedException
4434-    {
4435-        return findTrustAnchor(cert, trustAnchors, null);
4436-    }
4437+    // BEGIN android-removed
4438+    // /**
4439+    //  * Search the given Set of TrustAnchor's for one that is the
4440+    //  * issuer of the given X509 certificate. Uses the default provider
4441+    //  * for signature verification.
4442+    //  *
4443+    //  * @param cert the X509 certificate
4444+    //  * @param trustAnchors a Set of TrustAnchor's
4445+    //  *
4446+    //  * @return the <code>TrustAnchor</code> object if found or
4447+    //  * <code>null</code> if not.
4448+    //  *
4449+    //  * @exception AnnotatedException
4450+    //  *                if a TrustAnchor was found but the signature verification
4451+    //  *                on the given certificate has thrown an exception.
4452+    //  */
4453+    // protected static TrustAnchor findTrustAnchor(
4454+    //     X509Certificate cert,
4455+    //     Set             trustAnchors)
4456+    //         throws AnnotatedException
4457+    // {
4458+    //     return findTrustAnchor(cert, trustAnchors, null);
4459+    // }
4460+    // END android-removed
4461
4462+    // BEGIN android-changed
4463     /**
4464      * Search the given Set of TrustAnchor's for one that is the
4465      * issuer of the given X509 certificate. Uses the specified
4466@@ -140,8 +152,7 @@
4467      * if null.
4468      *
4469      * @param cert the X509 certificate
4470-     * @param trustAnchors a Set of TrustAnchor's
4471-     * @param sigProvider the provider to use for signature verification
4472+     * @param params used to find the trust anchors and signature provider
4473      *
4474      * @return the <code>TrustAnchor</code> object if found or
4475      * <code>null</code> if not.
4476@@ -152,10 +163,21 @@
4477      */
4478     protected static TrustAnchor findTrustAnchor(
4479         X509Certificate cert,
4480-        Set             trustAnchors,
4481-        String          sigProvider)
4482+        PKIXParameters  params)
4483             throws AnnotatedException
4484+    // END android-changed
4485     {
4486+        // BEGIN android-changed
4487+        // If we have a trust anchor index, use it.
4488+        if (params instanceof IndexedPKIXParameters) {
4489+            try {
4490+                IndexedPKIXParameters indexed = (IndexedPKIXParameters) params;
4491+                return indexed.findTrustAnchor(cert);
4492+            } catch (CertPathValidatorException e) {
4493+                throw new AnnotatedException(e.getMessage(), e);
4494+            }
4495+        }
4496+        // END android-changed
4497         TrustAnchor trust = null;
4498         PublicKey trustPublicKey = null;
4499         Exception invalidKeyEx = null;
4500@@ -172,21 +194,49 @@
4501             throw new AnnotatedException("Cannot set subject search criteria for trust anchor.", ex);
4502         }
4503
4504-        Iterator iter = trustAnchors.iterator();
4505+        // BEGIN android-changed
4506+        Iterator iter = params.getTrustAnchors().iterator();
4507+        // END android-changed
4508+        // BEGIN android-added
4509+        byte[] certBytes = null;
4510+        try {
4511+            certBytes = cert.getEncoded();
4512+        } catch (Exception e) {
4513+            // ignore, just continue
4514+        }
4515+        // END android-added
4516         while (iter.hasNext() && trust == null)
4517         {
4518             trust = (TrustAnchor) iter.next();
4519-            if (trust.getTrustedCert() != null)
4520+            // BEGIN android-changed
4521+            X509Certificate trustCert = trust.getTrustedCert();
4522+            // END android-changed
4523+            // BEGIN android-added
4524+            // If the trust anchor is identical to the certificate we're
4525+            // done. Just return the anchor.
4526+            // There is similar code in PKIXCertPathValidatorSpi.
4527+            try {
4528+                byte[] trustBytes = trustCert.getEncoded();
4529+                if (certBytes != null && Arrays.equals(trustBytes, certBytes)) {
4530+                    return trust;
4531+                }
4532+            } catch (Exception e) {
4533+                // ignore, continue and verify the certificate
4534+            }
4535+            // END android-added
4536+            // BEGIN android-changed
4537+            if (trustCert != null)
4538             {
4539-                if (certSelectX509.match(trust.getTrustedCert()))
4540+                if (certSelectX509.match(trustCert))
4541                 {
4542-                    trustPublicKey = trust.getTrustedCert().getPublicKey();
4543+                    trustPublicKey = trustCert.getPublicKey();
4544                 }
4545                 else
4546                 {
4547                     trust = null;
4548                 }
4549             }
4550+            // END android-changed
4551             else if (trust.getCAName() != null
4552                     && trust.getCAPublicKey() != null)
4553             {
4554@@ -216,7 +266,9 @@
4555             {
4556                 try
4557                 {
4558-                    verifyX509Certificate(cert, trustPublicKey, sigProvider);
4559+                    // BEGIN android-changed
4560+                    verifyX509Certificate(cert, trustPublicKey, params.getSigProvider());
4561+                    // END android-changed
4562                 }
4563                 catch (Exception ex)
4564                 {
4565@@ -248,7 +300,9 @@
4566             {
4567                 // look for URI
4568                 List list = (List) it.next();
4569-                if (list.get(0).equals(new Integer(GeneralName.uniformResourceIdentifier)))
4570+                // BEGIN android-changed
4571+                if (list.get(0).equals(Integer.valueOf(GeneralName.uniformResourceIdentifier)))
4572+                // END android-changed
4573                 {
4574                     // found
4575                     String temp = (String) list.get(1);
4576@@ -721,38 +775,40 @@
4577         {
4578             try
4579             {
4580-                if (location.startsWith("ldap://"))
4581-                {
4582-                    // ldap://directory.d-trust.net/CN=D-TRUST
4583-                    // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE
4584-                    // skip "ldap://"
4585-                    location = location.substring(7);
4586-                    // after first / baseDN starts
4587-                    String base = null;
4588-                    String url = null;
4589-                    if (location.indexOf("/") != -1)
4590-                    {
4591-                        base = location.substring(location.indexOf("/"));
4592-                        // URL
4593-                        url = "ldap://"
4594-                            + location.substring(0, location.indexOf("/"));
4595-                    }
4596-                    else
4597-                    {
4598-                        url = "ldap://" + location;
4599-                    }
4600-                    // use all purpose parameters
4601-                    X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder(
4602-                        url, base).build();
4603-                    pkixParams.addAdditionalStore(X509Store.getInstance(
4604-                        "CERTIFICATE/LDAP", params, "BC"));
4605-                    pkixParams.addAdditionalStore(X509Store.getInstance(
4606-                        "CRL/LDAP", params, "BC"));
4607-                    pkixParams.addAdditionalStore(X509Store.getInstance(
4608-                        "ATTRIBUTECERTIFICATE/LDAP", params, "BC"));
4609-                    pkixParams.addAdditionalStore(X509Store.getInstance(
4610-                        "CERTIFICATEPAIR/LDAP", params, "BC"));
4611-                }
4612+                // BEGIN android-removed
4613+                // if (location.startsWith("ldap://"))
4614+                // {
4615+                //     // ldap://directory.d-trust.net/CN=D-TRUST
4616+                //     // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE
4617+                //     // skip "ldap://"
4618+                //     location = location.substring(7);
4619+                //     // after first / baseDN starts
4620+                //     String base = null;
4621+                //     String url = null;
4622+                //     if (location.indexOf("/") != -1)
4623+                //     {
4624+                //         base = location.substring(location.indexOf("/"));
4625+                //         // URL
4626+                //         url = "ldap://"
4627+                //             + location.substring(0, location.indexOf("/"));
4628+                //     }
4629+                //     else
4630+                //     {
4631+                //         url = "ldap://" + location;
4632+                //     }
4633+                //     // use all purpose parameters
4634+                //     X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder(
4635+                //         url, base).build();
4636+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
4637+                //         "CERTIFICATE/LDAP", params, "BC"));
4638+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
4639+                //         "CRL/LDAP", params, "BC"));
4640+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
4641+                //         "ATTRIBUTECERTIFICATE/LDAP", params, "BC"));
4642+                //     pkixParams.addAdditionalStore(X509Store.getInstance(
4643+                //         "CERTIFICATEPAIR/LDAP", params, "BC"));
4644+                // }
4645+                // END android-removed
4646             }
4647             catch (Exception e)
4648             {
4649@@ -819,35 +875,37 @@
4650         return certs;
4651     }
4652
4653-    protected static Collection findCertificates(X509AttributeCertStoreSelector certSelect,
4654-                                                 List certStores)
4655-    throws AnnotatedException
4656-    {
4657-        Set certs = new HashSet();
4658-        Iterator iter = certStores.iterator();
4659-
4660-        while (iter.hasNext())
4661-        {
4662-            Object obj = iter.next();
4663-
4664-            if (obj instanceof X509Store)
4665-            {
4666-                X509Store certStore = (X509Store)obj;
4667-                try
4668-                {
4669-                    certs.addAll(certStore.getMatches(certSelect));
4670-                }
4671-                catch (StoreException e)
4672-                {
4673-                    throw
4674-
4675-                        new AnnotatedException(
4676-                            "Problem while picking certificates from X.509 store.", e);
4677-                }
4678-            }
4679-        }
4680-        return certs;
4681-    }
4682+    // BEGIN android-removed
4683+    // protected static Collection findCertificates(X509AttributeCertStoreSelector certSelect,
4684+    //                                              List certStores)
4685+    // throws AnnotatedException
4686+    // {
4687+    //     Set certs = new HashSet();
4688+    //     Iterator iter = certStores.iterator();
4689+    //
4690+    //     while (iter.hasNext())
4691+    //     {
4692+    //         Object obj = iter.next();
4693+    //
4694+    //         if (obj instanceof X509Store)
4695+    //         {
4696+    //             X509Store certStore = (X509Store)obj;
4697+    //             try
4698+    //             {
4699+    //                 certs.addAll(certStore.getMatches(certSelect));
4700+    //             }
4701+    //             catch (StoreException e)
4702+    //             {
4703+    //                 throw
4704+    //
4705+    //                     new AnnotatedException(
4706+    //                         "Problem while picking certificates from X.509 store.", e);
4707+    //             }
4708+    //         }
4709+    //     }
4710+    //     return certs;
4711+    // }
4712+    // END android-removed
4713
4714     protected static void addAdditionalStoresFromCRLDistributionPoint(
4715         CRLDistPoint crldp, ExtendedPKIXParameters pkixParams)
4716diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEBlockCipher.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEBlockCipher.java
4717--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEBlockCipher.java	2010-01-11 21:46:14.000000000 +0000
4718+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEBlockCipher.java	2011-09-03 18:19:15.000000000 +0000
4719@@ -7,22 +7,31 @@
4720 import org.bouncycastle.crypto.InvalidCipherTextException;
4721 import org.bouncycastle.crypto.engines.AESFastEngine;
4722 import org.bouncycastle.crypto.engines.BlowfishEngine;
4723-import org.bouncycastle.crypto.engines.CAST5Engine;
4724-import org.bouncycastle.crypto.engines.CAST6Engine;
4725+// BEGIN android-removed
4726+// import org.bouncycastle.crypto.engines.CAST5Engine;
4727+// import org.bouncycastle.crypto.engines.CAST6Engine;
4728+// END android-removed
4729 import org.bouncycastle.crypto.engines.DESEngine;
4730 import org.bouncycastle.crypto.engines.DESedeEngine;
4731-import org.bouncycastle.crypto.engines.GOST28147Engine;
4732+// BEGIN android-removed
4733+// import org.bouncycastle.crypto.engines.GOST28147Engine;
4734+// END android-removed
4735 import org.bouncycastle.crypto.engines.RC2Engine;
4736-import org.bouncycastle.crypto.engines.RC532Engine;
4737-import org.bouncycastle.crypto.engines.RC564Engine;
4738-import org.bouncycastle.crypto.engines.RC6Engine;
4739-import org.bouncycastle.crypto.engines.RijndaelEngine;
4740-import org.bouncycastle.crypto.engines.SEEDEngine;
4741-import org.bouncycastle.crypto.engines.SerpentEngine;
4742-import org.bouncycastle.crypto.engines.SkipjackEngine;
4743-import org.bouncycastle.crypto.engines.TEAEngine;
4744+// BEGIN android-removed
4745+// import org.bouncycastle.crypto.engines.RC532Engine;
4746+// import org.bouncycastle.crypto.engines.RC564Engine;
4747+// END android-removed
4748+// import org.bouncycastle.crypto.engines.RC6Engine;
4749+// import org.bouncycastle.crypto.engines.RijndaelEngine;
4750+// import org.bouncycastle.crypto.engines.SEEDEngine;
4751+// import org.bouncycastle.crypto.engines.SerpentEngine;
4752+// import org.bouncycastle.crypto.engines.SkipjackEngine;
4753+// import org.bouncycastle.crypto.engines.TEAEngine;
4754+// END android-removed
4755 import org.bouncycastle.crypto.engines.TwofishEngine;
4756-import org.bouncycastle.crypto.engines.XTEAEngine;
4757+// BEGIN android-removed
4758+// import org.bouncycastle.crypto.engines.XTEAEngine;
4759+// END android-removed
4760 import org.bouncycastle.crypto.modes.AEADBlockCipher;
4761 import org.bouncycastle.crypto.modes.CBCBlockCipher;
4762 import org.bouncycastle.crypto.modes.CCMBlockCipher;
4763@@ -32,8 +41,10 @@
4764 import org.bouncycastle.crypto.modes.GCMBlockCipher;
4765 import org.bouncycastle.crypto.modes.GOFBBlockCipher;
4766 import org.bouncycastle.crypto.modes.OFBBlockCipher;
4767-import org.bouncycastle.crypto.modes.OpenPGPCFBBlockCipher;
4768-import org.bouncycastle.crypto.modes.PGPCFBBlockCipher;
4769+// BEGIN android-removed
4770+// import org.bouncycastle.crypto.modes.OpenPGPCFBBlockCipher;
4771+// import org.bouncycastle.crypto.modes.PGPCFBBlockCipher;
4772+// END android-removed
4773 import org.bouncycastle.crypto.modes.SICBlockCipher;
4774 import org.bouncycastle.crypto.paddings.BlockCipherPadding;
4775 import org.bouncycastle.crypto.paddings.ISO10126d2Padding;
4776@@ -45,10 +56,12 @@
4777 import org.bouncycastle.crypto.params.KeyParameter;
4778 import org.bouncycastle.crypto.params.ParametersWithIV;
4779 import org.bouncycastle.crypto.params.ParametersWithRandom;
4780-import org.bouncycastle.crypto.params.ParametersWithSBox;
4781-import org.bouncycastle.crypto.params.RC2Parameters;
4782-import org.bouncycastle.crypto.params.RC5Parameters;
4783-import org.bouncycastle.jce.spec.GOST28147ParameterSpec;
4784+// BEGIN android-removed
4785+// import org.bouncycastle.crypto.params.ParametersWithSBox;
4786+// import org.bouncycastle.crypto.params.RC2Parameters;
4787+// import org.bouncycastle.crypto.params.RC5Parameters;
4788+// import org.bouncycastle.jce.spec.GOST28147ParameterSpec;
4789+// END android-removed
4790 import org.bouncycastle.util.Strings;
4791
4792 import javax.crypto.BadPaddingException;
4793@@ -59,8 +72,10 @@
4794 import javax.crypto.ShortBufferException;
4795 import javax.crypto.spec.IvParameterSpec;
4796 import javax.crypto.spec.PBEParameterSpec;
4797-import javax.crypto.spec.RC2ParameterSpec;
4798-import javax.crypto.spec.RC5ParameterSpec;
4799+// BEGIN android-removed
4800+// import javax.crypto.spec.RC2ParameterSpec;
4801+// import javax.crypto.spec.RC5ParameterSpec;
4802+// END android-removed
4803 import java.security.AlgorithmParameters;
4804 import java.security.InvalidAlgorithmParameterException;
4805 import java.security.InvalidKeyException;
4806@@ -78,11 +93,15 @@
4807     //
4808     private Class[]                 availableSpecs =
4809                                     {
4810-                                        RC2ParameterSpec.class,
4811-                                        RC5ParameterSpec.class,
4812+                                        // BEGIN android-removed
4813+                                        // RC2ParameterSpec.class,
4814+                                        // RC5ParameterSpec.class,
4815+                                        // END android-removed
4816                                         IvParameterSpec.class,
4817                                         PBEParameterSpec.class,
4818-                                        GOST28147ParameterSpec.class
4819+                                        // BEGIN android-removed
4820+                                        // GOST28147ParameterSpec.class
4821+                                        // END android-removed
4822                                     };
4823
4824     private BlockCipher             baseEngine;
4825@@ -237,20 +256,22 @@
4826                         new CFBBlockCipher(baseEngine, 8 * baseEngine.getBlockSize()));
4827             }
4828         }
4829-        else if (modeName.startsWith("PGP"))
4830-        {
4831-            boolean inlineIV = modeName.equalsIgnoreCase("PGPCFBwithIV");
4832-
4833-            ivLength = baseEngine.getBlockSize();
4834-            cipher = new BufferedGenericBlockCipher(
4835-                new PGPCFBBlockCipher(baseEngine, inlineIV));
4836-        }
4837-        else if (modeName.equalsIgnoreCase("OpenPGPCFB"))
4838-        {
4839-            ivLength = 0;
4840-            cipher = new BufferedGenericBlockCipher(
4841-                new OpenPGPCFBBlockCipher(baseEngine));
4842-        }
4843+        // BEGIN android-removed
4844+        // else if (modeName.startsWith("PGP"))
4845+        // {
4846+        //     boolean inlineIV = modeName.equalsIgnoreCase("PGPCFBwithIV");
4847+        //
4848+        //     ivLength = baseEngine.getBlockSize();
4849+        //     cipher = new BufferedGenericBlockCipher(
4850+        //         new PGPCFBBlockCipher(baseEngine, inlineIV));
4851+        // }
4852+        // else if (modeName.equalsIgnoreCase("OpenPGPCFB"))
4853+        // {
4854+        //     ivLength = 0;
4855+        //     cipher = new BufferedGenericBlockCipher(
4856+        //         new OpenPGPCFBBlockCipher(baseEngine));
4857+        // }
4858+        // END android-removed
4859         else if (modeName.startsWith("SIC"))
4860         {
4861             ivLength = baseEngine.getBlockSize();
4862@@ -376,13 +397,15 @@
4863             throw new InvalidKeyException("Key for algorithm " + key.getAlgorithm() + " not suitable for symmetric enryption.");
4864         }
4865
4866-        //
4867-        // for RC5-64 we must have some default parameters
4868-        //
4869-        if (params == null && baseEngine.getAlgorithmName().startsWith("RC5-64"))
4870-        {
4871-            throw new InvalidAlgorithmParameterException("RC5 requires an RC5ParametersSpec to be passed in.");
4872-        }
4873+        // BEGIN android-removed
4874+        // //
4875+        // // for RC5-64 we must have some default parameters
4876+        // //
4877+        // if (params == null && baseEngine.getAlgorithmName().startsWith("RC5-64"))
4878+        // {
4879+        //     throw new InvalidAlgorithmParameterException("RC5 requires an RC5ParametersSpec to be passed in.");
4880+        // }
4881+        // END android-removed
4882
4883         //
4884         // a note on iv's - if ivLength is zero the IV gets ignored (we don't use it).
4885@@ -448,63 +471,65 @@
4886                 param = new KeyParameter(key.getEncoded());
4887             }
4888         }
4889-        else if (params instanceof GOST28147ParameterSpec)
4890-        {
4891-            GOST28147ParameterSpec    gost28147Param = (GOST28147ParameterSpec)params;
4892-
4893-            param = new ParametersWithSBox(
4894-                       new KeyParameter(key.getEncoded()), ((GOST28147ParameterSpec)params).getSbox());
4895-
4896-            if (gost28147Param.getIV() != null && ivLength != 0)
4897-            {
4898-                param = new ParametersWithIV(param, gost28147Param.getIV());
4899-                ivParam = (ParametersWithIV)param;
4900-            }
4901-        }
4902-        else if (params instanceof RC2ParameterSpec)
4903-        {
4904-            RC2ParameterSpec    rc2Param = (RC2ParameterSpec)params;
4905-
4906-            param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits());
4907-
4908-            if (rc2Param.getIV() != null && ivLength != 0)
4909-            {
4910-                param = new ParametersWithIV(param, rc2Param.getIV());
4911-                ivParam = (ParametersWithIV)param;
4912-            }
4913-        }
4914-        else if (params instanceof RC5ParameterSpec)
4915-        {
4916-            RC5ParameterSpec    rc5Param = (RC5ParameterSpec)params;
4917-
4918-            param = new RC5Parameters(key.getEncoded(), ((RC5ParameterSpec)params).getRounds());
4919-            if (baseEngine.getAlgorithmName().startsWith("RC5"))
4920-            {
4921-                if (baseEngine.getAlgorithmName().equals("RC5-32"))
4922-                {
4923-                    if (rc5Param.getWordSize() != 32)
4924-                    {
4925-                        throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 32 not " + rc5Param.getWordSize() + ".");
4926-                    }
4927-                }
4928-                else if (baseEngine.getAlgorithmName().equals("RC5-64"))
4929-                {
4930-                    if (rc5Param.getWordSize() != 64)
4931-                    {
4932-                        throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 64 not " + rc5Param.getWordSize() + ".");
4933-                    }
4934-                }
4935-            }
4936-            else
4937-            {
4938-                throw new InvalidAlgorithmParameterException("RC5 parameters passed to a cipher that is not RC5.");
4939-            }
4940-            if ((rc5Param.getIV() != null) && (ivLength != 0))
4941-            {
4942-                param = new ParametersWithIV(param, rc5Param.getIV());
4943-                ivParam = (ParametersWithIV)param;
4944-            }
4945-        }
4946+        // BEGIN android-removed
4947+        // else if (params instanceof GOST28147ParameterSpec)
4948+        // {
4949+        //     GOST28147ParameterSpec    gost28147Param = (GOST28147ParameterSpec)params;
4950+        //
4951+        //     param = new ParametersWithSBox(
4952+        //                new KeyParameter(key.getEncoded()), ((GOST28147ParameterSpec)params).getSbox());
4953+        //
4954+        //     if (gost28147Param.getIV() != null && ivLength != 0)
4955+        //     {
4956+        //         param = new ParametersWithIV(param, gost28147Param.getIV());
4957+        //         ivParam = (ParametersWithIV)param;
4958+        //     }
4959+        // }
4960+        // else if (params instanceof RC2ParameterSpec)
4961+        // {
4962+        //     RC2ParameterSpec    rc2Param = (RC2ParameterSpec)params;
4963+        //
4964+        //     param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits());
4965+        //
4966+        //     if (rc2Param.getIV() != null && ivLength != 0)
4967+        //     {
4968+        //         param = new ParametersWithIV(param, rc2Param.getIV());
4969+        //         ivParam = (ParametersWithIV)param;
4970+        //     }
4971+        // }
4972+        // else if (params instanceof RC5ParameterSpec)
4973+        // {
4974+        //     RC5ParameterSpec    rc5Param = (RC5ParameterSpec)params;
4975+        //
4976+        //     param = new RC5Parameters(key.getEncoded(), ((RC5ParameterSpec)params).getRounds());
4977+        //     if (baseEngine.getAlgorithmName().startsWith("RC5"))
4978+        //     {
4979+        //         if (baseEngine.getAlgorithmName().equals("RC5-32"))
4980+        //         {
4981+        //             if (rc5Param.getWordSize() != 32)
4982+        //             {
4983+        //                 throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 32 not " + rc5Param.getWordSize() + ".");
4984+        //             }
4985+        //         }
4986+        //         else if (baseEngine.getAlgorithmName().equals("RC5-64"))
4987+        //         {
4988+        //             if (rc5Param.getWordSize() != 64)
4989+        //             {
4990+        //                 throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 64 not " + rc5Param.getWordSize() + ".");
4991+        //             }
4992+        //         }
4993+        //     }
4994+        //     else
4995+        //     {
4996+        //         throw new InvalidAlgorithmParameterException("RC5 parameters passed to a cipher that is not RC5.");
4997+        //     }
4998+        //     if ((rc5Param.getIV() != null) && (ivLength != 0))
4999+        //     {
5000+        //         param = new ParametersWithIV(param, rc5Param.getIV());
5001+        //         ivParam = (ParametersWithIV)param;
5002+        //     }
5003+        // }
5004+        // END android-removed
5005         else
5006         {
5007             throw new InvalidAlgorithmParameterException("unknown parameter type.");
5008@@ -708,10 +733,21 @@
5009         int     inputLen,
5010         byte[]  output,
5011         int     outputOffset)
5012-        throws IllegalBlockSizeException, BadPaddingException
5013+        throws IllegalBlockSizeException, BadPaddingException, ShortBufferException
5014     {
5015+        // BEGIN android-note
5016+        // added ShortBufferException to the throws statement
5017+        // END android-note
5018         int     len = 0;
5019
5020+        // BEGIN android-added
5021+        int outputLen = cipher.getOutputSize(inputLen);
5022+
5023+        if (outputLen + outputOffset > output.length) {
5024+            throw new ShortBufferException("need at least " + outputLen + " bytes");
5025+        }
5026+        // BEGIN android-added
5027+
5028         if (inputLen != 0)
5029         {
5030                 len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset);
5031@@ -753,17 +789,19 @@
5032         }
5033     }
5034
5035-    /**
5036-     * DESCBC
5037-     */
5038-    static public class DESCBC
5039-        extends JCEBlockCipher
5040-    {
5041-        public DESCBC()
5042-        {
5043-            super(new CBCBlockCipher(new DESEngine()), 64);
5044-        }
5045-    }
5046+    // BEGIN android-removed
5047+    // /**
5048+    //  * DESCBC
5049+    //  */
5050+    // static public class DESCBC
5051+    //     extends JCEBlockCipher
5052+    // {
5053+    //     public DESCBC()
5054+    //     {
5055+    //         super(new CBCBlockCipher(new DESEngine()), 64);
5056+    //     }
5057+    // }
5058+    // END android-removed
5059
5060     /**
5061      * DESede
5062@@ -777,52 +815,54 @@
5063         }
5064     }
5065
5066-    /**
5067-     * DESedeCBC
5068-     */
5069-    static public class DESedeCBC
5070-        extends JCEBlockCipher
5071-    {
5072-        public DESedeCBC()
5073-        {
5074-            super(new CBCBlockCipher(new DESedeEngine()), 64);
5075-        }
5076-    }
5077-
5078-    /**
5079-     *  GOST28147
5080-     */
5081-    static public class GOST28147
5082-        extends JCEBlockCipher
5083-    {
5084-        public GOST28147()
5085-        {
5086-            super(new GOST28147Engine());
5087-        }
5088-    }
5089-
5090-    static public class GOST28147cbc
5091-        extends JCEBlockCipher
5092-    {
5093-        public GOST28147cbc()
5094-        {
5095-            super(new CBCBlockCipher(new GOST28147Engine()), 64);
5096-        }
5097-    }
5098+    // BEGIN android-removed
5099+    // /**
5100+    //  * DESedeCBC
5101+    //  */
5102+    // static public class DESedeCBC
5103+    //     extends JCEBlockCipher
5104+    // {
5105+    //     public DESedeCBC()
5106+    //     {
5107+    //         super(new CBCBlockCipher(new DESedeEngine()), 64);
5108+    //     }
5109+    // }
5110+    //
5111+    // /**
5112+    //  *  GOST28147
5113+    //  */
5114+    // static public class GOST28147
5115+    //     extends JCEBlockCipher
5116+    // {
5117+    //     public GOST28147()
5118+    //     {
5119+    //         super(new GOST28147Engine());
5120+    //     }
5121+    // }
5122+    //
5123+    // static public class GOST28147cbc
5124+    //     extends JCEBlockCipher
5125+    // {
5126+    //     public GOST28147cbc()
5127+    //     {
5128+    //         super(new CBCBlockCipher(new GOST28147Engine()), 64);
5129+    //     }
5130+    // }
5131+    //
5132+    // /**
5133+    //  * SKIPJACK
5134+    //  */
5135+    // static public class Skipjack
5136+    //     extends JCEBlockCipher
5137+    // {
5138+    //     public Skipjack()
5139+    //     {
5140+    //         super(new SkipjackEngine());
5141+    //     }
5142+    // }
5143+    // END android-removed
5144
5145     /**
5146-     * SKIPJACK
5147-     */
5148-    static public class Skipjack
5149-        extends JCEBlockCipher
5150-    {
5151-        public Skipjack()
5152-        {
5153-            super(new SkipjackEngine());
5154-        }
5155-    }
5156-
5157-    /**
5158      * Blowfish
5159      */
5160     static public class Blowfish
5161@@ -833,236 +873,238 @@
5162             super(new BlowfishEngine());
5163         }
5164     }
5165-
5166-    /**
5167-     * Blowfish CBC
5168-     */
5169-    static public class BlowfishCBC
5170-        extends JCEBlockCipher
5171-    {
5172-        public BlowfishCBC()
5173-        {
5174-            super(new CBCBlockCipher(new BlowfishEngine()), 64);
5175-        }
5176-    }
5177-
5178-    /**
5179-     * Twofish
5180-     */
5181-    static public class Twofish
5182-        extends JCEBlockCipher
5183-    {
5184-        public Twofish()
5185-        {
5186-            super(new TwofishEngine());
5187-        }
5188-    }
5189-
5190-    /**
5191-     * RC2
5192-     */
5193-    static public class RC2
5194-        extends JCEBlockCipher
5195-    {
5196-        public RC2()
5197-        {
5198-            super(new RC2Engine());
5199-        }
5200-    }
5201-
5202-    /**
5203-     * RC2CBC
5204-     */
5205-    static public class RC2CBC
5206-        extends JCEBlockCipher
5207-    {
5208-        public RC2CBC()
5209-        {
5210-            super(new CBCBlockCipher(new RC2Engine()), 64);
5211-        }
5212-    }
5213-
5214-    /**
5215-     * RC5
5216-     */
5217-    static public class RC5
5218-        extends JCEBlockCipher
5219-    {
5220-        public RC5()
5221-        {
5222-            super(new RC532Engine());
5223-        }
5224-    }
5225-
5226-    /**
5227-     * RC564
5228-     */
5229-    static public class RC564
5230-        extends JCEBlockCipher
5231-    {
5232-        public RC564()
5233-        {
5234-            super(new RC564Engine());
5235-        }
5236-    }
5237-
5238-    /**
5239-     * RC6
5240-     */
5241-    static public class RC6
5242-        extends JCEBlockCipher
5243-    {
5244-        public RC6()
5245-        {
5246-            super(new RC6Engine());
5247-        }
5248-    }
5249-
5250-    /**
5251-     * AES
5252-     */
5253-    static public class AES
5254-        extends JCEBlockCipher
5255-    {
5256-        public AES()
5257-        {
5258-            super(new AESFastEngine());
5259-        }
5260-    }
5261-
5262-    /**
5263-     * AESCBC
5264-     */
5265-    static public class AESCBC
5266-        extends JCEBlockCipher
5267-    {
5268-        public AESCBC()
5269-        {
5270-            super(new CBCBlockCipher(new AESFastEngine()), 128);
5271-        }
5272-    }
5273-
5274-    /**
5275-     * AESCFB
5276-     */
5277-    static public class AESCFB
5278-        extends JCEBlockCipher
5279-    {
5280-        public AESCFB()
5281-        {
5282-            super(new CFBBlockCipher(new AESFastEngine(), 128), 128);
5283-        }
5284-    }
5285-
5286-    /**
5287-     * AESOFB
5288-     */
5289-    static public class AESOFB
5290-        extends JCEBlockCipher
5291-    {
5292-        public AESOFB()
5293-        {
5294-            super(new OFBBlockCipher(new AESFastEngine(), 128), 128);
5295-        }
5296-    }
5297-
5298-    /**
5299-     * Rijndael
5300-     */
5301-    static public class Rijndael
5302-        extends JCEBlockCipher
5303-    {
5304-        public Rijndael()
5305-        {
5306-            super(new RijndaelEngine());
5307-        }
5308-    }
5309-
5310-    /**
5311-     * Serpent
5312-     */
5313-    static public class Serpent
5314-        extends JCEBlockCipher
5315-    {
5316-        public Serpent()
5317-        {
5318-            super(new SerpentEngine());
5319-        }
5320-    }
5321-
5322-
5323
5324-    /**
5325-     * CAST5
5326-     */
5327-    static public class CAST5
5328-        extends JCEBlockCipher
5329-    {
5330-        public CAST5()
5331-        {
5332-            super(new CAST5Engine());
5333-        }
5334-    }
5335-
5336-    /**
5337-     * CAST5 CBC
5338-     */
5339-    static public class CAST5CBC
5340-        extends JCEBlockCipher
5341-    {
5342-        public CAST5CBC()
5343-        {
5344-            super(new CBCBlockCipher(new CAST5Engine()), 64);
5345-        }
5346-    }
5347-
5348-    /**
5349-     * CAST6
5350-     */
5351-    static public class CAST6
5352-        extends JCEBlockCipher
5353-    {
5354-        public CAST6()
5355-        {
5356-            super(new CAST6Engine());
5357-        }
5358-    }
5359-
5360-    /**
5361-     * TEA
5362-     */
5363-    static public class TEA
5364-        extends JCEBlockCipher
5365-    {
5366-        public TEA()
5367-        {
5368-            super(new TEAEngine());
5369-        }
5370-    }
5371-
5372-    /**
5373-     * XTEA
5374-     */
5375-    static public class XTEA
5376-        extends JCEBlockCipher
5377-    {
5378-        public XTEA()
5379-        {
5380-            super(new XTEAEngine());
5381-        }
5382-    }
5383-
5384-    /**
5385-     * SEED
5386-     */
5387-    static public class SEED
5388-        extends JCEBlockCipher
5389-    {
5390-        public SEED()
5391-        {
5392-            super(new SEEDEngine());
5393-        }
5394-    }
5395+    // BEGIN android-removed
5396+    // /**
5397+    //  * Blowfish CBC
5398+    //  */
5399+    // static public class BlowfishCBC
5400+    //     extends JCEBlockCipher
5401+    // {
5402+    //     public BlowfishCBC()
5403+    //     {
5404+    //         super(new CBCBlockCipher(new BlowfishEngine()), 64);
5405+    //     }
5406+    // }
5407+    //
5408+    // /**
5409+    //  * Twofish
5410+    //  */
5411+    // static public class Twofish
5412+    //     extends JCEBlockCipher
5413+    // {
5414+    //     public Twofish()
5415+    //     {
5416+    //         super(new TwofishEngine());
5417+    //     }
5418+    // }
5419+    //
5420+    // /**
5421+    //  * RC2
5422+    //  */
5423+    // static public class RC2
5424+    //     extends JCEBlockCipher
5425+    // {
5426+    //     public RC2()
5427+    //     {
5428+    //         super(new RC2Engine());
5429+    //     }
5430+    // }
5431+    //
5432+    // /**
5433+    //  * RC2CBC
5434+    //  */
5435+    // static public class RC2CBC
5436+    //     extends JCEBlockCipher
5437+    // {
5438+    //     public RC2CBC()
5439+    //     {
5440+    //         super(new CBCBlockCipher(new RC2Engine()), 64);
5441+    //     }
5442+    // }
5443+    //
5444+    // /**
5445+    //  * RC5
5446+    //  */
5447+    // static public class RC5
5448+    //     extends JCEBlockCipher
5449+    // {
5450+    //     public RC5()
5451+    //     {
5452+    //         super(new RC532Engine());
5453+    //     }
5454+    // }
5455+    //
5456+    // /**
5457+    //  * RC564
5458+    //  */
5459+    // static public class RC564
5460+    //     extends JCEBlockCipher
5461+    // {
5462+    //     public RC564()
5463+    //     {
5464+    //         super(new RC564Engine());
5465+    //     }
5466+    // }
5467+    //
5468+    // /**
5469+    //  * RC6
5470+    //  */
5471+    // static public class RC6
5472+    //     extends JCEBlockCipher
5473+    // {
5474+    //     public RC6()
5475+    //     {
5476+    //         super(new RC6Engine());
5477+    //     }
5478+    // }
5479+    //
5480+    // /**
5481+    //  * AES
5482+    //  */
5483+    // static public class AES
5484+    //     extends JCEBlockCipher
5485+    // {
5486+    //     public AES()
5487+    //     {
5488+    //         super(new AESFastEngine());
5489+    //     }
5490+    // }
5491+    //
5492+    // /**
5493+    //  * AESCBC
5494+    //  */
5495+    // static public class AESCBC
5496+    //     extends JCEBlockCipher
5497+    // {
5498+    //     public AESCBC()
5499+    //     {
5500+    //         super(new CBCBlockCipher(new AESFastEngine()), 128);
5501+    //     }
5502+    // }
5503+    //
5504+    // /**
5505+    //  * AESCFB
5506+    //  */
5507+    // static public class AESCFB
5508+    //     extends JCEBlockCipher
5509+    // {
5510+    //     public AESCFB()
5511+    //     {
5512+    //         super(new CFBBlockCipher(new AESFastEngine(), 128), 128);
5513+    //     }
5514+    // }
5515+    //
5516+    // /**
5517+    //  * AESOFB
5518+    //  */
5519+    // static public class AESOFB
5520+    //     extends JCEBlockCipher
5521+    // {
5522+    //     public AESOFB()
5523+    //     {
5524+    //         super(new OFBBlockCipher(new AESFastEngine(), 128), 128);
5525+    //     }
5526+    // }
5527+    //
5528+    // /**
5529+    //  * Rijndael
5530+    //  */
5531+    // static public class Rijndael
5532+    //     extends JCEBlockCipher
5533+    // {
5534+    //     public Rijndael()
5535+    //     {
5536+    //         super(new RijndaelEngine());
5537+    //     }
5538+    // }
5539+    //
5540+    // /**
5541+    //  * Serpent
5542+    //  */
5543+    // static public class Serpent
5544+    //     extends JCEBlockCipher
5545+    // {
5546+    //     public Serpent()
5547+    //     {
5548+    //         super(new SerpentEngine());
5549+    //     }
5550+    // }
5551+    //
5552+    //
5553+    //
5554+    // /**
5555+    //  * CAST5
5556+    //  */
5557+    // static public class CAST5
5558+    //     extends JCEBlockCipher
5559+    // {
5560+    //     public CAST5()
5561+    //     {
5562+    //         super(new CAST5Engine());
5563+    //     }
5564+    // }
5565+    //
5566+    // /**
5567+    //  * CAST5 CBC
5568+    //  */
5569+    // static public class CAST5CBC
5570+    //     extends JCEBlockCipher
5571+    // {
5572+    //     public CAST5CBC()
5573+    //     {
5574+    //         super(new CBCBlockCipher(new CAST5Engine()), 64);
5575+    //     }
5576+    // }
5577+    //
5578+    // /**
5579+    //  * CAST6
5580+    //  */
5581+    // static public class CAST6
5582+    //     extends JCEBlockCipher
5583+    // {
5584+    //     public CAST6()
5585+    //     {
5586+    //         super(new CAST6Engine());
5587+    //     }
5588+    // }
5589+    //
5590+    // /**
5591+    //  * TEA
5592+    //  */
5593+    // static public class TEA
5594+    //     extends JCEBlockCipher
5595+    // {
5596+    //     public TEA()
5597+    //     {
5598+    //         super(new TEAEngine());
5599+    //     }
5600+    // }
5601+    //
5602+    // /**
5603+    //  * XTEA
5604+    //  */
5605+    // static public class XTEA
5606+    //     extends JCEBlockCipher
5607+    // {
5608+    //     public XTEA()
5609+    //     {
5610+    //         super(new XTEAEngine());
5611+    //     }
5612+    // }
5613+    //
5614+    // /**
5615+    //  * SEED
5616+    //  */
5617+    // static public class SEED
5618+    //     extends JCEBlockCipher
5619+    // {
5620+    //     public SEED()
5621+    //     {
5622+    //         super(new SEEDEngine());
5623+    //     }
5624+    // }
5625+    // END android-removed
5626
5627     /**
5628      * PBEWithMD5AndDES
5629@@ -1087,7 +1129,7 @@
5630             super(new CBCBlockCipher(new RC2Engine()));
5631         }
5632     }
5633-
5634+
5635     /**
5636      * PBEWithSHA1AndDES
5637      */
5638@@ -1135,7 +1177,7 @@
5639             super(new CBCBlockCipher(new DESedeEngine()));
5640         }
5641     }
5642-
5643+
5644     /**
5645      * PBEWithSHAAnd128BitRC2-CBC
5646      */
5647@@ -1159,7 +1201,7 @@
5648             super(new CBCBlockCipher(new RC2Engine()));
5649         }
5650     }
5651-
5652+
5653     /**
5654      * PBEWithSHAAndTwofish-CBC
5655      */
5656@@ -1171,7 +1213,7 @@
5657             super(new CBCBlockCipher(new TwofishEngine()));
5658         }
5659     }
5660-
5661+
5662     /**
5663      * PBEWithAES-CBC
5664      */
5665diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java
5666--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java	2010-01-11 21:46:14.000000000 +0000
5667+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java	2011-09-03 18:19:15.000000000 +0000
5668@@ -37,9 +37,11 @@
5669
5670     static
5671     {
5672-        Integer i64 = new Integer(64);
5673-        Integer i192 = new Integer(192);
5674-        Integer i128 = new Integer(128);
5675+        // BEGIN android-changed
5676+        Integer i64 = Integer.valueOf(64);
5677+        Integer i192 = Integer.valueOf(192);
5678+        Integer i128 = Integer.valueOf(128);
5679+        // END android-changed
5680
5681         algorithms.put("DES", i64);
5682         algorithms.put("DESEDE", i192);
5683diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDigestUtil.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDigestUtil.java
5684--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDigestUtil.java	2010-01-11 21:46:14.000000000 +0000
5685+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDigestUtil.java	2011-09-03 18:19:15.000000000 +0000
5686@@ -12,7 +12,9 @@
5687 import org.bouncycastle.crypto.Digest;
5688 import org.bouncycastle.crypto.digests.MD5Digest;
5689 import org.bouncycastle.crypto.digests.SHA1Digest;
5690-import org.bouncycastle.crypto.digests.SHA224Digest;
5691+// BEGIN android-removed
5692+// import org.bouncycastle.crypto.digests.SHA224Digest;
5693+// END android-removed
5694 import org.bouncycastle.crypto.digests.SHA256Digest;
5695 import org.bouncycastle.crypto.digests.SHA384Digest;
5696 import org.bouncycastle.crypto.digests.SHA512Digest;
5697@@ -22,7 +24,9 @@
5698 {
5699     private static Set md5 = new HashSet();
5700     private static Set sha1 = new HashSet();
5701-    private static Set sha224 = new HashSet();
5702+    // BEGIN android-removed
5703+    // private static Set sha224 = new HashSet();
5704+    // END android-removed
5705     private static Set sha256 = new HashSet();
5706     private static Set sha384 = new HashSet();
5707     private static Set sha512 = new HashSet();
5708@@ -38,9 +42,11 @@
5709         sha1.add("SHA-1");
5710         sha1.add(OIWObjectIdentifiers.idSHA1.getId());
5711
5712-        sha224.add("SHA224");
5713-        sha224.add("SHA-224");
5714-        sha224.add(NISTObjectIdentifiers.id_sha224.getId());
5715+        // BEGIN android-removed
5716+        // sha224.add("SHA224");
5717+        // sha224.add("SHA-224");
5718+        // sha224.add(NISTObjectIdentifiers.id_sha224.getId());
5719+        // END android-removed
5720
5721         sha256.add("SHA256");
5722         sha256.add("SHA-256");
5723@@ -61,9 +67,11 @@
5724         oids.put("SHA-1", OIWObjectIdentifiers.idSHA1);
5725         oids.put(OIWObjectIdentifiers.idSHA1.getId(), OIWObjectIdentifiers.idSHA1);
5726
5727-        oids.put("SHA224", NISTObjectIdentifiers.id_sha224);
5728-        oids.put("SHA-224", NISTObjectIdentifiers.id_sha224);
5729-        oids.put(NISTObjectIdentifiers.id_sha224.getId(), NISTObjectIdentifiers.id_sha224);
5730+        // BEGIN android-removed
5731+        // oids.put("SHA224", NISTObjectIdentifiers.id_sha224);
5732+        // oids.put("SHA-224", NISTObjectIdentifiers.id_sha224);
5733+        // oids.put(NISTObjectIdentifiers.id_sha224.getId(), NISTObjectIdentifiers.id_sha224);
5734+        // END android-removed
5735
5736         oids.put("SHA256", NISTObjectIdentifiers.id_sha256);
5737         oids.put("SHA-256", NISTObjectIdentifiers.id_sha256);
5738@@ -91,10 +99,12 @@
5739         {
5740             return new MD5Digest();
5741         }
5742-        if (sha224.contains(digestName))
5743-        {
5744-            return new SHA224Digest();
5745-        }
5746+        // BEGIN android-removed
5747+        // if (sha224.contains(digestName))
5748+        // {
5749+        //     return new SHA224Digest();
5750+        // }
5751+        // END android-removed
5752         if (sha256.contains(digestName))
5753         {
5754             return new SHA256Digest();
5755@@ -116,7 +126,9 @@
5756         String digest2)
5757     {
5758         return (sha1.contains(digest1) && sha1.contains(digest2))
5759-            || (sha224.contains(digest1) && sha224.contains(digest2))
5760+            // BEGIN android-removed
5761+            // || (sha224.contains(digest1) && sha224.contains(digest2))
5762+            // END android-removed
5763             || (sha256.contains(digest1) && sha256.contains(digest2))
5764             || (sha384.contains(digest1) && sha384.contains(digest2))
5765             || (sha512.contains(digest1) && sha512.contains(digest2))
5766diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEKeyGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEKeyGenerator.java
5767--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEKeyGenerator.java	2010-01-11 21:46:14.000000000 +0000
5768+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEKeyGenerator.java	2011-09-03 18:19:15.000000000 +0000
5769@@ -145,30 +145,32 @@
5770         }
5771     }
5772
5773-    /**
5774-     * generate a desEDE key in the a-b-c format.
5775-     */
5776-    public static class DESede3
5777-        extends JCEKeyGenerator
5778-    {
5779-        public DESede3()
5780-        {
5781-            super("DESede3", 192, new DESedeKeyGenerator());
5782-        }
5783-    }
5784-
5785-    /**
5786-     * SKIPJACK
5787-     */
5788-    public static class Skipjack
5789-        extends JCEKeyGenerator
5790-    {
5791-        public Skipjack()
5792-        {
5793-            super("SKIPJACK", 80, new CipherKeyGenerator());
5794-        }
5795-    }
5796-
5797+    // BEGIN android-removed
5798+    // /**
5799+    //  * generate a desEDE key in the a-b-c format.
5800+    //  */
5801+    // public static class DESede3
5802+    //     extends JCEKeyGenerator
5803+    // {
5804+    //     public DESede3()
5805+    //     {
5806+    //         super("DESede3", 192, new DESedeKeyGenerator());
5807+    //     }
5808+    // }
5809+    //
5810+    // /**
5811+    //  * SKIPJACK
5812+    //  */
5813+    // public static class Skipjack
5814+    //     extends JCEKeyGenerator
5815+    // {
5816+    //     public Skipjack()
5817+    //     {
5818+    //         super("SKIPJACK", 80, new CipherKeyGenerator());
5819+    //     }
5820+    // }
5821+    // END android-removed
5822+
5823     /**
5824      * Blowfish
5825      */
5826@@ -180,31 +182,33 @@
5827             super("Blowfish", 128, new CipherKeyGenerator());
5828         }
5829     }
5830-
5831-    /**
5832-     * Twofish
5833-     */
5834-    public static class Twofish
5835-        extends JCEKeyGenerator
5836-    {
5837-        public Twofish()
5838-        {
5839-            super("Twofish", 256, new CipherKeyGenerator());
5840-        }
5841-    }
5842-
5843-    /**
5844-     * RC2
5845-     */
5846-    public static class RC2
5847-        extends JCEKeyGenerator
5848-    {
5849-        public RC2()
5850-        {
5851-            super("RC2", 128, new CipherKeyGenerator());
5852-        }
5853-    }
5854-
5855+
5856+    // BEGIN android-removed
5857+    // /**
5858+    //  * Twofish
5859+    //  */
5860+    // public static class Twofish
5861+    //     extends JCEKeyGenerator
5862+    // {
5863+    //     public Twofish()
5864+    //     {
5865+    //         super("Twofish", 256, new CipherKeyGenerator());
5866+    //     }
5867+    // }
5868+    //
5869+    // /**
5870+    //  * RC2
5871+    //  */
5872+    // public static class RC2
5873+    //     extends JCEKeyGenerator
5874+    // {
5875+    //     public RC2()
5876+    //     {
5877+    //         super("RC2", 128, new CipherKeyGenerator());
5878+    //     }
5879+    // }
5880+    // END android-removed
5881+
5882     /**
5883      * RC4
5884      */
5885@@ -216,203 +220,207 @@
5886             super("RC4", 128, new CipherKeyGenerator());
5887         }
5888     }
5889-
5890-    /**
5891-     * RC5
5892-     */
5893-    public static class RC5
5894-        extends JCEKeyGenerator
5895-    {
5896-        public RC5()
5897-        {
5898-            super("RC5", 128, new CipherKeyGenerator());
5899-        }
5900-    }
5901-
5902-    /**
5903-     * RC5
5904-     */
5905-    public static class RC564
5906-        extends JCEKeyGenerator
5907-    {
5908-        public RC564()
5909-        {
5910-            super("RC5-64", 256, new CipherKeyGenerator());
5911-        }
5912-    }
5913-
5914-    /**
5915-     * RC6
5916-     */
5917-    public static class RC6
5918-        extends JCEKeyGenerator
5919-    {
5920-        public RC6()
5921-        {
5922-            super("RC6", 256, new CipherKeyGenerator());
5923-        }
5924-    }
5925-
5926-    /**
5927-     * GOST28147
5928-     */
5929-    public static class GOST28147
5930-        extends JCEKeyGenerator
5931-    {
5932-        public GOST28147()
5933-        {
5934-            super("GOST28147", 256, new CipherKeyGenerator());
5935-        }
5936-    }
5937
5938-    /**
5939-     * Rijndael
5940-     */
5941-    public static class Rijndael
5942-        extends JCEKeyGenerator
5943-    {
5944-        public Rijndael()
5945-        {
5946-            super("Rijndael", 192, new CipherKeyGenerator());
5947-        }
5948-    }
5949-
5950-    /**
5951-     * Serpent
5952-     */
5953-    public static class Serpent
5954-        extends JCEKeyGenerator
5955-    {
5956-        public Serpent()
5957-        {
5958-            super("Serpent", 192, new CipherKeyGenerator());
5959-        }
5960-    }
5961+    // BEGIN android-removed
5962+    // /**
5963+    //  * RC5
5964+    //  */
5965+    // public static class RC5
5966+    //     extends JCEKeyGenerator
5967+    // {
5968+    //     public RC5()
5969+    //     {
5970+    //         super("RC5", 128, new CipherKeyGenerator());
5971+    //     }
5972+    // }
5973+    //
5974+    // /**
5975+    //  * RC5
5976+    //  */
5977+    // public static class RC564
5978+    //     extends JCEKeyGenerator
5979+    // {
5980+    //     public RC564()
5981+    //     {
5982+    //         super("RC5-64", 256, new CipherKeyGenerator());
5983+    //     }
5984+    // }
5985+    //
5986+    // /**
5987+    //  * RC6
5988+    //  */
5989+    // public static class RC6
5990+    //     extends JCEKeyGenerator
5991+    // {
5992+    //     public RC6()
5993+    //     {
5994+    //         super("RC6", 256, new CipherKeyGenerator());
5995+    //     }
5996+    // }
5997+    //
5998+    // /**
5999+    //  * GOST28147
6000+    //  */
6001+    // public static class GOST28147
6002+    //     extends JCEKeyGenerator
6003+    // {
6004+    //     public GOST28147()
6005+    //     {
6006+    //         super("GOST28147", 256, new CipherKeyGenerator());
6007+    //     }
6008+    // }
6009
6010-
6011-
6012-    /**
6013-     * CAST6
6014-     */
6015-    public static class CAST6
6016-        extends JCEKeyGenerator
6017-    {
6018-        public CAST6()
6019-        {
6020-            super("CAST6", 256, new CipherKeyGenerator());
6021-        }
6022-    }
6023-
6024-    /**
6025-     * TEA
6026-     */
6027-    public static class TEA
6028-        extends JCEKeyGenerator
6029-    {
6030-        public TEA()
6031-        {
6032-            super("TEA", 128, new CipherKeyGenerator());
6033-        }
6034-    }
6035-
6036-    /**
6037-     * XTEA
6038-     */
6039-    public static class XTEA
6040-        extends JCEKeyGenerator
6041-    {
6042-        public XTEA()
6043-        {
6044-            super("XTEA", 128, new CipherKeyGenerator());
6045-        }
6046-    }
6047-
6048-    /**
6049-     * Salsa20
6050-     */
6051-    public static class Salsa20
6052-        extends JCEKeyGenerator
6053-    {
6054-        public Salsa20()
6055-        {
6056-            super("Salsa20", 128, new CipherKeyGenerator());
6057-        }
6058-    }
6059-
6060-    /**
6061-     * HC128
6062-     */
6063-    public static class HC128
6064-        extends JCEKeyGenerator
6065-    {
6066-        public HC128()
6067-        {
6068-            super("HC128", 128, new CipherKeyGenerator());
6069-        }
6070-    }
6071-
6072-    /**
6073-     * HC256
6074-     */
6075-    public static class HC256
6076-        extends JCEKeyGenerator
6077-    {
6078-        public HC256()
6079-        {
6080-            super("HC256", 256, new CipherKeyGenerator());
6081-        }
6082-    }
6083-
6084-    /**
6085-     * VMPC
6086-     */
6087-    public static class VMPC
6088-        extends JCEKeyGenerator
6089-    {
6090-        public VMPC()
6091-        {
6092-            super("VMPC", 128, new CipherKeyGenerator());
6093-        }
6094-    }
6095-
6096-    /**
6097-     * VMPC-KSA3
6098-     */
6099-    public static class VMPCKSA3
6100-        extends JCEKeyGenerator
6101-    {
6102-        public VMPCKSA3()
6103-        {
6104-            super("VMPC-KSA3", 128, new CipherKeyGenerator());
6105-        }
6106-    }
6107+    // /**
6108+    //  * Rijndael
6109+    //  */
6110+    // public static class Rijndael
6111+    //     extends JCEKeyGenerator
6112+    // {
6113+    //     public Rijndael()
6114+    //     {
6115+    //         super("Rijndael", 192, new CipherKeyGenerator());
6116+    //     }
6117+    // }
6118+    //
6119+    // /**
6120+    //  * Serpent
6121+    //  */
6122+    // public static class Serpent
6123+    //     extends JCEKeyGenerator
6124+    // {
6125+    //     public Serpent()
6126+    //     {
6127+    //         super("Serpent", 192, new CipherKeyGenerator());
6128+    //     }
6129+    // }
6130+    //
6131+    //
6132+    //
6133+    // /**
6134+    //  * CAST6
6135+    //  */
6136+    // public static class CAST6
6137+    //     extends JCEKeyGenerator
6138+    // {
6139+    //     public CAST6()
6140+    //     {
6141+    //         super("CAST6", 256, new CipherKeyGenerator());
6142+    //     }
6143+    // }
6144+    //
6145+    // /**
6146+    //  * TEA
6147+    //  */
6148+    // public static class TEA
6149+    //     extends JCEKeyGenerator
6150+    // {
6151+    //     public TEA()
6152+    //     {
6153+    //         super("TEA", 128, new CipherKeyGenerator());
6154+    //     }
6155+    // }
6156+    //
6157+    // /**
6158+    //  * XTEA
6159+    //  */
6160+    // public static class XTEA
6161+    //     extends JCEKeyGenerator
6162+    // {
6163+    //     public XTEA()
6164+    //     {
6165+    //         super("XTEA", 128, new CipherKeyGenerator());
6166+    //     }
6167+    // }
6168+    //
6169+    // /**
6170+    //  * Salsa20
6171+    //  */
6172+    // public static class Salsa20
6173+    //     extends JCEKeyGenerator
6174+    // {
6175+    //     public Salsa20()
6176+    //     {
6177+    //         super("Salsa20", 128, new CipherKeyGenerator());
6178+    //     }
6179+    // }
6180+    //
6181+    // /**
6182+    //  * HC128
6183+    //  */
6184+    // public static class HC128
6185+    //     extends JCEKeyGenerator
6186+    // {
6187+    //     public HC128()
6188+    //     {
6189+    //         super("HC128", 128, new CipherKeyGenerator());
6190+    //     }
6191+    // }
6192+    //
6193+    // /**
6194+    //  * HC256
6195+    //  */
6196+    // public static class HC256
6197+    //     extends JCEKeyGenerator
6198+    // {
6199+    //     public HC256()
6200+    //     {
6201+    //         super("HC256", 256, new CipherKeyGenerator());
6202+    //     }
6203+    // }
6204+    //
6205+    // /**
6206+    //  * VMPC
6207+    //  */
6208+    // public static class VMPC
6209+    //     extends JCEKeyGenerator
6210+    // {
6211+    //     public VMPC()
6212+    //     {
6213+    //         super("VMPC", 128, new CipherKeyGenerator());
6214+    //     }
6215+    // }
6216+    //
6217+    // /**
6218+    //  * VMPC-KSA3
6219+    //  */
6220+    // public static class VMPCKSA3
6221+    //     extends JCEKeyGenerator
6222+    // {
6223+    //     public VMPCKSA3()
6224+    //     {
6225+    //         super("VMPC-KSA3", 128, new CipherKeyGenerator());
6226+    //     }
6227+    // }
6228+    // END android-removed
6229
6230     // HMAC Related secret keys..
6231
6232-    /**
6233-     * MD2HMAC
6234-     */
6235-    public static class MD2HMAC
6236-        extends JCEKeyGenerator
6237-    {
6238-        public MD2HMAC()
6239-        {
6240-            super("HMACMD2", 128, new CipherKeyGenerator());
6241-        }
6242-    }
6243-
6244-
6245-    /**
6246-     * MD4HMAC
6247-     */
6248-    public static class MD4HMAC
6249-        extends JCEKeyGenerator
6250-    {
6251-        public MD4HMAC()
6252-        {
6253-            super("HMACMD4", 128, new CipherKeyGenerator());
6254-        }
6255-    }
6256+    // BEGIN android-removed
6257+    // /**
6258+    //  * MD2HMAC
6259+    //  */
6260+    // public static class MD2HMAC
6261+    //     extends JCEKeyGenerator
6262+    // {
6263+    //     public MD2HMAC()
6264+    //     {
6265+    //         super("HMACMD2", 128, new CipherKeyGenerator());
6266+    //     }
6267+    // }
6268+    //
6269+    //
6270+    // /**
6271+    //  * MD4HMAC
6272+    //  */
6273+    // public static class MD4HMAC
6274+    //     extends JCEKeyGenerator
6275+    // {
6276+    //     public MD4HMAC()
6277+    //     {
6278+    //         super("HMACMD4", 128, new CipherKeyGenerator());
6279+    //     }
6280+    // }
6281+    // END android-removed
6282
6283     /**
6284      * MD5HMAC
6285@@ -427,29 +435,29 @@
6286     }
6287
6288
6289-    /**
6290-     * RIPE128HMAC
6291-     */
6292-    public static class RIPEMD128HMAC
6293-        extends JCEKeyGenerator
6294-    {
6295-        public RIPEMD128HMAC()
6296-        {
6297-            super("HMACRIPEMD128", 128, new CipherKeyGenerator());
6298-        }
6299-    }
6300-
6301-    /**
6302-     * RIPE160HMAC
6303-     */
6304-    public static class RIPEMD160HMAC
6305-        extends JCEKeyGenerator
6306-    {
6307-        public RIPEMD160HMAC()
6308-        {
6309-            super("HMACRIPEMD160", 160, new CipherKeyGenerator());
6310-        }
6311-    }
6312+    // /**
6313+    //  * RIPE128HMAC
6314+    //  */
6315+    // public static class RIPEMD128HMAC
6316+    //     extends JCEKeyGenerator
6317+    // {
6318+    //     public RIPEMD128HMAC()
6319+    //     {
6320+    //         super("HMACRIPEMD128", 128, new CipherKeyGenerator());
6321+    //     }
6322+    // }
6323+
6324+    // /**
6325+    //  * RIPE160HMAC
6326+    //  */
6327+    // public static class RIPEMD160HMAC
6328+    //     extends JCEKeyGenerator
6329+    // {
6330+    //     public RIPEMD160HMAC()
6331+    //     {
6332+    //         super("HMACRIPEMD160", 160, new CipherKeyGenerator());
6333+    //     }
6334+    // }
6335
6336
6337     /**
6338@@ -464,17 +472,19 @@
6339         }
6340     }
6341
6342-    /**
6343-     * HMACSHA224
6344-     */
6345-    public static class HMACSHA224
6346-        extends JCEKeyGenerator
6347-    {
6348-        public HMACSHA224()
6349-        {
6350-            super("HMACSHA224", 224, new CipherKeyGenerator());
6351-        }
6352-    }
6353+    // BEGIN android-removed
6354+    // /**
6355+    //  * HMACSHA224
6356+    //  */
6357+    // public static class HMACSHA224
6358+    //     extends JCEKeyGenerator
6359+    // {
6360+    //     public HMACSHA224()
6361+    //     {
6362+    //         super("HMACSHA224", 224, new CipherKeyGenerator());
6363+    //     }
6364+    // }
6365+    // END android-removed
6366
6367     /**
6368      * HMACSHA256
6369@@ -512,15 +522,17 @@
6370         }
6371     }
6372
6373-    /**
6374-     * HMACTIGER
6375-     */
6376-    public static class HMACTIGER
6377-        extends JCEKeyGenerator
6378-    {
6379-        public HMACTIGER()
6380-        {
6381-            super("HMACTIGER", 192, new CipherKeyGenerator());
6382-        }
6383-    }
6384+    // BEGIN android-removed
6385+    // /**
6386+    //  * HMACTIGER
6387+    //  */
6388+    // public static class HMACTIGER
6389+    //     extends JCEKeyGenerator
6390+    // {
6391+    //     public HMACTIGER()
6392+    //     {
6393+    //         super("HMACTIGER", 192, new CipherKeyGenerator());
6394+    //     }
6395+    // }
6396+    // END android-removed
6397 }
6398diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEMac.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEMac.java
6399--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEMac.java	2010-01-11 21:46:14.000000000 +0000
6400+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEMac.java	2011-09-03 18:19:15.000000000 +0000
6401@@ -2,29 +2,43 @@
6402
6403 import org.bouncycastle.crypto.CipherParameters;
6404 import org.bouncycastle.crypto.Mac;
6405-import org.bouncycastle.crypto.digests.MD2Digest;
6406-import org.bouncycastle.crypto.digests.MD4Digest;
6407+// BEGIN android-removed
6408+// import org.bouncycastle.crypto.digests.MD2Digest;
6409+// import org.bouncycastle.crypto.digests.MD4Digest;
6410+// END android-removed
6411 import org.bouncycastle.crypto.digests.MD5Digest;
6412-import org.bouncycastle.crypto.digests.RIPEMD128Digest;
6413-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
6414+// BEGIN android-removed
6415+// import org.bouncycastle.crypto.digests.RIPEMD128Digest;
6416+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
6417+// END android-removed
6418 import org.bouncycastle.crypto.digests.SHA1Digest;
6419-import org.bouncycastle.crypto.digests.SHA224Digest;
6420+// BEGIN android-removed
6421+// import org.bouncycastle.crypto.digests.SHA224Digest;
6422+// END android-removed
6423 import org.bouncycastle.crypto.digests.SHA256Digest;
6424 import org.bouncycastle.crypto.digests.SHA384Digest;
6425 import org.bouncycastle.crypto.digests.SHA512Digest;
6426-import org.bouncycastle.crypto.digests.TigerDigest;
6427+// BEGIN android-removed
6428+// import org.bouncycastle.crypto.digests.TigerDigest;
6429+// END android-removed
6430 import org.bouncycastle.crypto.engines.DESEngine;
6431 import org.bouncycastle.crypto.engines.DESedeEngine;
6432-import org.bouncycastle.crypto.engines.RC2Engine;
6433-import org.bouncycastle.crypto.engines.RC532Engine;
6434-import org.bouncycastle.crypto.engines.SkipjackEngine;
6435+// BEGIN android-removed
6436+// import org.bouncycastle.crypto.engines.RC2Engine;
6437+// import org.bouncycastle.crypto.engines.RC532Engine;
6438+// import org.bouncycastle.crypto.engines.SkipjackEngine;
6439+// END android-removed
6440 import org.bouncycastle.crypto.macs.CBCBlockCipherMac;
6441-import org.bouncycastle.crypto.macs.CFBBlockCipherMac;
6442-import org.bouncycastle.crypto.macs.GOST28147Mac;
6443+// BEGIN android-removed
6444+// import org.bouncycastle.crypto.macs.CFBBlockCipherMac;
6445+// import org.bouncycastle.crypto.macs.GOST28147Mac;
6446+// END android-removed
6447 import org.bouncycastle.crypto.macs.HMac;
6448-import org.bouncycastle.crypto.macs.ISO9797Alg3Mac;
6449-import org.bouncycastle.crypto.macs.OldHMac;
6450-import org.bouncycastle.crypto.macs.VMPCMac;
6451+// BEGIN android-removed
6452+// import org.bouncycastle.crypto.macs.ISO9797Alg3Mac;
6453+// import org.bouncycastle.crypto.macs.OldHMac;
6454+// import org.bouncycastle.crypto.macs.VMPCMac;
6455+// END android-removed
6456 import org.bouncycastle.crypto.paddings.ISO7816d4Padding;
6457 import org.bouncycastle.crypto.params.KeyParameter;
6458 import org.bouncycastle.crypto.params.ParametersWithIV;
6459@@ -146,224 +160,226 @@
6460      * the classes that extend directly off us.
6461      */
6462
6463-    /**
6464-     * DES
6465-     */
6466-    public static class DES
6467-        extends JCEMac
6468-    {
6469-        public DES()
6470-        {
6471-            super(new CBCBlockCipherMac(new DESEngine()));
6472-        }
6473-    }
6474-
6475-    /**
6476-     * DESede
6477-     */
6478-    public static class DESede
6479-        extends JCEMac
6480-    {
6481-        public DESede()
6482-        {
6483-            super(new CBCBlockCipherMac(new DESedeEngine()));
6484-        }
6485-    }
6486-
6487-    /**
6488-     * SKIPJACK
6489-     */
6490-    public static class Skipjack
6491-        extends JCEMac
6492-    {
6493-        public Skipjack()
6494-        {
6495-            super(new CBCBlockCipherMac(new SkipjackEngine()));
6496-        }
6497-    }
6498-
6499-    /**
6500-     * RC2
6501-     */
6502-    public static class RC2
6503-        extends JCEMac
6504-    {
6505-        public RC2()
6506-        {
6507-            super(new CBCBlockCipherMac(new RC2Engine()));
6508-        }
6509-    }
6510-
6511-    /**
6512-     * RC5
6513-     */
6514-    public static class RC5
6515-        extends JCEMac
6516-    {
6517-        public RC5()
6518-        {
6519-            super(new CBCBlockCipherMac(new RC532Engine()));
6520-        }
6521-    }
6522-
6523-    /**
6524-     * GOST28147
6525-     */
6526-    public static class GOST28147
6527-        extends JCEMac
6528-    {
6529-        public GOST28147()
6530-        {
6531-            super(new GOST28147Mac());
6532-        }
6533-    }
6534-
6535-    /**
6536-     * VMPC
6537-     */
6538-    public static class VMPC
6539-        extends JCEMac
6540-    {
6541-        public VMPC()
6542-        {
6543-            super(new VMPCMac());
6544-        }
6545-    }
6546-
6547-    /**
6548-     * DES
6549-     */
6550-    public static class DESCFB8
6551-        extends JCEMac
6552-    {
6553-        public DESCFB8()
6554-        {
6555-            super(new CFBBlockCipherMac(new DESEngine()));
6556-        }
6557-    }
6558-
6559-    /**
6560-     * DESede
6561-     */
6562-    public static class DESedeCFB8
6563-        extends JCEMac
6564-    {
6565-        public DESedeCFB8()
6566-        {
6567-            super(new CFBBlockCipherMac(new DESedeEngine()));
6568-        }
6569-    }
6570-
6571-    /**
6572-     * SKIPJACK
6573-     */
6574-    public static class SkipjackCFB8
6575-        extends JCEMac
6576-    {
6577-        public SkipjackCFB8()
6578-        {
6579-            super(new CFBBlockCipherMac(new SkipjackEngine()));
6580-        }
6581-    }
6582-
6583-    /**
6584-     * RC2CFB8
6585-     */
6586-    public static class RC2CFB8
6587-        extends JCEMac
6588-    {
6589-        public RC2CFB8()
6590-        {
6591-            super(new CFBBlockCipherMac(new RC2Engine()));
6592-        }
6593-    }
6594-
6595-    /**
6596-     * RC5CFB8
6597-     */
6598-    public static class RC5CFB8
6599-        extends JCEMac
6600-    {
6601-        public RC5CFB8()
6602-        {
6603-            super(new CFBBlockCipherMac(new RC532Engine()));
6604-        }
6605-    }
6606-
6607+    // BEGIN android-removed
6608+    // /**
6609+    //  * DES
6610+    //  */
6611+    // public static class DES
6612+    //     extends JCEMac
6613+    // {
6614+    //     public DES()
6615+    //     {
6616+    //         super(new CBCBlockCipherMac(new DESEngine()));
6617+    //     }
6618+    // }
6619+    //
6620+    // /**
6621+    //  * DESede
6622+    //  */
6623+    // public static class DESede
6624+    //     extends JCEMac
6625+    // {
6626+    //     public DESede()
6627+    //     {
6628+    //         super(new CBCBlockCipherMac(new DESedeEngine()));
6629+    //     }
6630+    // }
6631+    //
6632+    // /**
6633+    //  * SKIPJACK
6634+    //  */
6635+    // public static class Skipjack
6636+    //     extends JCEMac
6637+    // {
6638+    //     public Skipjack()
6639+    //     {
6640+    //         super(new CBCBlockCipherMac(new SkipjackEngine()));
6641+    //     }
6642+    // }
6643+    //
6644+    // /**
6645+    //  * RC2
6646+    //  */
6647+    // public static class RC2
6648+    //     extends JCEMac
6649+    // {
6650+    //     public RC2()
6651+    //     {
6652+    //         super(new CBCBlockCipherMac(new RC2Engine()));
6653+    //     }
6654+    // }
6655+    //
6656+    // /**
6657+    //  * RC5
6658+    //  */
6659+    // public static class RC5
6660+    //     extends JCEMac
6661+    // {
6662+    //     public RC5()
6663+    //     {
6664+    //         super(new CBCBlockCipherMac(new RC532Engine()));
6665+    //     }
6666+    // }
6667+    //
6668+    // /**
6669+    //  * GOST28147
6670+    //  */
6671+    // public static class GOST28147
6672+    //     extends JCEMac
6673+    // {
6674+    //     public GOST28147()
6675+    //     {
6676+    //         super(new GOST28147Mac());
6677+    //     }
6678+    // }
6679+    //
6680+    // /**
6681+    //  * VMPC
6682+    //  */
6683+    // public static class VMPC
6684+    //     extends JCEMac
6685+    // {
6686+    //     public VMPC()
6687+    //     {
6688+    //         super(new VMPCMac());
6689+    //     }
6690+    // }
6691+    //
6692+    // /**
6693+    //  * DES
6694+    //  */
6695+    // public static class DESCFB8
6696+    //     extends JCEMac
6697+    // {
6698+    //     public DESCFB8()
6699+    //     {
6700+    //         super(new CFBBlockCipherMac(new DESEngine()));
6701+    //     }
6702+    // }
6703+    //
6704+    // /**
6705+    //  * DESede
6706+    //  */
6707+    // public static class DESedeCFB8
6708+    //     extends JCEMac
6709+    // {
6710+    //     public DESedeCFB8()
6711+    //     {
6712+    //         super(new CFBBlockCipherMac(new DESedeEngine()));
6713+    //     }
6714+    // }
6715+    //
6716+    // /**
6717+    //  * SKIPJACK
6718+    //  */
6719+    // public static class SkipjackCFB8
6720+    //     extends JCEMac
6721+    // {
6722+    //     public SkipjackCFB8()
6723+    //     {
6724+    //         super(new CFBBlockCipherMac(new SkipjackEngine()));
6725+    //     }
6726+    // }
6727+    //
6728+    // /**
6729+    //  * RC2CFB8
6730+    //  */
6731+    // public static class RC2CFB8
6732+    //     extends JCEMac
6733+    // {
6734+    //     public RC2CFB8()
6735+    //     {
6736+    //         super(new CFBBlockCipherMac(new RC2Engine()));
6737+    //     }
6738+    // }
6739+    //
6740+    // /**
6741+    //  * RC5CFB8
6742+    //  */
6743+    // public static class RC5CFB8
6744+    //     extends JCEMac
6745+    // {
6746+    //     public RC5CFB8()
6747+    //     {
6748+    //         super(new CFBBlockCipherMac(new RC532Engine()));
6749+    //     }
6750+    // }
6751+    //
6752+    //
6753+    // /**
6754+    //  * DESede64
6755+    //  */
6756+    // public static class DESede64
6757+    //     extends JCEMac
6758+    // {
6759+    //     public DESede64()
6760+    //     {
6761+    //         super(new CBCBlockCipherMac(new DESedeEngine(), 64));
6762+    //     }
6763+    // }
6764+    //
6765+    // /**
6766+    //  * DESede64with7816-4Padding
6767+    //  */
6768+    // public static class DESede64with7816d4
6769+    //     extends JCEMac
6770+    // {
6771+    //     public DESede64with7816d4()
6772+    //     {
6773+    //         super(new CBCBlockCipherMac(new DESedeEngine(), 64, new ISO7816d4Padding()));
6774+    //     }
6775+    // }
6776+    //
6777+    // /**
6778+    //  * DES9797Alg3with7816-4Padding
6779+    //  */
6780+    // public static class DES9797Alg3with7816d4
6781+    //     extends JCEMac
6782+    // {
6783+    //     public DES9797Alg3with7816d4()
6784+    //     {
6785+    //         super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
6786+    //     }
6787+    // }
6788+    //
6789+    // /**
6790+    //  * DES9797Alg3
6791+    //  */
6792+    // public static class DES9797Alg3
6793+    //     extends JCEMac
6794+    // {
6795+    //     public DES9797Alg3()
6796+    //     {
6797+    //         super(new ISO9797Alg3Mac(new DESEngine()));
6798+    //     }
6799+    // }
6800+    //
6801+    // /**
6802+    //  * MD2 HMac
6803+    //  */
6804+    // public static class MD2
6805+    //     extends JCEMac
6806+    // {
6807+    //     public MD2()
6808+    //     {
6809+    //         super(new HMac(new MD2Digest()));
6810+    //     }
6811+    // }
6812+    //
6813+    // /**
6814+    //  * MD4 HMac
6815+    //  */
6816+    // public static class MD4
6817+    //     extends JCEMac
6818+    // {
6819+    //     public MD4()
6820+    //     {
6821+    //         super(new HMac(new MD4Digest()));
6822+    //     }
6823+    // }
6824+    // END android-removed
6825
6826     /**
6827-     * DESede64
6828-     */
6829-    public static class DESede64
6830-        extends JCEMac
6831-    {
6832-        public DESede64()
6833-        {
6834-            super(new CBCBlockCipherMac(new DESedeEngine(), 64));
6835-        }
6836-    }
6837-
6838-    /**
6839-     * DESede64with7816-4Padding
6840-     */
6841-    public static class DESede64with7816d4
6842-        extends JCEMac
6843-    {
6844-        public DESede64with7816d4()
6845-        {
6846-            super(new CBCBlockCipherMac(new DESedeEngine(), 64, new ISO7816d4Padding()));
6847-        }
6848-    }
6849-
6850-    /**
6851-     * DES9797Alg3with7816-4Padding
6852-     */
6853-    public static class DES9797Alg3with7816d4
6854-        extends JCEMac
6855-    {
6856-        public DES9797Alg3with7816d4()
6857-        {
6858-            super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding()));
6859-        }
6860-    }
6861-
6862-    /**
6863-     * DES9797Alg3
6864-     */
6865-    public static class DES9797Alg3
6866-        extends JCEMac
6867-    {
6868-        public DES9797Alg3()
6869-        {
6870-            super(new ISO9797Alg3Mac(new DESEngine()));
6871-        }
6872-    }
6873-
6874-    /**
6875-     * MD2 HMac
6876-     */
6877-    public static class MD2
6878-        extends JCEMac
6879-    {
6880-        public MD2()
6881-        {
6882-            super(new HMac(new MD2Digest()));
6883-        }
6884-    }
6885-
6886-    /**
6887-     * MD4 HMac
6888-     */
6889-    public static class MD4
6890-        extends JCEMac
6891-    {
6892-        public MD4()
6893-        {
6894-            super(new HMac(new MD4Digest()));
6895-        }
6896-    }
6897-
6898-    /**
6899      * MD5 HMac
6900      */
6901     public static class MD5
6902@@ -374,7 +390,7 @@
6903             super(new HMac(new MD5Digest()));
6904         }
6905     }
6906-
6907+
6908     /**
6909      * SHA1 HMac
6910      */
6911@@ -386,18 +402,20 @@
6912             super(new HMac(new SHA1Digest()));
6913         }
6914     }
6915-
6916-    /**
6917-     * SHA-224 HMac
6918-     */
6919-    public static class SHA224
6920-        extends JCEMac
6921-    {
6922-        public SHA224()
6923-        {
6924-            super(new HMac(new SHA224Digest()));
6925-        }
6926-    }
6927+
6928+    // BEGIN android-removed
6929+    // /**
6930+    //  * SHA-224 HMac
6931+    //  */
6932+    // public static class SHA224
6933+    //     extends JCEMac
6934+    // {
6935+    //     public SHA224()
6936+    //     {
6937+    //         super(new HMac(new SHA224Digest()));
6938+    //     }
6939+    // }
6940+    // END android-removed
6941
6942     /**
6943      * SHA-256 HMac
6944@@ -410,7 +428,7 @@
6945             super(new HMac(new SHA256Digest()));
6946         }
6947     }
6948-
6949+
6950     /**
6951      * SHA-384 HMac
6952      */
6953@@ -422,15 +440,17 @@
6954             super(new HMac(new SHA384Digest()));
6955         }
6956     }
6957-
6958-    public static class OldSHA384
6959-        extends JCEMac
6960-    {
6961-        public OldSHA384()
6962-        {
6963-            super(new OldHMac(new SHA384Digest()));
6964-        }
6965-    }
6966+
6967+    // BEGIN android-removed
6968+    // public static class OldSHA384
6969+    //     extends JCEMac
6970+    // {
6971+    //     public OldSHA384()
6972+    //     {
6973+    //         super(new OldHMac(new SHA384Digest()));
6974+    //     }
6975+    // }
6976+    // END android-removed
6977
6978     /**
6979      * SHA-512 HMac
6980@@ -443,73 +463,75 @@
6981             super(new HMac(new SHA512Digest()));
6982         }
6983     }
6984-
6985-    /**
6986-     * SHA-512 HMac
6987-     */
6988-    public static class OldSHA512
6989-        extends JCEMac
6990-    {
6991-        public OldSHA512()
6992-        {
6993-            super(new OldHMac(new SHA512Digest()));
6994-        }
6995-    }
6996
6997-    /**
6998-     * RIPEMD128 HMac
6999-     */
7000-    public static class RIPEMD128
7001-        extends JCEMac
7002-    {
7003-        public RIPEMD128()
7004-        {
7005-            super(new HMac(new RIPEMD128Digest()));
7006-        }
7007-    }
7008-
7009-    /**
7010-     * RIPEMD160 HMac
7011-     */
7012-    public static class RIPEMD160
7013-        extends JCEMac
7014-    {
7015-        public RIPEMD160()
7016-        {
7017-            super(new HMac(new RIPEMD160Digest()));
7018-        }
7019-    }
7020-
7021-    /**
7022-     * Tiger HMac
7023-     */
7024-    public static class Tiger
7025-        extends JCEMac
7026-    {
7027-        public Tiger()
7028-        {
7029-            super(new HMac(new TigerDigest()));
7030-        }
7031-    }
7032-
7033+    // BEGIN android-removed
7034+    // /**
7035+    //  * SHA-512 HMac
7036+    //  */
7037+    // public static class OldSHA512
7038+    //     extends JCEMac
7039+    // {
7040+    //     public OldSHA512()
7041+    //     {
7042+    //         super(new OldHMac(new SHA512Digest()));
7043+    //     }
7044+    // }
7045     //
7046-    // PKCS12 states that the same algorithm should be used
7047-    // for the key generation as is used in the HMAC, so that
7048-    // is what we do here.
7049+    // /**
7050+    //  * RIPEMD128 HMac
7051+    //  */
7052+    // public static class RIPEMD128
7053+    //     extends JCEMac
7054+    // {
7055+    //     public RIPEMD128()
7056+    //     {
7057+    //        super(new HMac(new RIPEMD128Digest()));
7058+    //     }
7059+    // }
7060     //
7061-
7062-    /**
7063-     * PBEWithHmacRIPEMD160
7064-     */
7065-    public static class PBEWithRIPEMD160
7066-        extends JCEMac
7067-    {
7068-        public PBEWithRIPEMD160()
7069-        {
7070-            super(new HMac(new RIPEMD160Digest()), PKCS12, RIPEMD160, 160);
7071-        }
7072-    }
7073-
7074+    // /**
7075+    //  * RIPEMD160 HMac
7076+    //  */
7077+    // public static class RIPEMD160
7078+    //     extends JCEMac
7079+    // {
7080+    //     public RIPEMD160()
7081+    //     {
7082+    //        super(new HMac(new RIPEMD160Digest()));
7083+    //     }
7084+    // }
7085+    //
7086+    // /**
7087+    //  * Tiger HMac
7088+    //  */
7089+    // public static class Tiger
7090+    //     extends JCEMac
7091+    // {
7092+    //     public Tiger()
7093+    //     {
7094+    //         super(new HMac(new TigerDigest()));
7095+    //     }
7096+    // }
7097+    //
7098+    // //
7099+    // // PKCS12 states that the same algorithm should be used
7100+    // // for the key generation as is used in the HMAC, so that
7101+    // // is what we do here.
7102+    // //
7103+    //
7104+    // /**
7105+    //  * PBEWithHmacRIPEMD160
7106+    //  */
7107+    // public static class PBEWithRIPEMD160
7108+    //     extends JCEMac
7109+    // {
7110+    //     public PBEWithRIPEMD160()
7111+    //     {
7112+    //         super(new HMac(new RIPEMD160Digest()), PKCS12, RIPEMD160, 160);
7113+    //     }
7114+    // }
7115+    // END android-removed
7116+
7117     /**
7118      * PBEWithHmacSHA
7119      */
7120@@ -521,16 +543,18 @@
7121             super(new HMac(new SHA1Digest()), PKCS12, SHA1, 160);
7122         }
7123     }
7124-
7125-    /**
7126-     * PBEWithHmacTiger
7127-     */
7128-    public static class PBEWithTiger
7129-        extends JCEMac
7130-    {
7131-        public PBEWithTiger()
7132-        {
7133-            super(new HMac(new TigerDigest()), PKCS12, TIGER, 192);
7134-        }
7135-    }
7136+
7137+    // BEGIN android-removed
7138+    //  /**
7139+    //   * PBEWithHmacTiger
7140+    //   */
7141+    // public static class PBEWithTiger
7142+    //     extends JCEMac
7143+    // {
7144+    //     public PBEWithTiger()
7145+    //     {
7146+    //         super(new HMac(new TigerDigest()), PKCS12, TIGER, 192);
7147+    //     }
7148+    // }
7149+    // END android-removed
7150 }
7151diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSACipher.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSACipher.java
7152--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSACipher.java	2010-01-11 21:46:14.000000000 +0000
7153+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSACipher.java	2011-09-03 18:19:15.000000000 +0000
7154@@ -534,48 +534,50 @@
7155         }
7156     }
7157
7158-    static public class PKCS1v1_5Padding
7159-        extends JCERSACipher
7160-    {
7161-        public PKCS1v1_5Padding()
7162-        {
7163-            super(new PKCS1Encoding(new RSABlindedEngine()));
7164-        }
7165-    }
7166-
7167-    static public class PKCS1v1_5Padding_PrivateOnly
7168-        extends JCERSACipher
7169-    {
7170-        public PKCS1v1_5Padding_PrivateOnly()
7171-        {
7172-            super(false, true, new PKCS1Encoding(new RSABlindedEngine()));
7173-        }
7174-    }
7175-
7176-    static public class PKCS1v1_5Padding_PublicOnly
7177-        extends JCERSACipher
7178-    {
7179-        public PKCS1v1_5Padding_PublicOnly()
7180-        {
7181-            super(true, false, new PKCS1Encoding(new RSABlindedEngine()));
7182-        }
7183-    }
7184-
7185-    static public class OAEPPadding
7186-        extends JCERSACipher
7187-    {
7188-        public OAEPPadding()
7189-        {
7190-            super(OAEPParameterSpec.DEFAULT);
7191-        }
7192-    }
7193-
7194-    static public class ISO9796d1Padding
7195-        extends JCERSACipher
7196-    {
7197-        public ISO9796d1Padding()
7198-        {
7199-            super(new ISO9796d1Encoding(new RSABlindedEngine()));
7200-        }
7201-    }
7202+    // BEGIN android-removed
7203+    // static public class PKCS1v1_5Padding
7204+    //     extends JCERSACipher
7205+    // {
7206+    //     public PKCS1v1_5Padding()
7207+    //     {
7208+    //         super(new PKCS1Encoding(new RSABlindedEngine()));
7209+    //     }
7210+    // }
7211+    //
7212+    // static public class PKCS1v1_5Padding_PrivateOnly
7213+    //     extends JCERSACipher
7214+    // {
7215+    //     public PKCS1v1_5Padding_PrivateOnly()
7216+    //     {
7217+    //         super(false, true, new PKCS1Encoding(new RSABlindedEngine()));
7218+    //     }
7219+    // }
7220+    //
7221+    // static public class PKCS1v1_5Padding_PublicOnly
7222+    //     extends JCERSACipher
7223+    // {
7224+    //     public PKCS1v1_5Padding_PublicOnly()
7225+    //     {
7226+    //         super(true, false, new PKCS1Encoding(new RSABlindedEngine()));
7227+    //     }
7228+    // }
7229+    //
7230+    // static public class OAEPPadding
7231+    //     extends JCERSACipher
7232+    // {
7233+    //     public OAEPPadding()
7234+    //     {
7235+    //         super(OAEPParameterSpec.DEFAULT);
7236+    //     }
7237+    // }
7238+    //
7239+    // static public class ISO9796d1Padding
7240+    //     extends JCERSACipher
7241+    // {
7242+    //     public ISO9796d1Padding()
7243+    //     {
7244+    //         super(new ISO9796d1Encoding(new RSABlindedEngine()));
7245+    //     }
7246+    // }
7247+    // END android-removed
7248 }
7249diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java
7250--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java	2010-01-11 21:46:14.000000000 +0000
7251+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java	2011-09-03 18:19:15.000000000 +0000
7252@@ -125,7 +125,9 @@
7253      */
7254     public byte[] getEncoded()
7255     {
7256-        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPrivateKeyStructure(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()).getDERObject());
7257+        // BEGIN android-changed
7258+        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKeyStructure(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()).getDERObject());
7259+        // END android-changed
7260
7261         return info.getDEREncoded();
7262     }
7263diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateKey.java
7264--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateKey.java	2010-01-11 21:46:14.000000000 +0000
7265+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateKey.java	2011-09-03 18:19:15.000000000 +0000
7266@@ -77,7 +77,9 @@
7267
7268     public byte[] getEncoded()
7269     {
7270-        PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPrivateKeyStructure(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO, ZERO, ZERO, ZERO).getDERObject());
7271+        // BEGIN android-changed
7272+        PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKeyStructure(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO, ZERO, ZERO, ZERO).getDERObject());
7273+        // END android-changed
7274
7275         return info.getDEREncoded();
7276     }
7277diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPublicKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPublicKey.java
7278--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPublicKey.java	2010-01-11 21:46:14.000000000 +0000
7279+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPublicKey.java	2011-09-03 18:19:15.000000000 +0000
7280@@ -90,7 +90,9 @@
7281
7282     public byte[] getEncoded()
7283     {
7284-        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
7285+        // BEGIN android-changed
7286+        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
7287+        // END android-changed
7288
7289         return info.getDEREncoded();
7290     }
7291diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCESecretKeyFactory.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCESecretKeyFactory.java
7292--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCESecretKeyFactory.java	2010-01-11 21:46:14.000000000 +0000
7293+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCESecretKeyFactory.java	2011-09-03 18:19:15.000000000 +0000
7294@@ -321,29 +321,31 @@
7295         }
7296     }
7297
7298-    /**
7299-     * PBEWithMD2AndDES
7300-     */
7301-    static public class PBEWithMD2AndDES
7302-        extends DESPBEKeyFactory
7303-    {
7304-        public PBEWithMD2AndDES()
7305-        {
7306-            super("PBEwithMD2andDES", PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, true, PKCS5S1, MD2, 64, 64);
7307-        }
7308-    }
7309-
7310-    /**
7311-     * PBEWithMD2AndRC2
7312-     */
7313-    static public class PBEWithMD2AndRC2
7314-        extends PBEKeyFactory
7315-    {
7316-        public PBEWithMD2AndRC2()
7317-        {
7318-            super("PBEwithMD2andRC2", PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, true, PKCS5S1, MD2, 64, 64);
7319-        }
7320-    }
7321+    // BEGIN android-removed
7322+    // /**
7323+    //  * PBEWithMD2AndDES
7324+    //  */
7325+    // static public class PBEWithMD2AndDES
7326+    //     extends DESPBEKeyFactory
7327+    // {
7328+    //     public PBEWithMD2AndDES()
7329+    //     {
7330+    //         super("PBEwithMD2andDES", PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, true, PKCS5S1, MD2, 64, 64);
7331+    //     }
7332+    // }
7333+    //
7334+    // /**
7335+    //  * PBEWithMD2AndRC2
7336+    //  */
7337+    // static public class PBEWithMD2AndRC2
7338+    //     extends PBEKeyFactory
7339+    // {
7340+    //     public PBEWithMD2AndRC2()
7341+    //     {
7342+    //         super("PBEwithMD2andRC2", PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, true, PKCS5S1, MD2, 64, 64);
7343+    //     }
7344+    // }
7345+    // END android-removed
7346
7347    /**
7348     * PBEWithMD5AndDES
7349@@ -477,17 +479,19 @@
7350        }
7351    }
7352
7353-   /**
7354-    * PBEWithHmacRIPEMD160
7355-    */
7356-   public static class PBEWithRIPEMD160
7357-       extends PBEKeyFactory
7358-   {
7359-       public PBEWithRIPEMD160()
7360-       {
7361-           super("PBEwithHmacRIPEMD160", null, false, PKCS12, RIPEMD160, 160, 0);
7362-       }
7363-   }
7364+   // BEGIN android-removed
7365+   // /**
7366+   //  * PBEWithHmacRIPEMD160
7367+   //  */
7368+   // public static class PBEWithRIPEMD160
7369+   //     extends PBEKeyFactory
7370+   // {
7371+   //     public PBEWithRIPEMD160()
7372+   //     {
7373+   //         super("PBEwithHmacRIPEMD160", null, false, PKCS12, RIPEMD160, 160, 0);
7374+   //     }
7375+   // }
7376+   // END android-removed
7377
7378    /**
7379     * PBEWithHmacSHA
7380@@ -501,17 +505,19 @@
7381        }
7382    }
7383
7384-   /**
7385-    * PBEWithHmacTiger
7386-    */
7387-   public static class PBEWithTiger
7388-       extends PBEKeyFactory
7389-   {
7390-       public PBEWithTiger()
7391-       {
7392-           super("PBEwithHmacTiger", null, false, PKCS12, TIGER, 192, 0);
7393-       }
7394-   }
7395+   // BEGIN android-removed
7396+   // /**
7397+   //  * PBEWithHmacTiger
7398+   //  */
7399+   // public static class PBEWithTiger
7400+   //     extends PBEKeyFactory
7401+   // {
7402+   //     public PBEWithTiger()
7403+   //     {
7404+   //         super("PBEwithHmacTiger", null, false, PKCS12, TIGER, 192, 0);
7405+   //     }
7406+   // }
7407+   // END android-removed
7408
7409    /**
7410     * PBEWithSHA1And128BitAES-BC
7411@@ -620,4 +626,56 @@
7412            super("PBEWithMD5And256BitAES-CBC-OpenSSL", null, true, OPENSSL, MD5, 256, 128);
7413        }
7414    }
7415+    // BEGIN android-added
7416+    static public class PBKDF2WithHmacSHA1
7417+        extends JCESecretKeyFactory
7418+    {
7419+        public PBKDF2WithHmacSHA1()
7420+        {
7421+            super("PBKDF2WithHmacSHA1", PKCSObjectIdentifiers.id_PBKDF2);
7422+        }
7423+
7424+        protected SecretKey engineGenerateSecret(
7425+            KeySpec keySpec)
7426+            throws InvalidKeySpecException
7427+        {
7428+            if (keySpec instanceof PBEKeySpec)
7429+            {
7430+                PBEKeySpec          pbeSpec = (PBEKeySpec)keySpec;
7431+
7432+                if (pbeSpec.getSalt() == null)
7433+                {
7434+                    throw new InvalidKeySpecException("missing required salt");
7435+                }
7436+
7437+                if (pbeSpec.getIterationCount() <= 0)
7438+                {
7439+                    throw new InvalidKeySpecException("positive iteration count required: "
7440+                                                      + pbeSpec.getIterationCount());
7441+                }
7442+
7443+                if (pbeSpec.getKeyLength() <= 0)
7444+                {
7445+                    throw new InvalidKeySpecException("positive key length required: "
7446+                                                      + pbeSpec.getKeyLength());
7447+                }
7448+
7449+                if (pbeSpec.getPassword().length == 0)
7450+                {
7451+                    throw new IllegalArgumentException("password empty");
7452+                }
7453+
7454+                int scheme = PKCS5S2;
7455+                int digest = SHA1;
7456+                int keySize = pbeSpec.getKeyLength();
7457+                int ivSize = -1;
7458+                CipherParameters param = Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize);
7459+
7460+                return new JCEPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param);
7461+            }
7462+
7463+            throw new InvalidKeySpecException("Invalid KeySpec");
7464+        }
7465+    }
7466+    // END android-added
7467 }
7468diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEStreamCipher.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEStreamCipher.java
7469--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEStreamCipher.java	2010-01-11 21:46:14.000000000 +0000
7470+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEStreamCipher.java	2011-09-03 18:19:15.000000000 +0000
7471@@ -5,17 +5,21 @@
7472 import org.bouncycastle.crypto.DataLengthException;
7473 import org.bouncycastle.crypto.StreamBlockCipher;
7474 import org.bouncycastle.crypto.StreamCipher;
7475-import org.bouncycastle.crypto.engines.BlowfishEngine;
7476-import org.bouncycastle.crypto.engines.DESEngine;
7477-import org.bouncycastle.crypto.engines.DESedeEngine;
7478-import org.bouncycastle.crypto.engines.HC128Engine;
7479-import org.bouncycastle.crypto.engines.HC256Engine;
7480+// BEGIN android-removed
7481+// import org.bouncycastle.crypto.engines.BlowfishEngine;
7482+// import org.bouncycastle.crypto.engines.DESEngine;
7483+// import org.bouncycastle.crypto.engines.DESedeEngine;
7484+// import org.bouncycastle.crypto.engines.HC128Engine;
7485+// import org.bouncycastle.crypto.engines.HC256Engine;
7486+// END android-removed
7487 import org.bouncycastle.crypto.engines.RC4Engine;
7488-import org.bouncycastle.crypto.engines.Salsa20Engine;
7489-import org.bouncycastle.crypto.engines.SkipjackEngine;
7490-import org.bouncycastle.crypto.engines.TwofishEngine;
7491-import org.bouncycastle.crypto.engines.VMPCEngine;
7492-import org.bouncycastle.crypto.engines.VMPCKSA3Engine;
7493+// BEGIN android-removed
7494+// import org.bouncycastle.crypto.engines.Salsa20Engine;
7495+// import org.bouncycastle.crypto.engines.SkipjackEngine;
7496+// import org.bouncycastle.crypto.engines.TwofishEngine;
7497+// import org.bouncycastle.crypto.engines.VMPCEngine;
7498+// import org.bouncycastle.crypto.engines.VMPCKSA3Engine;
7499+// END android-removed
7500 import org.bouncycastle.crypto.modes.CFBBlockCipher;
7501 import org.bouncycastle.crypto.modes.OFBBlockCipher;
7502 import org.bouncycastle.crypto.params.KeyParameter;
7503@@ -27,8 +31,10 @@
7504 import javax.crypto.ShortBufferException;
7505 import javax.crypto.spec.IvParameterSpec;
7506 import javax.crypto.spec.PBEParameterSpec;
7507-import javax.crypto.spec.RC2ParameterSpec;
7508-import javax.crypto.spec.RC5ParameterSpec;
7509+// BEGIN android-removed
7510+// import javax.crypto.spec.RC2ParameterSpec;
7511+// import javax.crypto.spec.RC5ParameterSpec;
7512+// END android-removed
7513 import java.security.AlgorithmParameters;
7514 import java.security.InvalidAlgorithmParameterException;
7515 import java.security.InvalidKeyException;
7516@@ -44,8 +50,10 @@
7517     //
7518     private Class[]                 availableSpecs =
7519                                     {
7520-                                        RC2ParameterSpec.class,
7521-                                        RC5ParameterSpec.class,
7522+                                        // BEGIN android-removed
7523+                                        // RC2ParameterSpec.class,
7524+                                        // RC5ParameterSpec.class,
7525+                                        // END android-removed
7526                                         IvParameterSpec.class,
7527                                         PBEParameterSpec.class
7528                                     };
7529@@ -374,125 +382,127 @@
7530      * The ciphers that inherit from us.
7531      */
7532
7533-    /**
7534-     * DES
7535-     */
7536-    static public class DES_CFB8
7537-        extends JCEStreamCipher
7538-    {
7539-        public DES_CFB8()
7540-        {
7541-            super(new CFBBlockCipher(new DESEngine(), 8), 64);
7542-        }
7543-    }
7544-
7545-    /**
7546-     * DESede
7547-     */
7548-    static public class DESede_CFB8
7549-        extends JCEStreamCipher
7550-    {
7551-        public DESede_CFB8()
7552-        {
7553-            super(new CFBBlockCipher(new DESedeEngine(), 8), 64);
7554-        }
7555-    }
7556-
7557-    /**
7558-     * SKIPJACK
7559-     */
7560-    static public class Skipjack_CFB8
7561-        extends JCEStreamCipher
7562-    {
7563-        public Skipjack_CFB8()
7564-        {
7565-            super(new CFBBlockCipher(new SkipjackEngine(), 8), 64);
7566-        }
7567-    }
7568-
7569-    /**
7570-     * Blowfish
7571-     */
7572-    static public class Blowfish_CFB8
7573-        extends JCEStreamCipher
7574-    {
7575-        public Blowfish_CFB8()
7576-        {
7577-            super(new CFBBlockCipher(new BlowfishEngine(), 8), 64);
7578-        }
7579-    }
7580-
7581-    /**
7582-     * Twofish
7583-     */
7584-    static public class Twofish_CFB8
7585-        extends JCEStreamCipher
7586-    {
7587-        public Twofish_CFB8()
7588-        {
7589-            super(new CFBBlockCipher(new TwofishEngine(), 8), 128);
7590-        }
7591-    }
7592-
7593-    /**
7594-     * DES
7595-     */
7596-    static public class DES_OFB8
7597-        extends JCEStreamCipher
7598-    {
7599-        public DES_OFB8()
7600-        {
7601-            super(new OFBBlockCipher(new DESEngine(), 8), 64);
7602-        }
7603-    }
7604-
7605-    /**
7606-     * DESede
7607-     */
7608-    static public class DESede_OFB8
7609-        extends JCEStreamCipher
7610-    {
7611-        public DESede_OFB8()
7612-        {
7613-            super(new OFBBlockCipher(new DESedeEngine(), 8), 64);
7614-        }
7615-    }
7616-
7617-    /**
7618-     * SKIPJACK
7619-     */
7620-    static public class Skipjack_OFB8
7621-        extends JCEStreamCipher
7622-    {
7623-        public Skipjack_OFB8()
7624-        {
7625-            super(new OFBBlockCipher(new SkipjackEngine(), 8), 64);
7626-        }
7627-    }
7628-
7629-    /**
7630-     * Blowfish
7631-     */
7632-    static public class Blowfish_OFB8
7633-        extends JCEStreamCipher
7634-    {
7635-        public Blowfish_OFB8()
7636-        {
7637-            super(new OFBBlockCipher(new BlowfishEngine(), 8), 64);
7638-        }
7639-    }
7640-
7641-    /**
7642-     * Twofish
7643-     */
7644-    static public class Twofish_OFB8
7645-        extends JCEStreamCipher
7646-    {
7647-        public Twofish_OFB8()
7648-        {
7649-            super(new OFBBlockCipher(new TwofishEngine(), 8), 128);
7650-        }
7651-    }
7652+    // BEGIN android-removed
7653+    // /**
7654+    //  * DES
7655+    //  */
7656+    // static public class DES_CFB8
7657+    //     extends JCEStreamCipher
7658+    // {
7659+    //     public DES_CFB8()
7660+    //     {
7661+    //         super(new CFBBlockCipher(new DESEngine(), 8), 64);
7662+    //     }
7663+    // }
7664+    //
7665+    // /**
7666+    //  * DESede
7667+    //  */
7668+    // static public class DESede_CFB8
7669+    //     extends JCEStreamCipher
7670+    // {
7671+    //     public DESede_CFB8()
7672+    //     {
7673+    //         super(new CFBBlockCipher(new DESedeEngine(), 8), 64);
7674+    //     }
7675+    // }
7676+    //
7677+    // /**
7678+    //  * SKIPJACK
7679+    //  */
7680+    // static public class Skipjack_CFB8
7681+    //     extends JCEStreamCipher
7682+    // {
7683+    //     public Skipjack_CFB8()
7684+    //     {
7685+    //         super(new CFBBlockCipher(new SkipjackEngine(), 8), 64);
7686+    //     }
7687+    // }
7688+    //
7689+    // /**
7690+    //  * Blowfish
7691+    //  */
7692+    // static public class Blowfish_CFB8
7693+    //     extends JCEStreamCipher
7694+    // {
7695+    //     public Blowfish_CFB8()
7696+    //     {
7697+    //         super(new CFBBlockCipher(new BlowfishEngine(), 8), 64);
7698+    //     }
7699+    // }
7700+    //
7701+    // /**
7702+    //  * Twofish
7703+    //  */
7704+    // static public class Twofish_CFB8
7705+    //     extends JCEStreamCipher
7706+    // {
7707+    //     public Twofish_CFB8()
7708+    //     {
7709+    //         super(new CFBBlockCipher(new TwofishEngine(), 8), 128);
7710+    //     }
7711+    // }
7712+    //
7713+    // /**
7714+    //  * DES
7715+    //  */
7716+    // static public class DES_OFB8
7717+    //     extends JCEStreamCipher
7718+    // {
7719+    //     public DES_OFB8()
7720+    //     {
7721+    //         super(new OFBBlockCipher(new DESEngine(), 8), 64);
7722+    //     }
7723+    // }
7724+    //
7725+    // /**
7726+    //  * DESede
7727+    //  */
7728+    // static public class DESede_OFB8
7729+    //     extends JCEStreamCipher
7730+    // {
7731+    //     public DESede_OFB8()
7732+    //     {
7733+    //         super(new OFBBlockCipher(new DESedeEngine(), 8), 64);
7734+    //     }
7735+    // }
7736+    //
7737+    // /**
7738+    //  * SKIPJACK
7739+    //  */
7740+    // static public class Skipjack_OFB8
7741+    //     extends JCEStreamCipher
7742+    // {
7743+    //     public Skipjack_OFB8()
7744+    //     {
7745+    //         super(new OFBBlockCipher(new SkipjackEngine(), 8), 64);
7746+    //     }
7747+    // }
7748+    //
7749+    // /**
7750+    //  * Blowfish
7751+    //  */
7752+    // static public class Blowfish_OFB8
7753+    //     extends JCEStreamCipher
7754+    // {
7755+    //     public Blowfish_OFB8()
7756+    //     {
7757+    //         super(new OFBBlockCipher(new BlowfishEngine(), 8), 64);
7758+    //     }
7759+    // }
7760+    //
7761+    // /**
7762+    //  * Twofish
7763+    //  */
7764+    // static public class Twofish_OFB8
7765+    //     extends JCEStreamCipher
7766+    // {
7767+    //     public Twofish_OFB8()
7768+    //     {
7769+    //         super(new OFBBlockCipher(new TwofishEngine(), 8), 128);
7770+    //     }
7771+    // }
7772+    // END android-removed
7773
7774     /**
7775      * RC4
7776@@ -517,7 +527,7 @@
7777             super(new RC4Engine(), 0);
7778         }
7779     }
7780-
7781+
7782     /**
7783      * PBEWithSHAAnd40BitRC4
7784      */
7785@@ -529,64 +539,66 @@
7786             super(new RC4Engine(), 0);
7787         }
7788     }
7789-
7790-    /**
7791-     * Salsa20
7792-     */
7793-    static public class Salsa20
7794-        extends JCEStreamCipher
7795-    {
7796-        public Salsa20()
7797-        {
7798-            super(new Salsa20Engine(), 8);
7799-        }
7800-    }
7801-
7802-    /**
7803-     * HC-128
7804-     */
7805-    static public class HC128
7806-        extends JCEStreamCipher
7807-    {
7808-        public HC128()
7809-        {
7810-            super(new HC128Engine(), 16);
7811-        }
7812-    }
7813-
7814-    /**
7815-     * HC-256
7816-     */
7817-    static public class HC256
7818-        extends JCEStreamCipher
7819-    {
7820-        public HC256()
7821-        {
7822-            super(new HC256Engine(), 32);
7823-        }
7824-    }
7825-
7826-    /**
7827-     * VMPC
7828-     */
7829-    static public class VMPC
7830-        extends JCEStreamCipher
7831-    {
7832-        public VMPC()
7833-        {
7834-            super(new VMPCEngine(), 16);
7835-        }
7836-    }
7837-
7838-    /**
7839-     * VMPC-KSA3
7840-     */
7841-    static public class VMPCKSA3
7842-        extends JCEStreamCipher
7843-    {
7844-        public VMPCKSA3()
7845-        {
7846-            super(new VMPCKSA3Engine(), 16);
7847-        }
7848-    }
7849+
7850+    // BEGIN android-removed
7851+    // /**
7852+    //  * Salsa20
7853+    //  */
7854+    // static public class Salsa20
7855+    //     extends JCEStreamCipher
7856+    // {
7857+    //     public Salsa20()
7858+    //     {
7859+    //         super(new Salsa20Engine(), 8);
7860+    //     }
7861+    // }
7862+    //
7863+    // /**
7864+    //  * HC-128
7865+    //  */
7866+    // static public class HC128
7867+    //     extends JCEStreamCipher
7868+    // {
7869+    //     public HC128()
7870+    //     {
7871+    //         super(new HC128Engine(), 16);
7872+    //     }
7873+    // }
7874+    //
7875+    // /**
7876+    //  * HC-256
7877+    //  */
7878+    // static public class HC256
7879+    //     extends JCEStreamCipher
7880+    // {
7881+    //     public HC256()
7882+    //     {
7883+    //         super(new HC256Engine(), 32);
7884+    //     }
7885+    // }
7886+    //
7887+    // /**
7888+    //  * VMPC
7889+    //  */
7890+    // static public class VMPC
7891+    //     extends JCEStreamCipher
7892+    // {
7893+    //     public VMPC()
7894+    //     {
7895+    //         super(new VMPCEngine(), 16);
7896+    //     }
7897+    // }
7898+    //
7899+    // /**
7900+    //  * VMPC-KSA3
7901+    //  */
7902+    // static public class VMPCKSA3
7903+    //     extends JCEStreamCipher
7904+    // {
7905+    //     public VMPCKSA3()
7906+    //     {
7907+    //         super(new VMPCKSA3Engine(), 16);
7908+    //     }
7909+    // }
7910+    // END android-removed
7911 }
7912diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java
7913--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java	2010-01-11 21:46:14.000000000 +0000
7914+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java	2011-09-03 18:19:15.000000000 +0000
7915@@ -2,19 +2,25 @@
7916
7917 import org.bouncycastle.crypto.generators.DHParametersGenerator;
7918 import org.bouncycastle.crypto.generators.DSAParametersGenerator;
7919-import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
7920-import org.bouncycastle.crypto.generators.GOST3410ParametersGenerator;
7921+// BEGIN android-removed
7922+// import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
7923+// import org.bouncycastle.crypto.generators.GOST3410ParametersGenerator;
7924+// END android-removed
7925 import org.bouncycastle.crypto.params.DHParameters;
7926 import org.bouncycastle.crypto.params.DSAParameters;
7927-import org.bouncycastle.crypto.params.ElGamalParameters;
7928-import org.bouncycastle.crypto.params.GOST3410Parameters;
7929-import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
7930-import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
7931+// BEGIN android-removed
7932+// import org.bouncycastle.crypto.params.ElGamalParameters;
7933+// import org.bouncycastle.crypto.params.GOST3410Parameters;
7934+// import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
7935+// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
7936+// END android-removed
7937
7938 import javax.crypto.spec.DHGenParameterSpec;
7939 import javax.crypto.spec.DHParameterSpec;
7940 import javax.crypto.spec.IvParameterSpec;
7941-import javax.crypto.spec.RC2ParameterSpec;
7942+// BEGIN android-removed
7943+// import javax.crypto.spec.RC2ParameterSpec;
7944+// END android-removed
7945 import java.security.AlgorithmParameterGeneratorSpi;
7946 import java.security.AlgorithmParameters;
7947 import java.security.InvalidAlgorithmParameterException;
7948@@ -144,196 +150,198 @@
7949         }
7950     }
7951
7952-    public static class GOST3410
7953-        extends JDKAlgorithmParameterGenerator
7954-    {
7955-        protected void engineInit(
7956-                AlgorithmParameterSpec  genParamSpec,
7957-                SecureRandom            random)
7958-        throws InvalidAlgorithmParameterException
7959-        {
7960-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for GOST3410 parameter generation.");
7961-        }
7962-
7963-        protected AlgorithmParameters engineGenerateParameters()
7964-        {
7965-            GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator();
7966-
7967-            if (random != null)
7968-            {
7969-                pGen.init(strength, 2, random);
7970-            }
7971-            else
7972-            {
7973-                pGen.init(strength, 2, new SecureRandom());
7974-            }
7975-
7976-            GOST3410Parameters p = pGen.generateParameters();
7977-
7978-            AlgorithmParameters params;
7979-
7980-            try
7981-            {
7982-                params = AlgorithmParameters.getInstance("GOST3410", "BC");
7983-                params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA())));
7984-            }
7985-            catch (Exception e)
7986-            {
7987-                throw new RuntimeException(e.getMessage());
7988-            }
7989-
7990-            return params;
7991-        }
7992-    }
7993-
7994-    public static class ElGamal
7995-        extends JDKAlgorithmParameterGenerator
7996-    {
7997-        private int l = 0;
7998-
7999-        protected void engineInit(
8000-            AlgorithmParameterSpec  genParamSpec,
8001-            SecureRandom            random)
8002-            throws InvalidAlgorithmParameterException
8003-        {
8004-            if (!(genParamSpec instanceof DHGenParameterSpec))
8005-            {
8006-                throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation");
8007-            }
8008-            DHGenParameterSpec  spec = (DHGenParameterSpec)genParamSpec;
8009-
8010-            this.strength = spec.getPrimeSize();
8011-            this.l = spec.getExponentSize();
8012-            this.random = random;
8013-        }
8014-
8015-        protected AlgorithmParameters engineGenerateParameters()
8016-        {
8017-            ElGamalParametersGenerator pGen = new ElGamalParametersGenerator();
8018-
8019-            if (random != null)
8020-            {
8021-                pGen.init(strength, 20, random);
8022-            }
8023-            else
8024-            {
8025-                pGen.init(strength, 20, new SecureRandom());
8026-            }
8027-
8028-            ElGamalParameters p = pGen.generateParameters();
8029-
8030-            AlgorithmParameters params;
8031-
8032-            try
8033-            {
8034-                params = AlgorithmParameters.getInstance("ElGamal", "BC");
8035-                params.init(new DHParameterSpec(p.getP(), p.getG(), l));
8036-            }
8037-            catch (Exception e)
8038-            {
8039-                throw new RuntimeException(e.getMessage());
8040-            }
8041-
8042-            return params;
8043-        }
8044-    }
8045-
8046-    public static class DES
8047-        extends JDKAlgorithmParameterGenerator
8048-    {
8049-        protected void engineInit(
8050-            AlgorithmParameterSpec  genParamSpec,
8051-            SecureRandom            random)
8052-            throws InvalidAlgorithmParameterException
8053-        {
8054-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for DES parameter generation.");
8055-        }
8056-
8057-        protected AlgorithmParameters engineGenerateParameters()
8058-        {
8059-            byte[]  iv = new byte[8];
8060-
8061-            if (random == null)
8062-            {
8063-                random = new SecureRandom();
8064-            }
8065-
8066-            random.nextBytes(iv);
8067-
8068-            AlgorithmParameters params;
8069-
8070-            try
8071-            {
8072-                params = AlgorithmParameters.getInstance("DES", "BC");
8073-                params.init(new IvParameterSpec(iv));
8074-            }
8075-            catch (Exception e)
8076-            {
8077-                throw new RuntimeException(e.getMessage());
8078-            }
8079-
8080-            return params;
8081-        }
8082-    }
8083-
8084-    public static class RC2
8085-        extends JDKAlgorithmParameterGenerator
8086-    {
8087-        RC2ParameterSpec    spec = null;
8088-
8089-        protected void engineInit(
8090-            AlgorithmParameterSpec  genParamSpec,
8091-            SecureRandom            random)
8092-            throws InvalidAlgorithmParameterException
8093-        {
8094-            if (genParamSpec instanceof RC2ParameterSpec)
8095-            {
8096-                spec = (RC2ParameterSpec)genParamSpec;
8097-                return;
8098-            }
8099-
8100-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for RC2 parameter generation.");
8101-        }
8102-
8103-        protected AlgorithmParameters engineGenerateParameters()
8104-        {
8105-            AlgorithmParameters params;
8106-
8107-            if (spec == null)
8108-            {
8109-                byte[]  iv = new byte[8];
8110-
8111-                if (random == null)
8112-                {
8113-                    random = new SecureRandom();
8114-                }
8115-
8116-                random.nextBytes(iv);
8117-
8118-                try
8119-                {
8120-                    params = AlgorithmParameters.getInstance("RC2", "BC");
8121-                    params.init(new IvParameterSpec(iv));
8122-                }
8123-                catch (Exception e)
8124-                {
8125-                    throw new RuntimeException(e.getMessage());
8126-                }
8127-            }
8128-            else
8129-            {
8130-                try
8131-                {
8132-                    params = AlgorithmParameters.getInstance("RC2", "BC");
8133-                    params.init(spec);
8134-                }
8135-                catch (Exception e)
8136-                {
8137-                    throw new RuntimeException(e.getMessage());
8138-                }
8139-            }
8140-
8141-            return params;
8142-        }
8143-    }
8144+   // BEGIN android-removed
8145+   // public static class GOST3410
8146+   //     extends JDKAlgorithmParameterGenerator
8147+   // {
8148+   //     protected void engineInit(
8149+   //             AlgorithmParameterSpec  genParamSpec,
8150+   //             SecureRandom            random)
8151+   //     throws InvalidAlgorithmParameterException
8152+   //     {
8153+   //         throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for GOST3410 parameter generation.");
8154+   //     }
8155+   //
8156+   //     protected AlgorithmParameters engineGenerateParameters()
8157+   //     {
8158+   //         GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator();
8159+   //
8160+   //         if (random != null)
8161+   //         {
8162+   //             pGen.init(strength, 2, random);
8163+   //         }
8164+   //         else
8165+   //         {
8166+   //             pGen.init(strength, 2, new SecureRandom());
8167+   //         }
8168+   //
8169+   //         GOST3410Parameters p = pGen.generateParameters();
8170+   //
8171+   //         AlgorithmParameters params;
8172+   //
8173+   //         try
8174+   //         {
8175+   //             params = AlgorithmParameters.getInstance("GOST3410", "BC");
8176+   //             params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA())));
8177+   //         }
8178+   //         catch (Exception e)
8179+   //         {
8180+   //             throw new RuntimeException(e.getMessage());
8181+   //         }
8182+   //
8183+   //         return params;
8184+   //     }
8185+   // }
8186+   //
8187+   // public static class ElGamal
8188+   //     extends JDKAlgorithmParameterGenerator
8189+   // {
8190+   //     private int l = 0;
8191+   //
8192+   //     protected void engineInit(
8193+   //         AlgorithmParameterSpec  genParamSpec,
8194+   //         SecureRandom            random)
8195+   //         throws InvalidAlgorithmParameterException
8196+   //     {
8197+   //         if (!(genParamSpec instanceof DHGenParameterSpec))
8198+   //         {
8199+   //             throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation");
8200+   //         }
8201+   //         DHGenParameterSpec  spec = (DHGenParameterSpec)genParamSpec;
8202+   //
8203+   //         this.strength = spec.getPrimeSize();
8204+   //         this.l = spec.getExponentSize();
8205+   //         this.random = random;
8206+   //     }
8207+   //
8208+   //     protected AlgorithmParameters engineGenerateParameters()
8209+   //     {
8210+   //         ElGamalParametersGenerator pGen = new ElGamalParametersGenerator();
8211+   //
8212+   //         if (random != null)
8213+   //         {
8214+   //             pGen.init(strength, 20, random);
8215+   //         }
8216+   //         else
8217+   //         {
8218+   //             pGen.init(strength, 20, new SecureRandom());
8219+   //         }
8220+   //
8221+   //         ElGamalParameters p = pGen.generateParameters();
8222+   //
8223+   //         AlgorithmParameters params;
8224+   //
8225+   //         try
8226+   //         {
8227+   //             params = AlgorithmParameters.getInstance("ElGamal", "BC");
8228+   //             params.init(new DHParameterSpec(p.getP(), p.getG(), l));
8229+   //         }
8230+   //         catch (Exception e)
8231+   //         {
8232+   //             throw new RuntimeException(e.getMessage());
8233+   //         }
8234+   //
8235+   //         return params;
8236+   //     }
8237+   // }
8238+   //
8239+   //  public static class DES
8240+   //      extends JDKAlgorithmParameterGenerator
8241+   //  {
8242+   //      protected void engineInit(
8243+   //          AlgorithmParameterSpec  genParamSpec,
8244+   //          SecureRandom            random)
8245+   //          throws InvalidAlgorithmParameterException
8246+   //      {
8247+   //          throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for DES parameter generation.");
8248+   //      }
8249+   //
8250+   //      protected AlgorithmParameters engineGenerateParameters()
8251+   //      {
8252+   //          byte[]  iv = new byte[8];
8253+   //
8254+   //          if (random == null)
8255+   //          {
8256+   //              random = new SecureRandom();
8257+   //          }
8258+   //
8259+   //          random.nextBytes(iv);
8260+   //
8261+   //          AlgorithmParameters params;
8262+   //
8263+   //          try
8264+   //          {
8265+   //              params = AlgorithmParameters.getInstance("DES", "BC");
8266+   //              params.init(new IvParameterSpec(iv));
8267+   //          }
8268+   //          catch (Exception e)
8269+   //          {
8270+   //              throw new RuntimeException(e.getMessage());
8271+   //          }
8272+   //
8273+   //          return params;
8274+   //      }
8275+   //  }
8276+   //
8277+   //  public static class RC2
8278+   //      extends JDKAlgorithmParameterGenerator
8279+   //  {
8280+   //      RC2ParameterSpec    spec = null;
8281+   //
8282+   //      protected void engineInit(
8283+   //          AlgorithmParameterSpec  genParamSpec,
8284+   //          SecureRandom            random)
8285+   //          throws InvalidAlgorithmParameterException
8286+   //      {
8287+   //          if (genParamSpec instanceof RC2ParameterSpec)
8288+   //          {
8289+   //              spec = (RC2ParameterSpec)genParamSpec;
8290+   //              return;
8291+   //          }
8292+   //
8293+   //          throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for RC2 parameter generation.");
8294+   //      }
8295+   //
8296+   //      protected AlgorithmParameters engineGenerateParameters()
8297+   //      {
8298+   //          AlgorithmParameters params;
8299+   //
8300+   //          if (spec == null)
8301+   //          {
8302+   //              byte[]  iv = new byte[8];
8303+   //
8304+   //              if (random == null)
8305+   //              {
8306+   //                  random = new SecureRandom();
8307+   //              }
8308+   //
8309+   //              random.nextBytes(iv);
8310+   //
8311+   //              try
8312+   //              {
8313+   //                  params = AlgorithmParameters.getInstance("RC2", "BC");
8314+   //                  params.init(new IvParameterSpec(iv));
8315+   //              }
8316+   //              catch (Exception e)
8317+   //              {
8318+   //                  throw new RuntimeException(e.getMessage());
8319+   //              }
8320+   //          }
8321+   //          else
8322+   //          {
8323+   //              try
8324+   //              {
8325+   //                  params = AlgorithmParameters.getInstance("RC2", "BC");
8326+   //                  params.init(spec);
8327+   //              }
8328+   //              catch (Exception e)
8329+   //              {
8330+   //                  throw new RuntimeException(e.getMessage());
8331+   //              }
8332+   //          }
8333+   //
8334+   //          return params;
8335+   //      }
8336+   //  }
8337+   // END android-removed
8338 }
8339diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java
8340--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java	2010-01-11 21:46:14.000000000 +0000
8341+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java	2011-09-03 18:19:15.000000000 +0000
8342@@ -10,21 +10,27 @@
8343 import org.bouncycastle.asn1.DERObjectIdentifier;
8344 import org.bouncycastle.asn1.DEROctetString;
8345 import org.bouncycastle.asn1.DERSequence;
8346-import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters;
8347-import org.bouncycastle.asn1.oiw.ElGamalParameter;
8348+// BEGIN android-removed
8349+// import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters;
8350+// import org.bouncycastle.asn1.oiw.ElGamalParameter;
8351+// END android-removed
8352 import org.bouncycastle.asn1.pkcs.DHParameter;
8353 import org.bouncycastle.asn1.pkcs.PKCS12PBEParams;
8354 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
8355-import org.bouncycastle.asn1.pkcs.RC2CBCParameter;
8356+// BEGIN android-removed
8357+// import org.bouncycastle.asn1.pkcs.RC2CBCParameter;
8358+// END android-removed
8359 import org.bouncycastle.asn1.pkcs.RSAESOAEPparams;
8360 import org.bouncycastle.asn1.pkcs.RSASSAPSSparams;
8361 import org.bouncycastle.asn1.pkcs.PBKDF2Params;
8362 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
8363 import org.bouncycastle.asn1.x509.DSAParameter;
8364-import org.bouncycastle.jce.spec.ElGamalParameterSpec;
8365-import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
8366-import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
8367-import org.bouncycastle.jce.spec.IESParameterSpec;
8368+// BEGIN android-removed
8369+// import org.bouncycastle.jce.spec.ElGamalParameterSpec;
8370+// import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
8371+// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
8372+// import org.bouncycastle.jce.spec.IESParameterSpec;
8373+// END android-removed
8374 import org.bouncycastle.util.Arrays;
8375
8376 import javax.crypto.spec.DHParameterSpec;
8377@@ -32,7 +38,9 @@
8378 import javax.crypto.spec.OAEPParameterSpec;
8379 import javax.crypto.spec.PBEParameterSpec;
8380 import javax.crypto.spec.PSource;
8381-import javax.crypto.spec.RC2ParameterSpec;
8382+// BEGIN android-removed
8383+// import javax.crypto.spec.RC2ParameterSpec;
8384+// END android-removed
8385 import java.io.IOException;
8386 import java.security.AlgorithmParametersSpi;
8387 import java.security.spec.AlgorithmParameterSpec;
8388@@ -68,13 +76,13 @@
8389         extends JDKAlgorithmParameters
8390     {
8391         private byte[]  iv;
8392-
8393+
8394         protected byte[] engineGetEncoded()
8395             throws IOException
8396         {
8397             return engineGetEncoded("ASN.1");
8398         }
8399-
8400+
8401         protected byte[] engineGetEncoded(
8402             String format)
8403             throws IOException
8404@@ -83,15 +91,15 @@
8405             {
8406                  return new DEROctetString(engineGetEncoded("RAW")).getEncoded();
8407             }
8408-
8409+
8410             if (format.equals("RAW"))
8411             {
8412                 return Arrays.clone(iv);
8413             }
8414-
8415+
8416             return null;
8417         }
8418-
8419+
8420         protected AlgorithmParameterSpec localEngineGetParameterSpec(
8421             Class paramSpec)
8422             throws InvalidParameterSpecException
8423@@ -100,10 +108,10 @@
8424             {
8425                 return new IvParameterSpec(iv);
8426             }
8427-
8428+
8429             throw new InvalidParameterSpecException("unknown parameter spec passed to IV parameters object.");
8430         }
8431-
8432+
8433         protected void engineInit(
8434             AlgorithmParameterSpec paramSpec)
8435             throws InvalidParameterSpecException
8436@@ -112,10 +120,10 @@
8437             {
8438                 throw new InvalidParameterSpecException("IvParameterSpec required to initialise a IV parameters algorithm parameters object");
8439             }
8440-
8441+
8442             this.iv = ((IvParameterSpec)paramSpec).getIV();
8443         }
8444-
8445+
8446         protected void engineInit(
8447             byte[] params)
8448             throws IOException
8449@@ -127,13 +135,13 @@
8450                     && params[0] == 0x04 && params[1] == params.length - 2)
8451             {
8452                 ASN1OctetString oct = (ASN1OctetString)ASN1Object.fromByteArray(params);
8453-
8454+
8455                 params = oct.getOctets();
8456             }
8457-
8458+
8459             this.iv = Arrays.clone(params);
8460         }
8461-
8462+
8463         protected void engineInit(
8464             byte[] params,
8465             String format)
8466@@ -144,204 +152,206 @@
8467                 try
8468                 {
8469                     ASN1OctetString oct = (ASN1OctetString)ASN1Object.fromByteArray(params);
8470-
8471+
8472                     engineInit(oct.getOctets());
8473                 }
8474                 catch (Exception e)
8475                 {
8476                     throw new IOException("Exception decoding: " + e);
8477                 }
8478-
8479+
8480                 return;
8481             }
8482-
8483+
8484             if (format.equals("RAW"))
8485             {
8486                 engineInit(params);
8487                 return;
8488             }
8489-
8490+
8491             throw new IOException("Unknown parameters format in IV parameters object");
8492         }
8493-
8494+
8495         protected String engineToString()
8496         {
8497             return "IV Parameters";
8498         }
8499     }
8500-
8501-    public static class RC2AlgorithmParameters
8502-        extends JDKAlgorithmParameters
8503-    {
8504-        private static final short[] table = {
8505-           0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
8506-           0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
8507-           0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
8508-           0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
8509-           0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
8510-           0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
8511-           0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
8512-           0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
8513-           0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
8514-           0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
8515-           0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
8516-           0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
8517-           0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
8518-           0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
8519-           0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
8520-           0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab
8521-        };
8522-
8523-        private static final short[] ekb = {
8524-           0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d, 0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5,
8525-           0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47, 0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5,
8526-           0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c, 0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef,
8527-           0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89, 0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d,
8528-           0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8, 0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb,
8529-           0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab, 0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d,
8530-           0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46, 0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3,
8531-           0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87, 0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61,
8532-           0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6, 0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1,
8533-           0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7, 0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21,
8534-           0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0, 0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42,
8535-           0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a, 0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f,
8536-           0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5, 0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7,
8537-           0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90, 0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15,
8538-           0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b, 0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7,
8539-           0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18, 0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd
8540-        };
8541-
8542-        private byte[]  iv;
8543-        private int     parameterVersion = 58;
8544-
8545-        protected byte[] engineGetEncoded()
8546-        {
8547-            return Arrays.clone(iv);
8548-        }
8549-
8550-        protected byte[] engineGetEncoded(
8551-            String format)
8552-            throws IOException
8553-        {
8554-            if (isASN1FormatString(format))
8555-            {
8556-                if (parameterVersion == -1)
8557-                {
8558-                    return new RC2CBCParameter(engineGetEncoded()).getEncoded();
8559-                }
8560-                else
8561-                {
8562-                    return new RC2CBCParameter(parameterVersion, engineGetEncoded()).getEncoded();
8563-                }
8564-            }
8565-
8566-            if (format.equals("RAW"))
8567-            {
8568-                return engineGetEncoded();
8569-            }
8570-
8571-            return null;
8572-        }
8573-
8574-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
8575-            Class paramSpec)
8576-            throws InvalidParameterSpecException
8577-        {
8578-            if (paramSpec == RC2ParameterSpec.class)
8579-            {
8580-                if (parameterVersion != -1)
8581-                {
8582-                    if (parameterVersion < 256)
8583-                    {
8584-                        return new RC2ParameterSpec(ekb[parameterVersion], iv);
8585-                    }
8586-                    else
8587-                    {
8588-                        return new RC2ParameterSpec(parameterVersion, iv);
8589-                    }
8590-                }
8591-            }
8592-
8593-            if (paramSpec == IvParameterSpec.class)
8594-            {
8595-                return new IvParameterSpec(iv);
8596-            }
8597-
8598-            throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
8599-        }
8600-
8601-        protected void engineInit(
8602-            AlgorithmParameterSpec paramSpec)
8603-            throws InvalidParameterSpecException
8604-        {
8605-            if (paramSpec instanceof IvParameterSpec)
8606-            {
8607-                this.iv = ((IvParameterSpec)paramSpec).getIV();
8608-            }
8609-            else if (paramSpec instanceof RC2ParameterSpec)
8610-            {
8611-                int effKeyBits = ((RC2ParameterSpec)paramSpec).getEffectiveKeyBits();
8612-                if (effKeyBits != -1)
8613-                {
8614-                    if (effKeyBits < 256)
8615-                    {
8616-                        parameterVersion = table[effKeyBits];
8617-                    }
8618-                    else
8619-                    {
8620-                        parameterVersion = effKeyBits;
8621-                    }
8622-                }
8623-
8624-                this.iv = ((RC2ParameterSpec)paramSpec).getIV();
8625-            }
8626-            else
8627-            {
8628-                throw new InvalidParameterSpecException("IvParameterSpec or RC2ParameterSpec required to initialise a RC2 parameters algorithm parameters object");
8629-            }
8630-        }
8631-
8632-        protected void engineInit(
8633-            byte[] params)
8634-            throws IOException
8635-        {
8636-            this.iv = Arrays.clone(params);
8637-        }
8638-
8639-        protected void engineInit(
8640-            byte[] params,
8641-            String format)
8642-            throws IOException
8643-        {
8644-            if (isASN1FormatString(format))
8645-            {
8646-                RC2CBCParameter p = RC2CBCParameter.getInstance(ASN1Object.fromByteArray(params));
8647-
8648-                if (p.getRC2ParameterVersion() != null)
8649-                {
8650-                    parameterVersion = p.getRC2ParameterVersion().intValue();
8651-                }
8652-
8653-                iv = p.getIV();
8654-
8655-                return;
8656-            }
8657-
8658-            if (format.equals("RAW"))
8659-            {
8660-                engineInit(params);
8661-                return;
8662-            }
8663-
8664-            throw new IOException("Unknown parameters format in IV parameters object");
8665-        }
8666-
8667-        protected String engineToString()
8668-        {
8669-            return "RC2 Parameters";
8670-        }
8671-    }
8672-
8673+
8674+    // BEGIN android-removed
8675+    // public static class RC2AlgorithmParameters
8676+    //     extends JDKAlgorithmParameters
8677+    // {
8678+    //     private static final short[] table = {
8679+    //        0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0,
8680+    //        0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a,
8681+    //        0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36,
8682+    //        0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c,
8683+    //        0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60,
8684+    //        0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa,
8685+    //        0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e,
8686+    //        0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf,
8687+    //        0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6,
8688+    //        0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3,
8689+    //        0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c,
8690+    //        0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2,
8691+    //        0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5,
8692+    //        0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5,
8693+    //        0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f,
8694+    //        0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab
8695+    //     };
8696+    //
8697+    //     private static final short[] ekb = {
8698+    //        0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d, 0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5,
8699+    //        0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47, 0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5,
8700+    //        0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c, 0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef,
8701+    //        0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89, 0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d,
8702+    //        0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8, 0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb,
8703+    //        0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab, 0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d,
8704+    //        0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46, 0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3,
8705+    //        0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87, 0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61,
8706+    //        0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6, 0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1,
8707+    //        0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7, 0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21,
8708+    //        0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0, 0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42,
8709+    //        0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a, 0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f,
8710+    //        0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5, 0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7,
8711+    //        0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90, 0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15,
8712+    //        0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b, 0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7,
8713+    //        0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18, 0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd
8714+    //     };
8715+    //
8716+    //     private byte[]  iv;
8717+    //     private int     parameterVersion = 58;
8718+    //
8719+    //     protected byte[] engineGetEncoded()
8720+    //     {
8721+    //         return Arrays.clone(iv);
8722+    //     }
8723+    //
8724+    //     protected byte[] engineGetEncoded(
8725+    //         String format)
8726+    //         throws IOException
8727+    //     {
8728+    //         if (isASN1FormatString(format))
8729+    //         {
8730+    //             if (parameterVersion == -1)
8731+    //             {
8732+    //                 return new RC2CBCParameter(engineGetEncoded()).getEncoded();
8733+    //             }
8734+    //             else
8735+    //             {
8736+    //                 return new RC2CBCParameter(parameterVersion, engineGetEncoded()).getEncoded();
8737+    //             }
8738+    //         }
8739+    //
8740+    //         if (format.equals("RAW"))
8741+    //         {
8742+    //             return engineGetEncoded();
8743+    //         }
8744+    //
8745+    //         return null;
8746+    //     }
8747+    //
8748+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
8749+    //         Class paramSpec)
8750+    //         throws InvalidParameterSpecException
8751+    //     {
8752+    //         if (paramSpec == RC2ParameterSpec.class)
8753+    //         {
8754+    //             if (parameterVersion != -1)
8755+    //             {
8756+    //                 if (parameterVersion < 256)
8757+    //                 {
8758+    //                     return new RC2ParameterSpec(ekb[parameterVersion], iv);
8759+    //                 }
8760+    //                 else
8761+    //                 {
8762+    //                     return new RC2ParameterSpec(parameterVersion, iv);
8763+    //                 }
8764+    //             }
8765+    //         }
8766+    //
8767+    //         if (paramSpec == IvParameterSpec.class)
8768+    //         {
8769+    //             return new IvParameterSpec(iv);
8770+    //         }
8771+    //
8772+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object.");
8773+    //     }
8774+    //
8775+    //     protected void engineInit(
8776+    //         AlgorithmParameterSpec paramSpec)
8777+    //         throws InvalidParameterSpecException
8778+    //     {
8779+    //         if (paramSpec instanceof IvParameterSpec)
8780+    //         {
8781+    //             this.iv = ((IvParameterSpec)paramSpec).getIV();
8782+    //         }
8783+    //         else if (paramSpec instanceof RC2ParameterSpec)
8784+    //         {
8785+    //             int effKeyBits = ((RC2ParameterSpec)paramSpec).getEffectiveKeyBits();
8786+    //             if (effKeyBits != -1)
8787+    //             {
8788+    //                 if (effKeyBits < 256)
8789+    //                 {
8790+    //                     parameterVersion = table[effKeyBits];
8791+    //                 }
8792+    //                 else
8793+    //                 {
8794+    //                     parameterVersion = effKeyBits;
8795+    //                 }
8796+    //             }
8797+    //
8798+    //             this.iv = ((RC2ParameterSpec)paramSpec).getIV();
8799+    //         }
8800+    //         else
8801+    //         {
8802+    //             throw new InvalidParameterSpecException("IvParameterSpec or RC2ParameterSpec required to initialise a RC2 parameters algorithm parameters object");
8803+    //         }
8804+    //     }
8805+    //
8806+    //     protected void engineInit(
8807+    //         byte[] params)
8808+    //         throws IOException
8809+    //     {
8810+    //         this.iv = Arrays.clone(params);
8811+    //     }
8812+    //
8813+    //     protected void engineInit(
8814+    //         byte[] params,
8815+    //         String format)
8816+    //         throws IOException
8817+    //     {
8818+    //         if (isASN1FormatString(format))
8819+    //         {
8820+    //             RC2CBCParameter p = RC2CBCParameter.getInstance(ASN1Object.fromByteArray(params));
8821+    //
8822+    //             if (p.getRC2ParameterVersion() != null)
8823+    //             {
8824+    //                 parameterVersion = p.getRC2ParameterVersion().intValue();
8825+    //             }
8826+    //
8827+    //             iv = p.getIV();
8828+    //
8829+    //             return;
8830+    //         }
8831+    //
8832+    //         if (format.equals("RAW"))
8833+    //         {
8834+    //             engineInit(params);
8835+    //             return;
8836+    //         }
8837+    //
8838+    //         throw new IOException("Unknown parameters format in IV parameters object");
8839+    //     }
8840+    //
8841+    //     protected String engineToString()
8842+    //     {
8843+    //         return "RC2 Parameters";
8844+    //     }
8845+    // }
8846+    // END android-removed
8847+
8848     public static class PBKDF2
8849         extends JDKAlgorithmParameters
8850     {
8851@@ -429,7 +439,7 @@
8852         extends JDKAlgorithmParameters
8853     {
8854         PKCS12PBEParams params;
8855-
8856+
8857         protected byte[] engineGetEncoded()
8858         {
8859             try
8860@@ -441,7 +451,7 @@
8861                 throw new RuntimeException("Oooops! " + e.toString());
8862             }
8863         }
8864-
8865+
8866         protected byte[] engineGetEncoded(
8867             String format)
8868         {
8869@@ -449,10 +459,10 @@
8870             {
8871                 return engineGetEncoded();
8872             }
8873-
8874+
8875             return null;
8876         }
8877-
8878+
8879         protected AlgorithmParameterSpec localEngineGetParameterSpec(
8880             Class paramSpec)
8881             throws InvalidParameterSpecException
8882@@ -462,10 +472,10 @@
8883                 return new PBEParameterSpec(params.getIV(),
8884                                 params.getIterations().intValue());
8885             }
8886-
8887+
8888             throw new InvalidParameterSpecException("unknown parameter spec passed to PKCS12 PBE parameters object.");
8889         }
8890-
8891+
8892         protected void engineInit(
8893             AlgorithmParameterSpec paramSpec)
8894             throws InvalidParameterSpecException
8895@@ -474,20 +484,20 @@
8896             {
8897                 throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PKCS12 PBE parameters algorithm parameters object");
8898             }
8899-
8900+
8901             PBEParameterSpec    pbeSpec = (PBEParameterSpec)paramSpec;
8902-
8903+
8904             this.params = new PKCS12PBEParams(pbeSpec.getSalt(),
8905                                 pbeSpec.getIterationCount());
8906         }
8907-
8908+
8909         protected void engineInit(
8910             byte[] params)
8911             throws IOException
8912         {
8913             this.params = PKCS12PBEParams.getInstance(ASN1Object.fromByteArray(params));
8914         }
8915-
8916+
8917         protected void engineInit(
8918             byte[] params,
8919             String format)
8920@@ -498,10 +508,10 @@
8921                 engineInit(params);
8922                 return;
8923             }
8924-
8925+
8926             throw new IOException("Unknown parameters format in PKCS12 PBE parameters object");
8927         }
8928-
8929+
8930         protected String engineToString()
8931         {
8932             return "PKCS12 PBE Parameters";
8933@@ -725,334 +735,336 @@
8934         }
8935     }
8936
8937-    public static class GOST3410
8938-        extends JDKAlgorithmParameters
8939-    {
8940-        GOST3410ParameterSpec     currentSpec;
8941-
8942-        /**
8943-         * Return the X.509 ASN.1 structure GOST3410Parameter.
8944-         * <p>
8945-         * <pre>
8946-         *  GOST3410Parameter ::= SEQUENCE {
8947-         *                   prime INTEGER, -- p
8948-         *                   subprime INTEGER, -- q
8949-         *                   base INTEGER, -- a}
8950-         * </pre>
8951-         */
8952-        protected byte[] engineGetEncoded()
8953-        {
8954-            GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID()));
8955-
8956-            try
8957-            {
8958-                return gost3410P.getEncoded(ASN1Encodable.DER);
8959-            }
8960-            catch (IOException e)
8961-            {
8962-                throw new RuntimeException("Error encoding GOST3410Parameters");
8963-            }
8964-        }
8965-
8966-        protected byte[] engineGetEncoded(
8967-                String format)
8968-        {
8969-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
8970-            {
8971-                return engineGetEncoded();
8972-            }
8973-
8974-            return null;
8975-        }
8976-
8977-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
8978-                Class paramSpec)
8979-        throws InvalidParameterSpecException
8980-        {
8981-            if (paramSpec == GOST3410PublicKeyParameterSetSpec.class)
8982-            {
8983-                return currentSpec;
8984-            }
8985-
8986-            throw new InvalidParameterSpecException("unknown parameter spec passed to GOST3410 parameters object.");
8987-        }
8988-
8989-        protected void engineInit(
8990-                AlgorithmParameterSpec paramSpec)
8991-        throws InvalidParameterSpecException
8992-        {
8993-            if (!(paramSpec instanceof GOST3410ParameterSpec))
8994-            {
8995-                throw new InvalidParameterSpecException("GOST3410ParameterSpec required to initialise a GOST3410 algorithm parameters object");
8996-            }
8997-
8998-            this.currentSpec = (GOST3410ParameterSpec)paramSpec;
8999-        }
9000-
9001-        protected void engineInit(
9002-                byte[] params)
9003-        throws IOException
9004-        {
9005-            try
9006-            {
9007-                ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params);
9008-
9009-                this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg(
9010-                    new GOST3410PublicKeyAlgParameters(seq));
9011-            }
9012-            catch (ClassCastException e)
9013-            {
9014-                throw new IOException("Not a valid GOST3410 Parameter encoding.");
9015-            }
9016-            catch (ArrayIndexOutOfBoundsException e)
9017-            {
9018-                throw new IOException("Not a valid GOST3410 Parameter encoding.");
9019-            }
9020-        }
9021-
9022-        protected void engineInit(
9023-                byte[] params,
9024-                String format)
9025-        throws IOException
9026-        {
9027-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9028-            {
9029-                engineInit(params);
9030-            }
9031-            else
9032-            {
9033-                throw new IOException("Unknown parameter format " + format);
9034-            }
9035-        }
9036-
9037-        protected String engineToString()
9038-        {
9039-            return "GOST3410 Parameters";
9040-        }
9041-    }
9042-
9043-    public static class ElGamal
9044-        extends JDKAlgorithmParameters
9045-    {
9046-        ElGamalParameterSpec     currentSpec;
9047-
9048-        /**
9049-         * Return the X.509 ASN.1 structure ElGamalParameter.
9050-         * <p>
9051-         * <pre>
9052-         *  ElGamalParameter ::= SEQUENCE {
9053-         *                   prime INTEGER, -- p
9054-         *                   base INTEGER, -- g}
9055-         * </pre>
9056-         */
9057-        protected byte[] engineGetEncoded()
9058-        {
9059-            ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG());
9060-
9061-            try
9062-            {
9063-                return elP.getEncoded(ASN1Encodable.DER);
9064-            }
9065-            catch (IOException e)
9066-            {
9067-                throw new RuntimeException("Error encoding ElGamalParameters");
9068-            }
9069-        }
9070-
9071-        protected byte[] engineGetEncoded(
9072-            String format)
9073-        {
9074-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9075-            {
9076-                return engineGetEncoded();
9077-            }
9078-
9079-            return null;
9080-        }
9081-
9082-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
9083-            Class paramSpec)
9084-            throws InvalidParameterSpecException
9085-        {
9086-            if (paramSpec == ElGamalParameterSpec.class)
9087-            {
9088-                return currentSpec;
9089-            }
9090-            else if (paramSpec == DHParameterSpec.class)
9091-            {
9092-                return new DHParameterSpec(currentSpec.getP(), currentSpec.getG());
9093-            }
9094-
9095-            throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
9096-        }
9097-
9098-        protected void engineInit(
9099-            AlgorithmParameterSpec paramSpec)
9100-            throws InvalidParameterSpecException
9101-        {
9102-            if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec))
9103-            {
9104-                throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
9105-            }
9106-
9107-            if (paramSpec instanceof ElGamalParameterSpec)
9108-            {
9109-                this.currentSpec = (ElGamalParameterSpec)paramSpec;
9110-            }
9111-            else
9112-            {
9113-                DHParameterSpec s = (DHParameterSpec)paramSpec;
9114-
9115-                this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
9116-            }
9117-        }
9118-
9119-        protected void engineInit(
9120-            byte[] params)
9121-            throws IOException
9122-        {
9123-            try
9124-            {
9125-                ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params));
9126-
9127-                currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
9128-            }
9129-            catch (ClassCastException e)
9130-            {
9131-                throw new IOException("Not a valid ElGamal Parameter encoding.");
9132-            }
9133-            catch (ArrayIndexOutOfBoundsException e)
9134-            {
9135-                throw new IOException("Not a valid ElGamal Parameter encoding.");
9136-            }
9137-        }
9138-
9139-        protected void engineInit(
9140-            byte[] params,
9141-            String format)
9142-            throws IOException
9143-        {
9144-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9145-            {
9146-                engineInit(params);
9147-            }
9148-            else
9149-            {
9150-                throw new IOException("Unknown parameter format " + format);
9151-            }
9152-        }
9153-
9154-        protected String engineToString()
9155-        {
9156-            return "ElGamal Parameters";
9157-        }
9158-    }
9159-
9160-    public static class IES
9161-        extends JDKAlgorithmParameters
9162-    {
9163-        IESParameterSpec     currentSpec;
9164-
9165-        /**
9166-         * in the absence of a standard way of doing it this will do for
9167-         * now...
9168-         */
9169-        protected byte[] engineGetEncoded()
9170-        {
9171-            try
9172-            {
9173-                ASN1EncodableVector v = new ASN1EncodableVector();
9174-
9175-                v.add(new DEROctetString(currentSpec.getDerivationV()));
9176-                v.add(new DEROctetString(currentSpec.getEncodingV()));
9177-                v.add(new DERInteger(currentSpec.getMacKeySize()));
9178-
9179-                return new DERSequence(v).getEncoded(ASN1Encodable.DER);
9180-            }
9181-            catch (IOException e)
9182-            {
9183-                throw new RuntimeException("Error encoding IESParameters");
9184-            }
9185-        }
9186-
9187-        protected byte[] engineGetEncoded(
9188-            String format)
9189-        {
9190-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9191-            {
9192-                return engineGetEncoded();
9193-            }
9194-
9195-            return null;
9196-        }
9197-
9198-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
9199-            Class paramSpec)
9200-            throws InvalidParameterSpecException
9201-        {
9202-            if (paramSpec == IESParameterSpec.class)
9203-            {
9204-                return currentSpec;
9205-            }
9206-
9207-            throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
9208-        }
9209-
9210-        protected void engineInit(
9211-            AlgorithmParameterSpec paramSpec)
9212-            throws InvalidParameterSpecException
9213-        {
9214-            if (!(paramSpec instanceof IESParameterSpec))
9215-            {
9216-                throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object");
9217-            }
9218-
9219-            this.currentSpec = (IESParameterSpec)paramSpec;
9220-        }
9221-
9222-        protected void engineInit(
9223-            byte[] params)
9224-            throws IOException
9225-        {
9226-            try
9227-            {
9228-                ASN1Sequence s = (ASN1Sequence)ASN1Object.fromByteArray(params);
9229-
9230-                this.currentSpec = new IESParameterSpec(
9231-                                        ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
9232-                                        ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
9233-                                        ((DERInteger)s.getObjectAt(0)).getValue().intValue());
9234-            }
9235-            catch (ClassCastException e)
9236-            {
9237-                throw new IOException("Not a valid IES Parameter encoding.");
9238-            }
9239-            catch (ArrayIndexOutOfBoundsException e)
9240-            {
9241-                throw new IOException("Not a valid IES Parameter encoding.");
9242-            }
9243-        }
9244-
9245-        protected void engineInit(
9246-            byte[] params,
9247-            String format)
9248-            throws IOException
9249-        {
9250-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9251-            {
9252-                engineInit(params);
9253-            }
9254-            else
9255-            {
9256-                throw new IOException("Unknown parameter format " + format);
9257-            }
9258-        }
9259-
9260-        protected String engineToString()
9261-        {
9262-            return "IES Parameters";
9263-        }
9264-    }
9265+    // BEGIN android-removed
9266+    // public static class GOST3410
9267+    //     extends JDKAlgorithmParameters
9268+    // {
9269+    //     GOST3410ParameterSpec     currentSpec;
9270+    //
9271+    //     /**
9272+    //      * Return the X.509 ASN.1 structure GOST3410Parameter.
9273+    //      * <p>
9274+    //      * <pre>
9275+    //      *  GOST3410Parameter ::= SEQUENCE {
9276+    //      *                   prime INTEGER, -- p
9277+    //      *                   subprime INTEGER, -- q
9278+    //      *                   base INTEGER, -- a}
9279+    //      * </pre>
9280+    //      */
9281+    //     protected byte[] engineGetEncoded()
9282+    //     {
9283+    //         GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID()));
9284+    //
9285+    //         try
9286+    //         {
9287+    //             return gost3410P.getEncoded(ASN1Encodable.DER);
9288+    //         }
9289+    //         catch (IOException e)
9290+    //         {
9291+    //             throw new RuntimeException("Error encoding GOST3410Parameters");
9292+    //         }
9293+    //     }
9294+    //
9295+    //     protected byte[] engineGetEncoded(
9296+    //             String format)
9297+    //     {
9298+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9299+    //         {
9300+    //             return engineGetEncoded();
9301+    //         }
9302+    //
9303+    //         return null;
9304+    //     }
9305+    //
9306+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
9307+    //             Class paramSpec)
9308+    //     throws InvalidParameterSpecException
9309+    //     {
9310+    //         if (paramSpec == GOST3410PublicKeyParameterSetSpec.class)
9311+    //         {
9312+    //             return currentSpec;
9313+    //         }
9314+    //
9315+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to GOST3410 parameters object.");
9316+    //     }
9317+    //
9318+    //     protected void engineInit(
9319+    //             AlgorithmParameterSpec paramSpec)
9320+    //     throws InvalidParameterSpecException
9321+    //     {
9322+    //         if (!(paramSpec instanceof GOST3410ParameterSpec))
9323+    //         {
9324+    //             throw new InvalidParameterSpecException("GOST3410ParameterSpec required to initialise a GOST3410 algorithm parameters object");
9325+    //         }
9326+    //
9327+    //         this.currentSpec = (GOST3410ParameterSpec)paramSpec;
9328+    //     }
9329+    //
9330+    //     protected void engineInit(
9331+    //             byte[] params)
9332+    //     throws IOException
9333+    //     {
9334+    //         try
9335+    //         {
9336+    //             ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params);
9337+    //
9338+    //             this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg(
9339+    //                 new GOST3410PublicKeyAlgParameters(seq));
9340+    //         }
9341+    //         catch (ClassCastException e)
9342+    //         {
9343+    //             throw new IOException("Not a valid GOST3410 Parameter encoding.");
9344+    //         }
9345+    //         catch (ArrayIndexOutOfBoundsException e)
9346+    //         {
9347+    //             throw new IOException("Not a valid GOST3410 Parameter encoding.");
9348+    //         }
9349+    //     }
9350+    //
9351+    //     protected void engineInit(
9352+    //             byte[] params,
9353+    //             String format)
9354+    //     throws IOException
9355+    //     {
9356+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9357+    //         {
9358+    //             engineInit(params);
9359+    //         }
9360+    //         else
9361+    //         {
9362+    //             throw new IOException("Unknown parameter format " + format);
9363+    //         }
9364+    //     }
9365+    //
9366+    //     protected String engineToString()
9367+    //     {
9368+    //         return "GOST3410 Parameters";
9369+    //     }
9370+    // }
9371+
9372+    // public static class ElGamal
9373+    //     extends JDKAlgorithmParameters
9374+    // {
9375+    //     ElGamalParameterSpec     currentSpec;
9376+    //
9377+    //     /**
9378+    //      * Return the X.509 ASN.1 structure ElGamalParameter.
9379+    //      * <p>
9380+    //      * <pre>
9381+    //      *  ElGamalParameter ::= SEQUENCE {
9382+    //      *                   prime INTEGER, -- p
9383+    //      *                   base INTEGER, -- g}
9384+    //      * </pre>
9385+    //      */
9386+    //     protected byte[] engineGetEncoded()
9387+    //     {
9388+    //         ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG());
9389+    //
9390+    //         try
9391+    //         {
9392+    //             return elP.getEncoded(ASN1Encodable.DER);
9393+    //         }
9394+    //         catch (IOException e)
9395+    //         {
9396+    //             throw new RuntimeException("Error encoding ElGamalParameters");
9397+    //         }
9398+    //     }
9399+    //
9400+    //     protected byte[] engineGetEncoded(
9401+    //         String format)
9402+    //     {
9403+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9404+    //         {
9405+    //             return engineGetEncoded();
9406+    //         }
9407+    //
9408+    //         return null;
9409+    //     }
9410+    //
9411+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
9412+    //         Class paramSpec)
9413+    //         throws InvalidParameterSpecException
9414+    //     {
9415+    //         if (paramSpec == ElGamalParameterSpec.class)
9416+    //         {
9417+    //             return currentSpec;
9418+    //         }
9419+    //         else if (paramSpec == DHParameterSpec.class)
9420+    //         {
9421+    //             return new DHParameterSpec(currentSpec.getP(), currentSpec.getG());
9422+    //         }
9423+    //
9424+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
9425+    //     }
9426+    //
9427+    //     protected void engineInit(
9428+    //         AlgorithmParameterSpec paramSpec)
9429+    //         throws InvalidParameterSpecException
9430+    //     {
9431+    //         if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec))
9432+    //         {
9433+    //             throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object");
9434+    //         }
9435+    //
9436+    //         if (paramSpec instanceof ElGamalParameterSpec)
9437+    //         {
9438+    //             this.currentSpec = (ElGamalParameterSpec)paramSpec;
9439+    //         }
9440+    //         else
9441+    //         {
9442+    //             DHParameterSpec s = (DHParameterSpec)paramSpec;
9443+    //
9444+    //             this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
9445+    //         }
9446+    //     }
9447+    //
9448+    //     protected void engineInit(
9449+    //         byte[] params)
9450+    //         throws IOException
9451+    //     {
9452+    //         try
9453+    //         {
9454+    //             ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params));
9455+    //
9456+    //             currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
9457+    //         }
9458+    //         catch (ClassCastException e)
9459+    //         {
9460+    //             throw new IOException("Not a valid ElGamal Parameter encoding.");
9461+    //         }
9462+    //         catch (ArrayIndexOutOfBoundsException e)
9463+    //         {
9464+    //             throw new IOException("Not a valid ElGamal Parameter encoding.");
9465+    //         }
9466+    //     }
9467+    //
9468+    //     protected void engineInit(
9469+    //         byte[] params,
9470+    //         String format)
9471+    //         throws IOException
9472+    //     {
9473+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9474+    //         {
9475+    //             engineInit(params);
9476+    //         }
9477+    //         else
9478+    //         {
9479+    //             throw new IOException("Unknown parameter format " + format);
9480+    //         }
9481+    //     }
9482+    //
9483+    //     protected String engineToString()
9484+    //     {
9485+    //         return "ElGamal Parameters";
9486+    //     }
9487+    // }
9488+    //
9489+    // public static class IES
9490+    //     extends JDKAlgorithmParameters
9491+    // {
9492+    //     IESParameterSpec     currentSpec;
9493+    //
9494+    //     /**
9495+    //      * in the absence of a standard way of doing it this will do for
9496+    //      * now...
9497+    //      */
9498+    //     protected byte[] engineGetEncoded()
9499+    //     {
9500+    //         try
9501+    //         {
9502+    //             ASN1EncodableVector v = new ASN1EncodableVector();
9503+    //
9504+    //             v.add(new DEROctetString(currentSpec.getDerivationV()));
9505+    //             v.add(new DEROctetString(currentSpec.getEncodingV()));
9506+    //             v.add(new DERInteger(currentSpec.getMacKeySize()));
9507+    //
9508+    //             return new DERSequence(v).getEncoded(ASN1Encodable.DER);
9509+    //         }
9510+    //         catch (IOException e)
9511+    //         {
9512+    //             throw new RuntimeException("Error encoding IESParameters");
9513+    //         }
9514+    //     }
9515+    //
9516+    //     protected byte[] engineGetEncoded(
9517+    //         String format)
9518+    //     {
9519+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9520+    //         {
9521+    //             return engineGetEncoded();
9522+    //         }
9523+    //
9524+    //         return null;
9525+    //     }
9526+    //
9527+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
9528+    //         Class paramSpec)
9529+    //         throws InvalidParameterSpecException
9530+    //     {
9531+    //         if (paramSpec == IESParameterSpec.class)
9532+    //         {
9533+    //             return currentSpec;
9534+    //         }
9535+    //
9536+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object.");
9537+    //     }
9538+    //
9539+    //     protected void engineInit(
9540+    //         AlgorithmParameterSpec paramSpec)
9541+    //         throws InvalidParameterSpecException
9542+    //     {
9543+    //         if (!(paramSpec instanceof IESParameterSpec))
9544+    //         {
9545+    //             throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object");
9546+    //         }
9547+    //
9548+    //         this.currentSpec = (IESParameterSpec)paramSpec;
9549+    //     }
9550+    //
9551+    //     protected void engineInit(
9552+    //         byte[] params)
9553+    //         throws IOException
9554+    //     {
9555+    //         try
9556+    //         {
9557+    //             ASN1Sequence s = (ASN1Sequence)ASN1Object.fromByteArray(params);
9558+    //
9559+    //             this.currentSpec = new IESParameterSpec(
9560+    //                                     ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
9561+    //                                     ((ASN1OctetString)s.getObjectAt(0)).getOctets(),
9562+    //                                     ((DERInteger)s.getObjectAt(0)).getValue().intValue());
9563+    //         }
9564+    //         catch (ClassCastException e)
9565+    //         {
9566+    //             throw new IOException("Not a valid IES Parameter encoding.");
9567+    //         }
9568+    //         catch (ArrayIndexOutOfBoundsException e)
9569+    //         {
9570+    //             throw new IOException("Not a valid IES Parameter encoding.");
9571+    //         }
9572+    //     }
9573+    //
9574+    //     protected void engineInit(
9575+    //         byte[] params,
9576+    //         String format)
9577+    //         throws IOException
9578+    //     {
9579+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9580+    //         {
9581+    //             engineInit(params);
9582+    //         }
9583+    //         else
9584+    //         {
9585+    //             throw new IOException("Unknown parameter format " + format);
9586+    //         }
9587+    //     }
9588+    //
9589+    //     protected String engineToString()
9590+    //     {
9591+    //         return "IES Parameters";
9592+    //     }
9593+    // }
9594+    // END android-removed
9595
9596     public static class OAEP
9597         extends JDKAlgorithmParameters
9598@@ -1066,11 +1078,15 @@
9599         {
9600             AlgorithmIdentifier     hashAlgorithm = new AlgorithmIdentifier(
9601                                                             JCEDigestUtil.getOID(currentSpec.getDigestAlgorithm()),
9602-                                                            new DERNull());
9603+                                                            // BEGIN android-changed
9604+                                                            DERNull.INSTANCE);
9605+                                                            // END android-changed
9606             MGF1ParameterSpec       mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters();
9607             AlgorithmIdentifier     maskGenAlgorithm = new AlgorithmIdentifier(
9608                                                             PKCSObjectIdentifiers.id_mgf1,
9609-                                                            new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull()));
9610+                                                            // BEGIN android-changed
9611+                                                            new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
9612+                                                            // END android-changed
9613             PSource.PSpecified      pSource = (PSource.PSpecified)currentSpec.getPSource();
9614             AlgorithmIdentifier     pSourceAlgorithm = new AlgorithmIdentifier(
9615                                                             PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue()));
9616@@ -1167,110 +1183,116 @@
9617         }
9618     }
9619
9620-    public static class PSS
9621-        extends JDKAlgorithmParameters
9622-    {
9623-        PSSParameterSpec     currentSpec;
9624-
9625-        /**
9626-         * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
9627-         */
9628-        protected byte[] engineGetEncoded()
9629-            throws IOException
9630-        {
9631-            PSSParameterSpec    pssSpec = currentSpec;
9632-            AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
9633-                                                JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()),
9634-                                                new DERNull());
9635-            MGF1ParameterSpec   mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
9636-            AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
9637-                                                PKCSObjectIdentifiers.id_mgf1,
9638-                                                new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull()));
9639-            RSASSAPSSparams     pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField()));
9640-
9641-            return pssP.getEncoded("DER");
9642-        }
9643-
9644-        protected byte[] engineGetEncoded(
9645-            String format)
9646-            throws IOException
9647-        {
9648-            if (format.equalsIgnoreCase("X.509")
9649-                    || format.equalsIgnoreCase("ASN.1"))
9650-            {
9651-                return engineGetEncoded();
9652-            }
9653-
9654-            return null;
9655-        }
9656-
9657-        protected AlgorithmParameterSpec localEngineGetParameterSpec(
9658-            Class paramSpec)
9659-            throws InvalidParameterSpecException
9660-        {
9661-            if (paramSpec == PSSParameterSpec.class && currentSpec != null)
9662-            {
9663-                return currentSpec;
9664-            }
9665-
9666-            throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
9667-        }
9668-
9669-        protected void engineInit(
9670-            AlgorithmParameterSpec paramSpec)
9671-            throws InvalidParameterSpecException
9672-        {
9673-            if (!(paramSpec instanceof PSSParameterSpec))
9674-            {
9675-                throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
9676-            }
9677-
9678-            this.currentSpec = (PSSParameterSpec)paramSpec;
9679-        }
9680-
9681-        protected void engineInit(
9682-            byte[] params)
9683-            throws IOException
9684-        {
9685-            try
9686-            {
9687-                RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params));
9688-
9689-                currentSpec = new PSSParameterSpec(
9690-                                       pssP.getHashAlgorithm().getObjectId().getId(),
9691-                                       pssP.getMaskGenAlgorithm().getObjectId().getId(),
9692-                                       new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()),
9693-                                       pssP.getSaltLength().getValue().intValue(),
9694-                                       pssP.getTrailerField().getValue().intValue());
9695-            }
9696-            catch (ClassCastException e)
9697-            {
9698-                throw new IOException("Not a valid PSS Parameter encoding.");
9699-            }
9700-            catch (ArrayIndexOutOfBoundsException e)
9701-            {
9702-                throw new IOException("Not a valid PSS Parameter encoding.");
9703-            }
9704-        }
9705-
9706-        protected void engineInit(
9707-            byte[] params,
9708-            String format)
9709-            throws IOException
9710-        {
9711-            if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9712-            {
9713-                engineInit(params);
9714-            }
9715-            else
9716-            {
9717-                throw new IOException("Unknown parameter format " + format);
9718-            }
9719-        }
9720-
9721-        protected String engineToString()
9722-        {
9723-            return "PSS Parameters";
9724-        }
9725-    }
9726+    // BEGIN android-removed
9727+    // public static class PSS
9728+    //     extends JDKAlgorithmParameters
9729+    // {
9730+    //     PSSParameterSpec     currentSpec;
9731+    //
9732+    //     /**
9733+    //      * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params.
9734+    //      */
9735+    //     protected byte[] engineGetEncoded()
9736+    //         throws IOException
9737+    //     {
9738+    //         PSSParameterSpec    pssSpec = currentSpec;
9739+    //         AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
9740+    //                                             JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()),
9741+    //                                             // BEGIN android-changed
9742+    //                                             DERNull.INSTANCE);
9743+    //                                             // END android-changed
9744+    //         MGF1ParameterSpec   mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters();
9745+    //         AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
9746+    //                                             PKCSObjectIdentifiers.id_mgf1,
9747+    //                                             // BEGIN android-changed
9748+    //                                             new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE));
9749+    //                                             // END android-changed
9750+    //         RSASSAPSSparams     pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField()));
9751+    //
9752+    //         return pssP.getEncoded("DER");
9753+    //     }
9754+    //
9755+    //     protected byte[] engineGetEncoded(
9756+    //         String format)
9757+    //         throws IOException
9758+    //     {
9759+    //         if (format.equalsIgnoreCase("X.509")
9760+    //                 || format.equalsIgnoreCase("ASN.1"))
9761+    //         {
9762+    //             return engineGetEncoded();
9763+    //         }
9764+    //
9765+    //         return null;
9766+    //     }
9767+    //
9768+    //     protected AlgorithmParameterSpec localEngineGetParameterSpec(
9769+    //         Class paramSpec)
9770+    //         throws InvalidParameterSpecException
9771+    //     {
9772+    //         if (paramSpec == PSSParameterSpec.class && currentSpec != null)
9773+    //         {
9774+    //             return currentSpec;
9775+    //         }
9776+    //
9777+    //         throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object.");
9778+    //     }
9779+    //
9780+    //     protected void engineInit(
9781+    //         AlgorithmParameterSpec paramSpec)
9782+    //         throws InvalidParameterSpecException
9783+    //     {
9784+    //         if (!(paramSpec instanceof PSSParameterSpec))
9785+    //         {
9786+    //             throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object");
9787+    //         }
9788+    //
9789+    //         this.currentSpec = (PSSParameterSpec)paramSpec;
9790+    //     }
9791+    //
9792+    //     protected void engineInit(
9793+    //         byte[] params)
9794+    //         throws IOException
9795+    //     {
9796+    //         try
9797+    //         {
9798+    //             RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params));
9799+    //
9800+    //             currentSpec = new PSSParameterSpec(
9801+    //                                    pssP.getHashAlgorithm().getObjectId().getId(),
9802+    //                                    pssP.getMaskGenAlgorithm().getObjectId().getId(),
9803+    //                                    new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()),
9804+    //                                    pssP.getSaltLength().getValue().intValue(),
9805+    //                                    pssP.getTrailerField().getValue().intValue());
9806+    //         }
9807+    //         catch (ClassCastException e)
9808+    //         {
9809+    //             throw new IOException("Not a valid PSS Parameter encoding.");
9810+    //         }
9811+    //         catch (ArrayIndexOutOfBoundsException e)
9812+    //         {
9813+    //             throw new IOException("Not a valid PSS Parameter encoding.");
9814+    //         }
9815+    //     }
9816+    //
9817+    //     protected void engineInit(
9818+    //         byte[] params,
9819+    //         String format)
9820+    //         throws IOException
9821+    //     {
9822+    //         if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509"))
9823+    //         {
9824+    //             engineInit(params);
9825+    //         }
9826+    //         else
9827+    //         {
9828+    //             throw new IOException("Unknown parameter format " + format);
9829+    //         }
9830+    //     }
9831+    //
9832+    //     protected String engineToString()
9833+    //     {
9834+    //         return "PSS Parameters";
9835+    //     }
9836+    // }
9837+    // END android-removed
9838 }
9839diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDSASigner.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDSASigner.java
9840--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDSASigner.java	2010-01-11 21:46:14.000000000 +0000
9841+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDSASigner.java	2011-09-03 18:19:15.000000000 +0000
9842@@ -22,13 +22,17 @@
9843 import org.bouncycastle.crypto.DSA;
9844 import org.bouncycastle.crypto.Digest;
9845 import org.bouncycastle.crypto.digests.SHA1Digest;
9846-import org.bouncycastle.crypto.digests.SHA224Digest;
9847+// BEGIN android-removed
9848+// import org.bouncycastle.crypto.digests.SHA224Digest;
9849+// END android-removed
9850 import org.bouncycastle.crypto.digests.SHA256Digest;
9851 import org.bouncycastle.crypto.digests.SHA384Digest;
9852 import org.bouncycastle.crypto.digests.SHA512Digest;
9853 import org.bouncycastle.crypto.params.ParametersWithRandom;
9854 import org.bouncycastle.crypto.signers.DSASigner;
9855-import org.bouncycastle.jce.interfaces.GOST3410Key;
9856+// BEGIN android-removed
9857+// import org.bouncycastle.jce.interfaces.GOST3410Key;
9858+// END android-removed
9859 import org.bouncycastle.jce.provider.util.NullDigest;
9860
9861 public class JDKDSASigner
9862@@ -53,11 +57,16 @@
9863     {
9864         CipherParameters    param;
9865
9866-        if (publicKey instanceof GOST3410Key)
9867-        {
9868-            param = GOST3410Util.generatePublicKeyParameter(publicKey);
9869-        }
9870-        else if (publicKey instanceof DSAKey)
9871+        // BEGIN android-removed
9872+        // if (publicKey instanceof GOST3410Key)
9873+        // {
9874+        //     param = GOST3410Util.generatePublicKeyParameter(publicKey);
9875+        // }
9876+        // else if (publicKey instanceof DSAKey)
9877+        // END android-removed
9878+        // BEGIN android-added
9879+        if (publicKey instanceof DSAKey)
9880+        // END android-added
9881         {
9882             param = DSAUtil.generatePublicKeyParameter(publicKey);
9883         }
9884@@ -103,14 +112,18 @@
9885     {
9886         CipherParameters    param;
9887
9888-        if (privateKey instanceof GOST3410Key)
9889-        {
9890-            param = GOST3410Util.generatePrivateKeyParameter(privateKey);
9891-        }
9892-        else
9893-        {
9894+        // BEGIN android-removed
9895+        // if (privateKey instanceof GOST3410Key)
9896+        // {
9897+        //     param = GOST3410Util.generatePrivateKeyParameter(privateKey);
9898+        // }
9899+        // else
9900+        // {
9901+        // END android-removed
9902             param = DSAUtil.generatePrivateKeyParameter(privateKey);
9903-        }
9904+        // BEGIN android-removed
9905+        // }
9906+        // END android-removed
9907
9908         if (random != null)
9909         {
9910@@ -231,42 +244,44 @@
9911             super(new SHA1Digest(), new DSASigner());
9912         }
9913     }
9914-
9915-    static public class dsa224
9916-        extends JDKDSASigner
9917-    {
9918-        public dsa224()
9919-        {
9920-            super(new SHA224Digest(), new DSASigner());
9921-        }
9922-    }
9923-
9924-    static public class dsa256
9925-        extends JDKDSASigner
9926-    {
9927-        public dsa256()
9928-        {
9929-            super(new SHA256Digest(), new DSASigner());
9930-        }
9931-    }
9932
9933-    static public class dsa384
9934-        extends JDKDSASigner
9935-    {
9936-        public dsa384()
9937-        {
9938-            super(new SHA384Digest(), new DSASigner());
9939-        }
9940-    }
9941-
9942-    static public class dsa512
9943-        extends JDKDSASigner
9944-    {
9945-        public dsa512()
9946-        {
9947-            super(new SHA512Digest(), new DSASigner());
9948-        }
9949-    }
9950+    // BEGIN android-removed
9951+    // static public class dsa224
9952+    //     extends JDKDSASigner
9953+    // {
9954+    //     public dsa224()
9955+    //     {
9956+    //         super(new SHA224Digest(), new DSASigner());
9957+    //     }
9958+    // }
9959+    //
9960+    // static public class dsa256
9961+    //     extends JDKDSASigner
9962+    // {
9963+    //     public dsa256()
9964+    //     {
9965+    //         super(new SHA256Digest(), new DSASigner());
9966+    //     }
9967+    // }
9968+    //
9969+    // static public class dsa384
9970+    //     extends JDKDSASigner
9971+    // {
9972+    //     public dsa384()
9973+    //     {
9974+    //         super(new SHA384Digest(), new DSASigner());
9975+    //     }
9976+    // }
9977+    //
9978+    // static public class dsa512
9979+    //     extends JDKDSASigner
9980+    // {
9981+    //     public dsa512()
9982+    //     {
9983+    //         super(new SHA512Digest(), new DSASigner());
9984+    //     }
9985+    // }
9986+    // END android-removed
9987
9988     static public class noneDSA
9989         extends JDKDSASigner
9990diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDigestSignature.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDigestSignature.java
9991--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDigestSignature.java	2010-01-11 21:46:14.000000000 +0000
9992+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDigestSignature.java	2011-09-03 18:19:15.000000000 +0000
9993@@ -23,14 +23,20 @@
9994 import org.bouncycastle.crypto.AsymmetricBlockCipher;
9995 import org.bouncycastle.crypto.CipherParameters;
9996 import org.bouncycastle.crypto.Digest;
9997-import org.bouncycastle.crypto.digests.MD2Digest;
9998-import org.bouncycastle.crypto.digests.MD4Digest;
9999+// BEGIN android-removed
10000+// import org.bouncycastle.crypto.digests.MD2Digest;
10001+// import org.bouncycastle.crypto.digests.MD4Digest;
10002+// END android-removed
10003 import org.bouncycastle.crypto.digests.MD5Digest;
10004-import org.bouncycastle.crypto.digests.RIPEMD128Digest;
10005-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
10006-import org.bouncycastle.crypto.digests.RIPEMD256Digest;
10007+// BEGIN android-removed
10008+// import org.bouncycastle.crypto.digests.RIPEMD128Digest;
10009+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
10010+// import org.bouncycastle.crypto.digests.RIPEMD256Digest;
10011+// END android-removed
10012 import org.bouncycastle.crypto.digests.SHA1Digest;
10013-import org.bouncycastle.crypto.digests.SHA224Digest;
10014+// BEGIN android-removed
10015+// import org.bouncycastle.crypto.digests.SHA224Digest;
10016+// END android-removed
10017 import org.bouncycastle.crypto.digests.SHA256Digest;
10018 import org.bouncycastle.crypto.digests.SHA384Digest;
10019 import org.bouncycastle.crypto.digests.SHA512Digest;
10020@@ -179,13 +185,13 @@
10021                 }
10022             }
10023         }
10024-        else if (sig.length == expected.length - 2)  // NULL left out
10025+        else if (expected.length == sig.length - 2)  // NULL left out
10026         {
10027             int sigOffset = sig.length - hash.length - 2;
10028             int expectedOffset = expected.length - hash.length - 2;
10029
10030-            expected[1] -= 2;      // adjust lengths
10031-            expected[3] -= 2;
10032+            sig[1] -= 2;      // adjust lengths
10033+            sig[3] -= 2;
10034
10035             for (int i = 0; i < hash.length; i++)
10036             {
10037@@ -195,7 +201,7 @@
10038                 }
10039             }
10040
10041-            for (int i = 0; i < sigOffset; i++)
10042+            for (int i = 0; i < expectedOffset; i++)
10043             {
10044                 if (sig[i] != expected[i])  // check header less NULL
10045                 {
10046@@ -265,14 +271,16 @@
10047         }
10048     }
10049
10050-    static public class SHA224WithRSAEncryption
10051-        extends JDKDigestSignature
10052-    {
10053-        public SHA224WithRSAEncryption()
10054-        {
10055-            super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10056-        }
10057-    }
10058+    // BEGIN android-removed
10059+    // static public class SHA224WithRSAEncryption
10060+    //     extends JDKDigestSignature
10061+    // {
10062+    //     public SHA224WithRSAEncryption()
10063+    //     {
10064+    //         super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10065+    //     }
10066+    // }
10067+    // END android-removed
10068
10069     static public class SHA256WithRSAEncryption
10070         extends JDKDigestSignature
10071@@ -301,23 +309,25 @@
10072         }
10073     }
10074
10075-    static public class MD2WithRSAEncryption
10076-        extends JDKDigestSignature
10077-    {
10078-        public MD2WithRSAEncryption()
10079-        {
10080-            super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10081-        }
10082-    }
10083-
10084-    static public class MD4WithRSAEncryption
10085-        extends JDKDigestSignature
10086-    {
10087-        public MD4WithRSAEncryption()
10088-        {
10089-            super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10090-        }
10091-    }
10092+    // BEGIN android-removed
10093+    // static public class MD2WithRSAEncryption
10094+    //     extends JDKDigestSignature
10095+    // {
10096+    //     public MD2WithRSAEncryption()
10097+    //     {
10098+    //         super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10099+    //     }
10100+    // }
10101+    //
10102+    // static public class MD4WithRSAEncryption
10103+    //     extends JDKDigestSignature
10104+    // {
10105+    //     public MD4WithRSAEncryption()
10106+    //     {
10107+    //         super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10108+    //     }
10109+    // }
10110+    // END android-removed
10111
10112     static public class MD5WithRSAEncryption
10113         extends JDKDigestSignature
10114@@ -328,39 +338,41 @@
10115         }
10116     }
10117
10118-    static public class RIPEMD160WithRSAEncryption
10119-        extends JDKDigestSignature
10120-    {
10121-        public RIPEMD160WithRSAEncryption()
10122-        {
10123-            super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10124-        }
10125-    }
10126-
10127-    static public class RIPEMD128WithRSAEncryption
10128-        extends JDKDigestSignature
10129-    {
10130-        public RIPEMD128WithRSAEncryption()
10131-        {
10132-            super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10133-        }
10134-    }
10135-
10136-    static public class RIPEMD256WithRSAEncryption
10137-        extends JDKDigestSignature
10138-    {
10139-        public RIPEMD256WithRSAEncryption()
10140-        {
10141-            super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10142-        }
10143-    }
10144-
10145-    static public class noneRSA
10146-        extends JDKDigestSignature
10147-    {
10148-        public noneRSA()
10149-        {
10150-            super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine()));
10151-        }
10152-    }
10153+    // BEGIN android-removed
10154+    // static public class RIPEMD160WithRSAEncryption
10155+    //     extends JDKDigestSignature
10156+    // {
10157+    //     public RIPEMD160WithRSAEncryption()
10158+    //     {
10159+    //         super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10160+    //     }
10161+    // }
10162+    //
10163+    // static public class RIPEMD128WithRSAEncryption
10164+    //     extends JDKDigestSignature
10165+    // {
10166+    //     public RIPEMD128WithRSAEncryption()
10167+    //     {
10168+    //         super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10169+    //     }
10170+    // }
10171+    //
10172+    // static public class RIPEMD256WithRSAEncryption
10173+    //     extends JDKDigestSignature
10174+    // {
10175+    //     public RIPEMD256WithRSAEncryption()
10176+    //     {
10177+    //         super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
10178+    //     }
10179+    // }
10180+    //
10181+    // static public class noneRSA
10182+    //     extends JDKDigestSignature
10183+    // {
10184+    //     public noneRSA()
10185+    //     {
10186+    //         super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine()));
10187+    //     }
10188+    // }
10189+    // END android-removed
10190 }
10191diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyFactory.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyFactory.java
10192--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyFactory.java	2010-01-11 21:46:14.000000000 +0000
10193+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyFactory.java	2011-09-03 18:19:15.000000000 +0000
10194@@ -36,17 +36,21 @@
10195 import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure;
10196 import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
10197 import org.bouncycastle.asn1.x9.X9ObjectIdentifiers;
10198-import org.bouncycastle.jce.interfaces.ElGamalPrivateKey;
10199-import org.bouncycastle.jce.interfaces.ElGamalPublicKey;
10200-import org.bouncycastle.jce.spec.ElGamalPrivateKeySpec;
10201-import org.bouncycastle.jce.spec.ElGamalPublicKeySpec;
10202-import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec;
10203-import org.bouncycastle.jce.spec.GOST3410PublicKeySpec;
10204+// BEGIN android-removed
10205+// import org.bouncycastle.jce.interfaces.ElGamalPrivateKey;
10206+// import org.bouncycastle.jce.interfaces.ElGamalPublicKey;
10207+// import org.bouncycastle.jce.spec.ElGamalPrivateKeySpec;
10208+// import org.bouncycastle.jce.spec.ElGamalPublicKeySpec;
10209+// import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec;
10210+// import org.bouncycastle.jce.spec.GOST3410PublicKeySpec;
10211+// END android-removed
10212
10213 public abstract class JDKKeyFactory
10214     extends KeyFactorySpi
10215 {
10216-    protected boolean elGamalFactory = false;
10217+    // BEGIN android-removed
10218+    // protected boolean elGamalFactory = false;
10219+    // END android-removed
10220
10221     public JDKKeyFactory()
10222     {
10223@@ -162,25 +166,33 @@
10224         }
10225         else if (key instanceof DHPublicKey)
10226         {
10227-            if (elGamalFactory)
10228-            {
10229-                return new JCEElGamalPublicKey((DHPublicKey)key);
10230-            }
10231-            else
10232-            {
10233+            // BEGIN android-removed
10234+            // if (elGamalFactory)
10235+            // {
10236+            //     return new JCEElGamalPublicKey((DHPublicKey)key);
10237+            // }
10238+            // else
10239+            // {
10240+            // END android-removed
10241                 return new JCEDHPublicKey((DHPublicKey)key);
10242-            }
10243+            // BEGIN android-removed
10244+            // }
10245+            // END android-removed
10246         }
10247         else if (key instanceof DHPrivateKey)
10248         {
10249-            if (elGamalFactory)
10250-            {
10251-                return new JCEElGamalPrivateKey((DHPrivateKey)key);
10252-            }
10253-            else
10254-            {
10255+            // BEGIN android-removed
10256+            // if (elGamalFactory)
10257+            // {
10258+            //     return new JCEElGamalPrivateKey((DHPrivateKey)key);
10259+            // }
10260+            // else
10261+            // {
10262+            // END android-removed
10263                 return new JCEDHPrivateKey((DHPrivateKey)key);
10264-            }
10265+            // BEGIN android-removed
10266+            // }
10267+            // END android-removed
10268         }
10269         else if (key instanceof DSAPublicKey)
10270         {
10271@@ -190,14 +202,16 @@
10272         {
10273             return new JDKDSAPrivateKey((DSAPrivateKey)key);
10274         }
10275-        else if (key instanceof ElGamalPublicKey)
10276-        {
10277-            return new JCEElGamalPublicKey((ElGamalPublicKey)key);
10278-        }
10279-        else if (key instanceof ElGamalPrivateKey)
10280-        {
10281-            return new JCEElGamalPrivateKey((ElGamalPrivateKey)key);
10282-        }
10283+        // BEGIN android-removed
10284+        // else if (key instanceof ElGamalPublicKey)
10285+        // {
10286+        //     return new JCEElGamalPublicKey((ElGamalPublicKey)key);
10287+        // }
10288+        // else if (key instanceof ElGamalPrivateKey)
10289+        // {
10290+        //    return new JCEElGamalPrivateKey((ElGamalPrivateKey)key);
10291+        // }
10292+        // END android-removed
10293
10294         throw new InvalidKeyException("key type unknown");
10295     }
10296@@ -233,10 +247,12 @@
10297         {
10298             return new JCEDHPublicKey(info);
10299         }
10300-        else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
10301-        {
10302-            return new JCEElGamalPublicKey(info);
10303-        }
10304+        // BEGIN android-removed
10305+        // else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
10306+        // {
10307+        //     return new JCEElGamalPublicKey(info);
10308+        // }
10309+        // END android-removed
10310         else if (algOid.equals(X9ObjectIdentifiers.id_dsa))
10311         {
10312             return new JDKDSAPublicKey(info);
10313@@ -245,18 +261,19 @@
10314         {
10315             return new JDKDSAPublicKey(info);
10316         }
10317-        else if (algOid.equals(X9ObjectIdentifiers.id_ecPublicKey))
10318-        {
10319-            return new JCEECPublicKey(info);
10320-        }
10321-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
10322-        {
10323-            return new JDKGOST3410PublicKey(info);
10324-        }
10325-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
10326-        {
10327-            return new JCEECPublicKey(info);
10328-        }
10329+        // BEGIN android-removed
10330+        // else if (algOid.equals(X9ObjectIdentifiers.id_ecPublicKey))
10331+        // {
10332+        //     return new JCEECPublicKey(info);
10333+        // }
10334+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
10335+        // {
10336+        //     return new JDKGOST3410PublicKey(info);
10337+        // }
10338+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
10339+        // {
10340+        //     return new JCEECPublicKey(info);
10341+        // }
10342         else
10343         {
10344             throw new RuntimeException("algorithm identifier " + algOid + " in key not recognised");
10345@@ -290,26 +307,30 @@
10346         {
10347               return new JCEDHPrivateKey(info);
10348         }
10349-        else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
10350-        {
10351-              return new JCEElGamalPrivateKey(info);
10352-        }
10353+        // BEGIN android-removed
10354+        // else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm))
10355+        // {
10356+        //       return new JCEElGamalPrivateKey(info);
10357+        // }
10358+        // END android-removed
10359         else if (algOid.equals(X9ObjectIdentifiers.id_dsa))
10360         {
10361               return new JDKDSAPrivateKey(info);
10362         }
10363-        else if (algOid.equals(X9ObjectIdentifiers.id_ecPublicKey))
10364-        {
10365-              return new JCEECPrivateKey(info);
10366-        }
10367-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
10368-        {
10369-              return new JDKGOST3410PrivateKey(info);
10370-        }
10371-        else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
10372-        {
10373-              return new JCEECPrivateKey(info);
10374-        }
10375+        // BEGIN android-removed
10376+        // else if (algOid.equals(X9ObjectIdentifiers.id_ecPublicKey))
10377+        // {
10378+        //       return new JCEECPrivateKey(info);
10379+        // }
10380+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94))
10381+        // {
10382+        //       return new JDKGOST3410PrivateKey(info);
10383+        // }
10384+        // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001))
10385+        // {
10386+        //       return new JCEECPrivateKey(info);
10387+        // }
10388+        // END android-removed
10389         else
10390         {
10391             throw new RuntimeException("algorithm identifier " + algOid + " in key not recognised");
10392@@ -440,89 +461,92 @@
10393         }
10394     }
10395
10396-    public static class GOST3410
10397-        extends JDKKeyFactory
10398-    {
10399-        public GOST3410()
10400-        {
10401-        }
10402-
10403-        protected PrivateKey engineGeneratePrivate(
10404-                KeySpec    keySpec)
10405-        throws InvalidKeySpecException
10406-        {
10407-            if (keySpec instanceof GOST3410PrivateKeySpec)
10408-            {
10409-                return new JDKGOST3410PrivateKey((GOST3410PrivateKeySpec)keySpec);
10410-            }
10411-
10412-            return super.engineGeneratePrivate(keySpec);
10413-        }
10414-
10415-        protected PublicKey engineGeneratePublic(
10416-                KeySpec    keySpec)
10417-        throws InvalidKeySpecException
10418-        {
10419-            if (keySpec instanceof GOST3410PublicKeySpec)
10420-            {
10421-                return new JDKGOST3410PublicKey((GOST3410PublicKeySpec)keySpec);
10422-            }
10423-
10424-            return super.engineGeneratePublic(keySpec);
10425-        }
10426-    }
10427-
10428-    public static class ElGamal
10429-        extends JDKKeyFactory
10430-    {
10431-        public ElGamal()
10432-        {
10433-            elGamalFactory = true;
10434-        }
10435-
10436-        protected PrivateKey engineGeneratePrivate(
10437-            KeySpec    keySpec)
10438-            throws InvalidKeySpecException
10439-        {
10440-            if (keySpec instanceof ElGamalPrivateKeySpec)
10441-            {
10442-                return new JCEElGamalPrivateKey((ElGamalPrivateKeySpec)keySpec);
10443-            }
10444-            else if (keySpec instanceof DHPrivateKeySpec)
10445-            {
10446-                return new JCEElGamalPrivateKey((DHPrivateKeySpec)keySpec);
10447-            }
10448-
10449-            return super.engineGeneratePrivate(keySpec);
10450-        }
10451+    // BEGIN android-removed
10452+    // public static class GOST3410
10453+    //     extends JDKKeyFactory
10454+    // {
10455+    //     public GOST3410()
10456+    //     {
10457+    //     }
10458+    //
10459+    //     protected PrivateKey engineGeneratePrivate(
10460+    //             KeySpec    keySpec)
10461+    //     throws InvalidKeySpecException
10462+    //     {
10463+    //         if (keySpec instanceof GOST3410PrivateKeySpec)
10464+    //         {
10465+    //             return new JDKGOST3410PrivateKey((GOST3410PrivateKeySpec)keySpec);
10466+    //         }
10467+    //
10468+    //         return super.engineGeneratePrivate(keySpec);
10469+    //     }
10470+    //
10471+    //     protected PublicKey engineGeneratePublic(
10472+    //             KeySpec    keySpec)
10473+    //     throws InvalidKeySpecException
10474+    //     {
10475+    //         if (keySpec instanceof GOST3410PublicKeySpec)
10476+    //         {
10477+    //             return new JDKGOST3410PublicKey((GOST3410PublicKeySpec)keySpec);
10478+    //         }
10479+    //
10480+    //         return super.engineGeneratePublic(keySpec);
10481+    //     }
10482+    // }
10483
10484-        protected PublicKey engineGeneratePublic(
10485-            KeySpec    keySpec)
10486-            throws InvalidKeySpecException
10487-        {
10488-            if (keySpec instanceof ElGamalPublicKeySpec)
10489-            {
10490-                return new JCEElGamalPublicKey((ElGamalPublicKeySpec)keySpec);
10491-            }
10492-            else if (keySpec instanceof DHPublicKeySpec)
10493-            {
10494-                return new JCEElGamalPublicKey((DHPublicKeySpec)keySpec);
10495-            }
10496-
10497-            return super.engineGeneratePublic(keySpec);
10498-        }
10499-    }
10500-
10501-
10502-    /**
10503-     * This isn't really correct, however the class path project API seems to think such
10504-     * a key factory will exist.
10505-     */
10506-    public static class X509
10507-        extends JDKKeyFactory
10508-    {
10509-        public X509()
10510-        {
10511-        }
10512-    }
10513+    // public static class ElGamal
10514+    //     extends JDKKeyFactory
10515+    // {
10516+    //     public ElGamal()
10517+    //     {
10518+    //         elGamalFactory = true;
10519+    //     }
10520+    //
10521+    //     protected PrivateKey engineGeneratePrivate(
10522+    //         KeySpec    keySpec)
10523+    //         throws InvalidKeySpecException
10524+    //     {
10525+    //         if (keySpec instanceof ElGamalPrivateKeySpec)
10526+    //         {
10527+    //             return new JCEElGamalPrivateKey((ElGamalPrivateKeySpec)keySpec);
10528+    //         }
10529+    //         else if (keySpec instanceof DHPrivateKeySpec)
10530+    //         {
10531+    //             return new JCEElGamalPrivateKey((DHPrivateKeySpec)keySpec);
10532+    //         }
10533+    //
10534+    //         return super.engineGeneratePrivate(keySpec);
10535+    //     }
10536+    //
10537+    //     protected PublicKey engineGeneratePublic(
10538+    //         KeySpec    keySpec)
10539+    //         throws InvalidKeySpecException
10540+    //     {
10541+    //         if (keySpec instanceof ElGamalPublicKeySpec)
10542+    //         {
10543+    //             return new JCEElGamalPublicKey((ElGamalPublicKeySpec)keySpec);
10544+    //         }
10545+    //         else if (keySpec instanceof DHPublicKeySpec)
10546+    //         {
10547+    //             return new JCEElGamalPublicKey((DHPublicKeySpec)keySpec);
10548+    //         }
10549+    //
10550+    //         return super.engineGeneratePublic(keySpec);
10551+    //     }
10552+    // }
10553+    //
10554+    //
10555+    //
10556+    // /**
10557+    //  * This isn't really correct, however the class path project API seems to think such
10558+    //  * a key factory will exist.
10559+    //  */
10560+    // public static class X509
10561+    //     extends JDKKeyFactory
10562+    // {
10563+    //     public X509()
10564+    //     {
10565+    //     }
10566+    // }
10567+    // END android-removed
10568 }
10569diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java
10570--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java	2010-01-11 21:46:14.000000000 +0000
10571+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java	2011-09-03 18:19:15.000000000 +0000
10572@@ -6,9 +6,11 @@
10573 import org.bouncycastle.crypto.generators.DHParametersGenerator;
10574 import org.bouncycastle.crypto.generators.DSAKeyPairGenerator;
10575 import org.bouncycastle.crypto.generators.DSAParametersGenerator;
10576-import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator;
10577-import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
10578-import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator;
10579+// BEGIN android-removed
10580+// import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator;
10581+// import org.bouncycastle.crypto.generators.ElGamalParametersGenerator;
10582+// import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator;
10583+// END android-removed
10584 import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
10585 import org.bouncycastle.crypto.params.DHKeyGenerationParameters;
10586 import org.bouncycastle.crypto.params.DHParameters;
10587@@ -18,20 +20,24 @@
10588 import org.bouncycastle.crypto.params.DSAParameters;
10589 import org.bouncycastle.crypto.params.DSAPrivateKeyParameters;
10590 import org.bouncycastle.crypto.params.DSAPublicKeyParameters;
10591-import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;
10592-import org.bouncycastle.crypto.params.ElGamalParameters;
10593-import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
10594-import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
10595-import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters;
10596-import org.bouncycastle.crypto.params.GOST3410Parameters;
10597-import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters;
10598-import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters;
10599+// BEGIN android-removed
10600+// import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters;
10601+// import org.bouncycastle.crypto.params.ElGamalParameters;
10602+// import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters;
10603+// import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters;
10604+// import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters;
10605+// import org.bouncycastle.crypto.params.GOST3410Parameters;
10606+// import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters;
10607+// import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters;
10608+// END android-removed
10609 import org.bouncycastle.crypto.params.RSAKeyGenerationParameters;
10610 import org.bouncycastle.crypto.params.RSAKeyParameters;
10611 import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters;
10612-import org.bouncycastle.jce.spec.ElGamalParameterSpec;
10613-import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
10614-import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
10615+// BEGIN android-removed
10616+// import org.bouncycastle.jce.spec.ElGamalParameterSpec;
10617+// import org.bouncycastle.jce.spec.GOST3410ParameterSpec;
10618+// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec;
10619+// END android-removed
10620
10621 import java.math.BigInteger;
10622 import java.security.InvalidAlgorithmParameterException;
10623@@ -163,7 +169,9 @@
10624         {
10625             if (!initialised)
10626             {
10627-                Integer paramStrength = new Integer(strength);
10628+                // BEGIN android-changed
10629+                Integer paramStrength = Integer.valueOf(strength);
10630+                // END android-changed
10631
10632                 if (params.containsKey(paramStrength))
10633                 {
10634@@ -260,139 +268,143 @@
10635         }
10636     }
10637
10638-    public static class ElGamal
10639-        extends JDKKeyPairGenerator
10640-    {
10641-        ElGamalKeyGenerationParameters  param;
10642-        ElGamalKeyPairGenerator         engine = new ElGamalKeyPairGenerator();
10643-        int                             strength = 1024;
10644-        int                             certainty = 20;
10645-        SecureRandom                    random = new SecureRandom();
10646-        boolean                         initialised = false;
10647-
10648-        public ElGamal()
10649-        {
10650-            super("ElGamal");
10651-        }
10652-
10653-        public void initialize(
10654-            int             strength,
10655-            SecureRandom    random)
10656-        {
10657-            this.strength = strength;
10658-            this.random = random;
10659-        }
10660-
10661-        public void initialize(
10662-            AlgorithmParameterSpec  params,
10663-            SecureRandom            random)
10664-            throws InvalidAlgorithmParameterException
10665-        {
10666-            if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec))
10667-            {
10668-                throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec");
10669-            }
10670-
10671-            if (params instanceof ElGamalParameterSpec)
10672-            {
10673-                ElGamalParameterSpec     elParams = (ElGamalParameterSpec)params;
10674-
10675-                param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG()));
10676-            }
10677-            else
10678-            {
10679-                DHParameterSpec     dhParams = (DHParameterSpec)params;
10680-
10681-                param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL()));
10682-            }
10683-
10684-            engine.init(param);
10685-            initialised = true;
10686-        }
10687-
10688-        public KeyPair generateKeyPair()
10689-        {
10690-            if (!initialised)
10691-            {
10692-                ElGamalParametersGenerator   pGen = new ElGamalParametersGenerator();
10693-
10694-                pGen.init(strength, certainty, random);
10695-                param = new ElGamalKeyGenerationParameters(random, pGen.generateParameters());
10696-                engine.init(param);
10697-                initialised = true;
10698-            }
10699-
10700-            AsymmetricCipherKeyPair         pair = engine.generateKeyPair();
10701-            ElGamalPublicKeyParameters      pub = (ElGamalPublicKeyParameters)pair.getPublic();
10702-            ElGamalPrivateKeyParameters     priv = (ElGamalPrivateKeyParameters)pair.getPrivate();
10703-
10704-            return new KeyPair(new JCEElGamalPublicKey(pub),
10705-                               new JCEElGamalPrivateKey(priv));
10706-        }
10707-    }
10708-
10709-    public static class GOST3410
10710-        extends JDKKeyPairGenerator
10711-    {
10712-        GOST3410KeyGenerationParameters param;
10713-        GOST3410KeyPairGenerator        engine = new GOST3410KeyPairGenerator();
10714-        GOST3410ParameterSpec           gost3410Params;
10715-        int                             strength = 1024;
10716-        SecureRandom                    random = null;
10717-        boolean                         initialised = false;
10718-
10719-        public GOST3410()
10720-        {
10721-            super("GOST3410");
10722-        }
10723-
10724-        public void initialize(
10725-            int             strength,
10726-            SecureRandom    random)
10727-        {
10728-            this.strength = strength;
10729-            this.random = random;
10730-        }
10731-
10732-        private void init(
10733-            GOST3410ParameterSpec gParams,
10734-            SecureRandom          random)
10735-        {
10736-            GOST3410PublicKeyParameterSetSpec spec = gParams.getPublicKeyParameters();
10737-
10738-            param = new GOST3410KeyGenerationParameters(random, new GOST3410Parameters(spec.getP(), spec.getQ(), spec.getA()));
10739-
10740-            engine.init(param);
10741-
10742-            initialised = true;
10743-            gost3410Params = gParams;
10744-        }
10745-
10746-        public void initialize(
10747-            AlgorithmParameterSpec  params,
10748-            SecureRandom            random)
10749-            throws InvalidAlgorithmParameterException
10750-        {
10751-            if (!(params instanceof GOST3410ParameterSpec))
10752-            {
10753-                throw new InvalidAlgorithmParameterException("parameter object not a GOST3410ParameterSpec");
10754-            }
10755-
10756-            init((GOST3410ParameterSpec)params, random);
10757-        }
10758-
10759-        public KeyPair generateKeyPair()
10760-        {
10761-            if (!initialised)
10762-            {
10763-                init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom());
10764-            }
10765-
10766-            AsymmetricCipherKeyPair   pair = engine.generateKeyPair();
10767-            GOST3410PublicKeyParameters  pub = (GOST3410PublicKeyParameters)pair.getPublic();
10768-            GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate();
10769-
10770-            return new KeyPair(new JDKGOST3410PublicKey(pub, gost3410Params), new JDKGOST3410PrivateKey(priv, gost3410Params));
10771-        }
10772-   }
10773+    // BEGIN android-removed
10774+    // public static class ElGamal
10775+    //     extends JDKKeyPairGenerator
10776+    // {
10777+    //     ElGamalKeyGenerationParameters  param;
10778+    //     ElGamalKeyPairGenerator         engine = new ElGamalKeyPairGenerator();
10779+    //     int                             strength = 1024;
10780+    //     int                             certainty = 20;
10781+    //     SecureRandom                    random = new SecureRandom();
10782+    //     boolean                         initialised = false;
10783+    //
10784+    //     public ElGamal()
10785+    //     {
10786+    //         super("ElGamal");
10787+    //     }
10788+    //
10789+    //     public void initialize(
10790+    //         int             strength,
10791+    //         SecureRandom    random)
10792+    //     {
10793+    //         this.strength = strength;
10794+    //         this.random = random;
10795+    //     }
10796+    //
10797+    //     public void initialize(
10798+    //         AlgorithmParameterSpec  params,
10799+    //         SecureRandom            random)
10800+    //         throws InvalidAlgorithmParameterException
10801+    //     {
10802+    //         if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec))
10803+    //         {
10804+    //             throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec");
10805+    //         }
10806+    //
10807+    //         if (params instanceof ElGamalParameterSpec)
10808+    //         {
10809+    //             ElGamalParameterSpec     elParams = (ElGamalParameterSpec)params;
10810+
10811+    //             param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG()));
10812+    //         }
10813+    //         else
10814+    //         {
10815+    //             DHParameterSpec     dhParams = (DHParameterSpec)params;
10816+    //
10817+    //             param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL()));
10818+    //         }
10819+    //
10820+    //         engine.init(param);
10821+    //         initialised = true;
10822+    //     }
10823+    //
10824+    //     public KeyPair generateKeyPair()
10825+    //     {
10826+    //         if (!initialised)
10827+    //         {
10828+    //             ElGamalParametersGenerator   pGen = new ElGamalParametersGenerator();
10829+    //
10830+    //             pGen.init(strength, certainty, random);
10831+    //             param = new ElGamalKeyGenerationParameters(random, pGen.generateParameters());
10832+    //             engine.init(param);
10833+    //             initialised = true;
10834+    //         }
10835+    //
10836+    //         AsymmetricCipherKeyPair         pair = engine.generateKeyPair();
10837+    //         ElGamalPublicKeyParameters      pub = (ElGamalPublicKeyParameters)pair.getPublic();
10838+    //         ElGamalPrivateKeyParameters     priv = (ElGamalPrivateKeyParameters)pair.getPrivate();
10839+    //
10840+    //         return new KeyPair(new JCEElGamalPublicKey(pub),
10841+    //                            new JCEElGamalPrivateKey(priv));
10842+    //     }
10843+    // }
10844+    // END android-removed
10845+
10846+   // BEGIN android-removed
10847+   //  public static class GOST3410
10848+   //      extends JDKKeyPairGenerator
10849+   //  {
10850+   //      GOST3410KeyGenerationParameters param;
10851+   //      GOST3410KeyPairGenerator        engine = new GOST3410KeyPairGenerator();
10852+   //      GOST3410ParameterSpec           gost3410Params;
10853+   //      int                             strength = 1024;
10854+   //      SecureRandom                    random = null;
10855+   //      boolean                         initialised = false;
10856+   //
10857+   //      public GOST3410()
10858+   //      {
10859+   //          super("GOST3410");
10860+   //      }
10861+   //
10862+   //      public void initialize(
10863+   //          int             strength,
10864+   //          SecureRandom    random)
10865+   //      {
10866+   //          this.strength = strength;
10867+   //          this.random = random;
10868+   //      }
10869+   //
10870+   //      private void init(
10871+   //          GOST3410ParameterSpec gParams,
10872+   //          SecureRandom          random)
10873+   //      {
10874+   //          GOST3410PublicKeyParameterSetSpec spec = gParams.getPublicKeyParameters();
10875+   //
10876+   //          param = new GOST3410KeyGenerationParameters(random, new GOST3410Parameters(spec.getP(), spec.getQ(), spec.getA()));
10877+   //
10878+   //          engine.init(param);
10879+   //
10880+   //          initialised = true;
10881+   //          gost3410Params = gParams;
10882+   //      }
10883+   //
10884+   //      public void initialize(
10885+   //          AlgorithmParameterSpec  params,
10886+   //          SecureRandom            random)
10887+   //          throws InvalidAlgorithmParameterException
10888+   //      {
10889+   //          if (!(params instanceof GOST3410ParameterSpec))
10890+   //          {
10891+   //              throw new InvalidAlgorithmParameterException("parameter object not a GOST3410ParameterSpec");
10892+   //          }
10893+   //
10894+   //          init((GOST3410ParameterSpec)params, random);
10895+   //      }
10896+   //
10897+   //      public KeyPair generateKeyPair()
10898+   //      {
10899+   //          if (!initialised)
10900+   //          {
10901+   //              init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom());
10902+   //          }
10903+   //
10904+   //          AsymmetricCipherKeyPair   pair = engine.generateKeyPair();
10905+   //          GOST3410PublicKeyParameters  pub = (GOST3410PublicKeyParameters)pair.getPublic();
10906+   //          GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate();
10907+   //
10908+   //          return new KeyPair(new JDKGOST3410PublicKey(pub, gost3410Params), new JDKGOST3410PrivateKey(priv, gost3410Params));
10909+   //      }
10910+   // }
10911+   // END android-removed
10912 }
10913diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyStore.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyStore.java
10914--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyStore.java	2010-01-11 21:46:14.000000000 +0000
10915+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyStore.java	2011-09-03 18:19:15.000000000 +0000
10916@@ -39,7 +39,12 @@
10917 import org.bouncycastle.crypto.CipherParameters;
10918 import org.bouncycastle.crypto.Digest;
10919 import org.bouncycastle.crypto.PBEParametersGenerator;
10920-import org.bouncycastle.crypto.digests.SHA1Digest;
10921+// BEGIN android-added
10922+import org.bouncycastle.crypto.digests.OpenSSLDigest;
10923+// END android-added
10924+// BEGIN android-removed
10925+// import org.bouncycastle.crypto.digests.SHA1Digest;
10926+// END android-removed
10927 import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
10928 import org.bouncycastle.crypto.io.DigestInputStream;
10929 import org.bouncycastle.crypto.io.DigestOutputStream;
10930@@ -442,6 +447,7 @@
10931         }
10932         catch (Exception e)
10933         {
10934+
10935             throw new IOException("Exception creating key: " + e.toString());
10936         }
10937     }
10938@@ -497,7 +503,13 @@
10939
10940         if (entry == null)
10941         {
10942-            throw new KeyStoreException("no such entry as " + alias);
10943+            // BEGIN android-removed
10944+            // Only throw if there is a problem removing, not if missing
10945+            // throw new KeyStoreException("no such entry as " + alias);
10946+            // END android-removed
10947+            // BEGIN android-added
10948+            return;
10949+            // END android-added
10950         }
10951
10952         table.remove(alias);
10953@@ -810,12 +822,16 @@
10954         //
10955         // we only do an integrity check if the password is provided.
10956         //
10957-        HMac hMac = new HMac(new SHA1Digest());
10958+        // BEGIN android-changed
10959+        HMac hMac = new HMac(new OpenSSLDigest.SHA1());
10960+        // END android-changed
10961         if (password != null && password.length != 0)
10962         {
10963             byte[] passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password);
10964
10965-            PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new SHA1Digest());
10966+            // BEGIN android-changed
10967+            PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new OpenSSLDigest.SHA1());
10968+            // END android-changed
10969             pbeGen.init(passKey, salt, iterationCount);
10970             CipherParameters macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize());
10971             Arrays.fill(passKey, (byte)0);
10972@@ -866,9 +882,11 @@
10973         dOut.write(salt);
10974         dOut.writeInt(iterationCount);
10975
10976-        HMac                    hMac = new HMac(new SHA1Digest());
10977+        // BEGIN android-changed
10978+        HMac                    hMac = new HMac(new OpenSSLDigest.SHA1());
10979         MacOutputStream         mOut = new MacOutputStream(dOut, hMac);
10980-        PBEParametersGenerator  pbeGen = new PKCS12ParametersGenerator(new SHA1Digest());
10981+        PBEParametersGenerator  pbeGen = new PKCS12ParametersGenerator(new OpenSSLDigest.SHA1());
10982+        // END android-changed
10983         byte[]                  passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password);
10984
10985         pbeGen.init(passKey, salt, iterationCount);
10986@@ -956,7 +974,9 @@
10987             Cipher cipher = this.makePBECipher(cipherAlg, Cipher.DECRYPT_MODE, password, salt, iterationCount);
10988             CipherInputStream cIn = new CipherInputStream(dIn, cipher);
10989
10990-            Digest dig = new SHA1Digest();
10991+            // BEGIN android-changed
10992+            Digest dig = new OpenSSLDigest.SHA1();
10993+            // END android-changed
10994             DigestInputStream  dgIn = new DigestInputStream(cIn, dig);
10995
10996             this.loadStore(dgIn);
10997@@ -996,8 +1016,9 @@
10998             cipher = this.makePBECipher(STORE_CIPHER, Cipher.ENCRYPT_MODE, password, salt, iterationCount);
10999
11000             CipherOutputStream  cOut = new CipherOutputStream(dOut, cipher);
11001-            DigestOutputStream  dgOut = new DigestOutputStream(cOut, new SHA1Digest());
11002-
11003+            // BEGIN android-changed
11004+            DigestOutputStream  dgOut = new DigestOutputStream(cOut, new OpenSSLDigest.SHA1());
11005+            // END android-changed
11006             this.saveStore(dgOut);
11007
11008             Digest  dig = dgOut.getDigest();
11009@@ -1009,5 +1030,5 @@
11010
11011             cOut.close();
11012         }
11013-    }
11014+    }
11015 }
11016diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKMessageDigest.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKMessageDigest.java
11017--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKMessageDigest.java	2010-01-11 21:46:14.000000000 +0000
11018+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKMessageDigest.java	2011-09-03 18:19:15.000000000 +0000
11019@@ -57,36 +57,38 @@
11020         {
11021             super(new SHA1Digest());
11022         }
11023-
11024+
11025         public Object clone()
11026             throws CloneNotSupportedException
11027         {
11028             SHA1 d = (SHA1)super.clone();
11029             d.digest = new SHA1Digest((SHA1Digest)digest);
11030-
11031-            return d;
11032-        }
11033-    }
11034-
11035-    static public class SHA224
11036-        extends JDKMessageDigest
11037-        implements Cloneable
11038-    {
11039-        public SHA224()
11040-        {
11041-            super(new SHA224Digest());
11042-        }
11043-
11044-        public Object clone()
11045-            throws CloneNotSupportedException
11046-        {
11047-            SHA224 d = (SHA224)super.clone();
11048-            d.digest = new SHA224Digest((SHA224Digest)digest);
11049-
11050+
11051             return d;
11052         }
11053     }
11054-
11055+
11056+    // BEGIN android-removed
11057+    // static public class SHA224
11058+    //     extends JDKMessageDigest
11059+    //     implements Cloneable
11060+    // {
11061+    //     public SHA224()
11062+    //     {
11063+    //         super(new SHA224Digest());
11064+    //     }
11065+    //
11066+    //     public Object clone()
11067+    //         throws CloneNotSupportedException
11068+    //     {
11069+    //         SHA224 d = (SHA224)super.clone();
11070+    //         d.digest = new SHA224Digest((SHA224Digest)digest);
11071+    //
11072+    //         return d;
11073+    //     }
11074+    // }
11075+    // END android-removed
11076+
11077     static public class SHA256
11078         extends JDKMessageDigest
11079         implements Cloneable
11080@@ -95,13 +97,13 @@
11081         {
11082             super(new SHA256Digest());
11083         }
11084-
11085+
11086         public Object clone()
11087             throws CloneNotSupportedException
11088         {
11089             SHA256 d = (SHA256)super.clone();
11090             d.digest = new SHA256Digest((SHA256Digest)digest);
11091-
11092+
11093             return d;
11094         }
11095     }
11096@@ -144,43 +146,45 @@
11097         }
11098     }
11099
11100-    static public class MD2
11101-        extends JDKMessageDigest
11102-        implements Cloneable
11103-    {
11104-        public MD2()
11105-        {
11106-            super(new MD2Digest());
11107-        }
11108-
11109-        public Object clone()
11110-            throws CloneNotSupportedException
11111-        {
11112-            MD2 d = (MD2)super.clone();
11113-            d.digest = new MD2Digest((MD2Digest)digest);
11114-
11115-            return d;
11116-        }
11117-    }
11118-
11119-    static public class MD4
11120-        extends JDKMessageDigest
11121-        implements Cloneable
11122-    {
11123-        public MD4()
11124-        {
11125-            super(new MD4Digest());
11126-        }
11127-
11128-        public Object clone()
11129-            throws CloneNotSupportedException
11130-        {
11131-            MD4 d = (MD4)super.clone();
11132-            d.digest = new MD4Digest((MD4Digest)digest);
11133-
11134-            return d;
11135-        }
11136-    }
11137+    // BEGIN android-removed
11138+    // static public class MD2
11139+    //     extends JDKMessageDigest
11140+    //     implements Cloneable
11141+    // {
11142+    //     public MD2()
11143+    //     {
11144+    //         super(new MD2Digest());
11145+    //     }
11146+    //
11147+    //     public Object clone()
11148+    //         throws CloneNotSupportedException
11149+    //     {
11150+    //         MD2 d = (MD2)super.clone();
11151+    //         d.digest = new MD2Digest((MD2Digest)digest);
11152+    //
11153+    //         return d;
11154+    //     }
11155+    // }
11156+    //
11157+    // static public class MD4
11158+    //     extends JDKMessageDigest
11159+    //     implements Cloneable
11160+    // {
11161+    //     public MD4()
11162+    //     {
11163+    //         super(new MD4Digest());
11164+    //     }
11165+    //
11166+    //     public Object clone()
11167+    //         throws CloneNotSupportedException
11168+    //     {
11169+    //         MD4 d = (MD4)super.clone();
11170+    //         d.digest = new MD4Digest((MD4Digest)digest);
11171+    //
11172+    //         return d;
11173+    //     }
11174+    // }
11175+    // END android-removed
11176
11177     static public class MD5
11178         extends JDKMessageDigest
11179@@ -190,147 +194,149 @@
11180         {
11181             super(new MD5Digest());
11182         }
11183-
11184+
11185         public Object clone()
11186             throws CloneNotSupportedException
11187         {
11188             MD5 d = (MD5)super.clone();
11189             d.digest = new MD5Digest((MD5Digest)digest);
11190-
11191-            return d;
11192-        }
11193-    }
11194-
11195-    static public class RIPEMD128
11196-        extends JDKMessageDigest
11197-        implements Cloneable
11198-    {
11199-        public RIPEMD128()
11200-        {
11201-            super(new RIPEMD128Digest());
11202-        }
11203-
11204-        public Object clone()
11205-            throws CloneNotSupportedException
11206-        {
11207-            RIPEMD128 d = (RIPEMD128)super.clone();
11208-            d.digest = new RIPEMD128Digest((RIPEMD128Digest)digest);
11209-
11210+
11211             return d;
11212         }
11213     }
11214
11215-    static public class RIPEMD160
11216-        extends JDKMessageDigest
11217-        implements Cloneable
11218-    {
11219-        public RIPEMD160()
11220-        {
11221-            super(new RIPEMD160Digest());
11222-        }
11223-
11224-        public Object clone()
11225-            throws CloneNotSupportedException
11226-        {
11227-            RIPEMD160 d = (RIPEMD160)super.clone();
11228-            d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);
11229-
11230-            return d;
11231-        }
11232-    }
11233-
11234-    static public class RIPEMD256
11235-        extends JDKMessageDigest
11236-        implements Cloneable
11237-    {
11238-        public RIPEMD256()
11239-        {
11240-            super(new RIPEMD256Digest());
11241-        }
11242-
11243-        public Object clone()
11244-            throws CloneNotSupportedException
11245-        {
11246-            RIPEMD256 d = (RIPEMD256)super.clone();
11247-            d.digest = new RIPEMD256Digest((RIPEMD256Digest)digest);
11248-
11249-            return d;
11250-        }
11251-    }
11252-
11253-    static public class RIPEMD320
11254-        extends JDKMessageDigest
11255-        implements Cloneable
11256-    {
11257-        public RIPEMD320()
11258-        {
11259-            super(new RIPEMD320Digest());
11260-        }
11261-
11262-        public Object clone()
11263-            throws CloneNotSupportedException
11264-        {
11265-            RIPEMD320 d = (RIPEMD320)super.clone();
11266-            d.digest = new RIPEMD320Digest((RIPEMD320Digest)digest);
11267-
11268-            return d;
11269-        }
11270-    }
11271-
11272-    static public class Tiger
11273-        extends JDKMessageDigest
11274-        implements Cloneable
11275-    {
11276-        public Tiger()
11277-        {
11278-            super(new TigerDigest());
11279-        }
11280-
11281-        public Object clone()
11282-            throws CloneNotSupportedException
11283-        {
11284-            Tiger d = (Tiger)super.clone();
11285-            d.digest = new TigerDigest((TigerDigest)digest);
11286-
11287-            return d;
11288-        }
11289-    }
11290-
11291-    static public class GOST3411
11292-        extends JDKMessageDigest
11293-        implements Cloneable
11294-    {
11295-        public GOST3411()
11296-        {
11297-            super(new GOST3411Digest());
11298-        }
11299-
11300-        public Object clone()
11301-        throws CloneNotSupportedException
11302-        {
11303-            GOST3411 d = (GOST3411)super.clone();
11304-            d.digest = new GOST3411Digest((GOST3411Digest)digest);
11305-
11306-            return d;
11307-        }
11308-    }
11309-
11310-    static public class Whirlpool
11311-       extends JDKMessageDigest
11312-       implements Cloneable
11313-    {
11314-        public Whirlpool()
11315-        {
11316-            super(new WhirlpoolDigest());
11317-        }
11318-
11319-        public Object clone()
11320-        throws CloneNotSupportedException
11321-        {
11322-            Whirlpool d = (Whirlpool)super.clone();
11323-            d.digest = new WhirlpoolDigest((WhirlpoolDigest)digest);
11324-
11325-            return d;
11326-        }
11327-    }
11328+    // BEGIN android-removed
11329+    // static public class RIPEMD128
11330+    //     extends JDKMessageDigest
11331+    //     implements Cloneable
11332+    // {
11333+    //     public RIPEMD128()
11334+    //     {
11335+    //         super(new RIPEMD128Digest());
11336+    //     }
11337+    //
11338+    //     public Object clone()
11339+    //         throws CloneNotSupportedException
11340+    //     {
11341+    //         RIPEMD128 d = (RIPEMD128)super.clone();
11342+    //         d.digest = new RIPEMD128Digest((RIPEMD128Digest)digest);
11343+    //
11344+    //         return d;
11345+    //     }
11346+    // }
11347+    //
11348+    // static public class RIPEMD160
11349+    //     extends JDKMessageDigest
11350+    //     implements Cloneable
11351+    // {
11352+    //     public RIPEMD160()
11353+    //     {
11354+    //         super(new RIPEMD160Digest());
11355+    //     }
11356+    //
11357+    //     public Object clone()
11358+    //         throws CloneNotSupportedException
11359+    //     {
11360+    //         RIPEMD160 d = (RIPEMD160)super.clone();
11361+    //         d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest);
11362+    //
11363+    //         return d;
11364+    //     }
11365+    // }
11366+    //
11367+    // static public class RIPEMD256
11368+    //     extends JDKMessageDigest
11369+    //     implements Cloneable
11370+    // {
11371+    //     public RIPEMD256()
11372+    //     {
11373+    //         super(new RIPEMD256Digest());
11374+    //     }
11375+    //
11376+    //     public Object clone()
11377+    //         throws CloneNotSupportedException
11378+    //     {
11379+    //         RIPEMD256 d = (RIPEMD256)super.clone();
11380+    //         d.digest = new RIPEMD256Digest((RIPEMD256Digest)digest);
11381+    //
11382+    //         return d;
11383+    //     }
11384+    // }
11385+    //
11386+    // static public class RIPEMD320
11387+    //     extends JDKMessageDigest
11388+    //     implements Cloneable
11389+    // {
11390+    //     public RIPEMD320()
11391+    //     {
11392+    //         super(new RIPEMD320Digest());
11393+    //     }
11394+    //
11395+    //     public Object clone()
11396+    //         throws CloneNotSupportedException
11397+    //     {
11398+    //         RIPEMD320 d = (RIPEMD320)super.clone();
11399+    //         d.digest = new RIPEMD320Digest((RIPEMD320Digest)digest);
11400+    //
11401+    //         return d;
11402+    //     }
11403+    // }
11404+    //
11405+    // static public class Tiger
11406+    //     extends JDKMessageDigest
11407+    //     implements Cloneable
11408+    // {
11409+    //     public Tiger()
11410+    //     {
11411+    //         super(new TigerDigest());
11412+    //     }
11413+    //
11414+    //     public Object clone()
11415+    //         throws CloneNotSupportedException
11416+    //     {
11417+    //         Tiger d = (Tiger)super.clone();
11418+    //         d.digest = new TigerDigest((TigerDigest)digest);
11419+    //
11420+    //         return d;
11421+    //     }
11422+    // }
11423+    //
11424+    // static public class GOST3411
11425+    //     extends JDKMessageDigest
11426+    //     implements Cloneable
11427+    // {
11428+    //     public GOST3411()
11429+    //     {
11430+    //         super(new GOST3411Digest());
11431+    //     }
11432+    //
11433+    //     public Object clone()
11434+    //     throws CloneNotSupportedException
11435+    //     {
11436+    //         GOST3411 d = (GOST3411)super.clone();
11437+    //         d.digest = new GOST3411Digest((GOST3411Digest)digest);
11438+    //
11439+    //         return d;
11440+    //     }
11441+    // }
11442+    //
11443+    // static public class Whirlpool
11444+    //    extends JDKMessageDigest
11445+    //    implements Cloneable
11446+    // {
11447+    //     public Whirlpool()
11448+    //     {
11449+    //         super(new WhirlpoolDigest());
11450+    //     }
11451+    //
11452+    //     public Object clone()
11453+    //     throws CloneNotSupportedException
11454+    //     {
11455+    //         Whirlpool d = (Whirlpool)super.clone();
11456+    //         d.digest = new WhirlpoolDigest((WhirlpoolDigest)digest);
11457+    //
11458+    //         return d;
11459+    //     }
11460+    // }
11461+    // END android-removed
11462 }
11463diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java
11464--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java	2010-01-11 21:46:14.000000000 +0000
11465+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java	2011-09-03 18:19:15.000000000 +0000
11466@@ -255,10 +255,13 @@
11467             }
11468         }
11469
11470-        if (c == null && k == null)
11471-        {
11472-            throw new KeyStoreException("no such entry as " + alias);
11473-        }
11474+        // BEGIN android-removed
11475+        // Only throw if there is a problem removing, not if missing
11476+        // if (c == null && k == null)
11477+        // {
11478+        //     throw new KeyStoreException("no such entry as " + alias);
11479+        // }
11480+        // END android-removed
11481     }
11482
11483     /**
11484@@ -433,6 +436,14 @@
11485
11486     public Date engineGetCreationDate(String alias)
11487     {
11488+        // BEGIN android-added
11489+        if (alias == null) {
11490+            throw new NullPointerException("alias == null");
11491+        }
11492+        if (keys.get(alias) == null && certs.get(alias) == null) {
11493+            return null;
11494+        }
11495+        // END android-added
11496         return new Date();
11497     }
11498
11499@@ -491,6 +502,11 @@
11500         Certificate[]   chain)
11501         throws KeyStoreException
11502     {
11503+        // BEGIN android-added
11504+        if (!(key instanceof PrivateKey)) {
11505+            throw new KeyStoreException("PKCS12 does not support non-PrivateKeys");
11506+        }
11507+        // END android-added
11508         if ((key instanceof PrivateKey) && (chain == null))
11509         {
11510             throw new KeyStoreException("no certificate chain for private key");
11511@@ -502,12 +518,18 @@
11512         }
11513
11514         keys.put(alias, key);
11515+        // BEGIN android-added
11516+        if (chain != null) {
11517+        // END android-added
11518         certs.put(alias, chain[0]);
11519
11520         for (int i = 0; i != chain.length; i++)
11521         {
11522             chainCerts.put(new CertId(chain[i].getPublicKey()), chain[i]);
11523         }
11524+        // BEGIN android-added
11525+        }
11526+        // END android-added
11527     }
11528
11529     public int engineSize()
11530@@ -1434,7 +1456,9 @@
11531         {
11532             byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data);
11533
11534-            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, new DERNull());
11535+            // BEGIN android-changed
11536+            AlgorithmIdentifier     algId = new AlgorithmIdentifier(id_SHA1, DERNull.INSTANCE);
11537+            // END android-changed
11538             DigestInfo              dInfo = new DigestInfo(algId, res);
11539
11540             mData = new MacData(dInfo, mSalt, itCount);
11541@@ -1484,32 +1508,34 @@
11542         }
11543     }
11544
11545-    public static class BCPKCS12KeyStore3DES
11546-        extends JDKPKCS12KeyStore
11547-    {
11548-        public BCPKCS12KeyStore3DES()
11549-        {
11550-            super(bcProvider, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
11551-        }
11552-    }
11553-
11554-    public static class DefPKCS12KeyStore
11555-        extends JDKPKCS12KeyStore
11556-    {
11557-        public DefPKCS12KeyStore()
11558-        {
11559-            super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC);
11560-        }
11561-    }
11562-
11563-    public static class DefPKCS12KeyStore3DES
11564-        extends JDKPKCS12KeyStore
11565-    {
11566-        public DefPKCS12KeyStore3DES()
11567-        {
11568-            super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
11569-        }
11570-    }
11571+    // BEGIN android-removed
11572+    // public static class BCPKCS12KeyStore3DES
11573+    //     extends JDKPKCS12KeyStore
11574+    // {
11575+    //     public BCPKCS12KeyStore3DES()
11576+    //     {
11577+    //         super(bcProvider, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
11578+    //     }
11579+    // }
11580+    //
11581+    // public static class DefPKCS12KeyStore
11582+    //     extends JDKPKCS12KeyStore
11583+    // {
11584+    //     public DefPKCS12KeyStore()
11585+    //     {
11586+    //         super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC);
11587+    //     }
11588+    // }
11589+    //
11590+    // public static class DefPKCS12KeyStore3DES
11591+    //     extends JDKPKCS12KeyStore
11592+    // {
11593+    //     public DefPKCS12KeyStore3DES()
11594+    //     {
11595+    //         super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC);
11596+    //     }
11597+    // }
11598+    // END android-removed
11599
11600     private static class IgnoresCaseHashtable
11601     {
11602@@ -1518,7 +1544,7 @@
11603
11604         public void put(String key, Object value)
11605         {
11606-            String lower = Strings.toLowerCase(key);
11607+            String lower = (key == null) ? null : Strings.toLowerCase(key);
11608             String k = (String)keys.get(lower);
11609             if (k != null)
11610             {
11611@@ -1536,7 +1562,9 @@
11612
11613         public Object remove(String alias)
11614         {
11615-            String k = (String)keys.remove(Strings.toLowerCase(alias));
11616+            // BEGIN android-changed
11617+            String k = (String)keys.remove(alias == null ? null : Strings.toLowerCase(alias));
11618+            // END android-changed
11619             if (k == null)
11620             {
11621                 return null;
11622@@ -1547,7 +1575,9 @@
11623
11624         public Object get(String alias)
11625         {
11626-            String k = (String)keys.get(Strings.toLowerCase(alias));
11627+            // BEGIN android-changed
11628+            String k = (String)keys.get(alias == null ? null : Strings.toLowerCase(alias));
11629+            // END android-changed
11630             if (k == null)
11631             {
11632                 return null;
11633diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PBE.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PBE.java
11634--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PBE.java	2010-01-11 21:46:14.000000000 +0000
11635+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PBE.java	2011-09-03 18:19:15.000000000 +0000
11636@@ -7,12 +7,18 @@
11637
11638 import org.bouncycastle.crypto.CipherParameters;
11639 import org.bouncycastle.crypto.PBEParametersGenerator;
11640-import org.bouncycastle.crypto.digests.MD2Digest;
11641+// BEGIN android-removed
11642+// import org.bouncycastle.crypto.digests.MD2Digest;
11643+// END android-removed
11644 import org.bouncycastle.crypto.digests.MD5Digest;
11645-import org.bouncycastle.crypto.digests.RIPEMD160Digest;
11646+// BEGIN android-removed
11647+// import org.bouncycastle.crypto.digests.RIPEMD160Digest;
11648+// END android-removed
11649 import org.bouncycastle.crypto.digests.SHA1Digest;
11650 import org.bouncycastle.crypto.digests.SHA256Digest;
11651-import org.bouncycastle.crypto.digests.TigerDigest;
11652+// BEGIN android-removed
11653+// import org.bouncycastle.crypto.digests.TigerDigest;
11654+// END android-removed
11655 import org.bouncycastle.crypto.generators.OpenSSLPBEParametersGenerator;
11656 import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator;
11657 import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator;
11658@@ -53,9 +59,11 @@
11659             {
11660                 switch (hash)
11661                 {
11662-                case MD2:
11663-                    generator = new PKCS5S1ParametersGenerator(new MD2Digest());
11664-                    break;
11665+                // BEGIN android-removed
11666+                // case MD2:
11667+                //     generator = new PKCS5S1ParametersGenerator(new MD2Digest());
11668+                //     break;
11669+                // END android-removed
11670                 case MD5:
11671                     generator = new PKCS5S1ParametersGenerator(new MD5Digest());
11672                     break;
11673@@ -74,21 +82,25 @@
11674             {
11675                 switch (hash)
11676                 {
11677-                case MD2:
11678-                    generator = new PKCS12ParametersGenerator(new MD2Digest());
11679-                    break;
11680+                // BEGIN android-removed
11681+                // case MD2:
11682+                //     generator = new PKCS12ParametersGenerator(new MD2Digest());
11683+                //     break;
11684+                // END android-removed
11685                 case MD5:
11686                     generator = new PKCS12ParametersGenerator(new MD5Digest());
11687                     break;
11688                 case SHA1:
11689                     generator = new PKCS12ParametersGenerator(new SHA1Digest());
11690                     break;
11691-                case RIPEMD160:
11692-                    generator = new PKCS12ParametersGenerator(new RIPEMD160Digest());
11693-                    break;
11694-                case TIGER:
11695-                    generator = new PKCS12ParametersGenerator(new TigerDigest());
11696-                    break;
11697+                // BEGIN android-removed
11698+                // case RIPEMD160:
11699+                //     generator = new PKCS12ParametersGenerator(new RIPEMD160Digest());
11700+                //     break;
11701+                // case TIGER:
11702+                //     generator = new PKCS12ParametersGenerator(new TigerDigest());
11703+                //     break;
11704+                // END android-removed
11705                 case SHA256:
11706                     generator = new PKCS12ParametersGenerator(new SHA256Digest());
11707                     break;
11708diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java
11709--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java	2010-01-11 21:46:14.000000000 +0000
11710+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java	2011-09-03 18:19:15.000000000 +0000
11711@@ -1,6 +1,9 @@
11712 package org.bouncycastle.jce.provider;
11713
11714 import org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier;
11715+// BEGIN android-added
11716+import org.bouncycastle.asn1.OrderedTable;
11717+// END android-added
11718 import org.bouncycastle.asn1.DERObjectIdentifier;
11719 import org.bouncycastle.asn1.DEREncodable;
11720 import org.bouncycastle.asn1.ASN1OutputStream;
11721@@ -17,65 +20,73 @@
11722 class PKCS12BagAttributeCarrierImpl
11723     implements PKCS12BagAttributeCarrier
11724 {
11725-    private Hashtable pkcs12Attributes;
11726-    private Vector pkcs12Ordering;
11727-
11728-    PKCS12BagAttributeCarrierImpl(Hashtable attributes, Vector ordering)
11729-    {
11730-        this.pkcs12Attributes = attributes;
11731-        this.pkcs12Ordering = ordering;
11732-    }
11733+    // BEGIN android-changed
11734+    private OrderedTable pkcs12 = new OrderedTable();
11735+    // END android-changed
11736+
11737+    // BEGIN android-removed
11738+    // PKCS12BagAttributeCarrierImpl(Hashtable attributes, Vector ordering)
11739+    // {
11740+    //     this.pkcs12Attributes = attributes;
11741+    //     this.pkcs12Ordering = ordering;
11742+    // }
11743+    // END android-removed
11744
11745     public PKCS12BagAttributeCarrierImpl()
11746     {
11747-        this(new Hashtable(), new Vector());
11748+        // BEGIN android-removed
11749+        // this(new Hashtable(), new Vector());
11750+        // END android-removed
11751     }
11752
11753     public void setBagAttribute(
11754         DERObjectIdentifier oid,
11755         DEREncodable        attribute)
11756     {
11757-        if (pkcs12Attributes.containsKey(oid))
11758-        {                           // preserve original ordering
11759-            pkcs12Attributes.put(oid, attribute);
11760-        }
11761-        else
11762-        {
11763-            pkcs12Attributes.put(oid, attribute);
11764-            pkcs12Ordering.addElement(oid);
11765-        }
11766+        // BEGIN android-changed
11767+        // preserve original ordering
11768+        pkcs12.put(oid, attribute);
11769+        // END android-changed
11770     }
11771
11772     public DEREncodable getBagAttribute(
11773         DERObjectIdentifier oid)
11774     {
11775-        return (DEREncodable)pkcs12Attributes.get(oid);
11776+        // BEGIN android-changed
11777+        return (DEREncodable)pkcs12.get(oid);
11778+        // END android-changed
11779     }
11780
11781     public Enumeration getBagAttributeKeys()
11782     {
11783-        return pkcs12Ordering.elements();
11784+        // BEGIN android-changed
11785+        return pkcs12.getKeys();
11786+        // END android-changed
11787     }
11788
11789     int size()
11790     {
11791-        return pkcs12Ordering.size();
11792-    }
11793-
11794-    Hashtable getAttributes()
11795-    {
11796-        return pkcs12Attributes;
11797-    }
11798-
11799-    Vector getOrdering()
11800-    {
11801-        return pkcs12Ordering;
11802-    }
11803+        // BEGIN android-changed
11804+        return pkcs12.size();
11805+        // END android-changed
11806+    }
11807+
11808+    // BEGIN android-removed
11809+    // Hashtable getAttributes()
11810+    // {
11811+    //     return pkcs12Attributes;
11812+    // }
11813+    //
11814+    // Vector getOrdering()
11815+    // {
11816+    //     return pkcs12Ordering;
11817+    // }
11818+    // END android-removed
11819
11820     public void writeObject(ObjectOutputStream out)
11821         throws IOException
11822     {
11823-        if (pkcs12Ordering.size() == 0)
11824+        if (pkcs12.size() == 0)
11825         {
11826             out.writeObject(new Hashtable());
11827             out.writeObject(new Vector());
11828@@ -92,7 +103,7 @@
11829                 DERObjectIdentifier    oid = (DERObjectIdentifier)e.nextElement();
11830
11831                 aOut.writeObject(oid);
11832-                aOut.writeObject(pkcs12Attributes.get(oid));
11833+                aOut.writeObject(pkcs12.get(oid));
11834             }
11835
11836             out.writeObject(bOut.toByteArray());
11837@@ -106,8 +117,11 @@
11838
11839         if (obj instanceof Hashtable)
11840         {
11841-            this.pkcs12Attributes = (Hashtable)obj;
11842-            this.pkcs12Ordering = (Vector)in.readObject();
11843+            // BEGIN android-changed
11844+            // we only write out Hashtable/Vector in empty case
11845+            in.readObject(); // consume empty Vector
11846+            this.pkcs12 = new OrderedTable();
11847+            // END android-changed
11848         }
11849         else
11850         {
11851diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPath.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPath.java
11852--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPath.java	2010-01-11 21:46:14.000000000 +0000
11853+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPath.java	2011-09-03 18:19:15.000000000 +0000
11854@@ -33,7 +33,9 @@
11855 import org.bouncycastle.asn1.pkcs.ContentInfo;
11856 import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
11857 import org.bouncycastle.asn1.pkcs.SignedData;
11858-import org.bouncycastle.openssl.PEMWriter;
11859+// BEGIN android-removed
11860+// import org.bouncycastle.openssl.PEMWriter;
11861+// END android-removed
11862
11863 /**
11864  * CertPath implementation for X.509 certificates.
11865@@ -295,27 +297,29 @@
11866             return toDEREncoded(new ContentInfo(
11867                     PKCSObjectIdentifiers.signedData, sd));
11868         }
11869-        else if (encoding.equalsIgnoreCase("PEM"))
11870-        {
11871-            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
11872-            PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
11873-
11874-            try
11875-            {
11876-                for (int i = 0; i != certificates.size(); i++)
11877-                {
11878-                    pWrt.writeObject(certificates.get(i));
11879-                }
11880-
11881-                pWrt.close();
11882-            }
11883-            catch (Exception e)
11884-            {
11885-                throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
11886-            }
11887-
11888-            return bOut.toByteArray();
11889-        }
11890+        // BEGIN android-removed
11891+        // else if (encoding.equalsIgnoreCase("PEM"))
11892+        // {
11893+        //     ByteArrayOutputStream bOut = new ByteArrayOutputStream();
11894+        //     PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
11895+        //
11896+        //     try
11897+        //     {
11898+        //         for (int i = 0; i != certificates.size(); i++)
11899+        //         {
11900+        //             pWrt.writeObject(certificates.get(i));
11901+        //         }
11902+        //
11903+        //         pWrt.close();
11904+        //     }
11905+        //     catch (Exception e)
11906+        //     {
11907+        //         throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
11908+        //     }
11909+        //
11910+        //     return bOut.toByteArray();
11911+        // }
11912+        // END android-removed
11913         else
11914         {
11915             throw new CertificateEncodingException("unsupported encoding: " + encoding);
11916diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java
11917--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java	2010-01-11 21:46:14.000000000 +0000
11918+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java	2011-09-03 18:19:15.000000000 +0000
11919@@ -172,8 +172,9 @@
11920         try
11921         {
11922             // check whether the issuer of <tbvCert> is a TrustAnchor
11923-            if (CertPathValidatorUtilities.findTrustAnchor(tbvCert, pkixParams.getTrustAnchors(),
11924-                pkixParams.getSigProvider()) != null)
11925+            // BEGIN android-changed
11926+            if (CertPathValidatorUtilities.findTrustAnchor(tbvCert, pkixParams) != null)
11927+                // END android-changed
11928             {
11929                 // exception message from possibly later tried certification
11930                 // chains
11931diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java
11932--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java	2010-01-11 21:46:14.000000000 +0000
11933+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java	2011-09-03 18:19:15.000000000 +0000
11934@@ -1,5 +1,8 @@
11935 package org.bouncycastle.jce.provider;
11936
11937+// BEGIN android-added
11938+import java.math.BigInteger;
11939+// END android-added
11940 import java.security.InvalidAlgorithmParameterException;
11941 import java.security.PublicKey;
11942 import java.security.cert.CertPath;
11943@@ -13,6 +16,7 @@
11944 import java.security.cert.TrustAnchor;
11945 import java.security.cert.X509Certificate;
11946 import java.util.ArrayList;
11947+import java.util.Arrays;
11948 import java.util.HashSet;
11949 import java.util.Iterator;
11950 import java.util.List;
11951@@ -20,9 +24,17 @@
11952
11953 import javax.security.auth.x500.X500Principal;
11954
11955+// BEGIN android-added
11956+import org.apache.harmony.xnet.provider.jsse.IndexedPKIXParameters;
11957+
11958+// END android-added
11959 import org.bouncycastle.asn1.DEREncodable;
11960 import org.bouncycastle.asn1.DERObjectIdentifier;
11961 import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
11962+// BEGIN android-added
11963+import org.bouncycastle.crypto.Digest;
11964+import org.bouncycastle.crypto.digests.OpenSSLDigest;
11965+// END android-added
11966 import org.bouncycastle.jce.exception.ExtCertPathValidatorException;
11967 import org.bouncycastle.x509.ExtendedPKIXParameters;
11968
11969@@ -33,6 +45,63 @@
11970 public class PKIXCertPathValidatorSpi
11971         extends CertPathValidatorSpi
11972 {
11973+    // BEGIN android-added
11974+
11975+    // From http://src.chromium.org/viewvc/chrome/trunk/src/net/base/x509_certificate.cc?revision=78748&view=markup
11976+    private static final Set<BigInteger> SERIAL_BLACKLIST = new HashSet<BigInteger>(Arrays.asList(
11977+        // Not a real certificate. For testing only.
11978+        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}),
11979+
11980+        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}),
11981+        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}),
11982+        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}),
11983+        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}),
11984+        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}),
11985+        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}),
11986+        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}),
11987+        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}),
11988+        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})
11989+    ));
11990+
11991+    // From http://src.chromium.org/viewvc/chrome/branches/782/src/net/base/x509_certificate.cc?r1=98750&r2=98749&pathrev=98750
11992+    private static final byte[][] PUBLIC_KEY_SHA1_BLACKLIST = {
11993+        // C=NL, O=DigiNotar, CN=DigiNotar Root CA/emailAddress=info@diginotar.nl
11994+        {(byte)0x41, (byte)0x0f, (byte)0x36, (byte)0x36, (byte)0x32, (byte)0x58, (byte)0xf3, (byte)0x0b, (byte)0x34, (byte)0x7d,
11995+         (byte)0x12, (byte)0xce, (byte)0x48, (byte)0x63, (byte)0xe4, (byte)0x33, (byte)0x43, (byte)0x78, (byte)0x06, (byte)0xa8},
11996+        // Subject: CN=DigiNotar Cyber CA
11997+        // Issuer: CN=GTE CyberTrust Global Root
11998+        {(byte)0xba, (byte)0x3e, (byte)0x7b, (byte)0xd3, (byte)0x8c, (byte)0xd7, (byte)0xe1, (byte)0xe6, (byte)0xb9, (byte)0xcd,
11999+         (byte)0x4c, (byte)0x21, (byte)0x99, (byte)0x62, (byte)0xe5, (byte)0x9d, (byte)0x7a, (byte)0x2f, (byte)0x4e, (byte)0x37},
12000+        // Subject: CN=DigiNotar Services 1024 CA
12001+        // Issuer: CN=Entrust.net
12002+        {(byte)0xe2, (byte)0x3b, (byte)0x8d, (byte)0x10, (byte)0x5f, (byte)0x87, (byte)0x71, (byte)0x0a, (byte)0x68, (byte)0xd9,
12003+         (byte)0x24, (byte)0x80, (byte)0x50, (byte)0xeb, (byte)0xef, (byte)0xc6, (byte)0x27, (byte)0xbe, (byte)0x4c, (byte)0xa6},
12004+        // Subject: CN=DigiNotar PKIoverheid CA Organisatie - G2
12005+        // Issuer: CN=Staat der Nederlanden Organisatie CA - G2
12006+        {(byte)0x7b, (byte)0x2e, (byte)0x16, (byte)0xbc, (byte)0x39, (byte)0xbc, (byte)0xd7, (byte)0x2b, (byte)0x45, (byte)0x6e,
12007+         (byte)0x9f, (byte)0x05, (byte)0x5d, (byte)0x1d, (byte)0xe6, (byte)0x15, (byte)0xb7, (byte)0x49, (byte)0x45, (byte)0xdb},
12008+        // Subject: CN=DigiNotar PKIoverheid CA Overheid en Bedrijven
12009+        // Issuer: CN=Staat der Nederlanden Overheid CA
12010+        {(byte)0xe8, (byte)0xf9, (byte)0x12, (byte)0x00, (byte)0xc6, (byte)0x5c, (byte)0xee, (byte)0x16, (byte)0xe0, (byte)0x39,
12011+         (byte)0xb9, (byte)0xf8, (byte)0x83, (byte)0x84, (byte)0x16, (byte)0x61, (byte)0x63, (byte)0x5f, (byte)0x81, (byte)0xc5},
12012+    };
12013+
12014+    private static boolean isPublicKeyBlackListed(PublicKey publicKey) {
12015+        byte[] encoded = publicKey.getEncoded();
12016+        Digest digest = new OpenSSLDigest.SHA1();
12017+        digest.update(encoded, 0, encoded.length);
12018+        byte[] out = new byte[digest.getDigestSize()];
12019+        digest.doFinal(out, 0);
12020+
12021+        for (byte[] sha1 : PUBLIC_KEY_SHA1_BLACKLIST) {
12022+            if (Arrays.equals(out, sha1)) {
12023+                return true;
12024+            }
12025+        }
12026+        return false;
12027+    }
12028+
12029+    // END android-added
12030
12031     public CertPathValidatorResult engineValidate(
12032             CertPath certPath,
12033@@ -46,6 +115,18 @@
12034                     + " instance.");
12035         }
12036
12037+        // BEGIN android-added
12038+        IndexedPKIXParameters indexedParams;
12039+        if (params instanceof IndexedPKIXParameters)
12040+        {
12041+            indexedParams = (IndexedPKIXParameters)params;
12042+        }
12043+        else
12044+        {
12045+            indexedParams = null;
12046+        }
12047+
12048+        // END android-added
12049         ExtendedPKIXParameters paramsPKIX;
12050         if (params instanceof ExtendedPKIXParameters)
12051         {
12052@@ -75,6 +156,22 @@
12053         {
12054             throw new CertPathValidatorException("Certification path is empty.", null, certPath, 0);
12055         }
12056+        // BEGIN android-added
12057+        {
12058+            X509Certificate cert = (X509Certificate) certs.get(0);
12059+
12060+            if (cert != null) {
12061+                BigInteger serial = cert.getSerialNumber();
12062+                if (serial != null && SERIAL_BLACKLIST.contains(serial)) {
12063+                    // emulate CRL exception message in RFC3280CertPathUtilities.checkCRLs
12064+                    String message = "Certificate revocation of serial 0x" + serial.toString(16);
12065+                    System.out.println(message);
12066+                    AnnotatedException e = new AnnotatedException(message);
12067+                    throw new CertPathValidatorException(e.getMessage(), e, certPath, 0);
12068+                }
12069+            }
12070+        }
12071+        // END android-added
12072
12073         //
12074         // (b)
12075@@ -90,10 +187,15 @@
12076         // (d)
12077         //
12078         TrustAnchor trust;
12079+        // BEGIN android-added
12080+        X509Certificate lastCert = (X509Certificate) certs.get(certs.size() - 1);
12081+        // END android-added
12082         try
12083         {
12084-            trust = CertPathValidatorUtilities.findTrustAnchor((X509Certificate) certs.get(certs.size() - 1),
12085-                    paramsPKIX.getTrustAnchors(), paramsPKIX.getSigProvider());
12086+            // BEGIN android-changed
12087+            trust = CertPathValidatorUtilities.findTrustAnchor(lastCert,
12088+                    indexedParams != null ? indexedParams : paramsPKIX);
12089+            // END android-changed
12090         }
12091         catch (AnnotatedException e)
12092         {
12093@@ -189,12 +291,25 @@
12094         X500Principal workingIssuerName;
12095
12096         X509Certificate sign = trust.getTrustedCert();
12097+        // BEGIN android-added
12098+        boolean trustAnchorInChain = false;
12099+        // END android-added
12100         try
12101         {
12102             if (sign != null)
12103             {
12104                 workingIssuerName = CertPathValidatorUtilities.getSubjectPrincipal(sign);
12105                 workingPublicKey = sign.getPublicKey();
12106+                // BEGIN android-added
12107+                // There is similar code in CertPathValidatorUtilities.
12108+                try {
12109+                    byte[] trustBytes = sign.getEncoded();
12110+                    byte[] certBytes = lastCert.getEncoded();
12111+                    trustAnchorInChain = Arrays.equals(trustBytes, certBytes);
12112+                } catch(Exception e) {
12113+                    // ignore, continue with trustAnchorInChain being false
12114+                }
12115+                // END android-added
12116             }
12117             else
12118             {
12119@@ -251,6 +366,15 @@
12120
12121         for (index = certs.size() - 1; index >= 0; index--)
12122         {
12123+            // BEGIN android-added
12124+            if (isPublicKeyBlackListed(workingPublicKey)) {
12125+                // emulate CRL exception message in RFC3280CertPathUtilities.checkCRLs
12126+                String message = "Certificate revocation of public key " + workingPublicKey;
12127+                System.out.println(message);
12128+                AnnotatedException e = new AnnotatedException(message);
12129+                throw new CertPathValidatorException(e.getMessage(), e, certPath, index);
12130+            }
12131+            // END android-added
12132             // try
12133             // {
12134             //
12135@@ -271,8 +395,10 @@
12136             // 6.1.3
12137             //
12138
12139+            // BEGIN android-changed
12140             RFC3280CertPathUtilities.processCertA(certPath, paramsPKIX, index, workingPublicKey,
12141-                verificationAlreadyPerformed, workingIssuerName, sign);
12142+                verificationAlreadyPerformed, workingIssuerName, sign, i, trustAnchorInChain);
12143+            // END android-changed
12144
12145             RFC3280CertPathUtilities.processCertBC(certPath, index, nameConstraintValidator);
12146
12147@@ -289,11 +415,18 @@
12148
12149             if (i != n)
12150             {
12151+                // BEGIN android-added
12152+                if (!(i == 1 && trustAnchorInChain)) // if not at the root certificate
12153+                {
12154+                // END android-added
12155                 if (cert != null && cert.getVersion() == 1)
12156                 {
12157                     throw new CertPathValidatorException("Version 1 certificates can't be used as CA ones.", null,
12158                             certPath, index);
12159                 }
12160+                // BEGIN android-added
12161+                }
12162+                // END android-added
12163
12164                 RFC3280CertPathUtilities.prepareNextCertA(certPath, index);
12165
12166@@ -317,7 +450,9 @@
12167                 inhibitAnyPolicy = RFC3280CertPathUtilities.prepareNextCertJ(certPath, index, inhibitAnyPolicy);
12168
12169                 // (k)
12170-                RFC3280CertPathUtilities.prepareNextCertK(certPath, index);
12171+                // BEGIN android-changed
12172+                RFC3280CertPathUtilities.prepareNextCertK(certPath, index, i, trustAnchorInChain);
12173+                // END android-changed
12174
12175                 // (l)
12176                 maxPathLength = RFC3280CertPathUtilities.prepareNextCertL(certPath, index, maxPathLength);
12177diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java
12178--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java	2010-01-11 21:46:14.000000000 +0000
12179+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java	2011-09-03 18:19:15.000000000 +0000
12180@@ -1533,7 +1533,9 @@
12181         for (Enumeration e = permitted.getObjects(); e.hasMoreElements();)
12182         {
12183             GeneralSubtree subtree = GeneralSubtree.getInstance(e.nextElement());
12184-            Integer tagNo = new Integer(subtree.getBase().getTagNo());
12185+            // BEGIN android-changed
12186+            Integer tagNo = Integer.valueOf(subtree.getBase().getTagNo());
12187+            // END android-changed
12188             if (subtreesMap.get(tagNo) == null)
12189             {
12190                 subtreesMap.put(tagNo, new HashSet());
12191diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/ProviderUtil.java bcprov-jdk16-145/org/bouncycastle/jce/provider/ProviderUtil.java
12192--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/ProviderUtil.java	2010-01-11 21:46:14.000000000 +0000
12193+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/ProviderUtil.java	2011-09-03 18:19:15.000000000 +0000
12194@@ -1,9 +1,13 @@
12195 package org.bouncycastle.jce.provider;
12196
12197 import org.bouncycastle.jce.ProviderConfigurationPermission;
12198-import org.bouncycastle.jce.provider.asymmetric.ec.EC5Util;
12199+// BEGIN android-removed
12200+// import org.bouncycastle.jce.provider.asymmetric.ec.EC5Util;
12201+// END android-removed
12202 import org.bouncycastle.jce.interfaces.ConfigurableProvider;
12203-import org.bouncycastle.jce.spec.ECParameterSpec;
12204+// BEGIN android-removed
12205+// import org.bouncycastle.jce.spec.ECParameterSpec;
12206+// END android-removed
12207
12208 import java.io.ByteArrayInputStream;
12209 import java.io.IOException;
12210@@ -20,68 +24,74 @@
12211                                                    "BC", ConfigurableProvider.EC_IMPLICITLY_CA);
12212
12213     private static ThreadLocal threadSpec = new ThreadLocal();
12214-    private static volatile ECParameterSpec ecImplicitCaParams;
12215+    // BEGIN android-removed
12216+    // private static volatile ECParameterSpec ecImplicitCaParams;
12217+    // END android-removed
12218
12219     static void setParameter(String parameterName, Object parameter)
12220     {
12221         SecurityManager securityManager = System.getSecurityManager();
12222
12223-        if (parameterName.equals(ConfigurableProvider.THREAD_LOCAL_EC_IMPLICITLY_CA))
12224-        {
12225-            ECParameterSpec curveSpec;
12226-
12227-            if (securityManager != null)
12228-            {
12229-                securityManager.checkPermission(BC_EC_LOCAL_PERMISSION);
12230-            }
12231-
12232-            if (parameter instanceof ECParameterSpec || parameter == null)
12233-            {
12234-                curveSpec = (ECParameterSpec)parameter;
12235-            }
12236-            else  // assume java.security.spec
12237-            {
12238-                curveSpec = EC5Util.convertSpec((java.security.spec.ECParameterSpec)parameter, false);
12239-            }
12240-
12241-            if (curveSpec == null)
12242-            {
12243-                threadSpec.remove();
12244-            }
12245-            else
12246-            {
12247-                threadSpec.set(curveSpec);
12248-            }
12249-        }
12250-        else if (parameterName.equals(ConfigurableProvider.EC_IMPLICITLY_CA))
12251-        {
12252-            if (securityManager != null)
12253-            {
12254-                securityManager.checkPermission(BC_EC_PERMISSION);
12255-            }
12256-
12257-            if (parameter instanceof ECParameterSpec || parameter == null)
12258-            {
12259-                ecImplicitCaParams = (ECParameterSpec)parameter;
12260-            }
12261-            else  // assume java.security.spec
12262-            {
12263-                ecImplicitCaParams = EC5Util.convertSpec((java.security.spec.ECParameterSpec)parameter, false);
12264-            }
12265-        }
12266+        // BEGIN android-removed
12267+        // if (parameterName.equals(ConfigurableProvider.THREAD_LOCAL_EC_IMPLICITLY_CA))
12268+        // {
12269+        //     ECParameterSpec curveSpec;
12270+        //
12271+        //     if (securityManager != null)
12272+        //     {
12273+        //         securityManager.checkPermission(BC_EC_LOCAL_PERMISSION);
12274+        //     }
12275+        //
12276+        //     if (parameter instanceof ECParameterSpec || parameter == null)
12277+        //     {
12278+        //         curveSpec = (ECParameterSpec)parameter;
12279+        //     }
12280+        //     else  // assume java.security.spec
12281+        //     {
12282+        //         curveSpec = EC5Util.convertSpec((java.security.spec.ECParameterSpec)parameter, false);
12283+        //     }
12284+        //
12285+        //     if (curveSpec == null)
12286+        //     {
12287+        //         threadSpec.remove();
12288+        //     }
12289+        //     else
12290+        //     {
12291+        //         threadSpec.set(curveSpec);
12292+        //     }
12293+        // }
12294+        // else if (parameterName.equals(ConfigurableProvider.EC_IMPLICITLY_CA))
12295+        // {
12296+        //     if (securityManager != null)
12297+        //     {
12298+        //         securityManager.checkPermission(BC_EC_PERMISSION);
12299+        //     }
12300+        //
12301+        //     if (parameter instanceof ECParameterSpec || parameter == null)
12302+        //     {
12303+        //         ecImplicitCaParams = (ECParameterSpec)parameter;
12304+        //     }
12305+        //     else  // assume java.security.spec
12306+        //     {
12307+        //         ecImplicitCaParams = EC5Util.convertSpec((java.security.spec.ECParameterSpec)parameter, false);
12308+        //     }
12309+        // }
12310+        // END android-removed
12311     }
12312
12313-    public static ECParameterSpec getEcImplicitlyCa()
12314-    {
12315-        ECParameterSpec spec = (ECParameterSpec)threadSpec.get();
12316-
12317-        if (spec != null)
12318-        {
12319-            return spec;
12320-        }
12321-
12322-        return ecImplicitCaParams;
12323-    }
12324+    // BEGIN android-removed
12325+    // public static ECParameterSpec getEcImplicitlyCa()
12326+    // {
12327+    //     ECParameterSpec spec = (ECParameterSpec)threadSpec.get();
12328+    //
12329+    //     if (spec != null)
12330+    //     {
12331+    //         return spec;
12332+    //     }
12333+    //
12334+    //     return ecImplicitCaParams;
12335+    // }
12336+    // END android-removed
12337
12338     static int getReadLimit(InputStream in)
12339         throws IOException
12340diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/RFC3280CertPathUtilities.java bcprov-jdk16-145/org/bouncycastle/jce/provider/RFC3280CertPathUtilities.java
12341--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/RFC3280CertPathUtilities.java	2010-01-11 21:46:14.000000000 +0000
12342+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/RFC3280CertPathUtilities.java	2011-09-03 18:19:15.000000000 +0000
12343@@ -1471,7 +1471,11 @@
12344         PublicKey workingPublicKey,
12345         boolean verificationAlreadyPerformed,
12346         X500Principal workingIssuerName,
12347-        X509Certificate sign)
12348+        X509Certificate sign,
12349+        // BEGIN android-added
12350+        int i,
12351+        boolean trustAnchorInChain)
12352+        // END android-added
12353         throws ExtCertPathValidatorException
12354     {
12355         List certs = certPath.getCertificates();
12356@@ -1485,8 +1489,15 @@
12357             {
12358                 // (a) (1)
12359                 //
12360+                // BEGIN android-added
12361+                if (!(i == 1 && trustAnchorInChain)) // if not at the root certificate
12362+                {
12363+                // END android-added
12364                 CertPathValidatorUtilities.verifyX509Certificate(cert, workingPublicKey,
12365                     paramsPKIX.getSigProvider());
12366+                // BEGIN android-added
12367+                }
12368+                // END android-added
12369             }
12370             catch (GeneralSecurityException e)
12371             {
12372@@ -2077,7 +2088,11 @@
12373
12374     protected static void prepareNextCertK(
12375         CertPath certPath,
12376-        int index)
12377+        int index,
12378+        // BEGIN android-added
12379+        int i,
12380+        boolean trustAnchorInChain)
12381+        // END android-added
12382         throws CertPathValidatorException
12383     {
12384         List certs = certPath.getCertificates();
12385@@ -2105,7 +2120,14 @@
12386         }
12387         else
12388         {
12389+            // BEGIN android-added
12390+            if (!(i == 1 && trustAnchorInChain)) // if not at the root certificate
12391+            {
12392+            // END android-added
12393             throw new CertPathValidatorException("Intermediate certificate lacks BasicConstraints");
12394+            // BEGIN android-added
12395+            }
12396+            // END android-added
12397         }
12398     }
12399
12400diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/WrapCipherSpi.java bcprov-jdk16-145/org/bouncycastle/jce/provider/WrapCipherSpi.java
12401--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/WrapCipherSpi.java	2010-01-11 21:46:14.000000000 +0000
12402+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/WrapCipherSpi.java	2011-09-03 18:19:15.000000000 +0000
12403@@ -12,8 +12,10 @@
12404 import org.bouncycastle.crypto.Wrapper;
12405 import org.bouncycastle.crypto.engines.DESedeEngine;
12406 import org.bouncycastle.crypto.engines.DESedeWrapEngine;
12407-import org.bouncycastle.crypto.engines.RC2WrapEngine;
12408-import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
12409+// BEGIN android-removed
12410+// import org.bouncycastle.crypto.engines.RC2WrapEngine;
12411+// import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
12412+// END android-removed
12413 import org.bouncycastle.crypto.params.KeyParameter;
12414 import org.bouncycastle.crypto.params.ParametersWithIV;
12415
12416@@ -25,8 +27,10 @@
12417 import javax.crypto.ShortBufferException;
12418 import javax.crypto.spec.IvParameterSpec;
12419 import javax.crypto.spec.PBEParameterSpec;
12420-import javax.crypto.spec.RC2ParameterSpec;
12421-import javax.crypto.spec.RC5ParameterSpec;
12422+// BEGIN android-removed
12423+// import javax.crypto.spec.RC2ParameterSpec;
12424+// import javax.crypto.spec.RC5ParameterSpec;
12425+// END android-removed
12426 import javax.crypto.spec.SecretKeySpec;
12427 import java.security.AlgorithmParameters;
12428 import java.security.InvalidAlgorithmParameterException;
12429@@ -52,8 +56,10 @@
12430                                     {
12431                                         IvParameterSpec.class,
12432                                         PBEParameterSpec.class,
12433-                                        RC2ParameterSpec.class,
12434-                                        RC5ParameterSpec.class
12435+                                        // BEGIN android-removed
12436+                                        // RC2ParameterSpec.class,
12437+                                        // RC5ParameterSpec.class
12438+                                        // END android-removed
12439                                     };
12440
12441     protected int                     pbeType = PKCS12;
12442@@ -265,16 +271,19 @@
12443         return null;
12444     }
12445
12446+    // BEGIN android-changed
12447+    // added ShortBufferException to throws statement
12448     protected int engineDoFinal(
12449         byte[]  input,
12450         int     inputOffset,
12451         int     inputLen,
12452         byte[]  output,
12453         int     outputOffset)
12454-        throws IllegalBlockSizeException, BadPaddingException
12455+        throws IllegalBlockSizeException, BadPaddingException, ShortBufferException
12456     {
12457         return 0;
12458     }
12459+    // END android-changed
12460
12461     protected byte[] engineWrap(
12462         Key     key)
12463@@ -307,7 +316,12 @@
12464         byte[]  wrappedKey,
12465         String  wrappedKeyAlgorithm,
12466         int     wrappedKeyType)
12467-    throws InvalidKeyException
12468+    // BEGIN android-removed
12469+    // throws InvalidKeyException
12470+    // END android-removed
12471+    // BEGIN android-added
12472+    throws InvalidKeyException, NoSuchAlgorithmException
12473+    // END android-added
12474     {
12475         byte[] encoded;
12476         try
12477@@ -354,15 +368,20 @@
12478
12479                 DERObjectIdentifier  oid = in.getAlgorithmId().getObjectId();
12480
12481-                if (oid.equals(X9ObjectIdentifiers.id_ecPublicKey))
12482-                {
12483-                    privKey = new JCEECPrivateKey(in);
12484-                }
12485-                else if (oid.equals(CryptoProObjectIdentifiers.gostR3410_94))
12486-                {
12487-                    privKey = new JDKGOST3410PrivateKey(in);
12488-                }
12489-                else if (oid.equals(X9ObjectIdentifiers.id_dsa))
12490+                // BEGIN android-removed
12491+                // if (oid.equals(X9ObjectIdentifiers.id_ecPublicKey))
12492+                // {
12493+                //     privKey = new JCEECPrivateKey(in);
12494+                // }
12495+                // else if (oid.equals(CryptoProObjectIdentifiers.gostR3410_94))
12496+                // {
12497+                //     privKey = new JDKGOST3410PrivateKey(in);
12498+                // }
12499+                // else if (oid.equals(X9ObjectIdentifiers.id_dsa))
12500+                // END android-removed
12501+                // BEGIN android-added
12502+                if (oid.equals(X9ObjectIdentifiers.id_dsa))
12503+                // END android-added
12504                 {
12505                     privKey = new JDKDSAPrivateKey(in);
12506                 }
12507@@ -405,10 +424,12 @@
12508             {
12509                 throw new InvalidKeyException("Unknown key type " + e.getMessage());
12510             }
12511-            catch (NoSuchAlgorithmException e)
12512-            {
12513-                throw new InvalidKeyException("Unknown key type " + e.getMessage());
12514-            }
12515+            // BEGIN android-removed
12516+            // catch (NoSuchAlgorithmException e)
12517+            // {
12518+            //     throw new InvalidKeyException("Unknown key type " + e.getMessage());
12519+            // }
12520+            // END android-removed
12521             catch (InvalidKeySpecException e2)
12522             {
12523                 throw new InvalidKeyException("Unknown key type " + e2.getMessage());
12524@@ -433,21 +454,23 @@
12525         }
12526     }
12527
12528-    public static class RC2Wrap
12529-        extends WrapCipherSpi
12530-    {
12531-        public RC2Wrap()
12532-        {
12533-            super(new RC2WrapEngine());
12534-        }
12535-    }
12536-
12537-    public static class RFC3211DESedeWrap
12538-        extends WrapCipherSpi
12539-    {
12540-        public RFC3211DESedeWrap()
12541-        {
12542-            super(new RFC3211WrapEngine(new DESedeEngine()), 8);
12543-        }
12544-    }
12545+    // BEGIN android-removed
12546+    // public static class RC2Wrap
12547+    //     extends WrapCipherSpi
12548+    // {
12549+    //     public RC2Wrap()
12550+    //     {
12551+    //         super(new RC2WrapEngine());
12552+    //     }
12553+    // }
12554+    //
12555+    // public static class RFC3211DESedeWrap
12556+    //     extends WrapCipherSpi
12557+    // {
12558+    //     public RFC3211DESedeWrap()
12559+    //     {
12560+    //         super(new RFC3211WrapEngine(new DESedeEngine()), 8);
12561+    //     }
12562+    // }
12563+    // END android-removed
12564 }
12565diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509CertificateObject.java bcprov-jdk16-145/org/bouncycastle/jce/provider/X509CertificateObject.java
12566--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509CertificateObject.java	2010-01-11 21:46:14.000000000 +0000
12567+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/X509CertificateObject.java	2011-09-03 18:19:15.000000000 +0000
12568@@ -518,12 +518,20 @@
12569         return JDKKeyFactory.createPublicKeyFromPublicKeyInfo(c.getSubjectPublicKeyInfo());
12570     }
12571
12572+    // BEGIN android-changed
12573+    private byte[] encoded;
12574+    // END android-changed
12575     public byte[] getEncoded()
12576         throws CertificateEncodingException
12577     {
12578         try
12579         {
12580-            return c.getEncoded(ASN1Encodable.DER);
12581+            // BEGIN android-changed
12582+            if (encoded == null) {
12583+                encoded = c.getEncoded(ASN1Encodable.DER);
12584+            }
12585+            return encoded;
12586+            // END android-changed
12587         }
12588         catch (IOException e)
12589         {
12590@@ -703,7 +711,7 @@
12591     {
12592         Signature   signature;
12593         String      sigName = X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm());
12594-
12595+
12596         try
12597         {
12598             signature = Signature.getInstance(sigName, "BC");
12599diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509SignatureUtil.java bcprov-jdk16-145/org/bouncycastle/jce/provider/X509SignatureUtil.java
12600--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509SignatureUtil.java	2010-01-11 21:46:14.000000000 +0000
12601+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/X509SignatureUtil.java	2011-09-03 18:19:15.000000000 +0000
12602@@ -25,7 +25,9 @@
12603
12604 class X509SignatureUtil
12605 {
12606-    private static final ASN1Null       derNull = new DERNull();
12607+    // BEGIN android-changed
12608+    private static final ASN1Null       derNull = DERNull.INSTANCE;
12609+    // END android-changed
12610
12611     static void setSignatureParameters(
12612         Signature signature,
12613@@ -66,12 +68,14 @@
12614
12615         if (params != null && !derNull.equals(params))
12616         {
12617-            if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
12618-            {
12619-                RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
12620-
12621-                return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
12622-            }
12623+            // BEGIN android-removed
12624+            // if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
12625+            // {
12626+            //     RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params);
12627+            //
12628+            //     return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1";
12629+            // }
12630+            // END android-removed
12631             if (sigAlgId.getObjectId().equals(X9ObjectIdentifiers.ecdsa_with_SHA2))
12632             {
12633                 ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params);
12634@@ -98,10 +102,12 @@
12635         {
12636             return "SHA1";
12637         }
12638-        else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
12639-        {
12640-            return "SHA224";
12641-        }
12642+        // BEGIN android-removed
12643+        // else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID))
12644+        // {
12645+        //     return "SHA224";
12646+        // }
12647+        // END android-removed
12648         else if (NISTObjectIdentifiers.id_sha256.equals(digestAlgOID))
12649         {
12650             return "SHA256";
12651@@ -114,22 +120,24 @@
12652         {
12653             return "SHA512";
12654         }
12655-        else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
12656-        {
12657-            return "RIPEMD128";
12658-        }
12659-        else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
12660-        {
12661-            return "RIPEMD160";
12662-        }
12663-        else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
12664-        {
12665-            return "RIPEMD256";
12666-        }
12667-        else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
12668-        {
12669-            return "GOST3411";
12670-        }
12671+        // BEGIN android-removed
12672+        // else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID))
12673+        // {
12674+        //     return "RIPEMD128";
12675+        // }
12676+        // else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID))
12677+        // {
12678+        //     return "RIPEMD160";
12679+        // }
12680+        // else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID))
12681+        // {
12682+        //     return "RIPEMD256";
12683+        // }
12684+        // else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID))
12685+        // {
12686+        //     return "GOST3411";
12687+        // }
12688+        // END android-removed
12689         else
12690         {
12691             return digestAlgOID.getId();
12692diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AES.java bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AES.java
12693--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AES.java	2010-01-11 21:46:14.000000000 +0000
12694+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AES.java	2011-09-03 18:19:15.000000000 +0000
12695@@ -5,7 +5,9 @@
12696 import org.bouncycastle.crypto.engines.AESEngine;
12697 import org.bouncycastle.crypto.engines.AESFastEngine;
12698 import org.bouncycastle.crypto.engines.AESWrapEngine;
12699-import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
12700+// BEGIN android-removed
12701+// import org.bouncycastle.crypto.engines.RFC3211WrapEngine;
12702+// END android-removed
12703 import org.bouncycastle.crypto.modes.CBCBlockCipher;
12704 import org.bouncycastle.crypto.modes.CFBBlockCipher;
12705 import org.bouncycastle.crypto.modes.OFBBlockCipher;
12706@@ -36,32 +38,34 @@
12707         }
12708     }
12709
12710-    public static class CBC
12711-       extends JCEBlockCipher
12712-    {
12713-        public CBC()
12714-        {
12715-            super(new CBCBlockCipher(new AESFastEngine()), 128);
12716-        }
12717-    }
12718-
12719-    static public class CFB
12720-        extends JCEBlockCipher
12721-    {
12722-        public CFB()
12723-        {
12724-            super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128);
12725-        }
12726-    }
12727-
12728-    static public class OFB
12729-        extends JCEBlockCipher
12730-    {
12731-        public OFB()
12732-        {
12733-            super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128);
12734-        }
12735-    }
12736+    // BEGIN android-removed
12737+    // public static class CBC
12738+    //    extends JCEBlockCipher
12739+    // {
12740+    //     public CBC()
12741+    //     {
12742+    //         super(new CBCBlockCipher(new AESFastEngine()), 128);
12743+    //     }
12744+    // }
12745+    //
12746+    // static public class CFB
12747+    //     extends JCEBlockCipher
12748+    // {
12749+    //     public CFB()
12750+    //     {
12751+    //         super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128);
12752+    //     }
12753+    // }
12754+    //
12755+    // static public class OFB
12756+    //     extends JCEBlockCipher
12757+    // {
12758+    //     public OFB()
12759+    //     {
12760+    //         super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128);
12761+    //     }
12762+    // }
12763+    // END android-removed
12764
12765     static public class Wrap
12766         extends WrapCipherSpi
12767@@ -72,14 +76,16 @@
12768         }
12769     }
12770
12771-    public static class RFC3211Wrap
12772-        extends WrapCipherSpi
12773-    {
12774-        public RFC3211Wrap()
12775-        {
12776-            super(new RFC3211WrapEngine(new AESEngine()), 16);
12777-        }
12778-    }
12779+    // BEGIN android-removed
12780+    // public static class RFC3211Wrap
12781+    //     extends WrapCipherSpi
12782+    // {
12783+    //     public RFC3211Wrap()
12784+    //     {
12785+    //         super(new RFC3211WrapEngine(new AESEngine()), 16);
12786+    //     }
12787+    // }
12788+    // END android-removed
12789
12790     public static class KeyGen
12791         extends JCEKeyGenerator
12792@@ -95,70 +101,72 @@
12793         }
12794     }
12795
12796-    public static class KeyGen128
12797-        extends KeyGen
12798-    {
12799-        public KeyGen128()
12800-        {
12801-            super(128);
12802-        }
12803-    }
12804-
12805-    public static class KeyGen192
12806-        extends KeyGen
12807-    {
12808-        public KeyGen192()
12809-        {
12810-            super(192);
12811-        }
12812-    }
12813-
12814-    public static class KeyGen256
12815-        extends KeyGen
12816-    {
12817-        public KeyGen256()
12818-        {
12819-            super(256);
12820-        }
12821-    }
12822-
12823-    public static class AlgParamGen
12824-        extends JDKAlgorithmParameterGenerator
12825-    {
12826-        protected void engineInit(
12827-            AlgorithmParameterSpec genParamSpec,
12828-            SecureRandom random)
12829-            throws InvalidAlgorithmParameterException
12830-        {
12831-            throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation.");
12832-        }
12833-
12834-        protected AlgorithmParameters engineGenerateParameters()
12835-        {
12836-            byte[]  iv = new byte[16];
12837-
12838-            if (random == null)
12839-            {
12840-                random = new SecureRandom();
12841-            }
12842-
12843-            random.nextBytes(iv);
12844-
12845-            AlgorithmParameters params;
12846-
12847-            try
12848-            {
12849-                params = AlgorithmParameters.getInstance("AES", "BC");
12850-                params.init(new IvParameterSpec(iv));
12851-            }
12852-            catch (Exception e)
12853-            {
12854-                throw new RuntimeException(e.getMessage());
12855-            }
12856-
12857-            return params;
12858-        }
12859-    }
12860+    // BEGIN android-removed
12861+    // public static class KeyGen128
12862+    //     extends KeyGen
12863+    // {
12864+    //     public KeyGen128()
12865+    //     {
12866+    //         super(128);
12867+    //     }
12868+    // }
12869+    //
12870+    // public static class KeyGen192
12871+    //     extends KeyGen
12872+    // {
12873+    //     public KeyGen192()
12874+    //     {
12875+    //         super(192);
12876+    //     }
12877+    // }
12878+    //
12879+    // public static class KeyGen256
12880+    //     extends KeyGen
12881+    // {
12882+    //     public KeyGen256()
12883+    //     {
12884+    //         super(256);
12885+    //     }
12886+    // }
12887+    //
12888+    // public static class AlgParamGen
12889+    //     extends JDKAlgorithmParameterGenerator
12890+    // {
12891+    //     protected void engineInit(
12892+    //         AlgorithmParameterSpec genParamSpec,
12893+    //         SecureRandom random)
12894+    //         throws InvalidAlgorithmParameterException
12895+    //     {
12896+    //         throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation.");
12897+    //     }
12898+    //
12899+    //     protected AlgorithmParameters engineGenerateParameters()
12900+    //     {
12901+    //         byte[]  iv = new byte[16];
12902+    //
12903+    //         if (random == null)
12904+    //         {
12905+    //             random = new SecureRandom();
12906+    //         }
12907+    //
12908+    //         random.nextBytes(iv);
12909+    //
12910+    //         AlgorithmParameters params;
12911+    //
12912+    //         try
12913+    //         {
12914+    //             params = AlgorithmParameters.getInstance("AES", "BC");
12915+    //             params.init(new IvParameterSpec(iv));
12916+    //         }
12917+    //         catch (Exception e)
12918+    //         {
12919+    //             throw new RuntimeException(e.getMessage());
12920+    //         }
12921+    //
12922+    //         return params;
12923+    //     }
12924+    // }
12925+    // END android-removed
12926
12927     public static class AlgParams
12928         extends JDKAlgorithmParameters.IVAlgorithmParameters
12929diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AESMappings.java bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AESMappings.java
12930--- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AESMappings.java	2010-01-11 21:46:14.000000000 +0000
12931+++ bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AESMappings.java	2011-09-03 18:19:15.000000000 +0000
12932@@ -26,55 +26,63 @@
12933         put("Alg.Alias.AlgorithmParameters." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
12934         put("Alg.Alias.AlgorithmParameters." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
12935
12936-        put("AlgorithmParameterGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$AlgParamGen");
12937-        put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES128, "AES");
12938-        put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES192, "AES");
12939-        put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES256, "AES");
12940-        put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "AES");
12941-        put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
12942-        put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
12943+        // BEGIN android-removed
12944+        // put("AlgorithmParameterGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$AlgParamGen");
12945+        // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES128, "AES");
12946+        // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES192, "AES");
12947+        // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES256, "AES");
12948+        // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "AES");
12949+        // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
12950+        // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
12951+        // END android-removed
12952
12953         put("Cipher.AES", "org.bouncycastle.jce.provider.symmetric.AES$ECB");
12954         put("Alg.Alias.Cipher." + wrongAES128, "AES");
12955         put("Alg.Alias.Cipher." + wrongAES192, "AES");
12956         put("Alg.Alias.Cipher." + wrongAES256, "AES");
12957-        put("Cipher." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
12958-        put("Cipher." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
12959-        put("Cipher." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB");
12960-        put("Cipher." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
12961-        put("Cipher." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
12962-        put("Cipher." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC");
12963-        put("Cipher." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
12964-        put("Cipher." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
12965-        put("Cipher." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB");
12966-        put("Cipher." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
12967-        put("Cipher." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
12968-        put("Cipher." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB");
12969+        // BEGIN android-changed
12970+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_ECB, "AES");
12971+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_ECB, "AES");
12972+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_ECB, "AES");
12973+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_CBC, "AES");
12974+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_CBC, "AES");
12975+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_CBC, "AES");
12976+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_OFB, "AES");
12977+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_OFB, "AES");
12978+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_OFB, "AES");
12979+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_CFB, "AES");
12980+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_CFB, "AES");
12981+        put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_CFB, "AES");
12982+        // END android-changed
12983         put("Cipher.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$Wrap");
12984         put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_wrap, "AESWRAP");
12985         put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_wrap, "AESWRAP");
12986         put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_wrap, "AESWRAP");
12987-        put("Cipher.AESRFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.AES$RFC3211Wrap");
12988+        // BEGIN android-removed
12989+        // put("Cipher.AESRFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.AES$RFC3211Wrap");
12990+        // END android-removed
12991
12992         put("KeyGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen");
12993-        put("KeyGenerator.2.16.840.1.101.3.4.2", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
12994-        put("KeyGenerator.2.16.840.1.101.3.4.22", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
12995-        put("KeyGenerator.2.16.840.1.101.3.4.42", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
12996-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
12997-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
12998-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
12999-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13000-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13001-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13002-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13003-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13004-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13005-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13006-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13007-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13008-        put("KeyGenerator.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen");
13009-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13010-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13011-        put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13012+        // BEGIN android-removed
13013+        // put("KeyGenerator.2.16.840.1.101.3.4.2", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13014+        // put("KeyGenerator.2.16.840.1.101.3.4.22", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13015+        // put("KeyGenerator.2.16.840.1.101.3.4.42", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13016+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13017+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13018+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13019+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13020+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13021+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13022+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13023+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13024+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13025+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13026+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13027+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13028+        // put("KeyGenerator.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen");
13029+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128");
13030+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192");
13031+        // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256");
13032+        // END android-removed
13033     }
13034 }
13035diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/x509/X509Util.java bcprov-jdk16-145/org/bouncycastle/x509/X509Util.java
13036--- bcprov-jdk16-145.orig/org/bouncycastle/x509/X509Util.java	2010-01-11 21:46:14.000000000 +0000
13037+++ bcprov-jdk16-145/org/bouncycastle/x509/X509Util.java	2011-09-03 18:19:15.000000000 +0000
13038@@ -43,8 +43,10 @@
13039
13040     static
13041     {
13042-        algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption);
13043-        algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption);
13044+        // BEGIN android-removed
13045+        // algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption);
13046+        // algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption);
13047+        // END android-removed
13048         algorithms.put("MD5WITHRSAENCRYPTION", PKCSObjectIdentifiers.md5WithRSAEncryption);
13049         algorithms.put("MD5WITHRSA", PKCSObjectIdentifiers.md5WithRSAEncryption);
13050         algorithms.put("SHA1WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha1WithRSAEncryption);
13051@@ -106,19 +108,29 @@
13052         //
13053         // explicit params
13054         //
13055-        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull());
13056+        // BEGIN android-changed
13057+        AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE);
13058+        // END android-changed
13059         params.put("SHA1WITHRSAANDMGF1", creatPSSParams(sha1AlgId, 20));
13060
13061-        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, new DERNull());
13062+        // BEGIN android-changed
13063+        AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE);
13064+        // END android-changed
13065         params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28));
13066
13067-        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, new DERNull());
13068+        // BEGIN android-changed
13069+        AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE);
13070+        // END android-changed
13071         params.put("SHA256WITHRSAANDMGF1", creatPSSParams(sha256AlgId, 32));
13072
13073-        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, new DERNull());
13074+        // BEGIN android-changed
13075+        AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE);
13076+        // END android-changed
13077         params.put("SHA384WITHRSAANDMGF1", creatPSSParams(sha384AlgId, 48));
13078
13079-        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, new DERNull());
13080+        // BEGIN android-changed
13081+        AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE);
13082+        // END android-changed
13083         params.put("SHA512WITHRSAANDMGF1", creatPSSParams(sha512AlgId, 64));
13084     }
13085
13086@@ -161,7 +173,9 @@
13087         }
13088         else
13089         {
13090-            return new AlgorithmIdentifier(sigOid, new DERNull());
13091+            // BEGIN android-changed
13092+            return new AlgorithmIdentifier(sigOid, DERNull.INSTANCE);
13093+            // END android-changed
13094         }
13095     }
13096
13097diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/x509/extension/X509ExtensionUtil.java bcprov-jdk16-145/org/bouncycastle/x509/extension/X509ExtensionUtil.java
13098--- bcprov-jdk16-145.orig/org/bouncycastle/x509/extension/X509ExtensionUtil.java	2010-01-11 21:46:14.000000000 +0000
13099+++ bcprov-jdk16-145/org/bouncycastle/x509/extension/X509ExtensionUtil.java	2011-09-03 18:19:15.000000000 +0000
13100@@ -62,7 +62,9 @@
13101             {
13102                 GeneralName genName = GeneralName.getInstance(it.nextElement());
13103                 List list = new ArrayList();
13104-                list.add(new Integer(genName.getTagNo()));
13105+                // BEGIN android-changed
13106+                list.add(Integer.valueOf(genName.getTagNo()));
13107+                // END android-changed
13108                 switch (genName.getTagNo())
13109                 {
13110                 case GeneralName.ediPartyName:
13111