| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Collection.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Collection.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Collection.java 1970-01-01 00:00:00.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Collection.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -0,0 +1,298 @@ |
| +package org.bouncycastle.asn1; |
| + |
| +import java.io.ByteArrayOutputStream; |
| +import java.io.IOException; |
| +import java.util.Enumeration; |
| +import java.util.ConcurrentModificationException; |
| + |
| +// BEGIN android-note |
| +/* |
| + * This is a new class that was synthesized from ASN1Sequence and |
| + * ASN1Set, but with extra smarts about efficiently storing its |
| + * elements. |
| + */ |
| +// END android-note |
| + |
| +/** |
| + * Base class for collection-like <code>DERObject</code>s. Instances |
| + * of this class will keep up to four elements directly, resorting to |
| + * an external collection only if more elements than that need to be |
| + * stored. |
| + */ |
| +public abstract class ASN1Collection |
| + extends ASN1Object |
| +{ |
| + /** >= 0; size of the collection */ |
| + private int size; |
| + |
| + /** null-ok; element #0 */ |
| + private DEREncodable obj0; |
| + |
| + /** null-ok; element #1 */ |
| + private DEREncodable obj1; |
| + |
| + /** null-ok; element #2 */ |
| + private DEREncodable obj2; |
| + |
| + /** null-ok; element #3 */ |
| + private DEREncodable obj3; |
| + |
| + /** null-ok; elements #4 and higher */ |
| + private DEREncodable[] rest; |
| + |
| + /** |
| + * Returns the object at the postion indicated by index. |
| + * |
| + * @param index the index (starting at zero) of the object |
| + * @return the object at the postion indicated by index |
| + */ |
| + public DEREncodable getObjectAt(int index) { |
| + if ((index < 0) || (index >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(index)); |
| + } |
| + |
| + switch (index) { |
| + case 0: return obj0; |
| + case 1: return obj1; |
| + case 2: return obj2; |
| + case 3: return obj3; |
| + default: return rest[index - 4]; |
| + } |
| + } |
| + |
| + /** |
| + * Returns the number of objects in this instance. |
| + * |
| + * @return the number of objects in this instance |
| + */ |
| + public int size() { |
| + return size; |
| + } |
| + |
| + /** {@inheritDoc} */ |
| + public final int hashCode() { |
| + Enumeration e = this.getObjects(); |
| + int hashCode = 0; |
| + |
| + while (e.hasMoreElements()) { |
| + Object o = e.nextElement(); |
| + |
| + if (o != null) { |
| + hashCode ^= o.hashCode(); |
| + } |
| + } |
| + |
| + return hashCode; |
| + } |
| + |
| + /** |
| + * Adds a new element to this instance. |
| + * |
| + * @param obj non-null; the instance to add |
| + */ |
| + protected void addObject(DEREncodable obj) { |
| + if (obj == null) { |
| + throw new NullPointerException("obj == null"); |
| + } |
| + |
| + int sz = size; |
| + |
| + switch (sz) { |
| + case 0: obj0 = obj; break; |
| + case 1: obj1 = obj; break; |
| + case 2: obj2 = obj; break; |
| + case 3: obj3 = obj; break; |
| + case 4: { |
| + // Initial allocation of rest. |
| + rest = new DEREncodable[5]; |
| + rest[0] = obj; |
| + break; |
| + } |
| + default: { |
| + int index = sz - 4; |
| + if (index >= rest.length) { |
| + // Grow rest. |
| + DEREncodable[] newRest = new DEREncodable[index * 2 + 10]; |
| + System.arraycopy(rest, 0, newRest, 0, rest.length); |
| + rest = newRest; |
| + } |
| + rest[index] = obj; |
| + break; |
| + } |
| + } |
| + |
| + size++; |
| + } |
| + |
| + /** |
| + * Sets the element at a given index (used by {@link #sort}). |
| + * |
| + * @param obj non-null; the object to set |
| + * @param index >= 0; the index |
| + */ |
| + private void setObjectAt(DEREncodable obj, int index) { |
| + switch (index) { |
| + case 0: obj0 = obj; break; |
| + case 1: obj1 = obj; break; |
| + case 2: obj2 = obj; break; |
| + case 3: obj3 = obj; break; |
| + default: { |
| + rest[index - 4] = obj; |
| + break; |
| + } |
| + } |
| + } |
| + |
| + /** |
| + * Encodes this instance to the given stream. |
| + * |
| + * @param out non-null; stream to encode to |
| + */ |
| + /*package*/ abstract void encode(DEROutputStream out) throws IOException; |
| + |
| + /** |
| + * Gets an enumeration of all the objects in this collection. |
| + * |
| + * @return non-null; the enumeration |
| + */ |
| + public Enumeration getObjects() { |
| + return new ASN1CollectionEnumeration(); |
| + } |
| + |
| + /** |
| + * Associated enumeration class. |
| + */ |
| + private class ASN1CollectionEnumeration implements Enumeration { |
| + /** original size; used for modification detection */ |
| + private final int origSize = size; |
| + |
| + /** >= 0; current cursor */ |
| + private int at = 0; |
| + |
| + /** {@inheritDoc} */ |
| + public boolean hasMoreElements() { |
| + if (size != origSize) { |
| + throw new ConcurrentModificationException(); |
| + } |
| + |
| + return at < origSize; |
| + } |
| + |
| + /** {@inheritDoc} */ |
| + public Object nextElement() { |
| + if (size != origSize) { |
| + throw new ConcurrentModificationException(); |
| + } |
| + |
| + switch (at++) { |
| + case 0: return obj0; |
| + case 1: return obj1; |
| + case 2: return obj2; |
| + case 3: return obj3; |
| + default: return rest[at - 5]; |
| + } |
| + } |
| + } |
| + |
| + /** |
| + * Sorts the elements in this instance. |
| + */ |
| + protected void sort() { |
| + if (size <= 1) { |
| + return; |
| + } |
| + |
| + boolean swapped = true; |
| + |
| + // TODO: This is bubble sort. Probably not the best choice. |
| + while (swapped) { |
| + int index = 0; |
| + byte[] a = getEncoded(getObjectAt(0)); |
| + |
| + swapped = false; |
| + |
| + while (index != size - 1) { |
| + int nextIndex = index + 1; |
| + byte[] b = getEncoded(getObjectAt(nextIndex)); |
| + |
| + if (lessThanOrEqual(a, b)) { |
| + a = b; |
| + } else { |
| + DEREncodable o = getObjectAt(index); |
| + |
| + setObjectAt(getObjectAt(nextIndex), index); |
| + setObjectAt(o, nextIndex); |
| + |
| + swapped = true; |
| + } |
| + |
| + index++; |
| + } |
| + } |
| + } |
| + |
| + /** |
| + * Returns true if a <= b (arrays are assumed padded with zeros). |
| + */ |
| + private static boolean lessThanOrEqual(byte[] a, byte[] b) { |
| + if (a.length <= b.length) { |
| + for (int i = 0; i != a.length; i++) { |
| + int l = a[i] & 0xff; |
| + int r = b[i] & 0xff; |
| + |
| + if (r > l) { |
| + return true; |
| + } else if (l > r) { |
| + return false; |
| + } |
| + } |
| + |
| + return true; |
| + } else { |
| + for (int i = 0; i != b.length; i++) { |
| + int l = a[i] & 0xff; |
| + int r = b[i] & 0xff; |
| + |
| + if (r > l) { |
| + return true; |
| + } else if (l > r) { |
| + return false; |
| + } |
| + } |
| + |
| + return false; |
| + } |
| + } |
| + |
| + /** |
| + * Gets the encoded form of an object. |
| + * |
| + * @param obj non-null; object to encode |
| + * @return non-null; the encoded form |
| + */ |
| + private static byte[] getEncoded(DEREncodable obj) { |
| + ByteArrayOutputStream bOut = new ByteArrayOutputStream(); |
| + ASN1OutputStream aOut = new ASN1OutputStream(bOut); |
| + |
| + try { |
| + aOut.writeObject(obj); |
| + } catch (IOException e) { |
| + throw new IllegalArgumentException( |
| + "cannot encode object added to collection"); |
| + } |
| + |
| + return bOut.toByteArray(); |
| + } |
| + |
| + /** {@inheritDoc} */ |
| + public final String toString() { |
| + StringBuilder sb = new StringBuilder(); |
| + sb.append('['); |
| + for (int i = 0; i < size; i++) { |
| + if (i != 0) sb.append(", "); |
| + sb.append(getObjectAt(i)); |
| + } |
| + sb.append(']'); |
| + return sb.toString(); |
| + } |
| +} |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1InputStream.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1InputStream.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1InputStream.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1InputStream.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -348,7 +348,9 @@ |
| case BMP_STRING: |
| return new DERBMPString(bytes); |
| case BOOLEAN: |
| - return new DERBoolean(bytes); |
| + // BEGIN android-changed |
| + return DERBoolean.getInstance(bytes); |
| + // END android-changed |
| case ENUMERATED: |
| return new DEREnumerated(bytes); |
| case GENERALIZED_TIME: |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Null.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Null.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Null.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Null.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -8,9 +8,11 @@ |
| public abstract class ASN1Null |
| extends ASN1Object |
| { |
| - public ASN1Null() |
| + // BEGIN android-changed |
| + /*package*/ ASN1Null() |
| { |
| } |
| + // END android-changed |
| |
| public int hashCode() |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Sequence.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Sequence.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Sequence.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Sequence.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -2,12 +2,20 @@ |
| |
| import java.io.IOException; |
| import java.util.Enumeration; |
| -import java.util.Vector; |
| +// BEGIN android-removed |
| +// import java.util.Vector; |
| +// END android-removed |
| + |
| +// BEGIN android-note |
| +// Changed inheritence of class. |
| +// END android-note |
| |
| public abstract class ASN1Sequence |
| - extends ASN1Object |
| + extends ASN1Collection |
| { |
| - private Vector seq = new Vector(); |
| + // BEGIN android-removed |
| + // private Vector seq = new Vector(); |
| + // END android-removed |
| |
| /** |
| * return an ASN1Sequence from the given object. |
| @@ -85,10 +93,12 @@ |
| throw new IllegalArgumentException("unknown object in getInstance: " + obj.getClass().getName()); |
| } |
| |
| - public Enumeration getObjects() |
| - { |
| - return seq.elements(); |
| - } |
| + // BEGIN android-removed |
| + // public Enumeration getObjects() |
| + // { |
| + // return seq.elements(); |
| + // } |
| + // END android-removed |
| |
| public ASN1SequenceParser parser() |
| { |
| @@ -127,45 +137,47 @@ |
| }; |
| } |
| |
| - /** |
| - * return the object at the sequence position indicated by index. |
| - * |
| - * @param index the sequence number (starting at zero) of the object |
| - * @return the object at the sequence position indicated by index. |
| - */ |
| - public DEREncodable getObjectAt( |
| - int index) |
| - { |
| - return (DEREncodable)seq.elementAt(index); |
| - } |
| - |
| - /** |
| - * return the number of objects in this sequence. |
| - * |
| - * @return the number of objects in this sequence. |
| - */ |
| - public int size() |
| - { |
| - return seq.size(); |
| - } |
| - |
| - public int hashCode() |
| - { |
| - Enumeration e = this.getObjects(); |
| - int hashCode = size(); |
| - |
| - while (e.hasMoreElements()) |
| - { |
| - Object o = e.nextElement(); |
| - hashCode *= 17; |
| - if (o != null) |
| - { |
| - hashCode ^= o.hashCode(); |
| - } |
| - } |
| - |
| - return hashCode; |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * return the object at the sequence position indicated by index. |
| + // * |
| + // * @param index the sequence number (starting at zero) of the object |
| + // * @return the object at the sequence position indicated by index. |
| + // */ |
| + // public DEREncodable getObjectAt( |
| + // int index) |
| + // { |
| + // return (DEREncodable)seq.elementAt(index); |
| + // } |
| + // |
| + // /** |
| + // * return the number of objects in this sequence. |
| + // * |
| + // * @return the number of objects in this sequence. |
| + // */ |
| + // public int size() |
| + // { |
| + // return seq.size(); |
| + // } |
| + // |
| + // public int hashCode() |
| + // { |
| + // Enumeration e = this.getObjects(); |
| + // int hashCode = size(); |
| + // |
| + // while (e.hasMoreElements()) |
| + // { |
| + // Object o = e.nextElement(); |
| + // hashCode *= 17; |
| + // if (o != null) |
| + // { |
| + // hashCode ^= o.hashCode(); |
| + // } |
| + // } |
| + // |
| + // return hashCode; |
| + // } |
| + // END android-removed |
| |
| boolean asn1Equals( |
| DERObject o) |
| @@ -201,17 +213,19 @@ |
| return true; |
| } |
| |
| - protected void addObject( |
| - DEREncodable obj) |
| - { |
| - seq.addElement(obj); |
| - } |
| - |
| - abstract void encode(DEROutputStream out) |
| - throws IOException; |
| - |
| - public String toString() |
| - { |
| - return seq.toString(); |
| - } |
| + // BEGIN android-removed |
| + //protected void addObject( |
| + // DEREncodable obj) |
| + //{ |
| + // seq.addElement(obj); |
| + //} |
| + |
| + //abstract void encode(DEROutputStream out) |
| + // throws IOException; |
| + |
| + //public String toString() |
| + //{ |
| + // return seq.toString(); |
| + //} |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Set.java bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Set.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/ASN1Set.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/ASN1Set.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -3,12 +3,20 @@ |
| import java.io.ByteArrayOutputStream; |
| import java.io.IOException; |
| import java.util.Enumeration; |
| -import java.util.Vector; |
| +// BEGIN android-removed |
| +// import java.util.Vector; |
| +// END android-removed |
| + |
| +// BEGIN android-note |
| +// Changed inheritence of class. |
| +// END android-note |
| |
| abstract public class ASN1Set |
| - extends ASN1Object |
| + extends ASN1Collection |
| { |
| - protected Vector set = new Vector(); |
| + // BEGIN android-removed |
| + // protected Vector set = new Vector(); |
| + // END android-removed |
| |
| /** |
| * return an ASN1Set from the given object. |
| @@ -104,32 +112,34 @@ |
| { |
| } |
| |
| - public Enumeration getObjects() |
| - { |
| - return set.elements(); |
| - } |
| - |
| - /** |
| - * return the object at the set position indicated by index. |
| - * |
| - * @param index the set number (starting at zero) of the object |
| - * @return the object at the set position indicated by index. |
| - */ |
| - public DEREncodable getObjectAt( |
| - int index) |
| - { |
| - return (DEREncodable)set.elementAt(index); |
| - } |
| - |
| - /** |
| - * return the number of objects in this set. |
| - * |
| - * @return the number of objects in this set. |
| - */ |
| - public int size() |
| - { |
| - return set.size(); |
| - } |
| + // BEGIN android-removed |
| + // public Enumeration getObjects() |
| + // { |
| + // return set.elements(); |
| + // } |
| + // |
| + // /** |
| + // * return the object at the set position indicated by index. |
| + // * |
| + // * @param index the set number (starting at zero) of the object |
| + // * @return the object at the set position indicated by index. |
| + // */ |
| + // public DEREncodable getObjectAt( |
| + // int index) |
| + // { |
| + // return (DEREncodable)set.elementAt(index); |
| + // } |
| + // |
| + // /** |
| + // * return the number of objects in this set. |
| + // * |
| + // * @return the number of objects in this set. |
| + // */ |
| + // public int size() |
| + // { |
| + // return set.size(); |
| + // } |
| + // END android-removed |
| |
| public ASN1SetParser parser() |
| { |
| @@ -168,23 +178,25 @@ |
| }; |
| } |
| |
| - public int hashCode() |
| - { |
| - Enumeration e = this.getObjects(); |
| - int hashCode = size(); |
| - |
| - while (e.hasMoreElements()) |
| - { |
| - Object o = e.nextElement(); |
| - hashCode *= 17; |
| - if (o != null) |
| - { |
| - hashCode ^= o.hashCode(); |
| - } |
| - } |
| - |
| - return hashCode; |
| - } |
| + // BEGIN android-removed |
| + // public int hashCode() |
| + // { |
| + // Enumeration e = this.getObjects(); |
| + // int hashCode = size(); |
| + // |
| + // while (e.hasMoreElements()) |
| + // { |
| + // Object o = e.nextElement(); |
| + // hashCode *= 17; |
| + // if (o != null) |
| + // { |
| + // hashCode ^= o.hashCode(); |
| + // } |
| + // } |
| + // |
| + // return hashCode; |
| + // } |
| + // END android-removed |
| |
| boolean asn1Equals( |
| DERObject o) |
| @@ -220,52 +232,54 @@ |
| return true; |
| } |
| |
| - /** |
| - * return true if a <= b (arrays are assumed padded with zeros). |
| - */ |
| - private boolean lessThanOrEqual( |
| - byte[] a, |
| - byte[] b) |
| - { |
| - if (a.length <= b.length) |
| - { |
| - for (int i = 0; i != a.length; i++) |
| - { |
| - int l = a[i] & 0xff; |
| - int r = b[i] & 0xff; |
| - |
| - if (r > l) |
| - { |
| - return true; |
| - } |
| - else if (l > r) |
| - { |
| - return false; |
| - } |
| - } |
| - |
| - return true; |
| - } |
| - else |
| - { |
| - for (int i = 0; i != b.length; i++) |
| - { |
| - int l = a[i] & 0xff; |
| - int r = b[i] & 0xff; |
| - |
| - if (r > l) |
| - { |
| - return true; |
| - } |
| - else if (l > r) |
| - { |
| - return false; |
| - } |
| - } |
| - |
| - return false; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * return true if a <= b (arrays are assumed padded with zeros). |
| + // */ |
| + // private boolean lessThanOrEqual( |
| + // byte[] a, |
| + // byte[] b) |
| + // { |
| + // if (a.length <= b.length) |
| + // { |
| + // for (int i = 0; i != a.length; i++) |
| + // { |
| + // int l = a[i] & 0xff; |
| + // int r = b[i] & 0xff; |
| + // |
| + // if (r > l) |
| + // { |
| + // return true; |
| + // } |
| + // else if (l > r) |
| + // { |
| + // return false; |
| + // } |
| + // } |
| + // |
| + // return true; |
| + // } |
| + // else |
| + // { |
| + // for (int i = 0; i != b.length; i++) |
| + // { |
| + // int l = a[i] & 0xff; |
| + // int r = b[i] & 0xff; |
| + // |
| + // if (r > l) |
| + // { |
| + // return true; |
| + // } |
| + // else if (l > r) |
| + // { |
| + // return false; |
| + // } |
| + // } |
| + // |
| + // return false; |
| + // } |
| + // } |
| + // END android-removed |
| |
| private byte[] getEncoded( |
| DEREncodable obj) |
| @@ -285,59 +299,61 @@ |
| return bOut.toByteArray(); |
| } |
| |
| - protected void sort() |
| - { |
| - if (set.size() > 1) |
| - { |
| - boolean swapped = true; |
| - int lastSwap = set.size() - 1; |
| - |
| - while (swapped) |
| - { |
| - int index = 0; |
| - int swapIndex = 0; |
| - byte[] a = getEncoded((DEREncodable)set.elementAt(0)); |
| - |
| - swapped = false; |
| - |
| - while (index != lastSwap) |
| - { |
| - byte[] b = getEncoded((DEREncodable)set.elementAt(index + 1)); |
| - |
| - if (lessThanOrEqual(a, b)) |
| - { |
| - a = b; |
| - } |
| - else |
| - { |
| - Object o = set.elementAt(index); |
| - |
| - set.setElementAt(set.elementAt(index + 1), index); |
| - set.setElementAt(o, index + 1); |
| - |
| - swapped = true; |
| - swapIndex = index; |
| - } |
| - |
| - index++; |
| - } |
| - |
| - lastSwap = swapIndex; |
| - } |
| - } |
| - } |
| - |
| - protected void addObject( |
| - DEREncodable obj) |
| - { |
| - set.addElement(obj); |
| - } |
| - |
| - abstract void encode(DEROutputStream out) |
| - throws IOException; |
| - |
| - public String toString() |
| - { |
| - return set.toString(); |
| - } |
| + // BEGIN android-removed |
| + // protected void sort() |
| + // { |
| + // if (set.size() > 1) |
| + // { |
| + // boolean swapped = true; |
| + // int lastSwap = set.size() - 1; |
| + // |
| + // while (swapped) |
| + // { |
| + // int index = 0; |
| + // int swapIndex = 0; |
| + // byte[] a = getEncoded((DEREncodable)set.elementAt(0)); |
| + // |
| + // swapped = false; |
| + // |
| + // while (index != lastSwap) |
| + // { |
| + // byte[] b = getEncoded((DEREncodable)set.elementAt(index + 1)); |
| + // |
| + // if (lessThanOrEqual(a, b)) |
| + // { |
| + // a = b; |
| + // } |
| + // else |
| + // { |
| + // Object o = set.elementAt(index); |
| + // |
| + // set.setElementAt(set.elementAt(index + 1), index); |
| + // set.setElementAt(o, index + 1); |
| + // |
| + // swapped = true; |
| + // swapIndex = index; |
| + // } |
| + // |
| + // index++; |
| + // } |
| + // |
| + // lastSwap = swapIndex; |
| + // } |
| + // } |
| + // } |
| + // |
| + // protected void addObject( |
| + // DEREncodable obj) |
| + // { |
| + // set.addElement(obj); |
| + // } |
| + // |
| + // abstract void encode(DEROutputStream out) |
| + // throws IOException; |
| + // |
| + // public String toString() |
| + // { |
| + // return set.toString(); |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERBoolean.java bcprov-jdk16-145/org/bouncycastle/asn1/DERBoolean.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERBoolean.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/DERBoolean.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -5,7 +5,9 @@ |
| public class DERBoolean |
| extends ASN1Object |
| { |
| - byte value; |
| + // BEGIN android-changed |
| + private final byte value; |
| + // END android-changed |
| |
| public static final DERBoolean FALSE = new DERBoolean(false); |
| public static final DERBoolean TRUE = new DERBoolean(true); |
| @@ -25,7 +27,9 @@ |
| |
| if (obj instanceof ASN1OctetString) |
| { |
| - return new DERBoolean(((ASN1OctetString)obj).getOctets()); |
| + // BEGIN android-changed |
| + return getInstance(((ASN1OctetString)obj).getOctets()); |
| + // END android-changed |
| } |
| |
| if (obj instanceof ASN1TaggedObject) |
| @@ -45,6 +49,17 @@ |
| return (value ? TRUE : FALSE); |
| } |
| |
| + // BEGIN android-added |
| + /** |
| + * return a DERBoolean from the passed in array. |
| + */ |
| + public static DERBoolean getInstance( |
| + byte[] octets) |
| + { |
| + return (octets[0] != 0) ? TRUE : FALSE; |
| + } |
| + // END android-added |
| + |
| /** |
| * return a Boolean from a tagged object. |
| * |
| @@ -60,18 +75,22 @@ |
| { |
| return getInstance(obj.getObject()); |
| } |
| - |
| - public DERBoolean( |
| - byte[] value) |
| - { |
| - this.value = value[0]; |
| - } |
| |
| - public DERBoolean( |
| + // BEGIN android-removed |
| + //private DERBoolean( |
| + // byte[] value) |
| + //{ |
| + // this.value = value[0]; |
| + //} |
| + // END android-removed |
| + |
| + // BEGIN android-changed |
| + private DERBoolean( |
| boolean value) |
| { |
| this.value = (value) ? (byte)0xff : (byte)0; |
| } |
| + // END android-changed |
| |
| public boolean isTrue() |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERInputStream.java bcprov-jdk16-145/org/bouncycastle/asn1/DERInputStream.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERInputStream.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/DERInputStream.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -144,7 +144,9 @@ |
| return new DERConstructedSet(v); |
| } |
| case BOOLEAN: |
| - return new DERBoolean(bytes); |
| + // BEGIN android-changed |
| + return DERBoolean.getInstance(bytes); |
| + // BEGIN android-changed |
| case INTEGER: |
| return new DERInteger(bytes); |
| case ENUMERATED: |
| @@ -195,7 +197,9 @@ |
| { |
| if ((tag & CONSTRUCTED) == 0) |
| { |
| - return new DERTaggedObject(false, tag & 0x1f, new DERNull()); |
| + // BEGIN android-changed |
| + return new DERTaggedObject(false, tag & 0x1f, DERNull.INSTANCE); |
| + // END android-changed |
| } |
| else |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERNull.java bcprov-jdk16-145/org/bouncycastle/asn1/DERNull.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERNull.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/DERNull.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -10,9 +10,13 @@ |
| { |
| public static final DERNull INSTANCE = new DERNull(); |
| |
| - byte[] zeroBytes = new byte[0]; |
| + // BEGIN android-changed |
| + private static final byte[] zeroBytes = new byte[0]; |
| + // END android-changed |
| |
| - public DERNull() |
| + // BEGIN android-changed |
| + protected DERNull() |
| + // END android-changed |
| { |
| } |
| |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERObjectIdentifier.java bcprov-jdk16-145/org/bouncycastle/asn1/DERObjectIdentifier.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERObjectIdentifier.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/DERObjectIdentifier.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -111,7 +111,13 @@ |
| } |
| } |
| |
| - this.identifier = objId.toString(); |
| + // BEGIN android-changed |
| + /* |
| + * Intern the identifier so there aren't hundreds of duplicates |
| + * (in practice). |
| + */ |
| + this.identifier = objId.toString().intern(); |
| + // END android-changed |
| } |
| |
| public DERObjectIdentifier( |
| @@ -122,7 +128,13 @@ |
| throw new IllegalArgumentException("string " + identifier + " not an OID"); |
| } |
| |
| - this.identifier = identifier; |
| + // BEGIN android-changed |
| + /* |
| + * Intern the identifier so there aren't hundreds of duplicates |
| + * (in practice). |
| + */ |
| + this.identifier = identifier.intern(); |
| + // END android-changed |
| } |
| |
| public String getId() |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERPrintableString.java bcprov-jdk16-145/org/bouncycastle/asn1/DERPrintableString.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/DERPrintableString.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/DERPrintableString.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -9,7 +9,9 @@ |
| extends ASN1Object |
| implements DERString |
| { |
| - String string; |
| + // BEGIN android-changed |
| + private final String string; |
| + // END android-changed |
| |
| /** |
| * return a printable string from the passed in object. |
| @@ -66,7 +68,9 @@ |
| cs[i] = (char)(string[i] & 0xff); |
| } |
| |
| - this.string = new String(cs); |
| + // BEGIN android-changed |
| + this.string = new String(cs).intern(); |
| + // END android-changed |
| } |
| |
| /** |
| @@ -95,7 +99,9 @@ |
| throw new IllegalArgumentException("string contains illegal characters"); |
| } |
| |
| - this.string = string; |
| + // BEGIN android-changed |
| + this.string = string.intern(); |
| + // END android-changed |
| } |
| |
| public String getString() |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/OrderedTable.java bcprov-jdk16-145/org/bouncycastle/asn1/OrderedTable.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/OrderedTable.java 1970-01-01 00:00:00.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/OrderedTable.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -0,0 +1,281 @@ |
| +package org.bouncycastle.asn1; |
| + |
| +import java.util.Enumeration; |
| +import java.util.ConcurrentModificationException; |
| + |
| +// BEGIN android-note |
| +/* |
| + * This is a new class that was synthesized from the observed |
| + * requirement for a lookup table that preserves order. Since in |
| + * practice the element count is typically very low, we just use a |
| + * flat list rather than doing any hashing / bucketing. |
| + */ |
| +// END android-note |
| + |
| +/** |
| + * Ordered lookup table. Instances of this class will keep up to four |
| + * key-value pairs directly, resorting to an external collection only |
| + * if more elements than that need to be stored. |
| + */ |
| +public final class OrderedTable { |
| + /** null-ok; key #0 */ |
| + private DERObjectIdentifier key0; |
| + |
| + /** null-ok; key #1 */ |
| + private DERObjectIdentifier key1; |
| + |
| + /** null-ok; key #2 */ |
| + private DERObjectIdentifier key2; |
| + |
| + /** null-ok; key #3 */ |
| + private DERObjectIdentifier key3; |
| + |
| + /** null-ok; value #0 */ |
| + private Object value0; |
| + |
| + /** null-ok; value #1 */ |
| + private Object value1; |
| + |
| + /** null-ok; value #2 */ |
| + private Object value2; |
| + |
| + /** null-ok; value #3 */ |
| + private Object value3; |
| + |
| + /** |
| + * null-ok; array of additional keys and values, alternating |
| + * key then value, etc. |
| + */ |
| + private Object[] rest; |
| + |
| + /** >= 0; number of elements in the list */ |
| + private int size; |
| + |
| + // Note: Default public constructor. |
| + |
| + /** |
| + * Adds an element assuming no duplicate key. |
| + * |
| + * @see #put |
| + * |
| + * @param key non-null; the key |
| + * @param value non-null; the value |
| + */ |
| + public void add(DERObjectIdentifier key, Object value) { |
| + if (key == null) { |
| + throw new NullPointerException("key == null"); |
| + } |
| + |
| + if (value == null) { |
| + throw new NullPointerException("value == null"); |
| + } |
| + |
| + int sz = size; |
| + |
| + switch (sz) { |
| + case 0: { |
| + key0 = key; |
| + value0 = value; |
| + break; |
| + } |
| + case 1: { |
| + key1 = key; |
| + value1 = value; |
| + break; |
| + } |
| + case 2: { |
| + key2 = key; |
| + value2 = value; |
| + break; |
| + } |
| + case 3: { |
| + key3 = key; |
| + value3 = value; |
| + break; |
| + } |
| + case 4: { |
| + // Do initial allocation of rest. |
| + rest = new Object[10]; |
| + rest[0] = key; |
| + rest[1] = value; |
| + break; |
| + } |
| + default: { |
| + int index = (sz - 4) * 2; |
| + int index1 = index + 1; |
| + if (index1 >= rest.length) { |
| + // Grow rest. |
| + Object[] newRest = new Object[index1 * 2 + 10]; |
| + System.arraycopy(rest, 0, newRest, 0, rest.length); |
| + rest = newRest; |
| + } |
| + rest[index] = key; |
| + rest[index1] = value; |
| + break; |
| + } |
| + } |
| + |
| + size = sz + 1; |
| + } |
| + |
| + /** |
| + * Gets the number of elements in this instance. |
| + */ |
| + public int size() { |
| + return size; |
| + } |
| + |
| + /** |
| + * Look up the given key, returning the associated value if found. |
| + * |
| + * @param key non-null; the key to look up |
| + * @return null-ok; the associated value |
| + */ |
| + public Object get(DERObjectIdentifier key) { |
| + int keyHash = key.hashCode(); |
| + int sz = size; |
| + |
| + for (int i = 0; i < size; i++) { |
| + DERObjectIdentifier probe = getKey(i); |
| + if ((probe.hashCode() == keyHash) && |
| + probe.equals(key)) { |
| + return getValue(i); |
| + } |
| + } |
| + |
| + return null; |
| + } |
| + |
| + /** |
| + * Replace a key if present, otherwise add |
| + * |
| + * @see #add |
| + * |
| + * @param key non-null; the key |
| + * @param value non-null; the value |
| + */ |
| + public void put(DERObjectIdentifier key, Object value) { |
| + if (key == null) { |
| + throw new NullPointerException("key == null"); |
| + } |
| + |
| + if (value == null) { |
| + throw new NullPointerException("value == null"); |
| + } |
| + |
| + int keyHash = key.hashCode(); |
| + int sz = size; |
| + |
| + for (int i = 0; i < size; i++) { |
| + DERObjectIdentifier probe = getKey(i); |
| + if ((probe.hashCode() == keyHash) && |
| + probe.equals(key)) { |
| + setValue(i, value); |
| + return; |
| + } |
| + } |
| + |
| + add(key, value); |
| + } |
| + |
| + /** |
| + * Gets the nth key. |
| + * |
| + * @param n index |
| + * @return non-null; the nth key |
| + */ |
| + public DERObjectIdentifier getKey(int n) { |
| + if ((n < 0) || (n >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(n)); |
| + } |
| + |
| + switch (n) { |
| + case 0: return key0; |
| + case 1: return key1; |
| + case 2: return key2; |
| + case 3: return key3; |
| + default: return (DERObjectIdentifier) rest[(n - 4) * 2]; |
| + } |
| + } |
| + |
| + /** |
| + * Gets the nth value. |
| + * |
| + * @param n index |
| + * @return non-null; the nth value |
| + */ |
| + public Object getValue(int n) { |
| + if ((n < 0) || (n >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(n)); |
| + } |
| + |
| + switch (n) { |
| + case 0: return value0; |
| + case 1: return value1; |
| + case 2: return value2; |
| + case 3: return value3; |
| + default: return rest[((n - 4) * 2) + 1]; |
| + } |
| + } |
| + |
| + /** |
| + * Sets the nth value. |
| + * |
| + * @param n index |
| + * @param value non-null object |
| + */ |
| + public void setValue(int n, Object value) { |
| + if ((n < 0) || (n >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(n)); |
| + } |
| + if (value == null) { |
| + throw new NullPointerException("value == null"); |
| + } |
| + |
| + switch (n) { |
| + case 0: value0 = value; return; |
| + case 1: value1 = value; return; |
| + case 2: value2 = value; return; |
| + case 3: value3 = value; return; |
| + default: rest[((n - 4) * 2) + 1] = value; return; |
| + } |
| + } |
| + |
| + /** |
| + * Gets an enumeration of the keys, in order. |
| + * |
| + * @return non-null; an enumeration of the keys |
| + */ |
| + public Enumeration getKeys() { |
| + return new KeyEnumeration(); |
| + } |
| + |
| + /** |
| + * Associated enumeration class. |
| + */ |
| + private class KeyEnumeration implements Enumeration { |
| + /** original size; used for modification detection */ |
| + private final int origSize = size; |
| + |
| + /** >= 0; current cursor */ |
| + private int at = 0; |
| + |
| + /** {@inheritDoc} */ |
| + public boolean hasMoreElements() { |
| + if (size != origSize) { |
| + throw new ConcurrentModificationException(); |
| + } |
| + |
| + return at < origSize; |
| + } |
| + |
| + /** {@inheritDoc} */ |
| + public Object nextElement() { |
| + if (size != origSize) { |
| + throw new ConcurrentModificationException(); |
| + } |
| + |
| + return getKey(at++); |
| + } |
| + } |
| +} |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/EncryptedPrivateKeyInfo.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -37,10 +37,13 @@ |
| public static EncryptedPrivateKeyInfo getInstance( |
| Object obj) |
| { |
| - if (obj instanceof EncryptedData) |
| + // BEGIN android-changed |
| + // fix copy and paste error in instanceof call |
| + if (obj instanceof EncryptedPrivateKeyInfo) |
| { |
| return (EncryptedPrivateKeyInfo)obj; |
| } |
| + // END android-changed |
| else if (obj instanceof ASN1Sequence) |
| { |
| return new EncryptedPrivateKeyInfo((ASN1Sequence)obj); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/PKCSObjectIdentifiers.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -10,7 +10,10 @@ |
| // |
| static final String pkcs_1 = "1.2.840.113549.1.1"; |
| static final DERObjectIdentifier rsaEncryption = new DERObjectIdentifier(pkcs_1 + ".1"); |
| - static final DERObjectIdentifier md2WithRSAEncryption = new DERObjectIdentifier(pkcs_1 + ".2"); |
| + // BEGIN android-removed |
| + // Dropping MD2 |
| + // static final DERObjectIdentifier md2WithRSAEncryption = new DERObjectIdentifier(pkcs_1 + ".2"); |
| + // END android-removed |
| static final DERObjectIdentifier md4WithRSAEncryption = new DERObjectIdentifier(pkcs_1 + ".3"); |
| static final DERObjectIdentifier md5WithRSAEncryption = new DERObjectIdentifier(pkcs_1 + ".4"); |
| static final DERObjectIdentifier sha1WithRSAEncryption = new DERObjectIdentifier(pkcs_1 + ".5"); |
| @@ -65,7 +68,10 @@ |
| // md2 OBJECT IDENTIFIER ::= |
| // {iso(1) member-body(2) US(840) rsadsi(113549) digestAlgorithm(2) 2} |
| // |
| - static final DERObjectIdentifier md2 = new DERObjectIdentifier(digestAlgorithm + ".2"); |
| + // BEGIN android-removed |
| + // Dropping MD2 |
| + // static final DERObjectIdentifier md2 = new DERObjectIdentifier(digestAlgorithm + ".2"); |
| + // END android-removed |
| |
| // |
| // md4 OBJECT IDENTIFIER ::= |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSAESOAEPparams.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -19,7 +19,9 @@ |
| private AlgorithmIdentifier maskGenAlgorithm; |
| private AlgorithmIdentifier pSourceAlgorithm; |
| |
| - public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull()); |
| + // BEGIN android-changed |
| + public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE); |
| + // END android-changed |
| public final static AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, DEFAULT_HASH_ALGORITHM); |
| public final static AlgorithmIdentifier DEFAULT_P_SOURCE_ALGORITHM = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(new byte[0])); |
| |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/pkcs/RSASSAPSSparams.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -20,7 +20,9 @@ |
| private DERInteger saltLength; |
| private DERInteger trailerField; |
| |
| - public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull()); |
| + // BEGIN android-changed |
| + public final static AlgorithmIdentifier DEFAULT_HASH_ALGORITHM = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE); |
| + // END android-changed |
| public final static AlgorithmIdentifier DEFAULT_MASK_GEN_FUNCTION = new AlgorithmIdentifier(PKCSObjectIdentifiers.id_mgf1, DEFAULT_HASH_ALGORITHM); |
| public final static DERInteger DEFAULT_SALT_LENGTH = new DERInteger(20); |
| public final static DERInteger DEFAULT_TRAILER_FIELD = new DERInteger(1); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/util/ASN1Dump.java bcprov-jdk16-145/org/bouncycastle/asn1/util/ASN1Dump.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/util/ASN1Dump.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/util/ASN1Dump.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -90,7 +90,9 @@ |
| { |
| Object o = e.nextElement(); |
| |
| - if (o == null || o.equals(new DERNull())) |
| + // BEGIN android-changed |
| + if (o == null || o.equals(DERNull.INSTANCE)) |
| + // END android-changed |
| { |
| buf.append(tab); |
| buf.append("NULL"); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/AttCertIssuer.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/AttCertIssuer.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/AttCertIssuer.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/AttCertIssuer.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -45,7 +45,7 @@ |
| ASN1TaggedObject obj, |
| boolean explicit) |
| { |
| - return getInstance(obj.getObject()); // must be explictly tagged |
| + return getInstance(obj.getObject()); // must be explicitly tagged |
| } |
| |
| /** |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/BasicConstraints.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/BasicConstraints.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/BasicConstraints.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/BasicConstraints.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -14,7 +14,9 @@ |
| public class BasicConstraints |
| extends ASN1Encodable |
| { |
| - DERBoolean cA = new DERBoolean(false); |
| + // BEGIN android-changed |
| + DERBoolean cA = DERBoolean.FALSE; |
| + // END android-changed |
| DERInteger pathLenConstraint = null; |
| |
| public static BasicConstraints getInstance( |
| @@ -89,7 +91,9 @@ |
| { |
| if (cA) |
| { |
| - this.cA = new DERBoolean(cA); |
| + // BEGIN android-changed |
| + this.cA = DERBoolean.getInstance(cA); |
| + // END android-changed |
| this.pathLenConstraint = new DERInteger(pathLenConstraint); |
| } |
| else |
| @@ -104,7 +108,9 @@ |
| { |
| if (cA) |
| { |
| - this.cA = new DERBoolean(true); |
| + // BEGIN android-changed |
| + this.cA = DERBoolean.TRUE; |
| + // END android-changed |
| } |
| else |
| { |
| @@ -121,7 +127,9 @@ |
| public BasicConstraints( |
| int pathLenConstraint) |
| { |
| - this.cA = new DERBoolean(true); |
| + // BEGIN android-changed |
| + this.cA = DERBoolean.TRUE; |
| + // END android-changed |
| this.pathLenConstraint = new DERInteger(pathLenConstraint); |
| } |
| |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/IssuingDistributionPoint.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -96,11 +96,15 @@ |
| } |
| if (onlyContainsUserCerts) |
| { |
| - vec.add(new DERTaggedObject(false, 1, new DERBoolean(true))); |
| + // BEGIN android-changed |
| + vec.add(new DERTaggedObject(false, 1, DERBoolean.TRUE)); |
| + // END android-changed |
| } |
| if (onlyContainsCACerts) |
| { |
| - vec.add(new DERTaggedObject(false, 2, new DERBoolean(true))); |
| + // BEGIN android-changed |
| + vec.add(new DERTaggedObject(false, 2, DERBoolean.TRUE)); |
| + // END android-changed |
| } |
| if (onlySomeReasons != null) |
| { |
| @@ -108,11 +112,15 @@ |
| } |
| if (indirectCRL) |
| { |
| - vec.add(new DERTaggedObject(false, 4, new DERBoolean(true))); |
| + // BEGIN android-changed |
| + vec.add(new DERTaggedObject(false, 4, DERBoolean.TRUE)); |
| + // END android-changed |
| } |
| if (onlyContainsAttributeCerts) |
| { |
| - vec.add(new DERTaggedObject(false, 5, new DERBoolean(true))); |
| + // BEGIN android-changed |
| + vec.add(new DERTaggedObject(false, 5, DERBoolean.TRUE)); |
| + // END android-changed |
| } |
| |
| seq = new DERSequence(vec); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Extensions.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Extensions.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Extensions.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Extensions.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -9,6 +9,9 @@ |
| import org.bouncycastle.asn1.DERObject; |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.DERSequence; |
| +// BEGIN android-added |
| +import org.bouncycastle.asn1.OrderedTable; |
| +// END android-added |
| |
| import java.util.Enumeration; |
| import java.util.Hashtable; |
| @@ -172,8 +175,9 @@ |
| */ |
| public static final DERObjectIdentifier TargetInformation = new DERObjectIdentifier("2.5.29.55"); |
| |
| - private Hashtable extensions = new Hashtable(); |
| - private Vector ordering = new Vector(); |
| + // BEGIN android-changed |
| + private OrderedTable table = new OrderedTable(); |
| + // END android-changed |
| |
| public static X509Extensions getInstance( |
| ASN1TaggedObject obj, |
| @@ -217,20 +221,26 @@ |
| { |
| ASN1Sequence s = ASN1Sequence.getInstance(e.nextElement()); |
| |
| - if (s.size() == 3) |
| + // BEGIN android-changed |
| + int sSize = s.size(); |
| + DERObjectIdentifier key = (DERObjectIdentifier) s.getObjectAt(0); |
| + Object value; |
| + |
| + if (sSize == 3) |
| { |
| - extensions.put(s.getObjectAt(0), new X509Extension(DERBoolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2)))); |
| + value = new X509Extension(DERBoolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))); |
| } |
| - else if (s.size() == 2) |
| + else if (sSize == 2) |
| { |
| - extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1)))); |
| + value = new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))); |
| } |
| else |
| { |
| - throw new IllegalArgumentException("Bad sequence size: " + s.size()); |
| + throw new IllegalArgumentException("Bad sequence size: " + sSize); |
| } |
| |
| - ordering.addElement(s.getObjectAt(0)); |
| + table.add(key, value); |
| + // END android-changed |
| } |
| } |
| |
| @@ -265,20 +275,14 @@ |
| e = ordering.elements(); |
| } |
| |
| - while (e.hasMoreElements()) |
| - { |
| - this.ordering.addElement(e.nextElement()); |
| - } |
| - |
| - e = this.ordering.elements(); |
| - |
| + // BEGIN android-changed |
| while (e.hasMoreElements()) |
| { |
| DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement(); |
| X509Extension ext = (X509Extension)extensions.get(oid); |
| - |
| - this.extensions.put(oid, ext); |
| + table.add(oid, ext); |
| } |
| + // END android-changed |
| } |
| |
| /** |
| @@ -293,23 +297,18 @@ |
| { |
| Enumeration e = objectIDs.elements(); |
| |
| - while (e.hasMoreElements()) |
| - { |
| - this.ordering.addElement(e.nextElement()); |
| - } |
| - |
| + // BEGIN android-changed |
| int count = 0; |
| |
| - e = this.ordering.elements(); |
| - |
| while (e.hasMoreElements()) |
| { |
| DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement(); |
| X509Extension ext = (X509Extension)values.elementAt(count); |
| |
| - this.extensions.put(oid, ext); |
| + table.add(oid, ext); |
| count++; |
| } |
| + // END android-changed |
| } |
| |
| /** |
| @@ -317,7 +316,9 @@ |
| */ |
| public Enumeration oids() |
| { |
| - return ordering.elements(); |
| + // BEGIN android-changed |
| + return table.getKeys(); |
| + // END android-changed |
| } |
| |
| /** |
| @@ -329,7 +330,9 @@ |
| public X509Extension getExtension( |
| DERObjectIdentifier oid) |
| { |
| - return (X509Extension)extensions.get(oid); |
| + // BEGIN android-changed |
| + return (X509Extension)table.get(oid); |
| + // END android-changed |
| } |
| |
| /** |
| @@ -345,19 +348,23 @@ |
| public DERObject toASN1Object() |
| { |
| ASN1EncodableVector vec = new ASN1EncodableVector(); |
| - Enumeration e = ordering.elements(); |
| + // BEGIN android-changed |
| + int size = table.size(); |
| |
| - while (e.hasMoreElements()) |
| + for (int i = 0; i < size; i++) |
| { |
| - DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement(); |
| - X509Extension ext = (X509Extension)extensions.get(oid); |
| + DERObjectIdentifier oid = table.getKey(i); |
| + X509Extension ext = (X509Extension)table.getValue(i); |
| + // END android-changed |
| ASN1EncodableVector v = new ASN1EncodableVector(); |
| |
| v.add(oid); |
| |
| if (ext.isCritical()) |
| { |
| - v.add(new DERBoolean(true)); |
| + // BEGIN android-changed |
| + v.add(DERBoolean.TRUE); |
| + // END android-changed |
| } |
| |
| v.add(ext.getValue()); |
| @@ -371,18 +378,24 @@ |
| public boolean equivalent( |
| X509Extensions other) |
| { |
| - if (extensions.size() != other.extensions.size()) |
| + // BEGIN android-changed |
| + if (table.size() != other.table.size()) |
| + // END android-changed |
| { |
| return false; |
| } |
| |
| - Enumeration e1 = extensions.keys(); |
| + // BEGIN android-changed |
| + Enumeration e1 = table.getKeys(); |
| + // END android-changed |
| |
| while (e1.hasMoreElements()) |
| { |
| - Object key = e1.nextElement(); |
| + // BEGIN android-changed |
| + DERObjectIdentifier key = (DERObjectIdentifier)e1.nextElement(); |
| |
| - if (!extensions.get(key).equals(other.extensions.get(key))) |
| + if (!table.get(key).equals(other.table.get(key))) |
| + // END android-changed |
| { |
| return false; |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Name.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Name.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509Name.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509Name.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -247,8 +247,10 @@ |
| */ |
| public static final Hashtable SymbolLookUp = DefaultLookUp; |
| |
| - private static final Boolean TRUE = new Boolean(true); // for J2ME compatibility |
| - private static final Boolean FALSE = new Boolean(false); |
| + // BEGIN android-removed |
| + //private static final Boolean TRUE = new Boolean(true); // for J2ME compatibility |
| + //private static final Boolean FALSE = new Boolean(false); |
| + // END android-removed |
| |
| static |
| { |
| @@ -340,9 +342,9 @@ |
| } |
| |
| private X509NameEntryConverter converter = null; |
| - private Vector ordering = new Vector(); |
| - private Vector values = new Vector(); |
| - private Vector added = new Vector(); |
| + // BEGIN android-changed |
| + private X509NameElementList elems = new X509NameElementList(); |
| + // END android-changed |
| |
| private ASN1Sequence seq; |
| |
| @@ -403,26 +405,30 @@ |
| throw new IllegalArgumentException("badly sized pair"); |
| } |
| |
| - ordering.addElement(DERObjectIdentifier.getInstance(s.getObjectAt(0))); |
| + // BEGIN android-changed |
| + DERObjectIdentifier key = DERObjectIdentifier.getInstance(s.getObjectAt(0)); |
| |
| DEREncodable value = s.getObjectAt(1); |
| + String valueStr; |
| if (value instanceof DERString && !(value instanceof DERUniversalString)) |
| { |
| String v = ((DERString)value).getString(); |
| if (v.length() > 0 && v.charAt(0) == '#') |
| { |
| - values.addElement("\\" + v); |
| + valueStr = "\\" + v; |
| } |
| else |
| { |
| - values.addElement(v); |
| + valueStr = v; |
| } |
| } |
| else |
| { |
| - values.addElement("#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded()))); |
| + valueStr = "#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded())); |
| } |
| - added.addElement((i != 0) ? TRUE : FALSE); // to allow earlier JDK compatibility |
| + boolean added = (i != 0); // to allow earlier JDK compatibility |
| + elems.add(key, valueStr, added); |
| + // END android-changed |
| } |
| } |
| } |
| @@ -476,14 +482,23 @@ |
| Hashtable attributes, |
| X509NameEntryConverter converter) |
| { |
| + // BEGIN android-changed |
| + DERObjectIdentifier problem = null; |
| this.converter = converter; |
| |
| if (ordering != null) |
| { |
| for (int i = 0; i != ordering.size(); i++) |
| { |
| - this.ordering.addElement(ordering.elementAt(i)); |
| - this.added.addElement(FALSE); |
| + DERObjectIdentifier key = |
| + (DERObjectIdentifier) ordering.elementAt(i); |
| + String value = (String) attributes.get(key); |
| + if (value == null) |
| + { |
| + problem = key; |
| + break; |
| + } |
| + elems.add(key, value); |
| } |
| } |
| else |
| @@ -492,22 +507,23 @@ |
| |
| while (e.hasMoreElements()) |
| { |
| - this.ordering.addElement(e.nextElement()); |
| - this.added.addElement(FALSE); |
| + DERObjectIdentifier key = |
| + (DERObjectIdentifier) e.nextElement(); |
| + String value = (String) attributes.get(key); |
| + if (value == null) |
| + { |
| + problem = key; |
| + break; |
| + } |
| + elems.add(key, value); |
| } |
| } |
| |
| - for (int i = 0; i != this.ordering.size(); i++) |
| + if (problem != null) |
| { |
| - DERObjectIdentifier oid = (DERObjectIdentifier)this.ordering.elementAt(i); |
| - |
| - if (attributes.get(oid) == null) |
| - { |
| - throw new IllegalArgumentException("No attribute for object id - " + oid.getId() + " - passed to distinguished name"); |
| - } |
| - |
| - this.values.addElement(attributes.get(oid)); // copy the hash table |
| + throw new IllegalArgumentException("No attribute for object id - " + problem.getId() + " - passed to distinguished name"); |
| } |
| + // END android-changed |
| } |
| |
| /** |
| @@ -540,9 +556,10 @@ |
| |
| for (int i = 0; i < oids.size(); i++) |
| { |
| - this.ordering.addElement(oids.elementAt(i)); |
| - this.values.addElement(values.elementAt(i)); |
| - this.added.addElement(FALSE); |
| + // BEGIN android-changed |
| + elems.add((DERObjectIdentifier) oids.elementAt(i), |
| + (String) values.elementAt(i)); |
| + // END android-changed |
| } |
| } |
| |
| @@ -679,7 +696,7 @@ |
| |
| if (index == -1) |
| { |
| - throw new IllegalArgumentException("badly formated directory string"); |
| + throw new IllegalArgumentException("badly formatted directory string"); |
| } |
| |
| String name = token.substring(0, index); |
| @@ -691,9 +708,9 @@ |
| X509NameTokenizer vTok = new X509NameTokenizer(value, '+'); |
| String v = vTok.nextToken(); |
| |
| - this.ordering.addElement(oid); |
| - this.values.addElement(v); |
| - this.added.addElement(FALSE); |
| + // BEGIN android-changed |
| + this.elems.add(oid, v); |
| + // END android-changed |
| |
| while (vTok.hasMoreTokens()) |
| { |
| @@ -702,48 +719,24 @@ |
| |
| String nm = sv.substring(0, ndx); |
| String vl = sv.substring(ndx + 1); |
| - this.ordering.addElement(decodeOID(nm, lookUp)); |
| - this.values.addElement(vl); |
| - this.added.addElement(TRUE); |
| + // BEGIN android-changed |
| + this.elems.add(decodeOID(nm, lookUp), vl, true); |
| + // END android-changed |
| } |
| } |
| else |
| { |
| - this.ordering.addElement(oid); |
| - this.values.addElement(value); |
| - this.added.addElement(FALSE); |
| + // BEGIN android-changed |
| + this.elems.add(oid, value); |
| + // END android-changed |
| } |
| } |
| |
| if (reverse) |
| { |
| - Vector o = new Vector(); |
| - Vector v = new Vector(); |
| - Vector a = new Vector(); |
| - |
| - int count = 1; |
| - |
| - for (int i = 0; i < this.ordering.size(); i++) |
| - { |
| - if (((Boolean)this.added.elementAt(i)).booleanValue()) |
| - { |
| - o.insertElementAt(this.ordering.elementAt(i), count); |
| - v.insertElementAt(this.values.elementAt(i), count); |
| - a.insertElementAt(this.added.elementAt(i), count); |
| - count++; |
| - } |
| - else |
| - { |
| - o.insertElementAt(this.ordering.elementAt(i), 0); |
| - v.insertElementAt(this.values.elementAt(i), 0); |
| - a.insertElementAt(this.added.elementAt(i), 0); |
| - count = 1; |
| - } |
| - } |
| - |
| - this.ordering = o; |
| - this.values = v; |
| - this.added = a; |
| + // BEGIN android-changed |
| + this.elems = this.elems.reverse(); |
| + // END android-changed |
| } |
| } |
| |
| @@ -752,14 +745,17 @@ |
| */ |
| public Vector getOIDs() |
| { |
| + // BEGIN android-changed |
| Vector v = new Vector(); |
| + int size = elems.size(); |
| |
| - for (int i = 0; i != ordering.size(); i++) |
| + for (int i = 0; i < size; i++) |
| { |
| - v.addElement(ordering.elementAt(i)); |
| + v.addElement(elems.getKey(i)); |
| } |
| |
| return v; |
| + // END android-changed |
| } |
| |
| /** |
| @@ -769,11 +765,14 @@ |
| public Vector getValues() |
| { |
| Vector v = new Vector(); |
| + // BEGIN android-changed |
| + int size = elems.size(); |
| |
| - for (int i = 0; i != values.size(); i++) |
| + for (int i = 0; i != size; i++) |
| { |
| - v.addElement(values.elementAt(i)); |
| + v.addElement(elems.getValue(i)); |
| } |
| + // END android-changed |
| |
| return v; |
| } |
| @@ -786,12 +785,14 @@ |
| DERObjectIdentifier oid) |
| { |
| Vector v = new Vector(); |
| + int size = elems.size(); |
| + // BEGIN android-changed |
| |
| - for (int i = 0; i != values.size(); i++) |
| + for (int i = 0; i != size; i++) |
| { |
| - if (ordering.elementAt(i).equals(oid)) |
| + if (elems.getKey(i).equals(oid)) |
| { |
| - String val = (String)values.elementAt(i); |
| + String val = elems.getValue(i); |
| |
| if (val.length() > 2 && val.charAt(0) == '\\' && val.charAt(1) == '#') |
| { |
| @@ -803,6 +804,7 @@ |
| } |
| } |
| } |
| + // END android-changed |
| |
| return v; |
| } |
| @@ -814,20 +816,23 @@ |
| ASN1EncodableVector vec = new ASN1EncodableVector(); |
| ASN1EncodableVector sVec = new ASN1EncodableVector(); |
| DERObjectIdentifier lstOid = null; |
| + // BEGIN android-changed |
| + int size = elems.size(); |
| |
| - for (int i = 0; i != ordering.size(); i++) |
| + for (int i = 0; i != size; i++) |
| { |
| ASN1EncodableVector v = new ASN1EncodableVector(); |
| - DERObjectIdentifier oid = (DERObjectIdentifier)ordering.elementAt(i); |
| + DERObjectIdentifier oid = elems.getKey(i); |
| |
| v.add(oid); |
| |
| - String str = (String)values.elementAt(i); |
| + String str = elems.getValue(i); |
| |
| v.add(converter.getConvertedValue(oid, str)); |
| |
| if (lstOid == null |
| - || ((Boolean)this.added.elementAt(i)).booleanValue()) |
| + || this.elems.getAdded(i)) |
| + // END android-changed |
| { |
| sVec.add(new DERSequence(v)); |
| } |
| @@ -845,6 +850,7 @@ |
| vec.add(new DERSet(sVec)); |
| |
| seq = new DERSequence(vec); |
| + // END android-changed |
| } |
| |
| return seq; |
| @@ -889,22 +895,28 @@ |
| return false; |
| } |
| |
| - int orderingSize = ordering.size(); |
| + // BEGIN android-changed |
| + int orderingSize = elems.size(); |
| |
| - if (orderingSize != other.ordering.size()) |
| + if (orderingSize != other.elems.size()) |
| + // END android-changed |
| { |
| return false; |
| } |
| |
| for (int i = 0; i < orderingSize; i++) |
| { |
| - DERObjectIdentifier oid = (DERObjectIdentifier)ordering.elementAt(i); |
| - DERObjectIdentifier oOid = (DERObjectIdentifier)other.ordering.elementAt(i); |
| + // BEGIN android-changed |
| + DERObjectIdentifier oid = elems.getKey(i); |
| + DERObjectIdentifier oOid = other.elems.getKey(i); |
| + // END android-changed |
| |
| if (oid.equals(oOid)) |
| { |
| - String value = (String)values.elementAt(i); |
| - String oValue = (String)other.values.elementAt(i); |
| + // BEGIN android-changed |
| + String value = elems.getValue(i); |
| + String oValue = other.elems.getValue(i); |
| + // END android-changed |
| |
| if (!equivalentStrings(value, oValue)) |
| { |
| @@ -930,9 +942,9 @@ |
| isHashCodeCalculated = true; |
| |
| // this needs to be order independent, like equals |
| - for (int i = 0; i != ordering.size(); i += 1) |
| + for (int i = 0; i != elems.size(); i += 1) |
| { |
| - String value = (String)values.elementAt(i); |
| + String value = (String)elems.getValue(i); |
| |
| value = canonicalize(value); |
| value = stripInternalSpaces(value); |
| @@ -976,9 +988,11 @@ |
| return false; |
| } |
| |
| - int orderingSize = ordering.size(); |
| + // BEGIN android-changed |
| + int orderingSize = elems.size(); |
| |
| - if (orderingSize != other.ordering.size()) |
| + if (orderingSize != other.elems.size()) |
| + // END android-changed |
| { |
| return false; |
| } |
| @@ -986,7 +1000,9 @@ |
| boolean[] indexes = new boolean[orderingSize]; |
| int start, end, delta; |
| |
| - if (ordering.elementAt(0).equals(other.ordering.elementAt(0))) // guess forward |
| + // BEGIN android-changed |
| + if (elems.getKey(0).equals(other.elems.getKey(0))) // guess forward |
| + // END android-changed |
| { |
| start = 0; |
| end = orderingSize; |
| @@ -1002,8 +1018,10 @@ |
| for (int i = start; i != end; i += delta) |
| { |
| boolean found = false; |
| - DERObjectIdentifier oid = (DERObjectIdentifier)ordering.elementAt(i); |
| - String value = (String)values.elementAt(i); |
| + // BEGIN android-changed |
| + DERObjectIdentifier oid = elems.getKey(i); |
| + String value = elems.getValue(i); |
| + // END android-changed |
| |
| for (int j = 0; j < orderingSize; j++) |
| { |
| @@ -1012,11 +1030,15 @@ |
| continue; |
| } |
| |
| - DERObjectIdentifier oOid = (DERObjectIdentifier)other.ordering.elementAt(j); |
| + // BEGIN android-changed |
| + DERObjectIdentifier oOid = other.elems.getKey(j); |
| + // END android-changed |
| |
| if (oid.equals(oOid)) |
| { |
| - String oValue = (String)other.values.elementAt(j); |
| + // BEGIN android-changed |
| + String oValue = other.elems.getValue(j); |
| + // END android-changed |
| |
| if (equivalentStrings(value, oValue)) |
| { |
| @@ -1181,28 +1203,36 @@ |
| |
| StringBuffer ava = null; |
| |
| - for (int i = 0; i < ordering.size(); i++) |
| + // BEGIN android-changed |
| + for (int i = 0; i < elems.size(); i++) |
| + // END android-changed |
| { |
| - if (((Boolean)added.elementAt(i)).booleanValue()) |
| + if (elems.getAdded(i)) |
| { |
| ava.append('+'); |
| appendValue(ava, oidSymbols, |
| - (DERObjectIdentifier)ordering.elementAt(i), |
| - (String)values.elementAt(i)); |
| + // BEGIN android-changed |
| + elems.getKey(i), |
| + elems.getValue(i)); |
| + // END android-changed |
| } |
| else |
| { |
| ava = new StringBuffer(); |
| appendValue(ava, oidSymbols, |
| - (DERObjectIdentifier)ordering.elementAt(i), |
| - (String)values.elementAt(i)); |
| + // BEGIN android-changed |
| + elems.getKey(i), |
| + elems.getValue(i)); |
| + // END android-changed |
| components.addElement(ava); |
| } |
| } |
| |
| if (reverse) |
| { |
| - for (int i = components.size() - 1; i >= 0; i--) |
| + // BEGIN android-changed |
| + for (int i = elems.size() - 1; i >= 0; i--) |
| + // END android-changed |
| { |
| if (first) |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameElementList.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameElementList.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameElementList.java 1970-01-01 00:00:00.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameElementList.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -0,0 +1,206 @@ |
| +package org.bouncycastle.asn1.x509; |
| + |
| +import java.util.ArrayList; |
| +import java.util.BitSet; |
| +import org.bouncycastle.asn1.DERObjectIdentifier; |
| + |
| +// BEGIN android-note |
| +// This class was extracted from X509Name as a way to keep the element |
| +// list in a more controlled fashion. |
| +// END android-note |
| + |
| +/** |
| + * List of elements of an X509 name. Each element has a key, a value, and |
| + * an "added" flag. |
| + */ |
| +public class X509NameElementList { |
| + /** null-ok; key #0 */ |
| + private DERObjectIdentifier key0; |
| + |
| + /** null-ok; key #1 */ |
| + private DERObjectIdentifier key1; |
| + |
| + /** null-ok; key #2 */ |
| + private DERObjectIdentifier key2; |
| + |
| + /** null-ok; key #3 */ |
| + private DERObjectIdentifier key3; |
| + |
| + /** null-ok; value #0 */ |
| + private String value0; |
| + |
| + /** null-ok; value #1 */ |
| + private String value1; |
| + |
| + /** null-ok; value #2 */ |
| + private String value2; |
| + |
| + /** null-ok; value #3 */ |
| + private String value3; |
| + |
| + /** |
| + * null-ok; array of additional keys and values, alternating |
| + * key then value, etc. |
| + */ |
| + private ArrayList<Object> rest; |
| + |
| + /** bit vector for all the "added" bits */ |
| + private BitSet added = new BitSet(); |
| + |
| + /** >= 0; number of elements in the list */ |
| + private int size; |
| + |
| + // Note: Default public constructor. |
| + |
| + /** |
| + * Adds an element. The "added" flag is set to false for the element. |
| + * |
| + * @param key non-null; the key |
| + * @param value non-null; the value |
| + */ |
| + public void add(DERObjectIdentifier key, String value) { |
| + add(key, value, false); |
| + } |
| + |
| + /** |
| + * Adds an element. |
| + * |
| + * @param key non-null; the key |
| + * @param value non-null; the value |
| + * @param added the added bit |
| + */ |
| + public void add(DERObjectIdentifier key, String value, boolean added) { |
| + if (key == null) { |
| + throw new NullPointerException("key == null"); |
| + } |
| + |
| + if (value == null) { |
| + throw new NullPointerException("value == null"); |
| + } |
| + |
| + int sz = size; |
| + |
| + switch (sz) { |
| + case 0: { |
| + key0 = key; |
| + value0 = value; |
| + break; |
| + } |
| + case 1: { |
| + key1 = key; |
| + value1 = value; |
| + break; |
| + } |
| + case 2: { |
| + key2 = key; |
| + value2 = value; |
| + break; |
| + } |
| + case 3: { |
| + key3 = key; |
| + value3 = value; |
| + break; |
| + } |
| + case 4: { |
| + // Do initial allocation of rest. |
| + rest = new ArrayList<Object>(); |
| + // Fall through... |
| + } |
| + default: { |
| + rest.add(key); |
| + rest.add(value); |
| + break; |
| + } |
| + } |
| + |
| + if (added) { |
| + this.added.set(sz); |
| + } |
| + |
| + size = sz + 1; |
| + } |
| + |
| + /** |
| + * Sets the "added" flag on the most recently added element. |
| + */ |
| + public void setLastAddedFlag() { |
| + added.set(size - 1); |
| + } |
| + |
| + /** |
| + * Gets the number of elements in this instance. |
| + */ |
| + public int size() { |
| + return size; |
| + } |
| + |
| + /** |
| + * Gets the nth key. |
| + * |
| + * @param n index |
| + * @return non-null; the nth key |
| + */ |
| + public DERObjectIdentifier getKey(int n) { |
| + if ((n < 0) || (n >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(n)); |
| + } |
| + |
| + switch (n) { |
| + case 0: return key0; |
| + case 1: return key1; |
| + case 2: return key2; |
| + case 3: return key3; |
| + default: return (DERObjectIdentifier) rest.get((n - 4) * 2); |
| + } |
| + } |
| + |
| + /** |
| + * Gets the nth value. |
| + * |
| + * @param n index |
| + * @return non-null; the nth value |
| + */ |
| + public String getValue(int n) { |
| + if ((n < 0) || (n >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(n)); |
| + } |
| + |
| + switch (n) { |
| + case 0: return value0; |
| + case 1: return value1; |
| + case 2: return value2; |
| + case 3: return value3; |
| + default: return (String) rest.get(((n - 4) * 2) + 1); |
| + } |
| + } |
| + |
| + /** |
| + * Gets the nth added flag bit. |
| + * |
| + * @param n index |
| + * @return the nth added flag bit |
| + */ |
| + public boolean getAdded(int n) { |
| + if ((n < 0) || (n >= size)) { |
| + throw new IndexOutOfBoundsException(Integer.toString(n)); |
| + } |
| + |
| + return added.get(n); |
| + } |
| + |
| + /** |
| + * Constructs and returns a new instance which consists of the |
| + * elements of this one in reverse order |
| + * |
| + * @return non-null; the reversed instance |
| + */ |
| + public X509NameElementList reverse() { |
| + X509NameElementList result = new X509NameElementList(); |
| + |
| + for (int i = size - 1; i >= 0; i--) { |
| + result.add(getKey(i), getValue(i), getAdded(i)); |
| + } |
| + |
| + return result; |
| + } |
| +} |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameTokenizer.java bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameTokenizer.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/asn1/x509/X509NameTokenizer.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/asn1/x509/X509NameTokenizer.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -58,6 +58,17 @@ |
| } |
| else |
| { |
| + // BEGIN android-added |
| + // copied from a newer version of BouncyCastle |
| + if (c == '#' && buf.charAt(buf.length() - 1) == '=') |
| + { |
| + buf.append('\\'); |
| + } |
| + else if (c == '+' && seperator != '+') |
| + { |
| + buf.append('\\'); |
| + } |
| + // END android-added |
| buf.append(c); |
| } |
| escaped = false; |
| @@ -96,4 +107,4 @@ |
| index = end; |
| return buf.toString().trim(); |
| } |
| -} |
| +} |
| \ No newline at end of file |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/PBEParametersGenerator.java bcprov-jdk16-145/org/bouncycastle/crypto/PBEParametersGenerator.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/PBEParametersGenerator.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/PBEParametersGenerator.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -136,7 +136,8 @@ |
| public static byte[] PKCS12PasswordToBytes( |
| char[] password) |
| { |
| - if (password.length > 0) |
| + // BEGIN android-changed |
| + if (password != null && password.length > 0) |
| { |
| // +1 for extra 2 pad bytes. |
| byte[] bytes = new byte[(password.length + 1) * 2]; |
| @@ -153,5 +154,6 @@ |
| { |
| return new byte[0]; |
| } |
| + // END android-changed |
| } |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/digests/OpenSSLDigest.java bcprov-jdk16-145/org/bouncycastle/crypto/digests/OpenSSLDigest.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/digests/OpenSSLDigest.java 1970-01-01 00:00:00.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/digests/OpenSSLDigest.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -0,0 +1,159 @@ |
| +/* |
| + * Copyright (C) 2008 The Android Open Source Project |
| + * |
| + * Licensed under the Apache License, Version 2.0 (the "License"); |
| + * you may not use this file except in compliance with the License. |
| + * You may obtain a copy of the License at |
| + * |
| + * http://www.apache.org/licenses/LICENSE-2.0 |
| + * |
| + * Unless required by applicable law or agreed to in writing, software |
| + * distributed under the License is distributed on an "AS IS" BASIS, |
| + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| + * See the License for the specific language governing permissions and |
| + * limitations under the License. |
| + */ |
| + |
| +package org.bouncycastle.crypto.digests; |
| + |
| +import org.apache.harmony.xnet.provider.jsse.NativeCrypto; |
| +import org.bouncycastle.crypto.ExtendedDigest; |
| + |
| +/** |
| + * Implements the BouncyCastle Digest interface using OpenSSL's EVP API. |
| + */ |
| +public class OpenSSLDigest implements ExtendedDigest { |
| + |
| + /** |
| + * Holds the standard name of the hashing algorithm, e.g. "SHA-1"; |
| + */ |
| + private final String algorithm; |
| + |
| + /** |
| + * Holds the EVP_MD for the hashing algorithm, e.g. EVP_get_digestbyname("sha1"); |
| + */ |
| + private final int evp_md; |
| + |
| + /** |
| + * Holds the output size of the message digest. |
| + */ |
| + private final int size; |
| + |
| + /** |
| + * Holds the block size of the message digest. |
| + */ |
| + private final int blockSize; |
| + |
| + /** |
| + * Holds a pointer to the native message digest context. It is |
| + * lazily initialized to avoid having to reallocate on reset when |
| + * its unlikely to be reused. |
| + */ |
| + private int ctx; |
| + |
| + /** |
| + * Holds a dummy buffer for writing single bytes to the digest. |
| + */ |
| + private final byte[] singleByte = new byte[1]; |
| + |
| + /** |
| + * Creates a new OpenSSLMessageDigest instance for the given algorithm |
| + * name. |
| + */ |
| + private OpenSSLDigest(String algorithm, int evp_md, int size, int blockSize) { |
| + this.algorithm = algorithm; |
| + this.evp_md = evp_md; |
| + this.size = size; |
| + this.blockSize = blockSize; |
| + } |
| + |
| + public String getAlgorithmName() { |
| + return algorithm; |
| + } |
| + |
| + public int getDigestSize() { |
| + return size; |
| + } |
| + |
| + public int getByteLength() { |
| + return blockSize; |
| + } |
| + |
| + public void reset() { |
| + free(); |
| + } |
| + |
| + public void update(byte in) { |
| + singleByte[0] = in; |
| + update(singleByte, 0, 1); |
| + } |
| + |
| + public void update(byte[] in, int inOff, int len) { |
| + NativeCrypto.EVP_DigestUpdate(getCtx(), in, inOff, len); |
| + } |
| + |
| + public int doFinal(byte[] out, int outOff) { |
| + int i = NativeCrypto.EVP_DigestFinal(getCtx(), out, outOff); |
| + ctx = 0; // EVP_DigestFinal frees the context as a side effect |
| + reset(); |
| + return i; |
| + } |
| + |
| + private int getCtx() { |
| + if (ctx == 0) { |
| + ctx = NativeCrypto.EVP_DigestInit(evp_md); |
| + } |
| + return ctx; |
| + } |
| + |
| + private void free() { |
| + if (ctx != 0) { |
| + NativeCrypto.EVP_MD_CTX_destroy(ctx); |
| + ctx = 0; |
| + } |
| + } |
| + |
| + @Override |
| + protected void finalize() throws Throwable { |
| + try { |
| + free(); |
| + } finally { |
| + super.finalize(); |
| + } |
| + } |
| + |
| + public static class MD5 extends OpenSSLDigest { |
| + private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("md5"); |
| + private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD); |
| + private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD); |
| + public MD5() { super("MD5", EVP_MD, SIZE, BLOCK_SIZE); } |
| + } |
| + |
| + public static class SHA1 extends OpenSSLDigest { |
| + private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha1"); |
| + private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD); |
| + private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD); |
| + public SHA1() { super("SHA-1", EVP_MD, SIZE, BLOCK_SIZE); } |
| + } |
| + |
| + public static class SHA256 extends OpenSSLDigest { |
| + private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha256"); |
| + private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD); |
| + private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD); |
| + public SHA256() { super("SHA-256", EVP_MD, SIZE, BLOCK_SIZE); } |
| + } |
| + |
| + public static class SHA384 extends OpenSSLDigest { |
| + private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha384"); |
| + private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD); |
| + private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD); |
| + public SHA384() { super("SHA-384", EVP_MD, SIZE, BLOCK_SIZE); } |
| + } |
| + |
| + public static class SHA512 extends OpenSSLDigest { |
| + private static final int EVP_MD = NativeCrypto.EVP_get_digestbyname("sha512"); |
| + private static final int SIZE = NativeCrypto.EVP_MD_size(EVP_MD); |
| + private static final int BLOCK_SIZE = NativeCrypto.EVP_MD_block_size(EVP_MD); |
| + public SHA512() { super("SHA-512", EVP_MD, SIZE, BLOCK_SIZE); } |
| + } |
| +} |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/engines/RC2Engine.java bcprov-jdk16-145/org/bouncycastle/crypto/engines/RC2Engine.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/engines/RC2Engine.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/engines/RC2Engine.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -313,4 +313,4 @@ |
| out[outOff + 6] = (byte)x76; |
| out[outOff + 7] = (byte)(x76 >> 8); |
| } |
| -} |
| +} |
| \ No newline at end of file |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/macs/HMac.java bcprov-jdk16-145/org/bouncycastle/crypto/macs/HMac.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/macs/HMac.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/macs/HMac.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -32,23 +32,23 @@ |
| { |
| blockLengths = new Hashtable(); |
| |
| - blockLengths.put("GOST3411", new Integer(32)); |
| + blockLengths.put("GOST3411", Integer.valueOf(32)); |
| |
| - blockLengths.put("MD2", new Integer(16)); |
| - blockLengths.put("MD4", new Integer(64)); |
| - blockLengths.put("MD5", new Integer(64)); |
| - |
| - blockLengths.put("RIPEMD128", new Integer(64)); |
| - blockLengths.put("RIPEMD160", new Integer(64)); |
| - |
| - blockLengths.put("SHA-1", new Integer(64)); |
| - blockLengths.put("SHA-224", new Integer(64)); |
| - blockLengths.put("SHA-256", new Integer(64)); |
| - blockLengths.put("SHA-384", new Integer(128)); |
| - blockLengths.put("SHA-512", new Integer(128)); |
| + blockLengths.put("MD2", Integer.valueOf(16)); |
| + blockLengths.put("MD4", Integer.valueOf(64)); |
| + blockLengths.put("MD5", Integer.valueOf(64)); |
| + |
| + blockLengths.put("RIPEMD128", Integer.valueOf(64)); |
| + blockLengths.put("RIPEMD160", Integer.valueOf(64)); |
| + |
| + blockLengths.put("SHA-1", Integer.valueOf(64)); |
| + blockLengths.put("SHA-224", Integer.valueOf(64)); |
| + blockLengths.put("SHA-256", Integer.valueOf(64)); |
| + blockLengths.put("SHA-384", Integer.valueOf(128)); |
| + blockLengths.put("SHA-512", Integer.valueOf(128)); |
| |
| - blockLengths.put("Tiger", new Integer(64)); |
| - blockLengths.put("Whirlpool", new Integer(64)); |
| + blockLengths.put("Tiger", Integer.valueOf(64)); |
| + blockLengths.put("Whirlpool", Integer.valueOf(64)); |
| } |
| |
| private static int getByteLength( |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/signers/RSADigestSigner.java bcprov-jdk16-145/org/bouncycastle/crypto/signers/RSADigestSigner.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/signers/RSADigestSigner.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/signers/RSADigestSigner.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -46,8 +46,10 @@ |
| oidMap.put("SHA-384", NISTObjectIdentifiers.id_sha384); |
| oidMap.put("SHA-512", NISTObjectIdentifiers.id_sha512); |
| |
| - oidMap.put("MD2", PKCSObjectIdentifiers.md2); |
| - oidMap.put("MD4", PKCSObjectIdentifiers.md4); |
| + // BEGIN android-removed |
| + // oidMap.put("MD2", PKCSObjectIdentifiers.md2); |
| + // oidMap.put("MD4", PKCSObjectIdentifiers.md4); |
| + // END android-removed |
| oidMap.put("MD5", PKCSObjectIdentifiers.md5); |
| } |
| |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PrivateKeyFactory.java bcprov-jdk16-145/org/bouncycastle/crypto/util/PrivateKeyFactory.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PrivateKeyFactory.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/util/PrivateKeyFactory.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -8,7 +8,9 @@ |
| import org.bouncycastle.asn1.DERObject; |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.nist.NISTNamedCurves; |
| -import org.bouncycastle.asn1.oiw.ElGamalParameter; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.oiw.ElGamalParameter; |
| +// END android-removed |
| import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers; |
| import org.bouncycastle.asn1.pkcs.DHParameter; |
| import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; |
| @@ -16,7 +18,9 @@ |
| import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure; |
| import org.bouncycastle.asn1.sec.ECPrivateKeyStructure; |
| import org.bouncycastle.asn1.sec.SECNamedCurves; |
| -import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
| import org.bouncycastle.asn1.x509.DSAParameter; |
| import org.bouncycastle.asn1.x9.X962NamedCurves; |
| @@ -30,8 +34,10 @@ |
| import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; |
| import org.bouncycastle.crypto.params.ECDomainParameters; |
| import org.bouncycastle.crypto.params.ECPrivateKeyParameters; |
| -import org.bouncycastle.crypto.params.ElGamalParameters; |
| -import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.params.ElGamalParameters; |
| +// import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; |
| +// END android-removed |
| import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; |
| |
| import java.io.IOException; |
| @@ -113,52 +119,56 @@ |
| |
| return new DHPrivateKeyParameters(derX.getValue(), dhParams); |
| } |
| - else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| - { |
| - ElGamalParameter params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters()); |
| - DERInteger derX = (DERInteger)keyInfo.getPrivateKey(); |
| - |
| - return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(params.getP(), params.getG())); |
| - } |
| + // BEGIN android-removed |
| + // else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| + // { |
| + // ElGamalParameter params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters()); |
| + // DERInteger derX = (DERInteger)keyInfo.getPrivateKey(); |
| + // |
| + // return new ElGamalPrivateKeyParameters(derX.getValue(), new ElGamalParameters(params.getP(), params.getG())); |
| + // } |
| + // END android-removed |
| else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa)) |
| { |
| DERInteger derX = (DERInteger)keyInfo.getPrivateKey(); |
| DEREncodable de = keyInfo.getAlgorithmId().getParameters(); |
| - |
| + |
| DSAParameters parameters = null; |
| if (de != null) |
| { |
| DSAParameter params = DSAParameter.getInstance(de.getDERObject()); |
| parameters = new DSAParameters(params.getP(), params.getQ(), params.getG()); |
| } |
| - |
| + |
| return new DSAPrivateKeyParameters(derX.getValue(), parameters); |
| } |
| else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_ecPublicKey)) |
| { |
| X962Parameters params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters()); |
| ECDomainParameters dParams = null; |
| - |
| + |
| if (params.isNamedCurve()) |
| { |
| DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters(); |
| X9ECParameters ecP = X962NamedCurves.getByOID(oid); |
| - |
| + |
| if (ecP == null) |
| { |
| ecP = SECNamedCurves.getByOID(oid); |
| - |
| + |
| if (ecP == null) |
| { |
| ecP = NISTNamedCurves.getByOID(oid); |
| - |
| - if (ecP == null) |
| - { |
| - ecP = TeleTrusTNamedCurves.getByOID(oid); |
| - } |
| + |
| + // BEGIN android-removed |
| + // if (ecP == null) |
| + // { |
| + // ecP = TeleTrusTNamedCurves.getByOID(oid); |
| + // } |
| + // END android-removed |
| } |
| } |
| - |
| + |
| dParams = new ECDomainParameters( |
| ecP.getCurve(), |
| ecP.getG(), |
| @@ -177,9 +187,9 @@ |
| ecP.getH(), |
| ecP.getSeed()); |
| } |
| - |
| + |
| ECPrivateKeyStructure ec = new ECPrivateKeyStructure((ASN1Sequence)keyInfo.getPrivateKey()); |
| - |
| + |
| return new ECPrivateKeyParameters(ec.getKey(), dParams); |
| } |
| else |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PublicKeyFactory.java bcprov-jdk16-145/org/bouncycastle/crypto/util/PublicKeyFactory.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/crypto/util/PublicKeyFactory.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/crypto/util/PublicKeyFactory.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -11,12 +11,16 @@ |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.DEROctetString; |
| import org.bouncycastle.asn1.nist.NISTNamedCurves; |
| -import org.bouncycastle.asn1.oiw.ElGamalParameter; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.oiw.ElGamalParameter; |
| +// END android-removed |
| import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers; |
| import org.bouncycastle.asn1.pkcs.DHParameter; |
| import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; |
| import org.bouncycastle.asn1.sec.SECNamedCurves; |
| -import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
| import org.bouncycastle.asn1.x509.DSAParameter; |
| import org.bouncycastle.asn1.x509.RSAPublicKeyStructure; |
| @@ -34,8 +38,10 @@ |
| import org.bouncycastle.crypto.params.DSAPublicKeyParameters; |
| import org.bouncycastle.crypto.params.ECDomainParameters; |
| import org.bouncycastle.crypto.params.ECPublicKeyParameters; |
| -import org.bouncycastle.crypto.params.ElGamalParameters; |
| -import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.params.ElGamalParameters; |
| +// import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; |
| +// END android-removed |
| import org.bouncycastle.crypto.params.RSAKeyParameters; |
| |
| import java.io.IOException; |
| @@ -112,13 +118,15 @@ |
| |
| return new DHPublicKeyParameters(derY.getValue(), dhParams); |
| } |
| - else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| - { |
| - ElGamalParameter params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters()); |
| - DERInteger derY = (DERInteger)keyInfo.getPublicKey(); |
| - |
| - return new ElGamalPublicKeyParameters(derY.getValue(), new ElGamalParameters(params.getP(), params.getG())); |
| - } |
| + // BEGIN android-removed |
| + // else if (algId.getObjectId().equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| + // { |
| + // ElGamalParameter params = new ElGamalParameter((ASN1Sequence)keyInfo.getAlgorithmId().getParameters()); |
| + // DERInteger derY = (DERInteger)keyInfo.getPublicKey(); |
| + // |
| + // return new ElGamalPublicKeyParameters(derY.getValue(), new ElGamalParameters(params.getP(), params.getG())); |
| + // } |
| + // END android-removed |
| else if (algId.getObjectId().equals(X9ObjectIdentifiers.id_dsa) |
| || algId.getObjectId().equals(OIWObjectIdentifiers.dsaWithSHA1)) |
| { |
| @@ -138,27 +146,29 @@ |
| { |
| X962Parameters params = new X962Parameters((DERObject)keyInfo.getAlgorithmId().getParameters()); |
| ECDomainParameters dParams = null; |
| - |
| + |
| if (params.isNamedCurve()) |
| { |
| DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters(); |
| X9ECParameters ecP = X962NamedCurves.getByOID(oid); |
| - |
| + |
| if (ecP == null) |
| { |
| ecP = SECNamedCurves.getByOID(oid); |
| - |
| + |
| if (ecP == null) |
| { |
| ecP = NISTNamedCurves.getByOID(oid); |
| - |
| - if (ecP == null) |
| - { |
| - ecP = TeleTrusTNamedCurves.getByOID(oid); |
| - } |
| + |
| + // BEGIN android-removed |
| + // if (ecP == null) |
| + // { |
| + // ecP = TeleTrusTNamedCurves.getByOID(oid); |
| + // } |
| + // END android-removed |
| } |
| } |
| - |
| + |
| dParams = new ECDomainParameters( |
| ecP.getCurve(), |
| ecP.getG(), |
| @@ -177,13 +187,13 @@ |
| ecP.getH(), |
| ecP.getSeed()); |
| } |
| - |
| + |
| DERBitString bits = keyInfo.getPublicKeyData(); |
| byte[] data = bits.getBytes(); |
| ASN1OctetString key = new DEROctetString(data); |
| - |
| + |
| X9ECPoint derQ = new X9ECPoint(dParams.getCurve(), key); |
| - |
| + |
| return new ECPublicKeyParameters(derQ.getPoint(), dParams); |
| } |
| else |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/PKCS10CertificationRequest.java bcprov-jdk16-145/org/bouncycastle/jce/PKCS10CertificationRequest.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/PKCS10CertificationRequest.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/PKCS10CertificationRequest.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -78,8 +78,11 @@ |
| |
| static |
| { |
| - algorithms.put("MD2WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.2")); |
| - algorithms.put("MD2WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.2")); |
| + // BEGIN android-removed |
| + // Dropping MD2 |
| + // algorithms.put("MD2WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.2")); |
| + // algorithms.put("MD2WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.2")); |
| + // END android-removed |
| algorithms.put("MD5WITHRSAENCRYPTION", new DERObjectIdentifier("1.2.840.113549.1.1.4")); |
| algorithms.put("MD5WITHRSA", new DERObjectIdentifier("1.2.840.113549.1.1.4")); |
| algorithms.put("RSAWITHMD5", new DERObjectIdentifier("1.2.840.113549.1.1.4")); |
| @@ -129,7 +132,10 @@ |
| oids.put(CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "GOST3411WITHECGOST3410"); |
| |
| oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.4"), "MD5WITHRSA"); |
| - oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA"); |
| + // BEGIN android-removed |
| + // Dropping MD2 |
| + // oids.put(new DERObjectIdentifier("1.2.840.113549.1.1.2"), "MD2WITHRSA"); |
| + // END android-removed |
| oids.put(new DERObjectIdentifier("1.2.840.10040.4.3"), "SHA1WITHDSA"); |
| oids.put(X9ObjectIdentifiers.ecdsa_with_SHA1, "SHA1WITHECDSA"); |
| oids.put(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224WITHECDSA"); |
| @@ -168,19 +174,29 @@ |
| // |
| // explicit params |
| // |
| - AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA1WITHRSAANDMGF1", creatPSSParams(sha1AlgId, 20)); |
| |
| - AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28)); |
| |
| - AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA256WITHRSAANDMGF1", creatPSSParams(sha256AlgId, 32)); |
| |
| - AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA384WITHRSAANDMGF1", creatPSSParams(sha384AlgId, 48)); |
| |
| - AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA512WITHRSAANDMGF1", creatPSSParams(sha512AlgId, 64)); |
| } |
| |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/BouncyCastleProvider.java bcprov-jdk16-145/org/bouncycastle/jce/provider/BouncyCastleProvider.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/BouncyCastleProvider.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/BouncyCastleProvider.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -45,7 +45,10 @@ |
| { |
| private static String info = "BouncyCastle Security Provider v1.45"; |
| |
| - public static String PROVIDER_NAME = "BC"; |
| + // BEGIN android-changed |
| + // this constant should be final |
| + public static final String PROVIDER_NAME = "BC"; |
| + // END android-changed |
| |
| /* |
| * Configurable symmetric ciphers |
| @@ -53,7 +56,12 @@ |
| private static final String SYMMETRIC_CIPHER_PACKAGE = "org.bouncycastle.jce.provider.symmetric."; |
| private static final String[] SYMMETRIC_CIPHERS = |
| { |
| - "AES", "Camellia", "CAST5", "Grainv1", "Grain128", "IDEA", "Noekeon", "SEED" |
| + // BEGIN android-removed |
| + // "AES", "Camellia", "CAST5", "Grainv1", "Grain128", "IDEA", "Noekeon", "SEED" |
| + // END android-removed |
| + // BEGIN android-added |
| + "AES", |
| + // END android-added |
| }; |
| |
| /* |
| @@ -89,26 +97,28 @@ |
| loadAlgorithms(SYMMETRIC_CIPHER_PACKAGE, SYMMETRIC_CIPHERS); |
| loadAlgorithms(ASYMMETRIC_CIPHER_PACKAGE, ASYMMETRIC_CIPHERS); |
| |
| - // |
| - // X509Store |
| - // |
| - put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection"); |
| - put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection"); |
| - put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection"); |
| - put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection"); |
| - |
| - put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts"); |
| - put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs"); |
| - put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts"); |
| - put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs"); |
| - |
| - // |
| - // X509StreamParser |
| - // |
| - put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser"); |
| - put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser"); |
| - put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser"); |
| - put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser"); |
| + // BEGIN android-removed |
| + // // |
| + // // X509Store |
| + // // |
| + // put("X509Store.CERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertCollection"); |
| + // put("X509Store.ATTRIBUTECERTIFICATE/COLLECTION", "org.bouncycastle.jce.provider.X509StoreAttrCertCollection"); |
| + // put("X509Store.CRL/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCRLCollection"); |
| + // put("X509Store.CERTIFICATEPAIR/COLLECTION", "org.bouncycastle.jce.provider.X509StoreCertPairCollection"); |
| + // |
| + // put("X509Store.CERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCerts"); |
| + // put("X509Store.CRL/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCRLs"); |
| + // put("X509Store.ATTRIBUTECERTIFICATE/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPAttrCerts"); |
| + // put("X509Store.CERTIFICATEPAIR/LDAP", "org.bouncycastle.jce.provider.X509StoreLDAPCertPairs"); |
| + // |
| + // // |
| + // // X509StreamParser |
| + // // |
| + // put("X509StreamParser.CERTIFICATE", "org.bouncycastle.jce.provider.X509CertParser"); |
| + // put("X509StreamParser.ATTRIBUTECERTIFICATE", "org.bouncycastle.jce.provider.X509AttrCertParser"); |
| + // put("X509StreamParser.CRL", "org.bouncycastle.jce.provider.X509CRLParser"); |
| + // put("X509StreamParser.CERTIFICATEPAIR", "org.bouncycastle.jce.provider.X509CertPairParser"); |
| + // END android-removed |
| |
| |
| // |
| @@ -117,14 +127,24 @@ |
| put("KeyStore.BKS", "org.bouncycastle.jce.provider.JDKKeyStore"); |
| put("KeyStore.BouncyCastle", "org.bouncycastle.jce.provider.JDKKeyStore$BouncyCastleStore"); |
| put("KeyStore.PKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore"); |
| - put("KeyStore.BCPKCS12", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore"); |
| - put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore"); |
| - |
| - put("KeyStore.PKCS12-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore"); |
| - put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES"); |
| - |
| - put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore"); |
| - put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES"); |
| + // BEGIN android-changed |
| + put("Alg.Alias.KeyStore.BCPKCS12", "PKCS12"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("KeyStore.PKCS12-DEF", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore"); |
| + // END android-removed |
| + |
| + // BEGIN android-changed |
| + put("Alg.Alias.KeyStore.PKCS12-3DES-40RC2", "PKCS12"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("KeyStore.PKCS12-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$BCPKCS12KeyStore3DES"); |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // put("KeyStore.PKCS12-DEF-3DES-40RC2", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore"); |
| + // put("KeyStore.PKCS12-DEF-3DES-3DES", "org.bouncycastle.jce.provider.JDKPKCS12KeyStore$DefPKCS12KeyStore3DES"); |
| + // END android-removed |
| |
| put("Alg.Alias.KeyStore.UBER", "BouncyCastle"); |
| put("Alg.Alias.KeyStore.BOUNCYCASTLE", "BouncyCastle"); |
| @@ -141,44 +161,63 @@ |
| // |
| put("AlgorithmParameterGenerator.DH", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DH"); |
| put("AlgorithmParameterGenerator.DSA", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DSA"); |
| - put("AlgorithmParameterGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$GOST3410"); |
| - put("AlgorithmParameterGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$ElGamal"); |
| - put("AlgorithmParameterGenerator.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| - put("AlgorithmParameterGenerator.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| - put("AlgorithmParameterGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| - put("AlgorithmParameterGenerator." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| - put("AlgorithmParameterGenerator.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2"); |
| - put("AlgorithmParameterGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2"); |
| + // BEGIN android-removed |
| + // put("AlgorithmParameterGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$GOST3410"); |
| + // put("AlgorithmParameterGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$ElGamal"); |
| + // put("AlgorithmParameterGenerator.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| + // put("AlgorithmParameterGenerator.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| + // put("AlgorithmParameterGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| + // put("AlgorithmParameterGenerator." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$DES"); |
| + // put("AlgorithmParameterGenerator.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2"); |
| + // put("AlgorithmParameterGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameterGenerator$RC2"); |
| + // END android-removed |
| |
| put("Alg.Alias.AlgorithmParameterGenerator.DIFFIEHELLMAN", "DH"); |
| - put("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.AlgorithmParameterGenerator.GOST-3410", "GOST3410"); |
| + // END android-removed |
| // |
| // algorithm parameters |
| // |
| put("AlgorithmParameters.OAEP", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$OAEP"); |
| - put("AlgorithmParameters.PSS", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PSS"); |
| + // BEGIN android-removed |
| + // put("AlgorithmParameters.PSS", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PSS"); |
| + // END android-removed |
| put("AlgorithmParameters.DH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$DH"); |
| put("Alg.Alias.AlgorithmParameters.DIFFIEHELLMAN", "DH"); |
| put("AlgorithmParameters.DSA", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$DSA"); |
| - put("AlgorithmParameters.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$ElGamal"); |
| - put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES"); |
| + // BEGIN android-removed |
| + // put("AlgorithmParameters.ELGAMAL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$ElGamal"); |
| + // put("AlgorithmParameters.IES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IES"); |
| + // END android-removed |
| put("AlgorithmParameters.PKCS12PBE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PKCS12PBE"); |
| - put("AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| - put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2"); |
| - |
| - put("AlgorithmParameters.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$GOST3410"); |
| - put("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410"); |
| + // BEGIN android-changed |
| + // redundant with below |
| + // put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "DESede"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("AlgorithmParameters." + PKCSObjectIdentifiers.id_PBKDF2, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$PBKDF2"); |
| + // |
| + // put("AlgorithmParameters.GOST3410", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$GOST3410"); |
| + // put("Alg.Alias.AlgorithmParameters.GOST-3410", "GOST3410"); |
| + // END android-removed |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES", "PKCS12PBE"); |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES", "PKCS12PBE"); |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC2", "PKCS12PBE"); |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDRC4", "PKCS12PBE"); |
| + // END android-removed |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDTWOFISH", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHA1ANDRC2-CBC", "PKCS12PBE"); |
| + // END android-removed |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE"); |
| - put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES3KEY-CBC", "PKCS12PBE"); |
| + // put("Alg.Alias.AlgorithmParameters.PBEWITHSHAANDDES2KEY-CBC", "PKCS12PBE"); |
| + // END android-removed |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC2-CBC", "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND40BITRC4", "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITRC2-CBC", "PKCS12PBE"); |
| @@ -192,7 +231,7 @@ |
| put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.5", "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.1.2.840.113549.1.12.1.6", "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWithSHAAnd3KeyTripleDES", "PKCS12PBE"); |
| - |
| + |
| put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.getId(), "PKCS12PBE"); |
| @@ -202,22 +241,24 @@ |
| |
| put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSAES_OAEP, "OAEP"); |
| |
| - put("Alg.Alias.AlgorithmParameters.RSAPSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.RSASSA-PSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSASSA_PSS, "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA1withRSA/PSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA224withRSA/PSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA256withRSA/PSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA384withRSA/PSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.RAWRSAPSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.NONEWITHRSAPSS", "PSS"); |
| - put("Alg.Alias.AlgorithmParameters.NONEWITHRSASSA-PSS", "PSS"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.AlgorithmParameters.RSAPSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.RSASSA-PSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.id_RSASSA_PSS, "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA1withRSA/PSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA224withRSA/PSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA256withRSA/PSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA384withRSA/PSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA512withRSA/PSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA1WITHRSAANDMGF1", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA224WITHRSAANDMGF1", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA256WITHRSAANDMGF1", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA384WITHRSAANDMGF1", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.SHA512WITHRSAANDMGF1", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.RAWRSAPSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.NONEWITHRSAPSS", "PSS"); |
| + // put("Alg.Alias.AlgorithmParameters.NONEWITHRSASSA-PSS", "PSS"); |
| + // END android-removed |
| |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND128BITAES-CBC-BC", "PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHAAND192BITAES-CBC-BC", "PKCS12PBE"); |
| @@ -234,12 +275,14 @@ |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND128BITAES-CBC-BC","PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND192BITAES-CBC-BC","PKCS12PBE"); |
| put("Alg.Alias.AlgorithmParameters.PBEWITHSHA-256AND256BITAES-CBC-BC","PKCS12PBE"); |
| - |
| - put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| - put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| - put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| - put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| - put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| + |
| + // BEGIN android-removed |
| + // put("AlgorithmParameters.SHA1WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| + // put("AlgorithmParameters.SHA224WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| + // put("AlgorithmParameters.SHA256WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| + // put("AlgorithmParameters.SHA384WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| + // put("AlgorithmParameters.SHA512WITHECDSA", "org.bouncycastle.jce.provider.JDKECDSAAlgParameters$SigAlgParameters"); |
| + // END android-removed |
| |
| // |
| // key agreement |
| @@ -252,97 +295,129 @@ |
| // |
| put("Cipher.DES", "org.bouncycastle.jce.provider.JCEBlockCipher$DES"); |
| put("Cipher.DESEDE", "org.bouncycastle.jce.provider.JCEBlockCipher$DESede"); |
| - put("Cipher." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESedeCBC"); |
| - put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESCBC"); |
| + // BEGIN android-removed |
| + // put("Cipher." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESedeCBC"); |
| + // put("Cipher." + OIWObjectIdentifiers.desCBC, "org.bouncycastle.jce.provider.JCEBlockCipher$DESCBC"); |
| + // END android-removed |
| put("Cipher.DESEDEWRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$DESEDEWrap"); |
| - put("Cipher." + PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "org.bouncycastle.jce.provider.WrapCipherSpi$DESEDEWrap"); |
| - put("Cipher.SKIPJACK", "org.bouncycastle.jce.provider.JCEBlockCipher$Skipjack"); |
| + // BEGIN android-changed |
| + put("Alg.Alias.Cipher." + PKCSObjectIdentifiers.id_alg_CMS3DESwrap, "DESEDEWRAP"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("Cipher.SKIPJACK", "org.bouncycastle.jce.provider.JCEBlockCipher$Skipjack"); |
| + // END android-removed |
| put("Cipher.BLOWFISH", "org.bouncycastle.jce.provider.JCEBlockCipher$Blowfish"); |
| - put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.JCEBlockCipher$BlowfishCBC"); |
| - put("Cipher.TWOFISH", "org.bouncycastle.jce.provider.JCEBlockCipher$Twofish"); |
| - put("Cipher.RC2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2"); |
| - put("Cipher.RC2WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap"); |
| - put("Cipher.1.2.840.113549.1.9.16.3.7", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap"); |
| + // BEGIN android-removed |
| + // put("Cipher.1.3.6.1.4.1.3029.1.2", "org.bouncycastle.jce.provider.JCEBlockCipher$BlowfishCBC"); |
| + // put("Cipher.TWOFISH", "org.bouncycastle.jce.provider.JCEBlockCipher$Twofish"); |
| + // put("Cipher.RC2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2"); |
| + // put("Cipher.RC2WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap"); |
| + // put("Cipher.1.2.840.113549.1.9.16.3.7", "org.bouncycastle.jce.provider.WrapCipherSpi$RC2Wrap"); |
| + // END android-removed |
| put("Cipher.ARC4", "org.bouncycastle.jce.provider.JCEStreamCipher$RC4"); |
| put("Alg.Alias.Cipher.1.2.840.113549.3.4", "ARC4"); |
| put("Alg.Alias.Cipher.ARCFOUR", "ARC4"); |
| put("Alg.Alias.Cipher.RC4", "ARC4"); |
| - put("Cipher.SALSA20", "org.bouncycastle.jce.provider.JCEStreamCipher$Salsa20"); |
| - put("Cipher.HC128", "org.bouncycastle.jce.provider.JCEStreamCipher$HC128"); |
| - put("Cipher.HC256", "org.bouncycastle.jce.provider.JCEStreamCipher$HC256"); |
| - put("Cipher.VMPC", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPC"); |
| - put("Cipher.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPCKSA3"); |
| - put("Cipher.RC5", "org.bouncycastle.jce.provider.JCEBlockCipher$RC5"); |
| - put("Cipher.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2CBC"); |
| - put("Alg.Alias.Cipher.RC5-32", "RC5"); |
| - put("Cipher.RC5-64", "org.bouncycastle.jce.provider.JCEBlockCipher$RC564"); |
| - put("Cipher.RC6", "org.bouncycastle.jce.provider.JCEBlockCipher$RC6"); |
| - put("Cipher.RIJNDAEL", "org.bouncycastle.jce.provider.JCEBlockCipher$Rijndael"); |
| - put("Cipher.DESEDERFC3211WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RFC3211DESedeWrap"); |
| - put("Cipher.SERPENT", "org.bouncycastle.jce.provider.JCEBlockCipher$Serpent"); |
| - |
| - |
| - put("Cipher.CAST6", "org.bouncycastle.jce.provider.JCEBlockCipher$CAST6"); |
| + // BEGIN android-removed |
| + // put("Cipher.SALSA20", "org.bouncycastle.jce.provider.JCEStreamCipher$Salsa20"); |
| + // put("Cipher.HC128", "org.bouncycastle.jce.provider.JCEStreamCipher$HC128"); |
| + // put("Cipher.HC256", "org.bouncycastle.jce.provider.JCEStreamCipher$HC256"); |
| + // put("Cipher.VMPC", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPC"); |
| + // put("Cipher.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEStreamCipher$VMPCKSA3"); |
| + // put("Cipher.RC5", "org.bouncycastle.jce.provider.JCEBlockCipher$RC5"); |
| + // put("Cipher.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEBlockCipher$RC2CBC"); |
| + // put("Alg.Alias.Cipher.RC5-32", "RC5"); |
| + // put("Cipher.RC5-64", "org.bouncycastle.jce.provider.JCEBlockCipher$RC564"); |
| + // put("Cipher.RC6", "org.bouncycastle.jce.provider.JCEBlockCipher$RC6"); |
| + // put("Cipher.RIJNDAEL", "org.bouncycastle.jce.provider.JCEBlockCipher$Rijndael"); |
| + // put("Cipher.DESEDERFC3211WRAP", "org.bouncycastle.jce.provider.WrapCipherSpi$RFC3211DESedeWrap"); |
| + // put("Cipher.SERPENT", "org.bouncycastle.jce.provider.JCEBlockCipher$Serpent"); |
| + // END android-removed |
| + |
| + |
| + // BEGIN android-removed |
| + // put("Cipher.CAST6", "org.bouncycastle.jce.provider.JCEBlockCipher$CAST6"); |
| + // END android-removed |
| put("Alg.Alias.Cipher.PBEWithSHAAnd3KeyTripleDES", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC"); |
| |
| - put("Cipher.GOST28147", "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147"); |
| - put("Alg.Alias.Cipher.GOST", "GOST28147"); |
| - put("Alg.Alias.Cipher.GOST-28147", "GOST28147"); |
| - put("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147cbc"); |
| - |
| - put("Cipher.TEA", "org.bouncycastle.jce.provider.JCEBlockCipher$TEA"); |
| - put("Cipher.XTEA", "org.bouncycastle.jce.provider.JCEBlockCipher$XTEA"); |
| + // BEGIN android-removed |
| + // put("Cipher.GOST28147", "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147"); |
| + // put("Alg.Alias.Cipher.GOST", "GOST28147"); |
| + // put("Alg.Alias.Cipher.GOST-28147", "GOST28147"); |
| + // put("Cipher." + CryptoProObjectIdentifiers.gostR28147_cbc, "org.bouncycastle.jce.provider.JCEBlockCipher$GOST28147cbc"); |
| + // |
| + // put("Cipher.TEA", "org.bouncycastle.jce.provider.JCEBlockCipher$TEA"); |
| + // put("Cipher.XTEA", "org.bouncycastle.jce.provider.JCEBlockCipher$XTEA"); |
| + // END android-removed |
| |
| put("Cipher.RSA", "org.bouncycastle.jce.provider.JCERSACipher$NoPadding"); |
| - put("Cipher.RSA/RAW", "org.bouncycastle.jce.provider.JCERSACipher$NoPadding"); |
| - put("Cipher.RSA/PKCS1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding"); |
| - put("Cipher.1.2.840.113549.1.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding"); |
| - put("Cipher.2.5.8.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding"); |
| - put("Cipher.RSA/1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PrivateOnly"); |
| - put("Cipher.RSA/2", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PublicOnly"); |
| - put("Cipher.RSA/OAEP", "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding"); |
| - put("Cipher." + PKCSObjectIdentifiers.id_RSAES_OAEP, "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding"); |
| - put("Cipher.RSA/ISO9796-1", "org.bouncycastle.jce.provider.JCERSACipher$ISO9796d1Padding"); |
| - |
| - put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES"); |
| - put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES"); |
| - put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES"); |
| - put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES"); |
| - put("Cipher.ELGAMAL", "org.bouncycastle.jce.provider.JCEElGamalCipher$NoPadding"); |
| - put("Cipher.ELGAMAL/PKCS1", "org.bouncycastle.jce.provider.JCEElGamalCipher$PKCS1v1_5Padding"); |
| + // BEGIN android-changed |
| + put("Alg.Alias.Cipher.RSA/RAW", "RSA"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("Cipher.RSA/PKCS1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding"); |
| + // put("Cipher.1.2.840.113549.1.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding"); |
| + // put("Cipher.2.5.8.1.1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding"); |
| + // put("Cipher.RSA/1", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PrivateOnly"); |
| + // put("Cipher.RSA/2", "org.bouncycastle.jce.provider.JCERSACipher$PKCS1v1_5Padding_PublicOnly"); |
| + // put("Cipher.RSA/OAEP", "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding"); |
| + // put("Cipher." + PKCSObjectIdentifiers.id_RSAES_OAEP, "org.bouncycastle.jce.provider.JCERSACipher$OAEPPadding"); |
| + // put("Cipher.RSA/ISO9796-1", "org.bouncycastle.jce.provider.JCERSACipher$ISO9796d1Padding"); |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // put("Cipher.ECIES", "org.bouncycastle.jce.provider.JCEIESCipher$ECIES"); |
| + // put("Cipher.BrokenECIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenECIES"); |
| + // put("Cipher.IES", "org.bouncycastle.jce.provider.JCEIESCipher$IES"); |
| + // put("Cipher.BrokenIES", "org.bouncycastle.jce.provider.JCEIESCipher$BrokenIES"); |
| + // put("Cipher.ELGAMAL", "org.bouncycastle.jce.provider.JCEElGamalCipher$NoPadding"); |
| + // put("Cipher.ELGAMAL/PKCS1", "org.bouncycastle.jce.provider.JCEElGamalCipher$PKCS1v1_5Padding"); |
| + // END android-removed |
| |
| put("Alg.Alias.Cipher.RSA//RAW", "RSA"); |
| put("Alg.Alias.Cipher.RSA//NOPADDING", "RSA"); |
| - put("Alg.Alias.Cipher.RSA//PKCS1PADDING", "RSA/PKCS1"); |
| - put("Alg.Alias.Cipher.RSA//OAEPPADDING", "RSA/OAEP"); |
| - put("Alg.Alias.Cipher.RSA//ISO9796-1PADDING", "RSA/ISO9796-1"); |
| - |
| - put("Alg.Alias.Cipher.ELGAMAL/ECB/PKCS1PADDING", "ELGAMAL/PKCS1"); |
| - put("Alg.Alias.Cipher.ELGAMAL/NONE/PKCS1PADDING", "ELGAMAL/PKCS1"); |
| - put("Alg.Alias.Cipher.ELGAMAL/NONE/NOPADDING", "ELGAMAL"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Cipher.RSA//PKCS1PADDING", "RSA/PKCS1"); |
| + // put("Alg.Alias.Cipher.RSA//OAEPPADDING", "RSA/OAEP"); |
| + // put("Alg.Alias.Cipher.RSA//ISO9796-1PADDING", "RSA/ISO9796-1"); |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Cipher.ELGAMAL/ECB/PKCS1PADDING", "ELGAMAL/PKCS1"); |
| + // put("Alg.Alias.Cipher.ELGAMAL/NONE/PKCS1PADDING", "ELGAMAL/PKCS1"); |
| + // put("Alg.Alias.Cipher.ELGAMAL/NONE/NOPADDING", "ELGAMAL"); |
| + // END android-removed |
| |
| put("Cipher.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndDES"); |
| - put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES"); |
| + // BEGIN android-removed |
| + // put("Cipher.BROKENPBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithMD5AndDES"); |
| + // END android-removed |
| put("Cipher.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithMD5AndRC2"); |
| put("Cipher.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndDES"); |
| - put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES"); |
| + // BEGIN android-removed |
| + // put("Cipher.BROKENPBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHA1AndDES"); |
| + // END android-removed |
| put("Cipher.PBEWITHSHA1ANDRC2", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHA1AndRC2"); |
| put("Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndDES3Key"); |
| - put("Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES3Key"); |
| - put("Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndDES3Key"); |
| + // BEGIN android-removed |
| + // put("Cipher.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES3Key"); |
| + // put("Cipher.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndDES3Key"); |
| + // END android-removed |
| put("Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndDES2Key"); |
| - put("Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES2Key"); |
| + // BEGIN android-removed |
| + // put("Cipher.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$BrokePBEWithSHAAndDES2Key"); |
| + // END android-removed |
| put("Cipher.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd128BitRC2"); |
| put("Cipher.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAnd40BitRC2"); |
| put("Cipher.PBEWITHSHAAND128BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd128BitRC4"); |
| put("Cipher.PBEWITHSHAAND40BITRC4", "org.bouncycastle.jce.provider.JCEStreamCipher$PBEWithSHAAnd40BitRC4"); |
| |
| - put("Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC", "Cipher.PBEWITHSHAAND3-KEYTRIPLEDES-CBC"); |
| - put("Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC", "Cipher.PBEWITHSHAAND2-KEYTRIPLEDES-CBC"); |
| - put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "Cipher.PBEWITHSHAAND128BITRC2-CBC"); |
| - put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "Cipher.PBEWITHSHAAND40BITRC2-CBC"); |
| - put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "Cipher.PBEWITHSHAAND128BITRC4"); |
| - put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "Cipher.PBEWITHSHAAND40BITRC4"); |
| + put("Alg.Alias.Cipher.PBEWITHSHA1AND3-KEYTRIPLEDES-CBC", "PBEWITHSHAAND3-KEYTRIPLEDES-CBC"); |
| + put("Alg.Alias.Cipher.PBEWITHSHA1AND2-KEYTRIPLEDES-CBC", "PBEWITHSHAAND2-KEYTRIPLEDES-CBC"); |
| + put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC2-CBC", "PBEWITHSHAAND128BITRC2-CBC"); |
| + put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC2-CBC", "PBEWITHSHAAND40BITRC2-CBC"); |
| + put("Alg.Alias.Cipher.PBEWITHSHA1AND128BITRC4", "PBEWITHSHAAND128BITRC4"); |
| + put("Alg.Alias.Cipher.PBEWITHSHA1AND40BITRC4", "PBEWITHSHAAND40BITRC4"); |
| |
| put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.getId(), "PBEWITHSHAAND128BITAES-CBC-BC"); |
| put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.getId(), "PBEWITHSHAAND192BITAES-CBC-BC"); |
| @@ -350,7 +425,7 @@ |
| put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC"); |
| put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC"); |
| put("Alg.Alias.Cipher." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC"); |
| - |
| + |
| put("Cipher.PBEWITHSHAAND128BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC"); |
| put("Cipher.PBEWITHSHAAND192BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC"); |
| put("Cipher.PBEWITHSHAAND256BITAES-CBC-BC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC"); |
| @@ -372,7 +447,9 @@ |
| put("Cipher.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithAESCBC"); |
| |
| put("Cipher.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCEBlockCipher$PBEWithSHAAndTwofish"); |
| - put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish"); |
| + // BEGIN android-removed |
| + // put("Cipher.OLDPBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.BrokenJCEBlockCipher$OldPBEWithSHAAndTwofish"); |
| + // END android-removed |
| |
| put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.1", "PBEWITHSHAAND128BITRC4"); |
| put("Alg.Alias.Cipher.1.2.840.113549.1.12.1.2", "PBEWITHSHAAND40BITRC4"); |
| @@ -387,38 +464,49 @@ |
| put("KeyGenerator.DES", "org.bouncycastle.jce.provider.JCEKeyGenerator$DES"); |
| put("Alg.Alias.KeyGenerator." + OIWObjectIdentifiers.desCBC, "DES"); |
| put("KeyGenerator.DESEDE", "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede"); |
| - put("KeyGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede3"); |
| - put("KeyGenerator.DESEDEWRAP", "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede"); |
| - put("KeyGenerator.SKIPJACK", "org.bouncycastle.jce.provider.JCEKeyGenerator$Skipjack"); |
| + // BEGIN android-removed |
| + // put("KeyGenerator." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede3"); |
| + // put("KeyGenerator.DESEDEWRAP", "org.bouncycastle.jce.provider.JCEKeyGenerator$DESede"); |
| + // put("KeyGenerator.SKIPJACK", "org.bouncycastle.jce.provider.JCEKeyGenerator$Skipjack"); |
| + // END android-removed |
| put("KeyGenerator.BLOWFISH", "org.bouncycastle.jce.provider.JCEKeyGenerator$Blowfish"); |
| put("Alg.Alias.KeyGenerator.1.3.6.1.4.1.3029.1.2", "BLOWFISH"); |
| - put("KeyGenerator.TWOFISH", "org.bouncycastle.jce.provider.JCEKeyGenerator$Twofish"); |
| - put("KeyGenerator.RC2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2"); |
| - put("KeyGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2"); |
| + // BEGIN android-removed |
| + // put("KeyGenerator.TWOFISH", "org.bouncycastle.jce.provider.JCEKeyGenerator$Twofish"); |
| + // put("KeyGenerator.RC2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2"); |
| + // put("KeyGenerator.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC2"); |
| + // END android-removed |
| put("KeyGenerator.RC4", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC4"); |
| put("Alg.Alias.KeyGenerator.ARC4", "RC4"); |
| - put("Alg.Alias.KeyGenerator.1.2.840.113549.3.4", "RC4"); |
| - put("KeyGenerator.RC5", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC5"); |
| - put("Alg.Alias.KeyGenerator.RC5-32", "RC5"); |
| - put("KeyGenerator.RC5-64", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC564"); |
| - put("KeyGenerator.RC6", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC6"); |
| - put("KeyGenerator.RIJNDAEL", "org.bouncycastle.jce.provider.JCEKeyGenerator$Rijndael"); |
| - |
| - put("KeyGenerator.SERPENT", "org.bouncycastle.jce.provider.JCEKeyGenerator$Serpent"); |
| - put("KeyGenerator.SALSA20", "org.bouncycastle.jce.provider.JCEKeyGenerator$Salsa20"); |
| - put("KeyGenerator.HC128", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC128"); |
| - put("KeyGenerator.HC256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC256"); |
| - put("KeyGenerator.VMPC", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPC"); |
| - put("KeyGenerator.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPCKSA3"); |
| - |
| - put("KeyGenerator.CAST6", "org.bouncycastle.jce.provider.JCEKeyGenerator$CAST6"); |
| - put("KeyGenerator.TEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$TEA"); |
| - put("KeyGenerator.XTEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$XTEA"); |
| - |
| - put("KeyGenerator.GOST28147", "org.bouncycastle.jce.provider.JCEKeyGenerator$GOST28147"); |
| - put("Alg.Alias.KeyGenerator.GOST", "GOST28147"); |
| - put("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147"); |
| - put("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147"); |
| + // BEGIN android-added |
| + put("Alg.Alias.KeyGenerator.ARCFOUR", "RC4"); |
| + // END android-added |
| + // BEGIN android-removed |
| + // put("Alg.Alias.KeyGenerator.1.2.840.113549.3.4", "RC4"); |
| + // put("KeyGenerator.RC5", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC5"); |
| + // put("Alg.Alias.KeyGenerator.RC5-32", "RC5"); |
| + // put("KeyGenerator.RC5-64", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC564"); |
| + // put("KeyGenerator.RC6", "org.bouncycastle.jce.provider.JCEKeyGenerator$RC6"); |
| + // put("KeyGenerator.RIJNDAEL", "org.bouncycastle.jce.provider.JCEKeyGenerator$Rijndael"); |
| + // |
| + // put("KeyGenerator.SERPENT", "org.bouncycastle.jce.provider.JCEKeyGenerator$Serpent"); |
| + // put("KeyGenerator.SALSA20", "org.bouncycastle.jce.provider.JCEKeyGenerator$Salsa20"); |
| + // put("KeyGenerator.HC128", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC128"); |
| + // put("KeyGenerator.HC256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HC256"); |
| + // put("KeyGenerator.VMPC", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPC"); |
| + // put("KeyGenerator.VMPC-KSA3", "org.bouncycastle.jce.provider.JCEKeyGenerator$VMPCKSA3"); |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // put("KeyGenerator.CAST6", "org.bouncycastle.jce.provider.JCEKeyGenerator$CAST6"); |
| + // put("KeyGenerator.TEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$TEA"); |
| + // put("KeyGenerator.XTEA", "org.bouncycastle.jce.provider.JCEKeyGenerator$XTEA"); |
| + // |
| + // put("KeyGenerator.GOST28147", "org.bouncycastle.jce.provider.JCEKeyGenerator$GOST28147"); |
| + // put("Alg.Alias.KeyGenerator.GOST", "GOST28147"); |
| + // put("Alg.Alias.KeyGenerator.GOST-28147", "GOST28147"); |
| + // put("Alg.Alias.KeyGenerator." + CryptoProObjectIdentifiers.gostR28147_cbc, "GOST28147"); |
| + // END android-removed |
| |
| // |
| // key pair generators. |
| @@ -426,14 +514,18 @@ |
| put("KeyPairGenerator.RSA", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$RSA"); |
| put("KeyPairGenerator.DH", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$DH"); |
| put("KeyPairGenerator.DSA", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$DSA"); |
| - put("KeyPairGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$ElGamal"); |
| + // BEGIN android-removed |
| + // put("KeyPairGenerator.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$ElGamal"); |
| + // END android-removed |
| |
| put("Alg.Alias.KeyPairGenerator.1.2.840.113549.1.1.1", "RSA"); |
| put("Alg.Alias.KeyPairGenerator.DIFFIEHELLMAN", "DH"); |
| |
| - put("KeyPairGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$GOST3410"); |
| - put("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410"); |
| - put("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410"); |
| + // BEGIN android-removed |
| + // put("KeyPairGenerator.GOST3410", "org.bouncycastle.jce.provider.JDKKeyPairGenerator$GOST3410"); |
| + // put("Alg.Alias.KeyPairGenerator.GOST-3410", "GOST3410"); |
| + // put("Alg.Alias.KeyPairGenerator.GOST-3410-94", "GOST3410"); |
| + // END android-removed |
| |
| // |
| // key factories |
| @@ -441,20 +533,24 @@ |
| put("KeyFactory.RSA", "org.bouncycastle.jce.provider.JDKKeyFactory$RSA"); |
| put("KeyFactory.DH", "org.bouncycastle.jce.provider.JDKKeyFactory$DH"); |
| put("KeyFactory.DSA", "org.bouncycastle.jce.provider.JDKKeyFactory$DSA"); |
| - put("KeyFactory.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal"); |
| - put("KeyFactory.ElGamal", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal"); |
| - |
| - put("KeyFactory.X.509", "org.bouncycastle.jce.provider.JDKKeyFactory$X509"); |
| + // BEGIN android-removed |
| + // put("KeyFactory.ELGAMAL", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal"); |
| + // put("KeyFactory.ElGamal", "org.bouncycastle.jce.provider.JDKKeyFactory$ElGamal"); |
| + // |
| + // put("KeyFactory.X.509", "org.bouncycastle.jce.provider.JDKKeyFactory$X509"); |
| + // END android-removed |
| |
| put("Alg.Alias.KeyFactory.1.2.840.113549.1.1.1", "RSA"); |
| put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSA"); |
| |
| put("Alg.Alias.KeyFactory.DIFFIEHELLMAN", "DH"); |
| |
| - put("KeyFactory.GOST3410", "org.bouncycastle.jce.provider.JDKKeyFactory$GOST3410"); |
| - put("Alg.Alias.KeyFactory.GOST-3410", "GOST3410"); |
| - put("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410"); |
| - put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_94, "GOST3410"); |
| + // BEGIN android-removed |
| + // put("KeyFactory.GOST3410", "org.bouncycastle.jce.provider.JDKKeyFactory$GOST3410"); |
| + // put("Alg.Alias.KeyFactory.GOST-3410", "GOST3410"); |
| + // put("Alg.Alias.KeyFactory.GOST-3410-94", "GOST3410"); |
| + // put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_94, "GOST3410"); |
| + // END android-removed |
| |
| // |
| // Algorithm parameters |
| @@ -462,16 +558,22 @@ |
| put("AlgorithmParameters.DES", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| put("Alg.Alias.AlgorithmParameters." + OIWObjectIdentifiers.desCBC, "DES"); |
| put("AlgorithmParameters.DESEDE", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| - put("AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| - put("AlgorithmParameters.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters"); |
| - put("AlgorithmParameters.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters"); |
| - put("AlgorithmParameters.RC5", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| - put("AlgorithmParameters.RC6", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // BEGIN android-changed |
| + put("Alg.Alias.AlgorithmParameters." + PKCSObjectIdentifiers.des_EDE3_CBC, "DESEDE"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("AlgorithmParameters.RC2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters"); |
| + // put("AlgorithmParameters.1.2.840.113549.3.2", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$RC2AlgorithmParameters"); |
| + // put("AlgorithmParameters.RC5", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // put("AlgorithmParameters.RC6", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // END android-removed |
| put("AlgorithmParameters.BLOWFISH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| put("Alg.Alias.AlgorithmParameters.1.3.6.1.4.1.3029.1.2", "BLOWFISH"); |
| - put("AlgorithmParameters.TWOFISH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| - put("AlgorithmParameters.SKIPJACK", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| - put("AlgorithmParameters.RIJNDAEL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // BEGIN android-removed |
| + // put("AlgorithmParameters.TWOFISH", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // put("AlgorithmParameters.SKIPJACK", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // put("AlgorithmParameters.RIJNDAEL", "org.bouncycastle.jce.provider.JDKAlgorithmParameters$IVAlgorithmParameters"); |
| + // END android-removed |
| |
| |
| // |
| @@ -479,8 +581,10 @@ |
| // |
| put("SecretKeyFactory.DES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$DES"); |
| put("SecretKeyFactory.DESEDE", "org.bouncycastle.jce.provider.JCESecretKeyFactory$DESede"); |
| - put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES"); |
| - put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2"); |
| + // BEGIN android-removed |
| + // put("SecretKeyFactory.PBEWITHMD2ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndDES"); |
| + // put("SecretKeyFactory.PBEWITHMD2ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD2AndRC2"); |
| + // END android-removed |
| put("SecretKeyFactory.PBEWITHMD5ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndDES"); |
| put("SecretKeyFactory.PBEWITHMD5ANDRC2", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5AndRC2"); |
| put("SecretKeyFactory.PBEWITHSHA1ANDDES", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA1AndDES"); |
| @@ -492,31 +596,41 @@ |
| put("SecretKeyFactory.PBEWITHSHAAND128BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd128BitRC2"); |
| put("SecretKeyFactory.PBEWITHSHAAND40BITRC2-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAnd40BitRC2"); |
| put("SecretKeyFactory.PBEWITHSHAANDTWOFISH-CBC", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHAAndTwofish"); |
| - put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160"); |
| + // BEGIN android-removed |
| + // put("SecretKeyFactory.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithRIPEMD160"); |
| + // END android-removed |
| put("SecretKeyFactory.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithSHA"); |
| - put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger"); |
| + // BEGIN android-removed |
| + // put("SecretKeyFactory.PBEWITHHMACTIGER", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithTiger"); |
| + // END android-removed |
| |
| put("SecretKeyFactory.PBEWITHMD5AND128BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And128BitAESCBCOpenSSL"); |
| put("SecretKeyFactory.PBEWITHMD5AND192BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And192BitAESCBCOpenSSL"); |
| put("SecretKeyFactory.PBEWITHMD5AND256BITAES-CBC-OPENSSL", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBEWithMD5And256BitAESCBCOpenSSL"); |
| |
| - put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5"); |
| - |
| - put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5"); |
| - put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5"); |
| - put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12"); |
| - put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12"); |
| - put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12"); |
| - put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12"); |
| - |
| - put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES"); |
| - put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.SecretKeyFactory.PBE", "PBE/PKCS5"); |
| + // |
| + // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHMD5ANDDES", "PBE/PKCS5"); |
| + // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHA1ANDDES", "PBE/PKCS5"); |
| + // put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12"); |
| + // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND3-KEYTRIPLEDES-CBC", "PBE/PKCS12"); |
| + // put("Alg.Alias.SecretKeyFactory.BROKENPBEWITHSHAAND2-KEYTRIPLEDES-CBC", "PBE/PKCS12"); |
| + // put("Alg.Alias.SecretKeyFactory.OLDPBEWITHSHAANDTWOFISH-CBC", "PBE/PKCS12"); |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDDES-CBC", "PBEWITHMD2ANDDES"); |
| + // put("Alg.Alias.SecretKeyFactory.PBEWITHMD2ANDRC2-CBC", "PBEWITHMD2ANDRC2"); |
| + // END android-removed |
| put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDDES-CBC", "PBEWITHMD5ANDDES"); |
| put("Alg.Alias.SecretKeyFactory.PBEWITHMD5ANDRC2-CBC", "PBEWITHMD5ANDRC2"); |
| put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDDES-CBC", "PBEWITHSHA1ANDDES"); |
| put("Alg.Alias.SecretKeyFactory.PBEWITHSHA1ANDRC2-CBC", "PBEWITHSHA1ANDRC2"); |
| - put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES"); |
| - put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, "PBEWITHMD2ANDDES"); |
| + // put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, "PBEWITHMD2ANDRC2"); |
| + // END android-removed |
| put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndDES_CBC, "PBEWITHMD5ANDDES"); |
| put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithMD5AndRC2_CBC, "PBEWITHMD5ANDRC2"); |
| put("Alg.Alias.SecretKeyFactory." + PKCSObjectIdentifiers.pbeWithSHA1AndDES_CBC, "PBEWITHSHA1ANDDES"); |
| @@ -553,6 +667,10 @@ |
| put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.getId(), "PBEWITHSHA256AND128BITAES-CBC-BC"); |
| put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.getId(), "PBEWITHSHA256AND192BITAES-CBC-BC"); |
| put("Alg.Alias.SecretKeyFactory." + BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.getId(), "PBEWITHSHA256AND256BITAES-CBC-BC"); |
| + // BEGIN android-added |
| + |
| + put("SecretKeyFactory.PBKDF2WithHmacSHA1", "org.bouncycastle.jce.provider.JCESecretKeyFactory$PBKDF2WithHmacSHA1"); |
| + // END android-added |
| |
| addMacAlgorithms(); |
| |
| @@ -561,16 +679,23 @@ |
| addSignatureAlgorithms(); |
| |
| // Certification Path API |
| - put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi"); |
| - put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi"); |
| - put("CertPathValidator.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi"); |
| - put("CertPathBuilder.RFC3280", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi"); |
| + // BEGIN android-removed |
| + // put("CertPathValidator.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathValidatorSpi"); |
| + // put("CertPathBuilder.RFC3281", "org.bouncycastle.jce.provider.PKIXAttrCertPathBuilderSpi"); |
| + // END android-removed |
| + // BEGIN android-changed |
| + // Use Alg.Alias so RFC3280 doesn't show up when iterating provider services, only PKIX |
| + put("Alg.Alias.CertPathValidator.RFC3280", "PKIX"); |
| + put("Alg.Alias.CertPathBuilder.RFC3280", "PKIX"); |
| + // END android-changed |
| put("CertPathValidator.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi"); |
| put("CertPathBuilder.PKIX", "org.bouncycastle.jce.provider.PKIXCertPathBuilderSpi"); |
| put("CertStore.Collection", "org.bouncycastle.jce.provider.CertStoreCollectionSpi"); |
| - put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi"); |
| - put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi"); |
| - put("Alg.Alias.CertStore.X509LDAP", "LDAP"); |
| + // BEGIN android-removed |
| + // put("CertStore.LDAP", "org.bouncycastle.jce.provider.X509LDAPCertStoreSpi"); |
| + // put("CertStore.Multi", "org.bouncycastle.jce.provider.MultiCertStoreSpi"); |
| + // put("Alg.Alias.CertStore.X509LDAP", "LDAP"); |
| + // END android-removed |
| } |
| |
| private void loadAlgorithms(String packageName, String[] names) |
| @@ -631,68 +756,72 @@ |
| // |
| private void addMacAlgorithms() |
| { |
| - put("Mac.DESMAC", "org.bouncycastle.jce.provider.JCEMac$DES"); |
| - put("Alg.Alias.Mac.DES", "DESMAC"); |
| - put("Mac.DESMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESCFB8"); |
| - put("Alg.Alias.Mac.DES/CFB8", "DESMAC/CFB8"); |
| - |
| - put("Mac.DESEDEMAC", "org.bouncycastle.jce.provider.JCEMac$DESede"); |
| - put("Alg.Alias.Mac.DESEDE", "DESEDEMAC"); |
| - put("Mac.DESEDEMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESedeCFB8"); |
| - put("Alg.Alias.Mac.DESEDE/CFB8", "DESEDEMAC/CFB8"); |
| - |
| - put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3"); |
| - put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797"); |
| - |
| - put("Mac.DESEDEMAC64", "org.bouncycastle.jce.provider.JCEMac$DESede64"); |
| - put("Alg.Alias.Mac.DESEDE64", "DESEDEMAC64"); |
| - |
| - put("Mac.DESEDEMAC64WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DESede64with7816d4"); |
| - put("Alg.Alias.Mac.DESEDE64WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING"); |
| - put("Alg.Alias.Mac.DESEDEISO9797ALG1MACWITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING"); |
| - put("Alg.Alias.Mac.DESEDEISO9797ALG1WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING"); |
| - |
| - put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3"); |
| - put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC"); |
| - put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4"); |
| - put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING"); |
| - |
| - put("Mac.SKIPJACKMAC", "org.bouncycastle.jce.provider.JCEMac$Skipjack"); |
| - put("Alg.Alias.Mac.SKIPJACK", "SKIPJACKMAC"); |
| - put("Mac.SKIPJACKMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$SkipjackCFB8"); |
| - put("Alg.Alias.Mac.SKIPJACK/CFB8", "SKIPJACKMAC/CFB8"); |
| - |
| - put("Mac.RC2MAC", "org.bouncycastle.jce.provider.JCEMac$RC2"); |
| - put("Alg.Alias.Mac.RC2", "RC2MAC"); |
| - put("Mac.RC2MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC2CFB8"); |
| - put("Alg.Alias.Mac.RC2/CFB8", "RC2MAC/CFB8"); |
| - |
| - put("Mac.RC5MAC", "org.bouncycastle.jce.provider.JCEMac$RC5"); |
| - put("Alg.Alias.Mac.RC5", "RC5MAC"); |
| - put("Mac.RC5MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC5CFB8"); |
| - put("Alg.Alias.Mac.RC5/CFB8", "RC5MAC/CFB8"); |
| - |
| - put("Mac.GOST28147MAC", "org.bouncycastle.jce.provider.JCEMac$GOST28147"); |
| - put("Alg.Alias.Mac.GOST28147", "GOST28147MAC"); |
| - |
| - put("Mac.VMPCMAC", "org.bouncycastle.jce.provider.JCEMac$VMPC"); |
| - put("Alg.Alias.Mac.VMPC", "VMPCMAC"); |
| - put("Alg.Alias.Mac.VMPC-MAC", "VMPCMAC"); |
| - |
| - put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384"); |
| - |
| - put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512"); |
| - |
| - addHMACAlgorithm("MD2", "org.bouncycastle.jce.provider.JCEMac$MD2", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD2HMAC"); |
| - addHMACAlgorithm("MD4", "org.bouncycastle.jce.provider.JCEMac$MD4", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD4HMAC"); |
| + // BEGIN android-removed |
| + // put("Mac.DESMAC", "org.bouncycastle.jce.provider.JCEMac$DES"); |
| + // put("Alg.Alias.Mac.DES", "DESMAC"); |
| + // put("Mac.DESMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESCFB8"); |
| + // put("Alg.Alias.Mac.DES/CFB8", "DESMAC/CFB8"); |
| + // |
| + // put("Mac.DESEDEMAC", "org.bouncycastle.jce.provider.JCEMac$DESede"); |
| + // put("Alg.Alias.Mac.DESEDE", "DESEDEMAC"); |
| + // put("Mac.DESEDEMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$DESedeCFB8"); |
| + // put("Alg.Alias.Mac.DESEDE/CFB8", "DESEDEMAC/CFB8"); |
| + // |
| + // put("Mac.DESWITHISO9797", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3"); |
| + // put("Alg.Alias.Mac.DESISO9797MAC", "DESWITHISO9797"); |
| + // |
| + // put("Mac.DESEDEMAC64", "org.bouncycastle.jce.provider.JCEMac$DESede64"); |
| + // put("Alg.Alias.Mac.DESEDE64", "DESEDEMAC64"); |
| + // |
| + // put("Mac.DESEDEMAC64WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DESede64with7816d4"); |
| + // put("Alg.Alias.Mac.DESEDE64WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING"); |
| + // put("Alg.Alias.Mac.DESEDEISO9797ALG1MACWITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING"); |
| + // put("Alg.Alias.Mac.DESEDEISO9797ALG1WITHISO7816-4PADDING", "DESEDEMAC64WITHISO7816-4PADDING"); |
| + // |
| + // put("Mac.ISO9797ALG3MAC", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3"); |
| + // put("Alg.Alias.Mac.ISO9797ALG3", "ISO9797ALG3MAC"); |
| + // put("Mac.ISO9797ALG3WITHISO7816-4PADDING", "org.bouncycastle.jce.provider.JCEMac$DES9797Alg3with7816d4"); |
| + // put("Alg.Alias.Mac.ISO9797ALG3MACWITHISO7816-4PADDING", "ISO9797ALG3WITHISO7816-4PADDING"); |
| + // |
| + // put("Mac.SKIPJACKMAC", "org.bouncycastle.jce.provider.JCEMac$Skipjack"); |
| + // put("Alg.Alias.Mac.SKIPJACK", "SKIPJACKMAC"); |
| + // put("Mac.SKIPJACKMAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$SkipjackCFB8"); |
| + // put("Alg.Alias.Mac.SKIPJACK/CFB8", "SKIPJACKMAC/CFB8"); |
| + // |
| + // put("Mac.RC2MAC", "org.bouncycastle.jce.provider.JCEMac$RC2"); |
| + // put("Alg.Alias.Mac.RC2", "RC2MAC"); |
| + // put("Mac.RC2MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC2CFB8"); |
| + // put("Alg.Alias.Mac.RC2/CFB8", "RC2MAC/CFB8"); |
| + // |
| + // put("Mac.RC5MAC", "org.bouncycastle.jce.provider.JCEMac$RC5"); |
| + // put("Alg.Alias.Mac.RC5", "RC5MAC"); |
| + // put("Mac.RC5MAC/CFB8", "org.bouncycastle.jce.provider.JCEMac$RC5CFB8"); |
| + // put("Alg.Alias.Mac.RC5/CFB8", "RC5MAC/CFB8"); |
| + // |
| + // put("Mac.GOST28147MAC", "org.bouncycastle.jce.provider.JCEMac$GOST28147"); |
| + // put("Alg.Alias.Mac.GOST28147", "GOST28147MAC"); |
| + // |
| + // put("Mac.VMPCMAC", "org.bouncycastle.jce.provider.JCEMac$VMPC"); |
| + // put("Alg.Alias.Mac.VMPC", "VMPCMAC"); |
| + // put("Alg.Alias.Mac.VMPC-MAC", "VMPCMAC"); |
| + // |
| + // put("Mac.OLDHMACSHA384", "org.bouncycastle.jce.provider.JCEMac$OldSHA384"); |
| + // |
| + // put("Mac.OLDHMACSHA512", "org.bouncycastle.jce.provider.JCEMac$OldSHA512"); |
| + // |
| + // addHMACAlgorithm("MD2", "org.bouncycastle.jce.provider.JCEMac$MD2", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD2HMAC"); |
| + // addHMACAlgorithm("MD4", "org.bouncycastle.jce.provider.JCEMac$MD4", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD4HMAC"); |
| + // END android-removed |
| addHMACAlgorithm("MD5", "org.bouncycastle.jce.provider.JCEMac$MD5", "org.bouncycastle.jce.provider.JCEKeyGenerator$MD5HMAC"); |
| addHMACAlias("MD5", IANAObjectIdentifiers.hmacMD5); |
| |
| addHMACAlgorithm("SHA1", "org.bouncycastle.jce.provider.JCEMac$SHA1", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA1"); |
| addHMACAlias("SHA1", PKCSObjectIdentifiers.id_hmacWithSHA1); |
| addHMACAlias("SHA1", IANAObjectIdentifiers.hmacSHA1); |
| - addHMACAlgorithm("SHA224", "org.bouncycastle.jce.provider.JCEMac$SHA224", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA224"); |
| - addHMACAlias("SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224); |
| + // BEGIN android-removed |
| + // addHMACAlgorithm("SHA224", "org.bouncycastle.jce.provider.JCEMac$SHA224", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA224"); |
| + // addHMACAlias("SHA224", PKCSObjectIdentifiers.id_hmacWithSHA224); |
| + // END android-removed |
| addHMACAlgorithm("SHA256", "org.bouncycastle.jce.provider.JCEMac$SHA256", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA256"); |
| addHMACAlias("SHA256", PKCSObjectIdentifiers.id_hmacWithSHA256); |
| addHMACAlgorithm("SHA384", "org.bouncycastle.jce.provider.JCEMac$SHA384", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA384"); |
| @@ -700,16 +829,20 @@ |
| addHMACAlgorithm("SHA512", "org.bouncycastle.jce.provider.JCEMac$SHA512", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACSHA512"); |
| addHMACAlias("SHA512", PKCSObjectIdentifiers.id_hmacWithSHA512); |
| |
| - addHMACAlgorithm("RIPEMD128", "org.bouncycastle.jce.provider.JCEMac$RIPEMD128", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD128HMAC"); |
| - addHMACAlgorithm("RIPEMD160", "org.bouncycastle.jce.provider.JCEMac$RIPEMD160", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD160HMAC"); |
| - addHMACAlias("RIPEMD160", IANAObjectIdentifiers.hmacRIPEMD160); |
| - |
| - addHMACAlgorithm("TIGER", "org.bouncycastle.jce.provider.JCEMac$Tiger", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACTIGER"); |
| - addHMACAlias("TIGER", IANAObjectIdentifiers.hmacTIGER); |
| + // BEGIN android-removed |
| + // addHMACAlgorithm("RIPEMD128", "org.bouncycastle.jce.provider.JCEMac$RIPEMD128", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD128HMAC"); |
| + // addHMACAlgorithm("RIPEMD160", "org.bouncycastle.jce.provider.JCEMac$RIPEMD160", "org.bouncycastle.jce.provider.JCEKeyGenerator$RIPEMD160HMAC"); |
| + // addHMACAlias("RIPEMD160", IANAObjectIdentifiers.hmacRIPEMD160); |
| + // |
| + // addHMACAlgorithm("TIGER", "org.bouncycastle.jce.provider.JCEMac$Tiger", "org.bouncycastle.jce.provider.JCEKeyGenerator$HMACTIGER"); |
| + // addHMACAlias("TIGER", IANAObjectIdentifiers.hmacTIGER); |
| + // END android-removed |
| |
| put("Mac.PBEWITHHMACSHA", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA"); |
| put("Mac.PBEWITHHMACSHA1", "org.bouncycastle.jce.provider.JCEMac$PBEWithSHA"); |
| - put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160"); |
| + // BEGIN android-removed |
| + // put("Mac.PBEWITHHMACRIPEMD160", "org.bouncycastle.jce.provider.JCEMac$PBEWithRIPEMD160"); |
| + // END android-removed |
| put("Alg.Alias.Mac.1.3.14.3.2.26", "PBEWITHHMACSHA"); |
| } |
| |
| @@ -747,9 +880,11 @@ |
| put("Alg.Alias.MessageDigest.SHA1", "SHA-1"); |
| put("Alg.Alias.MessageDigest.SHA", "SHA-1"); |
| put("Alg.Alias.MessageDigest." + OIWObjectIdentifiers.idSHA1, "SHA-1"); |
| - put("MessageDigest.SHA-224", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA224"); |
| - put("Alg.Alias.MessageDigest.SHA224", "SHA-224"); |
| - put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224"); |
| + // BEGIN android-removed |
| + // put("MessageDigest.SHA-224", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA224"); |
| + // put("Alg.Alias.MessageDigest.SHA224", "SHA-224"); |
| + // put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha224, "SHA-224"); |
| + // END android-removed |
| put("MessageDigest.SHA-256", "org.bouncycastle.jce.provider.JDKMessageDigest$SHA256"); |
| put("Alg.Alias.MessageDigest.SHA256", "SHA-256"); |
| put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha256, "SHA-256"); |
| @@ -760,27 +895,31 @@ |
| put("Alg.Alias.MessageDigest.SHA512", "SHA-512"); |
| put("Alg.Alias.MessageDigest." + NISTObjectIdentifiers.id_sha512, "SHA-512"); |
| |
| - put("MessageDigest.MD2", "org.bouncycastle.jce.provider.JDKMessageDigest$MD2"); |
| - put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md2, "MD2"); |
| - put("MessageDigest.MD4", "org.bouncycastle.jce.provider.JDKMessageDigest$MD4"); |
| - put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md4, "MD4"); |
| + // BEGIN android-removed |
| + // put("MessageDigest.MD2", "org.bouncycastle.jce.provider.JDKMessageDigest$MD2"); |
| + // put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md2, "MD2"); |
| + // put("MessageDigest.MD4", "org.bouncycastle.jce.provider.JDKMessageDigest$MD4"); |
| + // put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md4, "MD4"); |
| + // END android-removed |
| put("MessageDigest.MD5", "org.bouncycastle.jce.provider.JDKMessageDigest$MD5"); |
| put("Alg.Alias.MessageDigest." + PKCSObjectIdentifiers.md5, "MD5"); |
| - put("MessageDigest.RIPEMD128", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD128"); |
| - put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd128, "RIPEMD128"); |
| - put("MessageDigest.RIPEMD160", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD160"); |
| - put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd160, "RIPEMD160"); |
| - put("MessageDigest.RIPEMD256", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD256"); |
| - put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd256, "RIPEMD256"); |
| - put("MessageDigest.RIPEMD320", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD320"); |
| - put("MessageDigest.Tiger", "org.bouncycastle.jce.provider.JDKMessageDigest$Tiger"); |
| - |
| - put("MessageDigest.WHIRLPOOL", "org.bouncycastle.jce.provider.JDKMessageDigest$Whirlpool"); |
| - |
| - put("MessageDigest.GOST3411", "org.bouncycastle.jce.provider.JDKMessageDigest$GOST3411"); |
| - put("Alg.Alias.MessageDigest.GOST", "GOST3411"); |
| - put("Alg.Alias.MessageDigest.GOST-3411", "GOST3411"); |
| - put("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411"); |
| + // BEGIN android-removed |
| + // put("MessageDigest.RIPEMD128", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD128"); |
| + // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd128, "RIPEMD128"); |
| + // put("MessageDigest.RIPEMD160", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD160"); |
| + // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd160, "RIPEMD160"); |
| + // put("MessageDigest.RIPEMD256", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD256"); |
| + // put("Alg.Alias.MessageDigest." + TeleTrusTObjectIdentifiers.ripemd256, "RIPEMD256"); |
| + // put("MessageDigest.RIPEMD320", "org.bouncycastle.jce.provider.JDKMessageDigest$RIPEMD320"); |
| + // put("MessageDigest.Tiger", "org.bouncycastle.jce.provider.JDKMessageDigest$Tiger"); |
| + |
| + // put("MessageDigest.WHIRLPOOL", "org.bouncycastle.jce.provider.JDKMessageDigest$Whirlpool"); |
| + |
| + // put("MessageDigest.GOST3411", "org.bouncycastle.jce.provider.JDKMessageDigest$GOST3411"); |
| + // put("Alg.Alias.MessageDigest.GOST", "GOST3411"); |
| + // put("Alg.Alias.MessageDigest.GOST-3411", "GOST3411"); |
| + // put("Alg.Alias.MessageDigest." + CryptoProObjectIdentifiers.gostR3411, "GOST3411"); |
| + // END android-removed |
| } |
| |
| // |
| @@ -788,55 +927,70 @@ |
| // |
| private void addSignatureAlgorithms() |
| { |
| - put("Signature.MD2WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD2WithRSAEncryption"); |
| - put("Signature.MD4WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD4WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // Dropping MD2 |
| + // put("Signature.MD2WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD2WithRSAEncryption"); |
| + // put("Signature.MD4WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD4WithRSAEncryption"); |
| + // END android-removed |
| put("Signature.MD5WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$MD5WithRSAEncryption"); |
| put("Signature.SHA1WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA1WithRSAEncryption"); |
| - put("Signature.SHA224WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA224WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Signature.SHA224WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA224WithRSAEncryption"); |
| + // END android-removed |
| put("Signature.SHA256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA256WithRSAEncryption"); |
| put("Signature.SHA384WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA384WithRSAEncryption"); |
| put("Signature.SHA512WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$SHA512WithRSAEncryption"); |
| - put("Signature.RIPEMD160WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD160WithRSAEncryption"); |
| - put("Signature.RIPEMD128WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD128WithRSAEncryption"); |
| - put("Signature.RIPEMD256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD256WithRSAEncryption"); |
| - put("Signature.DSA", "org.bouncycastle.jce.provider.JDKDSASigner$stdDSA"); |
| + // BEGIN android-removed |
| + // put("Signature.RIPEMD160WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD160WithRSAEncryption"); |
| + // put("Signature.RIPEMD128WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD128WithRSAEncryption"); |
| + // put("Signature.RIPEMD256WithRSAEncryption", "org.bouncycastle.jce.provider.JDKDigestSignature$RIPEMD256WithRSAEncryption"); |
| + // END android-removed |
| + // BEGIN android-changed |
| + put("Signature.SHA1withDSA", "org.bouncycastle.jce.provider.JDKDSASigner$stdDSA"); |
| + // END android-changed |
| put("Signature.NONEWITHDSA", "org.bouncycastle.jce.provider.JDKDSASigner$noneDSA"); |
| - put("Signature.SHA1withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$SHA1WithRSAEncryption"); |
| - put("Signature.MD5withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$MD5WithRSAEncryption"); |
| - put("Signature.RIPEMD160withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$RIPEMD160WithRSAEncryption"); |
| - |
| - put("Signature.RSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA"); |
| - put("Signature." + PKCSObjectIdentifiers.id_RSASSA_PSS, "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA"); |
| - put("Signature.SHA1withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA1withRSA"); |
| - put("Signature.SHA224withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA224withRSA"); |
| - put("Signature.SHA256withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA256withRSA"); |
| - put("Signature.SHA384withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA384withRSA"); |
| - put("Signature.SHA512withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA512withRSA"); |
| - |
| - put("Signature.RSA", "org.bouncycastle.jce.provider.JDKDigestSignature$noneRSA"); |
| - put("Signature.RAWRSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$nonePSS"); |
| + // BEGIN android-removed |
| + // put("Signature.SHA1withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$SHA1WithRSAEncryption"); |
| + // put("Signature.MD5withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$MD5WithRSAEncryption"); |
| + // put("Signature.RIPEMD160withRSA/ISO9796-2", "org.bouncycastle.jce.provider.JDKISOSignature$RIPEMD160WithRSAEncryption"); |
| + // |
| + // put("Signature.RSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA"); |
| + // put("Signature." + PKCSObjectIdentifiers.id_RSASSA_PSS, "org.bouncycastle.jce.provider.JDKPSSSigner$PSSwithRSA"); |
| + // put("Signature.SHA1withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA1withRSA"); |
| + // put("Signature.SHA224withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA224withRSA"); |
| + // put("Signature.SHA256withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA256withRSA"); |
| + // put("Signature.SHA384withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA384withRSA"); |
| + // put("Signature.SHA512withRSA/PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$SHA512withRSA"); |
| + // |
| + // put("Signature.RSA", "org.bouncycastle.jce.provider.JDKDigestSignature$noneRSA"); |
| + // put("Signature.RAWRSASSA-PSS", "org.bouncycastle.jce.provider.JDKPSSSigner$nonePSS"); |
| + // END android-removed |
| |
| put("Alg.Alias.Signature.RAWDSA", "NONEWITHDSA"); |
| |
| - put("Alg.Alias.Signature.RAWRSA", "RSA"); |
| - put("Alg.Alias.Signature.NONEWITHRSA", "RSA"); |
| - put("Alg.Alias.Signature.RAWRSAPSS", "RAWRSASSA-PSS"); |
| - put("Alg.Alias.Signature.NONEWITHRSAPSS", "RAWRSASSA-PSS"); |
| - put("Alg.Alias.Signature.NONEWITHRSASSA-PSS", "RAWRSASSA-PSS"); |
| - |
| - put("Alg.Alias.Signature.RSAPSS", "RSASSA-PSS"); |
| - |
| - put("Alg.Alias.Signature.SHA1withRSAandMGF1", "SHA1withRSA/PSS"); |
| - put("Alg.Alias.Signature.SHA224withRSAandMGF1", "SHA224withRSA/PSS"); |
| - put("Alg.Alias.Signature.SHA256withRSAandMGF1", "SHA256withRSA/PSS"); |
| - put("Alg.Alias.Signature.SHA384withRSAandMGF1", "SHA384withRSA/PSS"); |
| - put("Alg.Alias.Signature.SHA512withRSAandMGF1", "SHA512withRSA/PSS"); |
| - |
| - put("Alg.Alias.Signature.MD2withRSAEncryption", "MD2WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD4withRSAEncryption", "MD4WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.RAWRSA", "RSA"); |
| + // put("Alg.Alias.Signature.NONEWITHRSA", "RSA"); |
| + // put("Alg.Alias.Signature.RAWRSAPSS", "RAWRSASSA-PSS"); |
| + // put("Alg.Alias.Signature.NONEWITHRSAPSS", "RAWRSASSA-PSS"); |
| + // put("Alg.Alias.Signature.NONEWITHRSASSA-PSS", "RAWRSASSA-PSS"); |
| + // |
| + // put("Alg.Alias.Signature.RSAPSS", "RSASSA-PSS"); |
| + // |
| + // put("Alg.Alias.Signature.SHA1withRSAandMGF1", "SHA1withRSA/PSS"); |
| + // put("Alg.Alias.Signature.SHA224withRSAandMGF1", "SHA224withRSA/PSS"); |
| + // put("Alg.Alias.Signature.SHA256withRSAandMGF1", "SHA256withRSA/PSS"); |
| + // put("Alg.Alias.Signature.SHA384withRSAandMGF1", "SHA384withRSA/PSS"); |
| + // put("Alg.Alias.Signature.SHA512withRSAandMGF1", "SHA512withRSA/PSS"); |
| + // |
| + // put("Alg.Alias.Signature.MD2withRSAEncryption", "MD2WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.MD4withRSAEncryption", "MD4WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature.MD5withRSAEncryption", "MD5WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA1withRSAEncryption", "SHA1WithRSAEncryption"); |
| - put("Alg.Alias.Signature.SHA224withRSAEncryption", "SHA224WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.SHA224withRSAEncryption", "SHA224WithRSAEncryption"); |
| + // END android-removed |
| |
| put("Alg.Alias.Signature.SHA256withRSAEncryption", "SHA256WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA384withRSAEncryption", "SHA384WithRSAEncryption"); |
| @@ -850,24 +1004,30 @@ |
| put("Alg.Alias.Signature.SHA384WITHRSAENCRYPTION", "SHA384WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA512WITHRSAENCRYPTION", "SHA512WithRSAEncryption"); |
| |
| - put("Alg.Alias.Signature.RIPEMD160withRSAEncryption", "RIPEMD160WithRSAEncryption"); |
| - |
| - put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md2WithRSAEncryption, "MD2WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD2WithRSA", "MD2WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD2withRSA", "MD2WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD2/RSA", "MD2WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // Dropping MD2 |
| + // put("Alg.Alias.Signature.RIPEMD160withRSAEncryption", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md2WithRSAEncryption, "MD2WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.MD2WithRSA", "MD2WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.MD2withRSA", "MD2WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.MD2/RSA", "MD2WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature.MD5WithRSA", "MD5WithRSAEncryption"); |
| put("Alg.Alias.Signature.MD5withRSA", "MD5WithRSAEncryption"); |
| put("Alg.Alias.Signature.MD5/RSA", "MD5WithRSAEncryption"); |
| put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md5WithRSAEncryption, "MD5WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD4WithRSA", "MD4WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD4withRSA", "MD4WithRSAEncryption"); |
| - put("Alg.Alias.Signature.MD4/RSA", "MD4WithRSAEncryption"); |
| - put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md4WithRSAEncryption, "MD4WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.MD4WithRSA", "MD4WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.MD4withRSA", "MD4WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.MD4/RSA", "MD4WithRSAEncryption"); |
| + // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.md4WithRSAEncryption, "MD4WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature.SHA1WithRSA", "SHA1WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA1withRSA", "SHA1WithRSAEncryption"); |
| - put("Alg.Alias.Signature.SHA224WithRSA", "SHA224WithRSAEncryption"); |
| - put("Alg.Alias.Signature.SHA224withRSA", "SHA224WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.SHA224WithRSA", "SHA224WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.SHA224withRSA", "SHA224WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature.SHA256WithRSA", "SHA256WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA256withRSA", "SHA256WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA384WithRSA", "SHA384WithRSAEncryption"); |
| @@ -877,92 +1037,110 @@ |
| put("Alg.Alias.Signature.SHA1/RSA", "SHA1WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA-1/RSA", "SHA1WithRSAEncryption"); |
| put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha1WithRSAEncryption, "SHA1WithRSAEncryption"); |
| - put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha224WithRSAEncryption, "SHA224WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha256WithRSAEncryption, "SHA256WithRSAEncryption"); |
| put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha384WithRSAEncryption, "SHA384WithRSAEncryption"); |
| put("Alg.Alias.Signature." + PKCSObjectIdentifiers.sha512WithRSAEncryption, "SHA512WithRSAEncryption"); |
| put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.1", "SHA1WithRSAEncryption"); |
| put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.113549.1.1.5", "SHA1WithRSAEncryption"); |
| put("Alg.Alias.Signature.1.2.840.113549.2.5with1.2.840.113549.1.1.1", "MD5WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD160WithRSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD160withRSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD128WithRSA", "RIPEMD128WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD128withRSA", "RIPEMD128WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD256WithRSA", "RIPEMD256WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD256withRSA", "RIPEMD256WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD-160/RSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RMD160withRSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RMD160/RSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.1.3.36.3.3.1.2", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.1.3.36.3.3.1.3", "RIPEMD128WithRSAEncryption"); |
| - put("Alg.Alias.Signature.1.3.36.3.3.1.4", "RIPEMD256WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.RIPEMD160WithRSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD160withRSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD128WithRSA", "RIPEMD128WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD128withRSA", "RIPEMD128WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD256WithRSA", "RIPEMD256WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD256withRSA", "RIPEMD256WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD-160/RSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RMD160withRSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RMD160/RSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.1.3.36.3.3.1.2", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.1.3.36.3.3.1.3", "RIPEMD128WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.1.3.36.3.3.1.4", "RIPEMD256WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature." + OIWObjectIdentifiers.sha1WithRSA, "SHA1WithRSAEncryption"); |
| |
| - put("Alg.Alias.Signature.MD2WITHRSAENCRYPTION", "MD2WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.MD2WITHRSAENCRYPTION", "MD2WithRSAEncryption"); |
| + // END android-removed |
| put("Alg.Alias.Signature.MD5WITHRSAENCRYPTION", "MD5WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA1WITHRSAENCRYPTION", "SHA1WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD160WITHRSAENCRYPTION", "RIPEMD160WithRSAEncryption"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.RIPEMD160WITHRSAENCRYPTION", "RIPEMD160WithRSAEncryption"); |
| + // END android-removed |
| |
| put("Alg.Alias.Signature.MD5WITHRSA", "MD5WithRSAEncryption"); |
| put("Alg.Alias.Signature.SHA1WITHRSA", "SHA1WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RMD160WITHRSA", "RIPEMD160WithRSAEncryption"); |
| - put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption"); |
| - |
| - addSignatureAlgorithm("SHA224", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa224", NISTObjectIdentifiers.dsa_with_sha224); |
| - addSignatureAlgorithm("SHA256", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa256", NISTObjectIdentifiers.dsa_with_sha256); |
| - addSignatureAlgorithm("SHA384", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa384", NISTObjectIdentifiers.dsa_with_sha384); |
| - addSignatureAlgorithm("SHA512", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa512", NISTObjectIdentifiers.dsa_with_sha512); |
| - |
| - put("Alg.Alias.Signature.SHA/DSA", "DSA"); |
| - put("Alg.Alias.Signature.SHA1withDSA", "DSA"); |
| - put("Alg.Alias.Signature.SHA1WITHDSA", "DSA"); |
| - put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "DSA"); |
| - put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3", "DSA"); |
| - put("Alg.Alias.Signature.DSAwithSHA1", "DSA"); |
| - put("Alg.Alias.Signature.DSAWITHSHA1", "DSA"); |
| - put("Alg.Alias.Signature.SHA1WithDSA", "DSA"); |
| - put("Alg.Alias.Signature.DSAWithSHA1", "DSA"); |
| - put("Alg.Alias.Signature.1.2.840.10040.4.3", "DSA"); |
| - put("Alg.Alias.Signature.MD5WithRSA/ISO9796-2", "MD5withRSA/ISO9796-2"); |
| - put("Alg.Alias.Signature.SHA1WithRSA/ISO9796-2", "SHA1withRSA/ISO9796-2"); |
| - put("Alg.Alias.Signature.RIPEMD160WithRSA/ISO9796-2", "RIPEMD160withRSA/ISO9796-2"); |
| - |
| - put("Signature.ECGOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$ecgost3410"); |
| - put("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410"); |
| - put("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410"); |
| - put("Alg.Alias.Signature.GOST3411withECGOST3410", "ECGOST3410"); |
| - put("Alg.Alias.Signature.GOST3411WITHECGOST3410", "ECGOST3410"); |
| - put("Alg.Alias.Signature.GOST3411WithECGOST3410", "ECGOST3410"); |
| - put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "ECGOST3410"); |
| - |
| - put("Signature.GOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$gost3410"); |
| - put("Alg.Alias.Signature.GOST-3410", "GOST3410"); |
| - put("Alg.Alias.Signature.GOST-3410-94", "GOST3410"); |
| - put("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410"); |
| - put("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410"); |
| - put("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410"); |
| - put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RMD160WITHRSA", "RIPEMD160WithRSAEncryption"); |
| + // put("Alg.Alias.Signature.RIPEMD160WITHRSA", "RIPEMD160WithRSAEncryption"); |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // addSignatureAlgorithm("SHA224", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa224", NISTObjectIdentifiers.dsa_with_sha224); |
| + // addSignatureAlgorithm("SHA256", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa256", NISTObjectIdentifiers.dsa_with_sha256); |
| + // addSignatureAlgorithm("SHA384", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa384", NISTObjectIdentifiers.dsa_with_sha384); |
| + // addSignatureAlgorithm("SHA512", "DSA", "org.bouncycastle.jce.provider.JDKDSASigner$dsa512", NISTObjectIdentifiers.dsa_with_sha512); |
| + // END android-removed |
| + |
| + // BEGIN android-changed |
| + put("Alg.Alias.Signature.SHA/DSA", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.DSA", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.SHA1WITHDSA", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.1", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.1.3.14.3.2.26with1.2.840.10040.4.3", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.DSAwithSHA1", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.DSAWITHSHA1", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.SHA1WithDSA", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.DSAWithSHA1", "SHA1withDSA"); |
| + put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA1withDSA"); |
| + // END android-changed |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature.MD5WithRSA/ISO9796-2", "MD5withRSA/ISO9796-2"); |
| + // put("Alg.Alias.Signature.SHA1WithRSA/ISO9796-2", "SHA1withRSA/ISO9796-2"); |
| + // put("Alg.Alias.Signature.RIPEMD160WithRSA/ISO9796-2", "RIPEMD160withRSA/ISO9796-2"); |
| + // |
| + // put("Signature.ECGOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$ecgost3410"); |
| + // put("Alg.Alias.Signature.ECGOST-3410", "ECGOST3410"); |
| + // put("Alg.Alias.Signature.GOST-3410-2001", "ECGOST3410"); |
| + // put("Alg.Alias.Signature.GOST3411withECGOST3410", "ECGOST3410"); |
| + // put("Alg.Alias.Signature.GOST3411WITHECGOST3410", "ECGOST3410"); |
| + // put("Alg.Alias.Signature.GOST3411WithECGOST3410", "ECGOST3410"); |
| + // put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_2001, "ECGOST3410"); |
| + // |
| + // put("Signature.GOST3410", "org.bouncycastle.jce.provider.JDKGOST3410Signer$gost3410"); |
| + // put("Alg.Alias.Signature.GOST-3410", "GOST3410"); |
| + // put("Alg.Alias.Signature.GOST-3410-94", "GOST3410"); |
| + // put("Alg.Alias.Signature.GOST3411withGOST3410", "GOST3410"); |
| + // put("Alg.Alias.Signature.GOST3411WITHGOST3410", "GOST3410"); |
| + // put("Alg.Alias.Signature.GOST3411WithGOST3410", "GOST3410"); |
| + // put("Alg.Alias.Signature." + CryptoProObjectIdentifiers.gostR3411_94_with_gostR3410_94, "GOST3410"); |
| + // END android-removed |
| } |
| |
| - private void addSignatureAlgorithm( |
| - String digest, |
| - String algorithm, |
| - String className, |
| - DERObjectIdentifier oid) |
| - { |
| - String mainName = digest + "WITH" + algorithm; |
| - String jdk11Variation1 = digest + "with" + algorithm; |
| - String jdk11Variation2 = digest + "With" + algorithm; |
| - String alias = digest + "/" + algorithm; |
| - |
| - put("Signature." + mainName, className); |
| - put("Alg.Alias.Signature." + jdk11Variation1, mainName); |
| - put("Alg.Alias.Signature." + jdk11Variation2, mainName); |
| - put("Alg.Alias.Signature." + alias, mainName); |
| - put("Alg.Alias.Signature." + oid, mainName); |
| - put("Alg.Alias.Signature.OID." + oid, mainName); |
| - } |
| + // BEGIN android-removed |
| + // private void addSignatureAlgorithm( |
| + // String digest, |
| + // String algorithm, |
| + // String className, |
| + // DERObjectIdentifier oid) |
| + // { |
| + // String mainName = digest + "WITH" + algorithm; |
| + // String jdk11Variation1 = digest + "with" + algorithm; |
| + // String jdk11Variation2 = digest + "With" + algorithm; |
| + // String alias = digest + "/" + algorithm; |
| + // |
| + // put("Signature." + mainName, className); |
| + // put("Alg.Alias.Signature." + jdk11Variation1, mainName); |
| + // put("Alg.Alias.Signature." + jdk11Variation2, mainName); |
| + // put("Alg.Alias.Signature." + alias, mainName); |
| + // put("Alg.Alias.Signature." + oid, mainName); |
| + // put("Alg.Alias.Signature.OID." + oid, mainName); |
| + // } |
| + // END android-removed |
| |
| public void setParameter(String parameterName, Object parameter) |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java bcprov-jdk16-145/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -24,6 +24,7 @@ |
| import java.security.spec.DSAPublicKeySpec; |
| import java.text.ParseException; |
| import java.util.ArrayList; |
| +import java.util.Arrays; |
| import java.util.Collection; |
| import java.util.Date; |
| import java.util.Enumeration; |
| @@ -35,6 +36,10 @@ |
| |
| import javax.security.auth.x500.X500Principal; |
| |
| +// BEGIN android-added |
| +import org.apache.harmony.xnet.provider.jsse.IndexedPKIXParameters; |
| + |
| +// END android-added |
| import org.bouncycastle.asn1.ASN1InputStream; |
| import org.bouncycastle.asn1.ASN1Object; |
| import org.bouncycastle.asn1.ASN1OctetString; |
| @@ -59,13 +64,17 @@ |
| import org.bouncycastle.asn1.x509.PolicyInformation; |
| import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; |
| import org.bouncycastle.asn1.x509.X509Extensions; |
| -import org.bouncycastle.jce.X509LDAPCertStoreParameters; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.X509LDAPCertStoreParameters; |
| +// END android-removed |
| import org.bouncycastle.jce.exception.ExtCertPathValidatorException; |
| import org.bouncycastle.util.Selector; |
| import org.bouncycastle.util.StoreException; |
| import org.bouncycastle.x509.ExtendedPKIXBuilderParameters; |
| import org.bouncycastle.x509.ExtendedPKIXParameters; |
| -import org.bouncycastle.x509.X509AttributeCertStoreSelector; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.x509.X509AttributeCertStoreSelector; |
| +// END android-removed |
| import org.bouncycastle.x509.X509AttributeCertificate; |
| import org.bouncycastle.x509.X509CRLStoreSelector; |
| import org.bouncycastle.x509.X509CertStoreSelector; |
| @@ -110,38 +119,38 @@ |
| "privilegeWithdrawn", |
| "aACompromise" }; |
| |
| - /** |
| - * Search the given Set of TrustAnchor's for one that is the |
| - * issuer of the given X509 certificate. Uses the default provider |
| - * for signature verification. |
| - * |
| - * @param cert the X509 certificate |
| - * @param trustAnchors a Set of TrustAnchor's |
| - * |
| - * @return the <code>TrustAnchor</code> object if found or |
| - * <code>null</code> if not. |
| - * |
| - * @exception AnnotatedException |
| - * if a TrustAnchor was found but the signature verification |
| - * on the given certificate has thrown an exception. |
| - */ |
| - protected static TrustAnchor findTrustAnchor( |
| - X509Certificate cert, |
| - Set trustAnchors) |
| - throws AnnotatedException |
| - { |
| - return findTrustAnchor(cert, trustAnchors, null); |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * Search the given Set of TrustAnchor's for one that is the |
| + // * issuer of the given X509 certificate. Uses the default provider |
| + // * for signature verification. |
| + // * |
| + // * @param cert the X509 certificate |
| + // * @param trustAnchors a Set of TrustAnchor's |
| + // * |
| + // * @return the <code>TrustAnchor</code> object if found or |
| + // * <code>null</code> if not. |
| + // * |
| + // * @exception AnnotatedException |
| + // * if a TrustAnchor was found but the signature verification |
| + // * on the given certificate has thrown an exception. |
| + // */ |
| + // protected static TrustAnchor findTrustAnchor( |
| + // X509Certificate cert, |
| + // Set trustAnchors) |
| + // throws AnnotatedException |
| + // { |
| + // return findTrustAnchor(cert, trustAnchors, null); |
| + // } |
| + // END android-removed |
| |
| + // BEGIN android-changed |
| /** |
| * Search the given Set of TrustAnchor's for one that is the |
| - * issuer of the given X509 certificate. Uses the specified |
| - * provider for signature verification, or the default provider |
| - * if null. |
| + * issuer of the given X509 certificate. |
| * |
| * @param cert the X509 certificate |
| - * @param trustAnchors a Set of TrustAnchor's |
| - * @param sigProvider the provider to use for signature verification |
| + * @param params used to find the trust anchors and signature provider |
| * |
| * @return the <code>TrustAnchor</code> object if found or |
| * <code>null</code> if not. |
| @@ -152,10 +161,21 @@ |
| */ |
| protected static TrustAnchor findTrustAnchor( |
| X509Certificate cert, |
| - Set trustAnchors, |
| - String sigProvider) |
| + PKIXParameters params) |
| throws AnnotatedException |
| + // END android-changed |
| { |
| + // BEGIN android-changed |
| + // If we have a trust anchor index, use it. |
| + if (params instanceof IndexedPKIXParameters) { |
| + try { |
| + IndexedPKIXParameters indexed = (IndexedPKIXParameters) params; |
| + return indexed.findTrustAnchor(cert); |
| + } catch (CertPathValidatorException e) { |
| + throw new AnnotatedException(e.getMessage(), e); |
| + } |
| + } |
| + // END android-changed |
| TrustAnchor trust = null; |
| PublicKey trustPublicKey = null; |
| Exception invalidKeyEx = null; |
| @@ -172,7 +192,9 @@ |
| throw new AnnotatedException("Cannot set subject search criteria for trust anchor.", ex); |
| } |
| |
| - Iterator iter = trustAnchors.iterator(); |
| + // BEGIN android-changed |
| + Iterator iter = params.getTrustAnchors().iterator(); |
| + // END android-changed |
| while (iter.hasNext() && trust == null) |
| { |
| trust = (TrustAnchor) iter.next(); |
| @@ -216,7 +238,9 @@ |
| { |
| try |
| { |
| - verifyX509Certificate(cert, trustPublicKey, sigProvider); |
| + // BEGIN android-changed |
| + verifyX509Certificate(cert, trustPublicKey, params.getSigProvider()); |
| + // END android-changed |
| } |
| catch (Exception ex) |
| { |
| @@ -248,7 +272,9 @@ |
| { |
| // look for URI |
| List list = (List) it.next(); |
| - if (list.get(0).equals(new Integer(GeneralName.uniformResourceIdentifier))) |
| + // BEGIN android-changed |
| + if (list.get(0).equals(Integer.valueOf(GeneralName.uniformResourceIdentifier))) |
| + // END android-changed |
| { |
| // found |
| String temp = (String) list.get(1); |
| @@ -721,38 +747,40 @@ |
| { |
| try |
| { |
| - if (location.startsWith("ldap://")) |
| - { |
| - // ldap://directory.d-trust.net/CN=D-TRUST |
| - // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE |
| - // skip "ldap://" |
| - location = location.substring(7); |
| - // after first / baseDN starts |
| - String base = null; |
| - String url = null; |
| - if (location.indexOf("/") != -1) |
| - { |
| - base = location.substring(location.indexOf("/")); |
| - // URL |
| - url = "ldap://" |
| - + location.substring(0, location.indexOf("/")); |
| - } |
| - else |
| - { |
| - url = "ldap://" + location; |
| - } |
| - // use all purpose parameters |
| - X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder( |
| - url, base).build(); |
| - pkixParams.addAdditionalStore(X509Store.getInstance( |
| - "CERTIFICATE/LDAP", params, "BC")); |
| - pkixParams.addAdditionalStore(X509Store.getInstance( |
| - "CRL/LDAP", params, "BC")); |
| - pkixParams.addAdditionalStore(X509Store.getInstance( |
| - "ATTRIBUTECERTIFICATE/LDAP", params, "BC")); |
| - pkixParams.addAdditionalStore(X509Store.getInstance( |
| - "CERTIFICATEPAIR/LDAP", params, "BC")); |
| - } |
| + // BEGIN android-removed |
| + // if (location.startsWith("ldap://")) |
| + // { |
| + // // ldap://directory.d-trust.net/CN=D-TRUST |
| + // // Qualified CA 2003 1:PN,O=D-Trust GmbH,C=DE |
| + // // skip "ldap://" |
| + // location = location.substring(7); |
| + // // after first / baseDN starts |
| + // String base = null; |
| + // String url = null; |
| + // if (location.indexOf("/") != -1) |
| + // { |
| + // base = location.substring(location.indexOf("/")); |
| + // // URL |
| + // url = "ldap://" |
| + // + location.substring(0, location.indexOf("/")); |
| + // } |
| + // else |
| + // { |
| + // url = "ldap://" + location; |
| + // } |
| + // // use all purpose parameters |
| + // X509LDAPCertStoreParameters params = new X509LDAPCertStoreParameters.Builder( |
| + // url, base).build(); |
| + // pkixParams.addAdditionalStore(X509Store.getInstance( |
| + // "CERTIFICATE/LDAP", params, "BC")); |
| + // pkixParams.addAdditionalStore(X509Store.getInstance( |
| + // "CRL/LDAP", params, "BC")); |
| + // pkixParams.addAdditionalStore(X509Store.getInstance( |
| + // "ATTRIBUTECERTIFICATE/LDAP", params, "BC")); |
| + // pkixParams.addAdditionalStore(X509Store.getInstance( |
| + // "CERTIFICATEPAIR/LDAP", params, "BC")); |
| + // } |
| + // END android-removed |
| } |
| catch (Exception e) |
| { |
| @@ -819,35 +847,37 @@ |
| return certs; |
| } |
| |
| - protected static Collection findCertificates(X509AttributeCertStoreSelector certSelect, |
| - List certStores) |
| - throws AnnotatedException |
| - { |
| - Set certs = new HashSet(); |
| - Iterator iter = certStores.iterator(); |
| - |
| - while (iter.hasNext()) |
| - { |
| - Object obj = iter.next(); |
| - |
| - if (obj instanceof X509Store) |
| - { |
| - X509Store certStore = (X509Store)obj; |
| - try |
| - { |
| - certs.addAll(certStore.getMatches(certSelect)); |
| - } |
| - catch (StoreException e) |
| - { |
| - throw |
| - |
| - new AnnotatedException( |
| - "Problem while picking certificates from X.509 store.", e); |
| - } |
| - } |
| - } |
| - return certs; |
| - } |
| + // BEGIN android-removed |
| + // protected static Collection findCertificates(X509AttributeCertStoreSelector certSelect, |
| + // List certStores) |
| + // throws AnnotatedException |
| + // { |
| + // Set certs = new HashSet(); |
| + // Iterator iter = certStores.iterator(); |
| + // |
| + // while (iter.hasNext()) |
| + // { |
| + // Object obj = iter.next(); |
| + // |
| + // if (obj instanceof X509Store) |
| + // { |
| + // X509Store certStore = (X509Store)obj; |
| + // try |
| + // { |
| + // certs.addAll(certStore.getMatches(certSelect)); |
| + // } |
| + // catch (StoreException e) |
| + // { |
| + // throw |
| + // |
| + // new AnnotatedException( |
| + // "Problem while picking certificates from X.509 store.", e); |
| + // } |
| + // } |
| + // } |
| + // return certs; |
| + // } |
| + // END android-removed |
| |
| protected static void addAdditionalStoresFromCRLDistributionPoint( |
| CRLDistPoint crldp, ExtendedPKIXParameters pkixParams) |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEBlockCipher.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEBlockCipher.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEBlockCipher.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEBlockCipher.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -7,22 +7,31 @@ |
| import org.bouncycastle.crypto.InvalidCipherTextException; |
| import org.bouncycastle.crypto.engines.AESFastEngine; |
| import org.bouncycastle.crypto.engines.BlowfishEngine; |
| -import org.bouncycastle.crypto.engines.CAST5Engine; |
| -import org.bouncycastle.crypto.engines.CAST6Engine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.CAST5Engine; |
| +// import org.bouncycastle.crypto.engines.CAST6Engine; |
| +// END android-removed |
| import org.bouncycastle.crypto.engines.DESEngine; |
| import org.bouncycastle.crypto.engines.DESedeEngine; |
| -import org.bouncycastle.crypto.engines.GOST28147Engine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.GOST28147Engine; |
| +// END android-removed |
| import org.bouncycastle.crypto.engines.RC2Engine; |
| -import org.bouncycastle.crypto.engines.RC532Engine; |
| -import org.bouncycastle.crypto.engines.RC564Engine; |
| -import org.bouncycastle.crypto.engines.RC6Engine; |
| -import org.bouncycastle.crypto.engines.RijndaelEngine; |
| -import org.bouncycastle.crypto.engines.SEEDEngine; |
| -import org.bouncycastle.crypto.engines.SerpentEngine; |
| -import org.bouncycastle.crypto.engines.SkipjackEngine; |
| -import org.bouncycastle.crypto.engines.TEAEngine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.RC532Engine; |
| +// import org.bouncycastle.crypto.engines.RC564Engine; |
| +// END android-removed |
| +// import org.bouncycastle.crypto.engines.RC6Engine; |
| +// import org.bouncycastle.crypto.engines.RijndaelEngine; |
| +// import org.bouncycastle.crypto.engines.SEEDEngine; |
| +// import org.bouncycastle.crypto.engines.SerpentEngine; |
| +// import org.bouncycastle.crypto.engines.SkipjackEngine; |
| +// import org.bouncycastle.crypto.engines.TEAEngine; |
| +// END android-removed |
| import org.bouncycastle.crypto.engines.TwofishEngine; |
| -import org.bouncycastle.crypto.engines.XTEAEngine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.XTEAEngine; |
| +// END android-removed |
| import org.bouncycastle.crypto.modes.AEADBlockCipher; |
| import org.bouncycastle.crypto.modes.CBCBlockCipher; |
| import org.bouncycastle.crypto.modes.CCMBlockCipher; |
| @@ -32,8 +41,10 @@ |
| import org.bouncycastle.crypto.modes.GCMBlockCipher; |
| import org.bouncycastle.crypto.modes.GOFBBlockCipher; |
| import org.bouncycastle.crypto.modes.OFBBlockCipher; |
| -import org.bouncycastle.crypto.modes.OpenPGPCFBBlockCipher; |
| -import org.bouncycastle.crypto.modes.PGPCFBBlockCipher; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.modes.OpenPGPCFBBlockCipher; |
| +// import org.bouncycastle.crypto.modes.PGPCFBBlockCipher; |
| +// END android-removed |
| import org.bouncycastle.crypto.modes.SICBlockCipher; |
| import org.bouncycastle.crypto.paddings.BlockCipherPadding; |
| import org.bouncycastle.crypto.paddings.ISO10126d2Padding; |
| @@ -45,10 +56,12 @@ |
| import org.bouncycastle.crypto.params.KeyParameter; |
| import org.bouncycastle.crypto.params.ParametersWithIV; |
| import org.bouncycastle.crypto.params.ParametersWithRandom; |
| -import org.bouncycastle.crypto.params.ParametersWithSBox; |
| -import org.bouncycastle.crypto.params.RC2Parameters; |
| -import org.bouncycastle.crypto.params.RC5Parameters; |
| -import org.bouncycastle.jce.spec.GOST28147ParameterSpec; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.params.ParametersWithSBox; |
| +// import org.bouncycastle.crypto.params.RC2Parameters; |
| +// import org.bouncycastle.crypto.params.RC5Parameters; |
| +// import org.bouncycastle.jce.spec.GOST28147ParameterSpec; |
| +// END android-removed |
| import org.bouncycastle.util.Strings; |
| |
| import javax.crypto.BadPaddingException; |
| @@ -59,8 +72,10 @@ |
| import javax.crypto.ShortBufferException; |
| import javax.crypto.spec.IvParameterSpec; |
| import javax.crypto.spec.PBEParameterSpec; |
| -import javax.crypto.spec.RC2ParameterSpec; |
| -import javax.crypto.spec.RC5ParameterSpec; |
| +// BEGIN android-removed |
| +// import javax.crypto.spec.RC2ParameterSpec; |
| +// import javax.crypto.spec.RC5ParameterSpec; |
| +// END android-removed |
| import java.security.AlgorithmParameters; |
| import java.security.InvalidAlgorithmParameterException; |
| import java.security.InvalidKeyException; |
| @@ -78,11 +93,15 @@ |
| // |
| private Class[] availableSpecs = |
| { |
| - RC2ParameterSpec.class, |
| - RC5ParameterSpec.class, |
| + // BEGIN android-removed |
| + // RC2ParameterSpec.class, |
| + // RC5ParameterSpec.class, |
| + // END android-removed |
| IvParameterSpec.class, |
| PBEParameterSpec.class, |
| - GOST28147ParameterSpec.class |
| + // BEGIN android-removed |
| + // GOST28147ParameterSpec.class |
| + // END android-removed |
| }; |
| |
| private BlockCipher baseEngine; |
| @@ -237,20 +256,22 @@ |
| new CFBBlockCipher(baseEngine, 8 * baseEngine.getBlockSize())); |
| } |
| } |
| - else if (modeName.startsWith("PGP")) |
| - { |
| - boolean inlineIV = modeName.equalsIgnoreCase("PGPCFBwithIV"); |
| - |
| - ivLength = baseEngine.getBlockSize(); |
| - cipher = new BufferedGenericBlockCipher( |
| - new PGPCFBBlockCipher(baseEngine, inlineIV)); |
| - } |
| - else if (modeName.equalsIgnoreCase("OpenPGPCFB")) |
| - { |
| - ivLength = 0; |
| - cipher = new BufferedGenericBlockCipher( |
| - new OpenPGPCFBBlockCipher(baseEngine)); |
| - } |
| + // BEGIN android-removed |
| + // else if (modeName.startsWith("PGP")) |
| + // { |
| + // boolean inlineIV = modeName.equalsIgnoreCase("PGPCFBwithIV"); |
| + // |
| + // ivLength = baseEngine.getBlockSize(); |
| + // cipher = new BufferedGenericBlockCipher( |
| + // new PGPCFBBlockCipher(baseEngine, inlineIV)); |
| + // } |
| + // else if (modeName.equalsIgnoreCase("OpenPGPCFB")) |
| + // { |
| + // ivLength = 0; |
| + // cipher = new BufferedGenericBlockCipher( |
| + // new OpenPGPCFBBlockCipher(baseEngine)); |
| + // } |
| + // END android-removed |
| else if (modeName.startsWith("SIC")) |
| { |
| ivLength = baseEngine.getBlockSize(); |
| @@ -376,13 +397,15 @@ |
| throw new InvalidKeyException("Key for algorithm " + key.getAlgorithm() + " not suitable for symmetric enryption."); |
| } |
| |
| - // |
| - // for RC5-64 we must have some default parameters |
| - // |
| - if (params == null && baseEngine.getAlgorithmName().startsWith("RC5-64")) |
| - { |
| - throw new InvalidAlgorithmParameterException("RC5 requires an RC5ParametersSpec to be passed in."); |
| - } |
| + // BEGIN android-removed |
| + // // |
| + // // for RC5-64 we must have some default parameters |
| + // // |
| + // if (params == null && baseEngine.getAlgorithmName().startsWith("RC5-64")) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("RC5 requires an RC5ParametersSpec to be passed in."); |
| + // } |
| + // END android-removed |
| |
| // |
| // a note on iv's - if ivLength is zero the IV gets ignored (we don't use it). |
| @@ -448,63 +471,65 @@ |
| param = new KeyParameter(key.getEncoded()); |
| } |
| } |
| - else if (params instanceof GOST28147ParameterSpec) |
| - { |
| - GOST28147ParameterSpec gost28147Param = (GOST28147ParameterSpec)params; |
| - |
| - param = new ParametersWithSBox( |
| - new KeyParameter(key.getEncoded()), ((GOST28147ParameterSpec)params).getSbox()); |
| - |
| - if (gost28147Param.getIV() != null && ivLength != 0) |
| - { |
| - param = new ParametersWithIV(param, gost28147Param.getIV()); |
| - ivParam = (ParametersWithIV)param; |
| - } |
| - } |
| - else if (params instanceof RC2ParameterSpec) |
| - { |
| - RC2ParameterSpec rc2Param = (RC2ParameterSpec)params; |
| - |
| - param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits()); |
| - |
| - if (rc2Param.getIV() != null && ivLength != 0) |
| - { |
| - param = new ParametersWithIV(param, rc2Param.getIV()); |
| - ivParam = (ParametersWithIV)param; |
| - } |
| - } |
| - else if (params instanceof RC5ParameterSpec) |
| - { |
| - RC5ParameterSpec rc5Param = (RC5ParameterSpec)params; |
| - |
| - param = new RC5Parameters(key.getEncoded(), ((RC5ParameterSpec)params).getRounds()); |
| - if (baseEngine.getAlgorithmName().startsWith("RC5")) |
| - { |
| - if (baseEngine.getAlgorithmName().equals("RC5-32")) |
| - { |
| - if (rc5Param.getWordSize() != 32) |
| - { |
| - throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 32 not " + rc5Param.getWordSize() + "."); |
| - } |
| - } |
| - else if (baseEngine.getAlgorithmName().equals("RC5-64")) |
| - { |
| - if (rc5Param.getWordSize() != 64) |
| - { |
| - throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 64 not " + rc5Param.getWordSize() + "."); |
| - } |
| - } |
| - } |
| - else |
| - { |
| - throw new InvalidAlgorithmParameterException("RC5 parameters passed to a cipher that is not RC5."); |
| - } |
| - if ((rc5Param.getIV() != null) && (ivLength != 0)) |
| - { |
| - param = new ParametersWithIV(param, rc5Param.getIV()); |
| - ivParam = (ParametersWithIV)param; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // else if (params instanceof GOST28147ParameterSpec) |
| + // { |
| + // GOST28147ParameterSpec gost28147Param = (GOST28147ParameterSpec)params; |
| + // |
| + // param = new ParametersWithSBox( |
| + // new KeyParameter(key.getEncoded()), ((GOST28147ParameterSpec)params).getSbox()); |
| + // |
| + // if (gost28147Param.getIV() != null && ivLength != 0) |
| + // { |
| + // param = new ParametersWithIV(param, gost28147Param.getIV()); |
| + // ivParam = (ParametersWithIV)param; |
| + // } |
| + // } |
| + // else if (params instanceof RC2ParameterSpec) |
| + // { |
| + // RC2ParameterSpec rc2Param = (RC2ParameterSpec)params; |
| + // |
| + // param = new RC2Parameters(key.getEncoded(), ((RC2ParameterSpec)params).getEffectiveKeyBits()); |
| + // |
| + // if (rc2Param.getIV() != null && ivLength != 0) |
| + // { |
| + // param = new ParametersWithIV(param, rc2Param.getIV()); |
| + // ivParam = (ParametersWithIV)param; |
| + // } |
| + // } |
| + // else if (params instanceof RC5ParameterSpec) |
| + // { |
| + // RC5ParameterSpec rc5Param = (RC5ParameterSpec)params; |
| + // |
| + // param = new RC5Parameters(key.getEncoded(), ((RC5ParameterSpec)params).getRounds()); |
| + // if (baseEngine.getAlgorithmName().startsWith("RC5")) |
| + // { |
| + // if (baseEngine.getAlgorithmName().equals("RC5-32")) |
| + // { |
| + // if (rc5Param.getWordSize() != 32) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 32 not " + rc5Param.getWordSize() + "."); |
| + // } |
| + // } |
| + // else if (baseEngine.getAlgorithmName().equals("RC5-64")) |
| + // { |
| + // if (rc5Param.getWordSize() != 64) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("RC5 already set up for a word size of 64 not " + rc5Param.getWordSize() + "."); |
| + // } |
| + // } |
| + // } |
| + // else |
| + // { |
| + // throw new InvalidAlgorithmParameterException("RC5 parameters passed to a cipher that is not RC5."); |
| + // } |
| + // if ((rc5Param.getIV() != null) && (ivLength != 0)) |
| + // { |
| + // param = new ParametersWithIV(param, rc5Param.getIV()); |
| + // ivParam = (ParametersWithIV)param; |
| + // } |
| + // } |
| + // END android-removed |
| else |
| { |
| throw new InvalidAlgorithmParameterException("unknown parameter type."); |
| @@ -708,10 +733,21 @@ |
| int inputLen, |
| byte[] output, |
| int outputOffset) |
| - throws IllegalBlockSizeException, BadPaddingException |
| + throws IllegalBlockSizeException, BadPaddingException, ShortBufferException |
| { |
| + // BEGIN android-note |
| + // added ShortBufferException to the throws statement |
| + // END android-note |
| int len = 0; |
| |
| + // BEGIN android-added |
| + int outputLen = cipher.getOutputSize(inputLen); |
| + |
| + if (outputLen + outputOffset > output.length) { |
| + throw new ShortBufferException("need at least " + outputLen + " bytes"); |
| + } |
| + // BEGIN android-added |
| + |
| if (inputLen != 0) |
| { |
| len = cipher.processBytes(input, inputOffset, inputLen, output, outputOffset); |
| @@ -753,17 +789,19 @@ |
| } |
| } |
| |
| - /** |
| - * DESCBC |
| - */ |
| - static public class DESCBC |
| - extends JCEBlockCipher |
| - { |
| - public DESCBC() |
| - { |
| - super(new CBCBlockCipher(new DESEngine()), 64); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * DESCBC |
| + // */ |
| + // static public class DESCBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public DESCBC() |
| + // { |
| + // super(new CBCBlockCipher(new DESEngine()), 64); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * DESede |
| @@ -777,52 +815,54 @@ |
| } |
| } |
| |
| - /** |
| - * DESedeCBC |
| - */ |
| - static public class DESedeCBC |
| - extends JCEBlockCipher |
| - { |
| - public DESedeCBC() |
| - { |
| - super(new CBCBlockCipher(new DESedeEngine()), 64); |
| - } |
| - } |
| - |
| - /** |
| - * GOST28147 |
| - */ |
| - static public class GOST28147 |
| - extends JCEBlockCipher |
| - { |
| - public GOST28147() |
| - { |
| - super(new GOST28147Engine()); |
| - } |
| - } |
| - |
| - static public class GOST28147cbc |
| - extends JCEBlockCipher |
| - { |
| - public GOST28147cbc() |
| - { |
| - super(new CBCBlockCipher(new GOST28147Engine()), 64); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * DESedeCBC |
| + // */ |
| + // static public class DESedeCBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public DESedeCBC() |
| + // { |
| + // super(new CBCBlockCipher(new DESedeEngine()), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * GOST28147 |
| + // */ |
| + // static public class GOST28147 |
| + // extends JCEBlockCipher |
| + // { |
| + // public GOST28147() |
| + // { |
| + // super(new GOST28147Engine()); |
| + // } |
| + // } |
| + // |
| + // static public class GOST28147cbc |
| + // extends JCEBlockCipher |
| + // { |
| + // public GOST28147cbc() |
| + // { |
| + // super(new CBCBlockCipher(new GOST28147Engine()), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SKIPJACK |
| + // */ |
| + // static public class Skipjack |
| + // extends JCEBlockCipher |
| + // { |
| + // public Skipjack() |
| + // { |
| + // super(new SkipjackEngine()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| - * SKIPJACK |
| - */ |
| - static public class Skipjack |
| - extends JCEBlockCipher |
| - { |
| - public Skipjack() |
| - { |
| - super(new SkipjackEngine()); |
| - } |
| - } |
| - |
| - /** |
| * Blowfish |
| */ |
| static public class Blowfish |
| @@ -833,236 +873,238 @@ |
| super(new BlowfishEngine()); |
| } |
| } |
| - |
| - /** |
| - * Blowfish CBC |
| - */ |
| - static public class BlowfishCBC |
| - extends JCEBlockCipher |
| - { |
| - public BlowfishCBC() |
| - { |
| - super(new CBCBlockCipher(new BlowfishEngine()), 64); |
| - } |
| - } |
| - |
| - /** |
| - * Twofish |
| - */ |
| - static public class Twofish |
| - extends JCEBlockCipher |
| - { |
| - public Twofish() |
| - { |
| - super(new TwofishEngine()); |
| - } |
| - } |
| - |
| - /** |
| - * RC2 |
| - */ |
| - static public class RC2 |
| - extends JCEBlockCipher |
| - { |
| - public RC2() |
| - { |
| - super(new RC2Engine()); |
| - } |
| - } |
| - |
| - /** |
| - * RC2CBC |
| - */ |
| - static public class RC2CBC |
| - extends JCEBlockCipher |
| - { |
| - public RC2CBC() |
| - { |
| - super(new CBCBlockCipher(new RC2Engine()), 64); |
| - } |
| - } |
| - |
| - /** |
| - * RC5 |
| - */ |
| - static public class RC5 |
| - extends JCEBlockCipher |
| - { |
| - public RC5() |
| - { |
| - super(new RC532Engine()); |
| - } |
| - } |
| - |
| - /** |
| - * RC564 |
| - */ |
| - static public class RC564 |
| - extends JCEBlockCipher |
| - { |
| - public RC564() |
| - { |
| - super(new RC564Engine()); |
| - } |
| - } |
| - |
| - /** |
| - * RC6 |
| - */ |
| - static public class RC6 |
| - extends JCEBlockCipher |
| - { |
| - public RC6() |
| - { |
| - super(new RC6Engine()); |
| - } |
| - } |
| - |
| - /** |
| - * AES |
| - */ |
| - static public class AES |
| - extends JCEBlockCipher |
| - { |
| - public AES() |
| - { |
| - super(new AESFastEngine()); |
| - } |
| - } |
| - |
| - /** |
| - * AESCBC |
| - */ |
| - static public class AESCBC |
| - extends JCEBlockCipher |
| - { |
| - public AESCBC() |
| - { |
| - super(new CBCBlockCipher(new AESFastEngine()), 128); |
| - } |
| - } |
| - |
| - /** |
| - * AESCFB |
| - */ |
| - static public class AESCFB |
| - extends JCEBlockCipher |
| - { |
| - public AESCFB() |
| - { |
| - super(new CFBBlockCipher(new AESFastEngine(), 128), 128); |
| - } |
| - } |
| - |
| - /** |
| - * AESOFB |
| - */ |
| - static public class AESOFB |
| - extends JCEBlockCipher |
| - { |
| - public AESOFB() |
| - { |
| - super(new OFBBlockCipher(new AESFastEngine(), 128), 128); |
| - } |
| - } |
| - |
| - /** |
| - * Rijndael |
| - */ |
| - static public class Rijndael |
| - extends JCEBlockCipher |
| - { |
| - public Rijndael() |
| - { |
| - super(new RijndaelEngine()); |
| - } |
| - } |
| - |
| - /** |
| - * Serpent |
| - */ |
| - static public class Serpent |
| - extends JCEBlockCipher |
| - { |
| - public Serpent() |
| - { |
| - super(new SerpentEngine()); |
| - } |
| - } |
| - |
| - |
| |
| - /** |
| - * CAST5 |
| - */ |
| - static public class CAST5 |
| - extends JCEBlockCipher |
| - { |
| - public CAST5() |
| - { |
| - super(new CAST5Engine()); |
| - } |
| - } |
| - |
| - /** |
| - * CAST5 CBC |
| - */ |
| - static public class CAST5CBC |
| - extends JCEBlockCipher |
| - { |
| - public CAST5CBC() |
| - { |
| - super(new CBCBlockCipher(new CAST5Engine()), 64); |
| - } |
| - } |
| - |
| - /** |
| - * CAST6 |
| - */ |
| - static public class CAST6 |
| - extends JCEBlockCipher |
| - { |
| - public CAST6() |
| - { |
| - super(new CAST6Engine()); |
| - } |
| - } |
| - |
| - /** |
| - * TEA |
| - */ |
| - static public class TEA |
| - extends JCEBlockCipher |
| - { |
| - public TEA() |
| - { |
| - super(new TEAEngine()); |
| - } |
| - } |
| - |
| - /** |
| - * XTEA |
| - */ |
| - static public class XTEA |
| - extends JCEBlockCipher |
| - { |
| - public XTEA() |
| - { |
| - super(new XTEAEngine()); |
| - } |
| - } |
| - |
| - /** |
| - * SEED |
| - */ |
| - static public class SEED |
| - extends JCEBlockCipher |
| - { |
| - public SEED() |
| - { |
| - super(new SEEDEngine()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * Blowfish CBC |
| + // */ |
| + // static public class BlowfishCBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public BlowfishCBC() |
| + // { |
| + // super(new CBCBlockCipher(new BlowfishEngine()), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Twofish |
| + // */ |
| + // static public class Twofish |
| + // extends JCEBlockCipher |
| + // { |
| + // public Twofish() |
| + // { |
| + // super(new TwofishEngine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC2 |
| + // */ |
| + // static public class RC2 |
| + // extends JCEBlockCipher |
| + // { |
| + // public RC2() |
| + // { |
| + // super(new RC2Engine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC2CBC |
| + // */ |
| + // static public class RC2CBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public RC2CBC() |
| + // { |
| + // super(new CBCBlockCipher(new RC2Engine()), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC5 |
| + // */ |
| + // static public class RC5 |
| + // extends JCEBlockCipher |
| + // { |
| + // public RC5() |
| + // { |
| + // super(new RC532Engine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC564 |
| + // */ |
| + // static public class RC564 |
| + // extends JCEBlockCipher |
| + // { |
| + // public RC564() |
| + // { |
| + // super(new RC564Engine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC6 |
| + // */ |
| + // static public class RC6 |
| + // extends JCEBlockCipher |
| + // { |
| + // public RC6() |
| + // { |
| + // super(new RC6Engine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * AES |
| + // */ |
| + // static public class AES |
| + // extends JCEBlockCipher |
| + // { |
| + // public AES() |
| + // { |
| + // super(new AESFastEngine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * AESCBC |
| + // */ |
| + // static public class AESCBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public AESCBC() |
| + // { |
| + // super(new CBCBlockCipher(new AESFastEngine()), 128); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * AESCFB |
| + // */ |
| + // static public class AESCFB |
| + // extends JCEBlockCipher |
| + // { |
| + // public AESCFB() |
| + // { |
| + // super(new CFBBlockCipher(new AESFastEngine(), 128), 128); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * AESOFB |
| + // */ |
| + // static public class AESOFB |
| + // extends JCEBlockCipher |
| + // { |
| + // public AESOFB() |
| + // { |
| + // super(new OFBBlockCipher(new AESFastEngine(), 128), 128); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Rijndael |
| + // */ |
| + // static public class Rijndael |
| + // extends JCEBlockCipher |
| + // { |
| + // public Rijndael() |
| + // { |
| + // super(new RijndaelEngine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Serpent |
| + // */ |
| + // static public class Serpent |
| + // extends JCEBlockCipher |
| + // { |
| + // public Serpent() |
| + // { |
| + // super(new SerpentEngine()); |
| + // } |
| + // } |
| + // |
| + // |
| + // |
| + // /** |
| + // * CAST5 |
| + // */ |
| + // static public class CAST5 |
| + // extends JCEBlockCipher |
| + // { |
| + // public CAST5() |
| + // { |
| + // super(new CAST5Engine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * CAST5 CBC |
| + // */ |
| + // static public class CAST5CBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public CAST5CBC() |
| + // { |
| + // super(new CBCBlockCipher(new CAST5Engine()), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * CAST6 |
| + // */ |
| + // static public class CAST6 |
| + // extends JCEBlockCipher |
| + // { |
| + // public CAST6() |
| + // { |
| + // super(new CAST6Engine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * TEA |
| + // */ |
| + // static public class TEA |
| + // extends JCEBlockCipher |
| + // { |
| + // public TEA() |
| + // { |
| + // super(new TEAEngine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * XTEA |
| + // */ |
| + // static public class XTEA |
| + // extends JCEBlockCipher |
| + // { |
| + // public XTEA() |
| + // { |
| + // super(new XTEAEngine()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SEED |
| + // */ |
| + // static public class SEED |
| + // extends JCEBlockCipher |
| + // { |
| + // public SEED() |
| + // { |
| + // super(new SEEDEngine()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * PBEWithMD5AndDES |
| @@ -1087,7 +1129,7 @@ |
| super(new CBCBlockCipher(new RC2Engine())); |
| } |
| } |
| - |
| + |
| /** |
| * PBEWithSHA1AndDES |
| */ |
| @@ -1135,7 +1177,7 @@ |
| super(new CBCBlockCipher(new DESedeEngine())); |
| } |
| } |
| - |
| + |
| /** |
| * PBEWithSHAAnd128BitRC2-CBC |
| */ |
| @@ -1159,7 +1201,7 @@ |
| super(new CBCBlockCipher(new RC2Engine())); |
| } |
| } |
| - |
| + |
| /** |
| * PBEWithSHAAndTwofish-CBC |
| */ |
| @@ -1171,7 +1213,7 @@ |
| super(new CBCBlockCipher(new TwofishEngine())); |
| } |
| } |
| - |
| + |
| /** |
| * PBEWithAES-CBC |
| */ |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDHKeyAgreement.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -37,9 +37,11 @@ |
| |
| static |
| { |
| - Integer i64 = new Integer(64); |
| - Integer i192 = new Integer(192); |
| - Integer i128 = new Integer(128); |
| + // BEGIN android-changed |
| + Integer i64 = Integer.valueOf(64); |
| + Integer i192 = Integer.valueOf(192); |
| + Integer i128 = Integer.valueOf(128); |
| + // END android-changed |
| |
| algorithms.put("DES", i64); |
| algorithms.put("DESEDE", i192); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDigestUtil.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDigestUtil.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEDigestUtil.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEDigestUtil.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -12,7 +12,9 @@ |
| import org.bouncycastle.crypto.Digest; |
| import org.bouncycastle.crypto.digests.MD5Digest; |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| -import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA256Digest; |
| import org.bouncycastle.crypto.digests.SHA384Digest; |
| import org.bouncycastle.crypto.digests.SHA512Digest; |
| @@ -22,7 +24,9 @@ |
| { |
| private static Set md5 = new HashSet(); |
| private static Set sha1 = new HashSet(); |
| - private static Set sha224 = new HashSet(); |
| + // BEGIN android-removed |
| + // private static Set sha224 = new HashSet(); |
| + // END android-removed |
| private static Set sha256 = new HashSet(); |
| private static Set sha384 = new HashSet(); |
| private static Set sha512 = new HashSet(); |
| @@ -38,9 +42,11 @@ |
| sha1.add("SHA-1"); |
| sha1.add(OIWObjectIdentifiers.idSHA1.getId()); |
| |
| - sha224.add("SHA224"); |
| - sha224.add("SHA-224"); |
| - sha224.add(NISTObjectIdentifiers.id_sha224.getId()); |
| + // BEGIN android-removed |
| + // sha224.add("SHA224"); |
| + // sha224.add("SHA-224"); |
| + // sha224.add(NISTObjectIdentifiers.id_sha224.getId()); |
| + // END android-removed |
| |
| sha256.add("SHA256"); |
| sha256.add("SHA-256"); |
| @@ -61,9 +67,11 @@ |
| oids.put("SHA-1", OIWObjectIdentifiers.idSHA1); |
| oids.put(OIWObjectIdentifiers.idSHA1.getId(), OIWObjectIdentifiers.idSHA1); |
| |
| - oids.put("SHA224", NISTObjectIdentifiers.id_sha224); |
| - oids.put("SHA-224", NISTObjectIdentifiers.id_sha224); |
| - oids.put(NISTObjectIdentifiers.id_sha224.getId(), NISTObjectIdentifiers.id_sha224); |
| + // BEGIN android-removed |
| + // oids.put("SHA224", NISTObjectIdentifiers.id_sha224); |
| + // oids.put("SHA-224", NISTObjectIdentifiers.id_sha224); |
| + // oids.put(NISTObjectIdentifiers.id_sha224.getId(), NISTObjectIdentifiers.id_sha224); |
| + // END android-removed |
| |
| oids.put("SHA256", NISTObjectIdentifiers.id_sha256); |
| oids.put("SHA-256", NISTObjectIdentifiers.id_sha256); |
| @@ -91,10 +99,12 @@ |
| { |
| return new MD5Digest(); |
| } |
| - if (sha224.contains(digestName)) |
| - { |
| - return new SHA224Digest(); |
| - } |
| + // BEGIN android-removed |
| + // if (sha224.contains(digestName)) |
| + // { |
| + // return new SHA224Digest(); |
| + // } |
| + // END android-removed |
| if (sha256.contains(digestName)) |
| { |
| return new SHA256Digest(); |
| @@ -116,7 +126,9 @@ |
| String digest2) |
| { |
| return (sha1.contains(digest1) && sha1.contains(digest2)) |
| - || (sha224.contains(digest1) && sha224.contains(digest2)) |
| + // BEGIN android-removed |
| + // || (sha224.contains(digest1) && sha224.contains(digest2)) |
| + // END android-removed |
| || (sha256.contains(digest1) && sha256.contains(digest2)) |
| || (sha384.contains(digest1) && sha384.contains(digest2)) |
| || (sha512.contains(digest1) && sha512.contains(digest2)) |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEECPrivateKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEECPrivateKey.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEECPrivateKey.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEECPrivateKey.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -20,7 +20,9 @@ |
| import org.bouncycastle.asn1.DERObject; |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers; |
| -import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; |
| import org.bouncycastle.asn1.sec.ECPrivateKeyStructure; |
| import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
| @@ -199,21 +201,23 @@ |
| DERObjectIdentifier oid = (DERObjectIdentifier)params.getParameters(); |
| X9ECParameters ecP = ECUtil.getNamedCurveByOid(oid); |
| |
| - if (ecP == null) // GOST Curve |
| - { |
| - ECDomainParameters gParam = ECGOST3410NamedCurves.getByOID(oid); |
| - EllipticCurve ellipticCurve = EC5Util.convertCurve(gParam.getCurve(), gParam.getSeed()); |
| - |
| - ecSpec = new ECNamedCurveSpec( |
| - ECGOST3410NamedCurves.getName(oid), |
| - ellipticCurve, |
| - new ECPoint( |
| - gParam.getG().getX().toBigInteger(), |
| - gParam.getG().getY().toBigInteger()), |
| - gParam.getN(), |
| - gParam.getH()); |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (ecP == null) // GOST Curve |
| + // { |
| + // ECDomainParameters gParam = ECGOST3410NamedCurves.getByOID(oid); |
| + // EllipticCurve ellipticCurve = EC5Util.convertCurve(gParam.getCurve(), gParam.getSeed()); |
| + // |
| + // ecSpec = new ECNamedCurveSpec( |
| + // ECGOST3410NamedCurves.getName(oid), |
| + // ellipticCurve, |
| + // new ECPoint( |
| + // gParam.getG().getX().toBigInteger(), |
| + // gParam.getG().getY().toBigInteger()), |
| + // gParam.getN(), |
| + // gParam.getH()); |
| + // } |
| + // else |
| + // END android-removed |
| { |
| EllipticCurve ellipticCurve = EC5Util.convertCurve(ecP.getCurve(), ecP.getSeed()); |
| |
| @@ -321,11 +325,13 @@ |
| keyStructure = new ECPrivateKeyStructure(this.getS(), params); |
| } |
| |
| - if (algorithm.equals("ECGOST3410")) |
| - { |
| - info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), keyStructure.getDERObject()); |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (algorithm.equals("ECGOST3410")) |
| + // { |
| + // info = new PrivateKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), keyStructure.getDERObject()); |
| + // } |
| + // else |
| + // END android-removed |
| { |
| |
| info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_ecPublicKey, params.getDERObject()), keyStructure.getDERObject()); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEECPublicKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEECPublicKey.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEECPublicKey.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEECPublicKey.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -20,8 +20,10 @@ |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.DEROctetString; |
| import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers; |
| -import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| -import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters; |
| +// END android-removed |
| import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
| import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; |
| import org.bouncycastle.asn1.x9.X962Parameters; |
| @@ -31,11 +33,15 @@ |
| import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; |
| import org.bouncycastle.crypto.params.ECDomainParameters; |
| import org.bouncycastle.crypto.params.ECPublicKeyParameters; |
| -import org.bouncycastle.jce.ECGOST3410NamedCurveTable; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.ECGOST3410NamedCurveTable; |
| +// END android-removed |
| import org.bouncycastle.jce.interfaces.ECPointEncoder; |
| import org.bouncycastle.jce.provider.asymmetric.ec.EC5Util; |
| import org.bouncycastle.jce.provider.asymmetric.ec.ECUtil; |
| -import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.spec.ECNamedCurveParameterSpec; |
| +// END android-removed |
| import org.bouncycastle.jce.spec.ECNamedCurveSpec; |
| import org.bouncycastle.math.ec.ECCurve; |
| |
| @@ -46,7 +52,9 @@ |
| private org.bouncycastle.math.ec.ECPoint q; |
| private ECParameterSpec ecSpec; |
| private boolean withCompression; |
| - private GOST3410PublicKeyAlgParameters gostParams; |
| + // BEGIN android-removed |
| + // private GOST3410PublicKeyAlgParameters gostParams; |
| + // END android-removed |
| |
| public JCEECPublicKey( |
| String algorithm, |
| @@ -56,7 +64,9 @@ |
| this.q = key.q; |
| this.ecSpec = key.ecSpec; |
| this.withCompression = key.withCompression; |
| - this.gostParams = key.gostParams; |
| + // BEGIN android-removed |
| + // this.gostParams = key.gostParams; |
| + // END android-removed |
| } |
| |
| public JCEECPublicKey( |
| @@ -179,54 +189,56 @@ |
| |
| private void populateFromPubKeyInfo(SubjectPublicKeyInfo info) |
| { |
| - if (info.getAlgorithmId().getObjectId().equals(CryptoProObjectIdentifiers.gostR3410_2001)) |
| - { |
| - DERBitString bits = info.getPublicKeyData(); |
| - ASN1OctetString key; |
| - this.algorithm = "ECGOST3410"; |
| - |
| - try |
| - { |
| - key = (ASN1OctetString) ASN1Object.fromByteArray(bits.getBytes()); |
| - } |
| - catch (IOException ex) |
| - { |
| - throw new IllegalArgumentException("error recovering public key"); |
| - } |
| - |
| - byte[] keyEnc = key.getOctets(); |
| - byte[] x = new byte[32]; |
| - byte[] y = new byte[32]; |
| - |
| - for (int i = 0; i != x.length; i++) |
| - { |
| - x[i] = keyEnc[32 - 1 - i]; |
| - } |
| - |
| - for (int i = 0; i != y.length; i++) |
| - { |
| - y[i] = keyEnc[64 - 1 - i]; |
| - } |
| - |
| - gostParams = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters()); |
| - |
| - ECNamedCurveParameterSpec spec = ECGOST3410NamedCurveTable.getParameterSpec(ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet())); |
| - |
| - ECCurve curve = spec.getCurve(); |
| - EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getSeed()); |
| - |
| - this.q = curve.createPoint(new BigInteger(1, x), new BigInteger(1, y), false); |
| - |
| - ecSpec = new ECNamedCurveSpec( |
| - ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()), |
| - ellipticCurve, |
| - new ECPoint( |
| - spec.getG().getX().toBigInteger(), |
| - spec.getG().getY().toBigInteger()), |
| - spec.getN(), spec.getH()); |
| - |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (info.getAlgorithmId().getObjectId().equals(CryptoProObjectIdentifiers.gostR3410_2001)) |
| + // { |
| + // DERBitString bits = info.getPublicKeyData(); |
| + // ASN1OctetString key; |
| + // this.algorithm = "ECGOST3410"; |
| + // |
| + // try |
| + // { |
| + // key = (ASN1OctetString) ASN1Object.fromByteArray(bits.getBytes()); |
| + // } |
| + // catch (IOException ex) |
| + // { |
| + // throw new IllegalArgumentException("error recovering public key"); |
| + // } |
| + // |
| + // byte[] keyEnc = key.getOctets(); |
| + // byte[] x = new byte[32]; |
| + // byte[] y = new byte[32]; |
| + // |
| + // for (int i = 0; i != x.length; i++) |
| + // { |
| + // x[i] = keyEnc[32 - 1 - i]; |
| + // } |
| + // |
| + // for (int i = 0; i != y.length; i++) |
| + // { |
| + // y[i] = keyEnc[64 - 1 - i]; |
| + // } |
| + // |
| + // gostParams = new GOST3410PublicKeyAlgParameters((ASN1Sequence)info.getAlgorithmId().getParameters()); |
| + // |
| + // ECNamedCurveParameterSpec spec = ECGOST3410NamedCurveTable.getParameterSpec(ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet())); |
| + // |
| + // ECCurve curve = spec.getCurve(); |
| + // EllipticCurve ellipticCurve = EC5Util.convertCurve(curve, spec.getSeed()); |
| + // |
| + // this.q = curve.createPoint(new BigInteger(1, x), new BigInteger(1, y), false); |
| + // |
| + // ecSpec = new ECNamedCurveSpec( |
| + // ECGOST3410NamedCurves.getName(gostParams.getPublicKeyParamSet()), |
| + // ellipticCurve, |
| + // new ECPoint( |
| + // spec.getG().getX().toBigInteger(), |
| + // spec.getG().getY().toBigInteger()), |
| + // spec.getN(), spec.getH()); |
| + // |
| + // } |
| + // else |
| + // END android-removed |
| { |
| X962Parameters params = new X962Parameters((DERObject)info.getAlgorithmId().getParameters()); |
| ECCurve curve; |
| @@ -315,45 +327,47 @@ |
| ASN1Encodable params; |
| SubjectPublicKeyInfo info; |
| |
| - if (algorithm.equals("ECGOST3410")) |
| - { |
| - if (gostParams != null) |
| - { |
| - params = gostParams; |
| - } |
| - else |
| - { |
| - if (ecSpec instanceof ECNamedCurveSpec) |
| - { |
| - params = new GOST3410PublicKeyAlgParameters( |
| - ECGOST3410NamedCurves.getOID(((ECNamedCurveSpec)ecSpec).getName()), |
| - CryptoProObjectIdentifiers.gostR3411_94_CryptoProParamSet); |
| - } |
| - else |
| - { // strictly speaking this may not be applicable... |
| - ECCurve curve = EC5Util.convertCurve(ecSpec.getCurve()); |
| - |
| - X9ECParameters ecP = new X9ECParameters( |
| - curve, |
| - EC5Util.convertPoint(curve, ecSpec.getGenerator(), withCompression), |
| - ecSpec.getOrder(), |
| - BigInteger.valueOf(ecSpec.getCofactor()), |
| - ecSpec.getCurve().getSeed()); |
| - |
| - params = new X962Parameters(ecP); |
| - } |
| - } |
| - |
| - BigInteger bX = this.q.getX().toBigInteger(); |
| - BigInteger bY = this.q.getY().toBigInteger(); |
| - byte[] encKey = new byte[64]; |
| - |
| - extractBytes(encKey, 0, bX); |
| - extractBytes(encKey, 32, bY); |
| - |
| - info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), new DEROctetString(encKey)); |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (algorithm.equals("ECGOST3410")) |
| + // { |
| + // if (gostParams != null) |
| + // { |
| + // params = gostParams; |
| + // } |
| + // else |
| + // { |
| + // if (ecSpec instanceof ECNamedCurveSpec) |
| + // { |
| + // params = new GOST3410PublicKeyAlgParameters( |
| + // ECGOST3410NamedCurves.getOID(((ECNamedCurveSpec)ecSpec).getName()), |
| + // CryptoProObjectIdentifiers.gostR3411_94_CryptoProParamSet); |
| + // } |
| + // else |
| + // { // strictly speaking this may not be applicable... |
| + // ECCurve curve = EC5Util.convertCurve(ecSpec.getCurve()); |
| + // |
| + // X9ECParameters ecP = new X9ECParameters( |
| + // curve, |
| + // EC5Util.convertPoint(curve, ecSpec.getGenerator(), withCompression), |
| + // ecSpec.getOrder(), |
| + // BigInteger.valueOf(ecSpec.getCofactor()), |
| + // ecSpec.getCurve().getSeed()); |
| + // |
| + // params = new X962Parameters(ecP); |
| + // } |
| + // } |
| + // |
| + // BigInteger bX = this.q.getX().toBigInteger(); |
| + // BigInteger bY = this.q.getY().toBigInteger(); |
| + // byte[] encKey = new byte[64]; |
| + // |
| + // extractBytes(encKey, 0, bX); |
| + // extractBytes(encKey, 32, bY); |
| + // |
| + // info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(CryptoProObjectIdentifiers.gostR3410_2001, params.getDERObject()), new DEROctetString(encKey)); |
| + // } |
| + // else |
| + // END android-removed |
| { |
| if (ecSpec instanceof ECNamedCurveSpec) |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEKeyGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEKeyGenerator.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEKeyGenerator.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEKeyGenerator.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -57,6 +57,11 @@ |
| { |
| try |
| { |
| + // BEGIN android-added |
| + if (random == null) { |
| + random = new SecureRandom(); |
| + } |
| + // END android-added |
| engine.init(new KeyGenerationParameters(random, keySize)); |
| uninitialised = false; |
| } |
| @@ -145,30 +150,32 @@ |
| } |
| } |
| |
| - /** |
| - * generate a desEDE key in the a-b-c format. |
| - */ |
| - public static class DESede3 |
| - extends JCEKeyGenerator |
| - { |
| - public DESede3() |
| - { |
| - super("DESede3", 192, new DESedeKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * SKIPJACK |
| - */ |
| - public static class Skipjack |
| - extends JCEKeyGenerator |
| - { |
| - public Skipjack() |
| - { |
| - super("SKIPJACK", 80, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| + // BEGIN android-removed |
| + // /** |
| + // * generate a desEDE key in the a-b-c format. |
| + // */ |
| + // public static class DESede3 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public DESede3() |
| + // { |
| + // super("DESede3", 192, new DESedeKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SKIPJACK |
| + // */ |
| + // public static class Skipjack |
| + // extends JCEKeyGenerator |
| + // { |
| + // public Skipjack() |
| + // { |
| + // super("SKIPJACK", 80, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // END android-removed |
| + |
| /** |
| * Blowfish |
| */ |
| @@ -180,31 +187,33 @@ |
| super("Blowfish", 128, new CipherKeyGenerator()); |
| } |
| } |
| - |
| - /** |
| - * Twofish |
| - */ |
| - public static class Twofish |
| - extends JCEKeyGenerator |
| - { |
| - public Twofish() |
| - { |
| - super("Twofish", 256, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * RC2 |
| - */ |
| - public static class RC2 |
| - extends JCEKeyGenerator |
| - { |
| - public RC2() |
| - { |
| - super("RC2", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| + |
| + // BEGIN android-removed |
| + // /** |
| + // * Twofish |
| + // */ |
| + // public static class Twofish |
| + // extends JCEKeyGenerator |
| + // { |
| + // public Twofish() |
| + // { |
| + // super("Twofish", 256, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC2 |
| + // */ |
| + // public static class RC2 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public RC2() |
| + // { |
| + // super("RC2", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // END android-removed |
| + |
| /** |
| * RC4 |
| */ |
| @@ -216,203 +225,207 @@ |
| super("RC4", 128, new CipherKeyGenerator()); |
| } |
| } |
| - |
| - /** |
| - * RC5 |
| - */ |
| - public static class RC5 |
| - extends JCEKeyGenerator |
| - { |
| - public RC5() |
| - { |
| - super("RC5", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * RC5 |
| - */ |
| - public static class RC564 |
| - extends JCEKeyGenerator |
| - { |
| - public RC564() |
| - { |
| - super("RC5-64", 256, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * RC6 |
| - */ |
| - public static class RC6 |
| - extends JCEKeyGenerator |
| - { |
| - public RC6() |
| - { |
| - super("RC6", 256, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * GOST28147 |
| - */ |
| - public static class GOST28147 |
| - extends JCEKeyGenerator |
| - { |
| - public GOST28147() |
| - { |
| - super("GOST28147", 256, new CipherKeyGenerator()); |
| - } |
| - } |
| |
| - /** |
| - * Rijndael |
| - */ |
| - public static class Rijndael |
| - extends JCEKeyGenerator |
| - { |
| - public Rijndael() |
| - { |
| - super("Rijndael", 192, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * Serpent |
| - */ |
| - public static class Serpent |
| - extends JCEKeyGenerator |
| - { |
| - public Serpent() |
| - { |
| - super("Serpent", 192, new CipherKeyGenerator()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * RC5 |
| + // */ |
| + // public static class RC5 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public RC5() |
| + // { |
| + // super("RC5", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC5 |
| + // */ |
| + // public static class RC564 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public RC564() |
| + // { |
| + // super("RC5-64", 256, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC6 |
| + // */ |
| + // public static class RC6 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public RC6() |
| + // { |
| + // super("RC6", 256, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * GOST28147 |
| + // */ |
| + // public static class GOST28147 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public GOST28147() |
| + // { |
| + // super("GOST28147", 256, new CipherKeyGenerator()); |
| + // } |
| + // } |
| |
| - |
| - |
| - /** |
| - * CAST6 |
| - */ |
| - public static class CAST6 |
| - extends JCEKeyGenerator |
| - { |
| - public CAST6() |
| - { |
| - super("CAST6", 256, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * TEA |
| - */ |
| - public static class TEA |
| - extends JCEKeyGenerator |
| - { |
| - public TEA() |
| - { |
| - super("TEA", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * XTEA |
| - */ |
| - public static class XTEA |
| - extends JCEKeyGenerator |
| - { |
| - public XTEA() |
| - { |
| - super("XTEA", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * Salsa20 |
| - */ |
| - public static class Salsa20 |
| - extends JCEKeyGenerator |
| - { |
| - public Salsa20() |
| - { |
| - super("Salsa20", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * HC128 |
| - */ |
| - public static class HC128 |
| - extends JCEKeyGenerator |
| - { |
| - public HC128() |
| - { |
| - super("HC128", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * HC256 |
| - */ |
| - public static class HC256 |
| - extends JCEKeyGenerator |
| - { |
| - public HC256() |
| - { |
| - super("HC256", 256, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * VMPC |
| - */ |
| - public static class VMPC |
| - extends JCEKeyGenerator |
| - { |
| - public VMPC() |
| - { |
| - super("VMPC", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * VMPC-KSA3 |
| - */ |
| - public static class VMPCKSA3 |
| - extends JCEKeyGenerator |
| - { |
| - public VMPCKSA3() |
| - { |
| - super("VMPC-KSA3", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| + // /** |
| + // * Rijndael |
| + // */ |
| + // public static class Rijndael |
| + // extends JCEKeyGenerator |
| + // { |
| + // public Rijndael() |
| + // { |
| + // super("Rijndael", 192, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Serpent |
| + // */ |
| + // public static class Serpent |
| + // extends JCEKeyGenerator |
| + // { |
| + // public Serpent() |
| + // { |
| + // super("Serpent", 192, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // |
| + // |
| + // /** |
| + // * CAST6 |
| + // */ |
| + // public static class CAST6 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public CAST6() |
| + // { |
| + // super("CAST6", 256, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * TEA |
| + // */ |
| + // public static class TEA |
| + // extends JCEKeyGenerator |
| + // { |
| + // public TEA() |
| + // { |
| + // super("TEA", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * XTEA |
| + // */ |
| + // public static class XTEA |
| + // extends JCEKeyGenerator |
| + // { |
| + // public XTEA() |
| + // { |
| + // super("XTEA", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Salsa20 |
| + // */ |
| + // public static class Salsa20 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public Salsa20() |
| + // { |
| + // super("Salsa20", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * HC128 |
| + // */ |
| + // public static class HC128 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public HC128() |
| + // { |
| + // super("HC128", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * HC256 |
| + // */ |
| + // public static class HC256 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public HC256() |
| + // { |
| + // super("HC256", 256, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * VMPC |
| + // */ |
| + // public static class VMPC |
| + // extends JCEKeyGenerator |
| + // { |
| + // public VMPC() |
| + // { |
| + // super("VMPC", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * VMPC-KSA3 |
| + // */ |
| + // public static class VMPCKSA3 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public VMPCKSA3() |
| + // { |
| + // super("VMPC-KSA3", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| // HMAC Related secret keys.. |
| |
| - /** |
| - * MD2HMAC |
| - */ |
| - public static class MD2HMAC |
| - extends JCEKeyGenerator |
| - { |
| - public MD2HMAC() |
| - { |
| - super("HMACMD2", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - |
| - /** |
| - * MD4HMAC |
| - */ |
| - public static class MD4HMAC |
| - extends JCEKeyGenerator |
| - { |
| - public MD4HMAC() |
| - { |
| - super("HMACMD4", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * MD2HMAC |
| + // */ |
| + // public static class MD2HMAC |
| + // extends JCEKeyGenerator |
| + // { |
| + // public MD2HMAC() |
| + // { |
| + // super("HMACMD2", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // |
| + // |
| + // /** |
| + // * MD4HMAC |
| + // */ |
| + // public static class MD4HMAC |
| + // extends JCEKeyGenerator |
| + // { |
| + // public MD4HMAC() |
| + // { |
| + // super("HMACMD4", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * MD5HMAC |
| @@ -427,29 +440,29 @@ |
| } |
| |
| |
| - /** |
| - * RIPE128HMAC |
| - */ |
| - public static class RIPEMD128HMAC |
| - extends JCEKeyGenerator |
| - { |
| - public RIPEMD128HMAC() |
| - { |
| - super("HMACRIPEMD128", 128, new CipherKeyGenerator()); |
| - } |
| - } |
| - |
| - /** |
| - * RIPE160HMAC |
| - */ |
| - public static class RIPEMD160HMAC |
| - extends JCEKeyGenerator |
| - { |
| - public RIPEMD160HMAC() |
| - { |
| - super("HMACRIPEMD160", 160, new CipherKeyGenerator()); |
| - } |
| - } |
| + // /** |
| + // * RIPE128HMAC |
| + // */ |
| + // public static class RIPEMD128HMAC |
| + // extends JCEKeyGenerator |
| + // { |
| + // public RIPEMD128HMAC() |
| + // { |
| + // super("HMACRIPEMD128", 128, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + |
| + // /** |
| + // * RIPE160HMAC |
| + // */ |
| + // public static class RIPEMD160HMAC |
| + // extends JCEKeyGenerator |
| + // { |
| + // public RIPEMD160HMAC() |
| + // { |
| + // super("HMACRIPEMD160", 160, new CipherKeyGenerator()); |
| + // } |
| + // } |
| |
| |
| /** |
| @@ -464,17 +477,19 @@ |
| } |
| } |
| |
| - /** |
| - * HMACSHA224 |
| - */ |
| - public static class HMACSHA224 |
| - extends JCEKeyGenerator |
| - { |
| - public HMACSHA224() |
| - { |
| - super("HMACSHA224", 224, new CipherKeyGenerator()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * HMACSHA224 |
| + // */ |
| + // public static class HMACSHA224 |
| + // extends JCEKeyGenerator |
| + // { |
| + // public HMACSHA224() |
| + // { |
| + // super("HMACSHA224", 224, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * HMACSHA256 |
| @@ -512,15 +527,17 @@ |
| } |
| } |
| |
| - /** |
| - * HMACTIGER |
| - */ |
| - public static class HMACTIGER |
| - extends JCEKeyGenerator |
| - { |
| - public HMACTIGER() |
| - { |
| - super("HMACTIGER", 192, new CipherKeyGenerator()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * HMACTIGER |
| + // */ |
| + // public static class HMACTIGER |
| + // extends JCEKeyGenerator |
| + // { |
| + // public HMACTIGER() |
| + // { |
| + // super("HMACTIGER", 192, new CipherKeyGenerator()); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEMac.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEMac.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEMac.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEMac.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -2,29 +2,43 @@ |
| |
| import org.bouncycastle.crypto.CipherParameters; |
| import org.bouncycastle.crypto.Mac; |
| -import org.bouncycastle.crypto.digests.MD2Digest; |
| -import org.bouncycastle.crypto.digests.MD4Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.MD2Digest; |
| +// import org.bouncycastle.crypto.digests.MD4Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.MD5Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD128Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.RIPEMD128Digest; |
| +// import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| -import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA256Digest; |
| import org.bouncycastle.crypto.digests.SHA384Digest; |
| import org.bouncycastle.crypto.digests.SHA512Digest; |
| -import org.bouncycastle.crypto.digests.TigerDigest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.TigerDigest; |
| +// END android-removed |
| import org.bouncycastle.crypto.engines.DESEngine; |
| import org.bouncycastle.crypto.engines.DESedeEngine; |
| -import org.bouncycastle.crypto.engines.RC2Engine; |
| -import org.bouncycastle.crypto.engines.RC532Engine; |
| -import org.bouncycastle.crypto.engines.SkipjackEngine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.RC2Engine; |
| +// import org.bouncycastle.crypto.engines.RC532Engine; |
| +// import org.bouncycastle.crypto.engines.SkipjackEngine; |
| +// END android-removed |
| import org.bouncycastle.crypto.macs.CBCBlockCipherMac; |
| -import org.bouncycastle.crypto.macs.CFBBlockCipherMac; |
| -import org.bouncycastle.crypto.macs.GOST28147Mac; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.macs.CFBBlockCipherMac; |
| +// import org.bouncycastle.crypto.macs.GOST28147Mac; |
| +// END android-removed |
| import org.bouncycastle.crypto.macs.HMac; |
| -import org.bouncycastle.crypto.macs.ISO9797Alg3Mac; |
| -import org.bouncycastle.crypto.macs.OldHMac; |
| -import org.bouncycastle.crypto.macs.VMPCMac; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.macs.ISO9797Alg3Mac; |
| +// import org.bouncycastle.crypto.macs.OldHMac; |
| +// import org.bouncycastle.crypto.macs.VMPCMac; |
| +// END android-removed |
| import org.bouncycastle.crypto.paddings.ISO7816d4Padding; |
| import org.bouncycastle.crypto.params.KeyParameter; |
| import org.bouncycastle.crypto.params.ParametersWithIV; |
| @@ -146,224 +160,226 @@ |
| * the classes that extend directly off us. |
| */ |
| |
| - /** |
| - * DES |
| - */ |
| - public static class DES |
| - extends JCEMac |
| - { |
| - public DES() |
| - { |
| - super(new CBCBlockCipherMac(new DESEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * DESede |
| - */ |
| - public static class DESede |
| - extends JCEMac |
| - { |
| - public DESede() |
| - { |
| - super(new CBCBlockCipherMac(new DESedeEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * SKIPJACK |
| - */ |
| - public static class Skipjack |
| - extends JCEMac |
| - { |
| - public Skipjack() |
| - { |
| - super(new CBCBlockCipherMac(new SkipjackEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * RC2 |
| - */ |
| - public static class RC2 |
| - extends JCEMac |
| - { |
| - public RC2() |
| - { |
| - super(new CBCBlockCipherMac(new RC2Engine())); |
| - } |
| - } |
| - |
| - /** |
| - * RC5 |
| - */ |
| - public static class RC5 |
| - extends JCEMac |
| - { |
| - public RC5() |
| - { |
| - super(new CBCBlockCipherMac(new RC532Engine())); |
| - } |
| - } |
| - |
| - /** |
| - * GOST28147 |
| - */ |
| - public static class GOST28147 |
| - extends JCEMac |
| - { |
| - public GOST28147() |
| - { |
| - super(new GOST28147Mac()); |
| - } |
| - } |
| - |
| - /** |
| - * VMPC |
| - */ |
| - public static class VMPC |
| - extends JCEMac |
| - { |
| - public VMPC() |
| - { |
| - super(new VMPCMac()); |
| - } |
| - } |
| - |
| - /** |
| - * DES |
| - */ |
| - public static class DESCFB8 |
| - extends JCEMac |
| - { |
| - public DESCFB8() |
| - { |
| - super(new CFBBlockCipherMac(new DESEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * DESede |
| - */ |
| - public static class DESedeCFB8 |
| - extends JCEMac |
| - { |
| - public DESedeCFB8() |
| - { |
| - super(new CFBBlockCipherMac(new DESedeEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * SKIPJACK |
| - */ |
| - public static class SkipjackCFB8 |
| - extends JCEMac |
| - { |
| - public SkipjackCFB8() |
| - { |
| - super(new CFBBlockCipherMac(new SkipjackEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * RC2CFB8 |
| - */ |
| - public static class RC2CFB8 |
| - extends JCEMac |
| - { |
| - public RC2CFB8() |
| - { |
| - super(new CFBBlockCipherMac(new RC2Engine())); |
| - } |
| - } |
| - |
| - /** |
| - * RC5CFB8 |
| - */ |
| - public static class RC5CFB8 |
| - extends JCEMac |
| - { |
| - public RC5CFB8() |
| - { |
| - super(new CFBBlockCipherMac(new RC532Engine())); |
| - } |
| - } |
| - |
| + // BEGIN android-removed |
| + // /** |
| + // * DES |
| + // */ |
| + // public static class DES |
| + // extends JCEMac |
| + // { |
| + // public DES() |
| + // { |
| + // super(new CBCBlockCipherMac(new DESEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DESede |
| + // */ |
| + // public static class DESede |
| + // extends JCEMac |
| + // { |
| + // public DESede() |
| + // { |
| + // super(new CBCBlockCipherMac(new DESedeEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SKIPJACK |
| + // */ |
| + // public static class Skipjack |
| + // extends JCEMac |
| + // { |
| + // public Skipjack() |
| + // { |
| + // super(new CBCBlockCipherMac(new SkipjackEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC2 |
| + // */ |
| + // public static class RC2 |
| + // extends JCEMac |
| + // { |
| + // public RC2() |
| + // { |
| + // super(new CBCBlockCipherMac(new RC2Engine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC5 |
| + // */ |
| + // public static class RC5 |
| + // extends JCEMac |
| + // { |
| + // public RC5() |
| + // { |
| + // super(new CBCBlockCipherMac(new RC532Engine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * GOST28147 |
| + // */ |
| + // public static class GOST28147 |
| + // extends JCEMac |
| + // { |
| + // public GOST28147() |
| + // { |
| + // super(new GOST28147Mac()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * VMPC |
| + // */ |
| + // public static class VMPC |
| + // extends JCEMac |
| + // { |
| + // public VMPC() |
| + // { |
| + // super(new VMPCMac()); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DES |
| + // */ |
| + // public static class DESCFB8 |
| + // extends JCEMac |
| + // { |
| + // public DESCFB8() |
| + // { |
| + // super(new CFBBlockCipherMac(new DESEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DESede |
| + // */ |
| + // public static class DESedeCFB8 |
| + // extends JCEMac |
| + // { |
| + // public DESedeCFB8() |
| + // { |
| + // super(new CFBBlockCipherMac(new DESedeEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SKIPJACK |
| + // */ |
| + // public static class SkipjackCFB8 |
| + // extends JCEMac |
| + // { |
| + // public SkipjackCFB8() |
| + // { |
| + // super(new CFBBlockCipherMac(new SkipjackEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC2CFB8 |
| + // */ |
| + // public static class RC2CFB8 |
| + // extends JCEMac |
| + // { |
| + // public RC2CFB8() |
| + // { |
| + // super(new CFBBlockCipherMac(new RC2Engine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * RC5CFB8 |
| + // */ |
| + // public static class RC5CFB8 |
| + // extends JCEMac |
| + // { |
| + // public RC5CFB8() |
| + // { |
| + // super(new CFBBlockCipherMac(new RC532Engine())); |
| + // } |
| + // } |
| + // |
| + // |
| + // /** |
| + // * DESede64 |
| + // */ |
| + // public static class DESede64 |
| + // extends JCEMac |
| + // { |
| + // public DESede64() |
| + // { |
| + // super(new CBCBlockCipherMac(new DESedeEngine(), 64)); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DESede64with7816-4Padding |
| + // */ |
| + // public static class DESede64with7816d4 |
| + // extends JCEMac |
| + // { |
| + // public DESede64with7816d4() |
| + // { |
| + // super(new CBCBlockCipherMac(new DESedeEngine(), 64, new ISO7816d4Padding())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DES9797Alg3with7816-4Padding |
| + // */ |
| + // public static class DES9797Alg3with7816d4 |
| + // extends JCEMac |
| + // { |
| + // public DES9797Alg3with7816d4() |
| + // { |
| + // super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DES9797Alg3 |
| + // */ |
| + // public static class DES9797Alg3 |
| + // extends JCEMac |
| + // { |
| + // public DES9797Alg3() |
| + // { |
| + // super(new ISO9797Alg3Mac(new DESEngine())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * MD2 HMac |
| + // */ |
| + // public static class MD2 |
| + // extends JCEMac |
| + // { |
| + // public MD2() |
| + // { |
| + // super(new HMac(new MD2Digest())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * MD4 HMac |
| + // */ |
| + // public static class MD4 |
| + // extends JCEMac |
| + // { |
| + // public MD4() |
| + // { |
| + // super(new HMac(new MD4Digest())); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| - * DESede64 |
| - */ |
| - public static class DESede64 |
| - extends JCEMac |
| - { |
| - public DESede64() |
| - { |
| - super(new CBCBlockCipherMac(new DESedeEngine(), 64)); |
| - } |
| - } |
| - |
| - /** |
| - * DESede64with7816-4Padding |
| - */ |
| - public static class DESede64with7816d4 |
| - extends JCEMac |
| - { |
| - public DESede64with7816d4() |
| - { |
| - super(new CBCBlockCipherMac(new DESedeEngine(), 64, new ISO7816d4Padding())); |
| - } |
| - } |
| - |
| - /** |
| - * DES9797Alg3with7816-4Padding |
| - */ |
| - public static class DES9797Alg3with7816d4 |
| - extends JCEMac |
| - { |
| - public DES9797Alg3with7816d4() |
| - { |
| - super(new ISO9797Alg3Mac(new DESEngine(), new ISO7816d4Padding())); |
| - } |
| - } |
| - |
| - /** |
| - * DES9797Alg3 |
| - */ |
| - public static class DES9797Alg3 |
| - extends JCEMac |
| - { |
| - public DES9797Alg3() |
| - { |
| - super(new ISO9797Alg3Mac(new DESEngine())); |
| - } |
| - } |
| - |
| - /** |
| - * MD2 HMac |
| - */ |
| - public static class MD2 |
| - extends JCEMac |
| - { |
| - public MD2() |
| - { |
| - super(new HMac(new MD2Digest())); |
| - } |
| - } |
| - |
| - /** |
| - * MD4 HMac |
| - */ |
| - public static class MD4 |
| - extends JCEMac |
| - { |
| - public MD4() |
| - { |
| - super(new HMac(new MD4Digest())); |
| - } |
| - } |
| - |
| - /** |
| * MD5 HMac |
| */ |
| public static class MD5 |
| @@ -374,7 +390,7 @@ |
| super(new HMac(new MD5Digest())); |
| } |
| } |
| - |
| + |
| /** |
| * SHA1 HMac |
| */ |
| @@ -386,18 +402,20 @@ |
| super(new HMac(new SHA1Digest())); |
| } |
| } |
| - |
| - /** |
| - * SHA-224 HMac |
| - */ |
| - public static class SHA224 |
| - extends JCEMac |
| - { |
| - public SHA224() |
| - { |
| - super(new HMac(new SHA224Digest())); |
| - } |
| - } |
| + |
| + // BEGIN android-removed |
| + // /** |
| + // * SHA-224 HMac |
| + // */ |
| + // public static class SHA224 |
| + // extends JCEMac |
| + // { |
| + // public SHA224() |
| + // { |
| + // super(new HMac(new SHA224Digest())); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * SHA-256 HMac |
| @@ -410,7 +428,7 @@ |
| super(new HMac(new SHA256Digest())); |
| } |
| } |
| - |
| + |
| /** |
| * SHA-384 HMac |
| */ |
| @@ -422,15 +440,17 @@ |
| super(new HMac(new SHA384Digest())); |
| } |
| } |
| - |
| - public static class OldSHA384 |
| - extends JCEMac |
| - { |
| - public OldSHA384() |
| - { |
| - super(new OldHMac(new SHA384Digest())); |
| - } |
| - } |
| + |
| + // BEGIN android-removed |
| + // public static class OldSHA384 |
| + // extends JCEMac |
| + // { |
| + // public OldSHA384() |
| + // { |
| + // super(new OldHMac(new SHA384Digest())); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * SHA-512 HMac |
| @@ -443,73 +463,75 @@ |
| super(new HMac(new SHA512Digest())); |
| } |
| } |
| - |
| - /** |
| - * SHA-512 HMac |
| - */ |
| - public static class OldSHA512 |
| - extends JCEMac |
| - { |
| - public OldSHA512() |
| - { |
| - super(new OldHMac(new SHA512Digest())); |
| - } |
| - } |
| |
| - /** |
| - * RIPEMD128 HMac |
| - */ |
| - public static class RIPEMD128 |
| - extends JCEMac |
| - { |
| - public RIPEMD128() |
| - { |
| - super(new HMac(new RIPEMD128Digest())); |
| - } |
| - } |
| - |
| - /** |
| - * RIPEMD160 HMac |
| - */ |
| - public static class RIPEMD160 |
| - extends JCEMac |
| - { |
| - public RIPEMD160() |
| - { |
| - super(new HMac(new RIPEMD160Digest())); |
| - } |
| - } |
| - |
| - /** |
| - * Tiger HMac |
| - */ |
| - public static class Tiger |
| - extends JCEMac |
| - { |
| - public Tiger() |
| - { |
| - super(new HMac(new TigerDigest())); |
| - } |
| - } |
| - |
| + // BEGIN android-removed |
| + // /** |
| + // * SHA-512 HMac |
| + // */ |
| + // public static class OldSHA512 |
| + // extends JCEMac |
| + // { |
| + // public OldSHA512() |
| + // { |
| + // super(new OldHMac(new SHA512Digest())); |
| + // } |
| + // } |
| // |
| - // PKCS12 states that the same algorithm should be used |
| - // for the key generation as is used in the HMAC, so that |
| - // is what we do here. |
| + // /** |
| + // * RIPEMD128 HMac |
| + // */ |
| + // public static class RIPEMD128 |
| + // extends JCEMac |
| + // { |
| + // public RIPEMD128() |
| + // { |
| + // super(new HMac(new RIPEMD128Digest())); |
| + // } |
| + // } |
| // |
| - |
| - /** |
| - * PBEWithHmacRIPEMD160 |
| - */ |
| - public static class PBEWithRIPEMD160 |
| - extends JCEMac |
| - { |
| - public PBEWithRIPEMD160() |
| - { |
| - super(new HMac(new RIPEMD160Digest()), PKCS12, RIPEMD160, 160); |
| - } |
| - } |
| - |
| + // /** |
| + // * RIPEMD160 HMac |
| + // */ |
| + // public static class RIPEMD160 |
| + // extends JCEMac |
| + // { |
| + // public RIPEMD160() |
| + // { |
| + // super(new HMac(new RIPEMD160Digest())); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Tiger HMac |
| + // */ |
| + // public static class Tiger |
| + // extends JCEMac |
| + // { |
| + // public Tiger() |
| + // { |
| + // super(new HMac(new TigerDigest())); |
| + // } |
| + // } |
| + // |
| + // // |
| + // // PKCS12 states that the same algorithm should be used |
| + // // for the key generation as is used in the HMAC, so that |
| + // // is what we do here. |
| + // // |
| + // |
| + // /** |
| + // * PBEWithHmacRIPEMD160 |
| + // */ |
| + // public static class PBEWithRIPEMD160 |
| + // extends JCEMac |
| + // { |
| + // public PBEWithRIPEMD160() |
| + // { |
| + // super(new HMac(new RIPEMD160Digest()), PKCS12, RIPEMD160, 160); |
| + // } |
| + // } |
| + // END android-removed |
| + |
| /** |
| * PBEWithHmacSHA |
| */ |
| @@ -521,16 +543,18 @@ |
| super(new HMac(new SHA1Digest()), PKCS12, SHA1, 160); |
| } |
| } |
| - |
| - /** |
| - * PBEWithHmacTiger |
| - */ |
| - public static class PBEWithTiger |
| - extends JCEMac |
| - { |
| - public PBEWithTiger() |
| - { |
| - super(new HMac(new TigerDigest()), PKCS12, TIGER, 192); |
| - } |
| - } |
| + |
| + // BEGIN android-removed |
| + // /** |
| + // * PBEWithHmacTiger |
| + // */ |
| + // public static class PBEWithTiger |
| + // extends JCEMac |
| + // { |
| + // public PBEWithTiger() |
| + // { |
| + // super(new HMac(new TigerDigest()), PKCS12, TIGER, 192); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSACipher.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSACipher.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSACipher.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSACipher.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -534,48 +534,50 @@ |
| } |
| } |
| |
| - static public class PKCS1v1_5Padding |
| - extends JCERSACipher |
| - { |
| - public PKCS1v1_5Padding() |
| - { |
| - super(new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class PKCS1v1_5Padding_PrivateOnly |
| - extends JCERSACipher |
| - { |
| - public PKCS1v1_5Padding_PrivateOnly() |
| - { |
| - super(false, true, new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class PKCS1v1_5Padding_PublicOnly |
| - extends JCERSACipher |
| - { |
| - public PKCS1v1_5Padding_PublicOnly() |
| - { |
| - super(true, false, new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class OAEPPadding |
| - extends JCERSACipher |
| - { |
| - public OAEPPadding() |
| - { |
| - super(OAEPParameterSpec.DEFAULT); |
| - } |
| - } |
| - |
| - static public class ISO9796d1Padding |
| - extends JCERSACipher |
| - { |
| - public ISO9796d1Padding() |
| - { |
| - super(new ISO9796d1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class PKCS1v1_5Padding |
| + // extends JCERSACipher |
| + // { |
| + // public PKCS1v1_5Padding() |
| + // { |
| + // super(new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class PKCS1v1_5Padding_PrivateOnly |
| + // extends JCERSACipher |
| + // { |
| + // public PKCS1v1_5Padding_PrivateOnly() |
| + // { |
| + // super(false, true, new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class PKCS1v1_5Padding_PublicOnly |
| + // extends JCERSACipher |
| + // { |
| + // public PKCS1v1_5Padding_PublicOnly() |
| + // { |
| + // super(true, false, new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class OAEPPadding |
| + // extends JCERSACipher |
| + // { |
| + // public OAEPPadding() |
| + // { |
| + // super(OAEPParameterSpec.DEFAULT); |
| + // } |
| + // } |
| + // |
| + // static public class ISO9796d1Padding |
| + // extends JCERSACipher |
| + // { |
| + // public ISO9796d1Padding() |
| + // { |
| + // super(new ISO9796d1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateCrtKey.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -125,7 +125,9 @@ |
| */ |
| public byte[] getEncoded() |
| { |
| - PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPrivateKeyStructure(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()).getDERObject()); |
| + // BEGIN android-changed |
| + PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKeyStructure(getModulus(), getPublicExponent(), getPrivateExponent(), getPrimeP(), getPrimeQ(), getPrimeExponentP(), getPrimeExponentQ(), getCrtCoefficient()).getDERObject()); |
| + // END android-changed |
| |
| return info.getDEREncoded(); |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateKey.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPrivateKey.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPrivateKey.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -77,7 +77,9 @@ |
| |
| public byte[] getEncoded() |
| { |
| - PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPrivateKeyStructure(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO, ZERO, ZERO, ZERO).getDERObject()); |
| + // BEGIN android-changed |
| + PrivateKeyInfo info = new PrivateKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPrivateKeyStructure(getModulus(), ZERO, getPrivateExponent(), ZERO, ZERO, ZERO, ZERO, ZERO).getDERObject()); |
| + // END android-changed |
| |
| return info.getDEREncoded(); |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPublicKey.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPublicKey.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCERSAPublicKey.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCERSAPublicKey.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -90,7 +90,9 @@ |
| |
| public byte[] getEncoded() |
| { |
| - SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, new DERNull()), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject()); |
| + // BEGIN android-changed |
| + SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.INSTANCE), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject()); |
| + // END android-changed |
| |
| return info.getDEREncoded(); |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCESecretKeyFactory.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCESecretKeyFactory.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCESecretKeyFactory.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCESecretKeyFactory.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -321,29 +321,31 @@ |
| } |
| } |
| |
| - /** |
| - * PBEWithMD2AndDES |
| - */ |
| - static public class PBEWithMD2AndDES |
| - extends DESPBEKeyFactory |
| - { |
| - public PBEWithMD2AndDES() |
| - { |
| - super("PBEwithMD2andDES", PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, true, PKCS5S1, MD2, 64, 64); |
| - } |
| - } |
| - |
| - /** |
| - * PBEWithMD2AndRC2 |
| - */ |
| - static public class PBEWithMD2AndRC2 |
| - extends PBEKeyFactory |
| - { |
| - public PBEWithMD2AndRC2() |
| - { |
| - super("PBEwithMD2andRC2", PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, true, PKCS5S1, MD2, 64, 64); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * PBEWithMD2AndDES |
| + // */ |
| + // static public class PBEWithMD2AndDES |
| + // extends DESPBEKeyFactory |
| + // { |
| + // public PBEWithMD2AndDES() |
| + // { |
| + // super("PBEwithMD2andDES", PKCSObjectIdentifiers.pbeWithMD2AndDES_CBC, true, PKCS5S1, MD2, 64, 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * PBEWithMD2AndRC2 |
| + // */ |
| + // static public class PBEWithMD2AndRC2 |
| + // extends PBEKeyFactory |
| + // { |
| + // public PBEWithMD2AndRC2() |
| + // { |
| + // super("PBEwithMD2andRC2", PKCSObjectIdentifiers.pbeWithMD2AndRC2_CBC, true, PKCS5S1, MD2, 64, 64); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * PBEWithMD5AndDES |
| @@ -477,17 +479,19 @@ |
| } |
| } |
| |
| - /** |
| - * PBEWithHmacRIPEMD160 |
| - */ |
| - public static class PBEWithRIPEMD160 |
| - extends PBEKeyFactory |
| - { |
| - public PBEWithRIPEMD160() |
| - { |
| - super("PBEwithHmacRIPEMD160", null, false, PKCS12, RIPEMD160, 160, 0); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * PBEWithHmacRIPEMD160 |
| + // */ |
| + // public static class PBEWithRIPEMD160 |
| + // extends PBEKeyFactory |
| + // { |
| + // public PBEWithRIPEMD160() |
| + // { |
| + // super("PBEwithHmacRIPEMD160", null, false, PKCS12, RIPEMD160, 160, 0); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * PBEWithHmacSHA |
| @@ -501,17 +505,19 @@ |
| } |
| } |
| |
| - /** |
| - * PBEWithHmacTiger |
| - */ |
| - public static class PBEWithTiger |
| - extends PBEKeyFactory |
| - { |
| - public PBEWithTiger() |
| - { |
| - super("PBEwithHmacTiger", null, false, PKCS12, TIGER, 192, 0); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * PBEWithHmacTiger |
| + // */ |
| + // public static class PBEWithTiger |
| + // extends PBEKeyFactory |
| + // { |
| + // public PBEWithTiger() |
| + // { |
| + // super("PBEwithHmacTiger", null, false, PKCS12, TIGER, 192, 0); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * PBEWithSHA1And128BitAES-BC |
| @@ -620,4 +626,56 @@ |
| super("PBEWithMD5And256BitAES-CBC-OpenSSL", null, true, OPENSSL, MD5, 256, 128); |
| } |
| } |
| + // BEGIN android-added |
| + static public class PBKDF2WithHmacSHA1 |
| + extends JCESecretKeyFactory |
| + { |
| + public PBKDF2WithHmacSHA1() |
| + { |
| + super("PBKDF2WithHmacSHA1", PKCSObjectIdentifiers.id_PBKDF2); |
| + } |
| + |
| + protected SecretKey engineGenerateSecret( |
| + KeySpec keySpec) |
| + throws InvalidKeySpecException |
| + { |
| + if (keySpec instanceof PBEKeySpec) |
| + { |
| + PBEKeySpec pbeSpec = (PBEKeySpec)keySpec; |
| + |
| + if (pbeSpec.getSalt() == null) |
| + { |
| + throw new InvalidKeySpecException("missing required salt"); |
| + } |
| + |
| + if (pbeSpec.getIterationCount() <= 0) |
| + { |
| + throw new InvalidKeySpecException("positive iteration count required: " |
| + + pbeSpec.getIterationCount()); |
| + } |
| + |
| + if (pbeSpec.getKeyLength() <= 0) |
| + { |
| + throw new InvalidKeySpecException("positive key length required: " |
| + + pbeSpec.getKeyLength()); |
| + } |
| + |
| + if (pbeSpec.getPassword().length == 0) |
| + { |
| + throw new IllegalArgumentException("password empty"); |
| + } |
| + |
| + int scheme = PKCS5S2; |
| + int digest = SHA1; |
| + int keySize = pbeSpec.getKeyLength(); |
| + int ivSize = -1; |
| + CipherParameters param = Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize); |
| + |
| + return new JCEPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param); |
| + } |
| + |
| + throw new InvalidKeySpecException("Invalid KeySpec"); |
| + } |
| + } |
| + // END android-added |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEStreamCipher.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEStreamCipher.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JCEStreamCipher.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JCEStreamCipher.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -5,17 +5,21 @@ |
| import org.bouncycastle.crypto.DataLengthException; |
| import org.bouncycastle.crypto.StreamBlockCipher; |
| import org.bouncycastle.crypto.StreamCipher; |
| -import org.bouncycastle.crypto.engines.BlowfishEngine; |
| -import org.bouncycastle.crypto.engines.DESEngine; |
| -import org.bouncycastle.crypto.engines.DESedeEngine; |
| -import org.bouncycastle.crypto.engines.HC128Engine; |
| -import org.bouncycastle.crypto.engines.HC256Engine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.BlowfishEngine; |
| +// import org.bouncycastle.crypto.engines.DESEngine; |
| +// import org.bouncycastle.crypto.engines.DESedeEngine; |
| +// import org.bouncycastle.crypto.engines.HC128Engine; |
| +// import org.bouncycastle.crypto.engines.HC256Engine; |
| +// END android-removed |
| import org.bouncycastle.crypto.engines.RC4Engine; |
| -import org.bouncycastle.crypto.engines.Salsa20Engine; |
| -import org.bouncycastle.crypto.engines.SkipjackEngine; |
| -import org.bouncycastle.crypto.engines.TwofishEngine; |
| -import org.bouncycastle.crypto.engines.VMPCEngine; |
| -import org.bouncycastle.crypto.engines.VMPCKSA3Engine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.Salsa20Engine; |
| +// import org.bouncycastle.crypto.engines.SkipjackEngine; |
| +// import org.bouncycastle.crypto.engines.TwofishEngine; |
| +// import org.bouncycastle.crypto.engines.VMPCEngine; |
| +// import org.bouncycastle.crypto.engines.VMPCKSA3Engine; |
| +// END android-removed |
| import org.bouncycastle.crypto.modes.CFBBlockCipher; |
| import org.bouncycastle.crypto.modes.OFBBlockCipher; |
| import org.bouncycastle.crypto.params.KeyParameter; |
| @@ -27,8 +31,10 @@ |
| import javax.crypto.ShortBufferException; |
| import javax.crypto.spec.IvParameterSpec; |
| import javax.crypto.spec.PBEParameterSpec; |
| -import javax.crypto.spec.RC2ParameterSpec; |
| -import javax.crypto.spec.RC5ParameterSpec; |
| +// BEGIN android-removed |
| +// import javax.crypto.spec.RC2ParameterSpec; |
| +// import javax.crypto.spec.RC5ParameterSpec; |
| +// END android-removed |
| import java.security.AlgorithmParameters; |
| import java.security.InvalidAlgorithmParameterException; |
| import java.security.InvalidKeyException; |
| @@ -44,8 +50,10 @@ |
| // |
| private Class[] availableSpecs = |
| { |
| - RC2ParameterSpec.class, |
| - RC5ParameterSpec.class, |
| + // BEGIN android-removed |
| + // RC2ParameterSpec.class, |
| + // RC5ParameterSpec.class, |
| + // END android-removed |
| IvParameterSpec.class, |
| PBEParameterSpec.class |
| }; |
| @@ -374,125 +382,127 @@ |
| * The ciphers that inherit from us. |
| */ |
| |
| - /** |
| - * DES |
| - */ |
| - static public class DES_CFB8 |
| - extends JCEStreamCipher |
| - { |
| - public DES_CFB8() |
| - { |
| - super(new CFBBlockCipher(new DESEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * DESede |
| - */ |
| - static public class DESede_CFB8 |
| - extends JCEStreamCipher |
| - { |
| - public DESede_CFB8() |
| - { |
| - super(new CFBBlockCipher(new DESedeEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * SKIPJACK |
| - */ |
| - static public class Skipjack_CFB8 |
| - extends JCEStreamCipher |
| - { |
| - public Skipjack_CFB8() |
| - { |
| - super(new CFBBlockCipher(new SkipjackEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * Blowfish |
| - */ |
| - static public class Blowfish_CFB8 |
| - extends JCEStreamCipher |
| - { |
| - public Blowfish_CFB8() |
| - { |
| - super(new CFBBlockCipher(new BlowfishEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * Twofish |
| - */ |
| - static public class Twofish_CFB8 |
| - extends JCEStreamCipher |
| - { |
| - public Twofish_CFB8() |
| - { |
| - super(new CFBBlockCipher(new TwofishEngine(), 8), 128); |
| - } |
| - } |
| - |
| - /** |
| - * DES |
| - */ |
| - static public class DES_OFB8 |
| - extends JCEStreamCipher |
| - { |
| - public DES_OFB8() |
| - { |
| - super(new OFBBlockCipher(new DESEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * DESede |
| - */ |
| - static public class DESede_OFB8 |
| - extends JCEStreamCipher |
| - { |
| - public DESede_OFB8() |
| - { |
| - super(new OFBBlockCipher(new DESedeEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * SKIPJACK |
| - */ |
| - static public class Skipjack_OFB8 |
| - extends JCEStreamCipher |
| - { |
| - public Skipjack_OFB8() |
| - { |
| - super(new OFBBlockCipher(new SkipjackEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * Blowfish |
| - */ |
| - static public class Blowfish_OFB8 |
| - extends JCEStreamCipher |
| - { |
| - public Blowfish_OFB8() |
| - { |
| - super(new OFBBlockCipher(new BlowfishEngine(), 8), 64); |
| - } |
| - } |
| - |
| - /** |
| - * Twofish |
| - */ |
| - static public class Twofish_OFB8 |
| - extends JCEStreamCipher |
| - { |
| - public Twofish_OFB8() |
| - { |
| - super(new OFBBlockCipher(new TwofishEngine(), 8), 128); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // /** |
| + // * DES |
| + // */ |
| + // static public class DES_CFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public DES_CFB8() |
| + // { |
| + // super(new CFBBlockCipher(new DESEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DESede |
| + // */ |
| + // static public class DESede_CFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public DESede_CFB8() |
| + // { |
| + // super(new CFBBlockCipher(new DESedeEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SKIPJACK |
| + // */ |
| + // static public class Skipjack_CFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Skipjack_CFB8() |
| + // { |
| + // super(new CFBBlockCipher(new SkipjackEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Blowfish |
| + // */ |
| + // static public class Blowfish_CFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Blowfish_CFB8() |
| + // { |
| + // super(new CFBBlockCipher(new BlowfishEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Twofish |
| + // */ |
| + // static public class Twofish_CFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Twofish_CFB8() |
| + // { |
| + // super(new CFBBlockCipher(new TwofishEngine(), 8), 128); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DES |
| + // */ |
| + // static public class DES_OFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public DES_OFB8() |
| + // { |
| + // super(new OFBBlockCipher(new DESEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * DESede |
| + // */ |
| + // static public class DESede_OFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public DESede_OFB8() |
| + // { |
| + // super(new OFBBlockCipher(new DESedeEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * SKIPJACK |
| + // */ |
| + // static public class Skipjack_OFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Skipjack_OFB8() |
| + // { |
| + // super(new OFBBlockCipher(new SkipjackEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Blowfish |
| + // */ |
| + // static public class Blowfish_OFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Blowfish_OFB8() |
| + // { |
| + // super(new OFBBlockCipher(new BlowfishEngine(), 8), 64); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * Twofish |
| + // */ |
| + // static public class Twofish_OFB8 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Twofish_OFB8() |
| + // { |
| + // super(new OFBBlockCipher(new TwofishEngine(), 8), 128); |
| + // } |
| + // } |
| + // END android-removed |
| |
| /** |
| * RC4 |
| @@ -517,7 +527,7 @@ |
| super(new RC4Engine(), 0); |
| } |
| } |
| - |
| + |
| /** |
| * PBEWithSHAAnd40BitRC4 |
| */ |
| @@ -529,64 +539,66 @@ |
| super(new RC4Engine(), 0); |
| } |
| } |
| - |
| - /** |
| - * Salsa20 |
| - */ |
| - static public class Salsa20 |
| - extends JCEStreamCipher |
| - { |
| - public Salsa20() |
| - { |
| - super(new Salsa20Engine(), 8); |
| - } |
| - } |
| - |
| - /** |
| - * HC-128 |
| - */ |
| - static public class HC128 |
| - extends JCEStreamCipher |
| - { |
| - public HC128() |
| - { |
| - super(new HC128Engine(), 16); |
| - } |
| - } |
| - |
| - /** |
| - * HC-256 |
| - */ |
| - static public class HC256 |
| - extends JCEStreamCipher |
| - { |
| - public HC256() |
| - { |
| - super(new HC256Engine(), 32); |
| - } |
| - } |
| - |
| - /** |
| - * VMPC |
| - */ |
| - static public class VMPC |
| - extends JCEStreamCipher |
| - { |
| - public VMPC() |
| - { |
| - super(new VMPCEngine(), 16); |
| - } |
| - } |
| - |
| - /** |
| - * VMPC-KSA3 |
| - */ |
| - static public class VMPCKSA3 |
| - extends JCEStreamCipher |
| - { |
| - public VMPCKSA3() |
| - { |
| - super(new VMPCKSA3Engine(), 16); |
| - } |
| - } |
| + |
| + // BEGIN android-removed |
| + // /** |
| + // * Salsa20 |
| + // */ |
| + // static public class Salsa20 |
| + // extends JCEStreamCipher |
| + // { |
| + // public Salsa20() |
| + // { |
| + // super(new Salsa20Engine(), 8); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * HC-128 |
| + // */ |
| + // static public class HC128 |
| + // extends JCEStreamCipher |
| + // { |
| + // public HC128() |
| + // { |
| + // super(new HC128Engine(), 16); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * HC-256 |
| + // */ |
| + // static public class HC256 |
| + // extends JCEStreamCipher |
| + // { |
| + // public HC256() |
| + // { |
| + // super(new HC256Engine(), 32); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * VMPC |
| + // */ |
| + // static public class VMPC |
| + // extends JCEStreamCipher |
| + // { |
| + // public VMPC() |
| + // { |
| + // super(new VMPCEngine(), 16); |
| + // } |
| + // } |
| + // |
| + // /** |
| + // * VMPC-KSA3 |
| + // */ |
| + // static public class VMPCKSA3 |
| + // extends JCEStreamCipher |
| + // { |
| + // public VMPCKSA3() |
| + // { |
| + // super(new VMPCKSA3Engine(), 16); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameterGenerator.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -2,19 +2,25 @@ |
| |
| import org.bouncycastle.crypto.generators.DHParametersGenerator; |
| import org.bouncycastle.crypto.generators.DSAParametersGenerator; |
| -import org.bouncycastle.crypto.generators.ElGamalParametersGenerator; |
| -import org.bouncycastle.crypto.generators.GOST3410ParametersGenerator; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.generators.ElGamalParametersGenerator; |
| +// import org.bouncycastle.crypto.generators.GOST3410ParametersGenerator; |
| +// END android-removed |
| import org.bouncycastle.crypto.params.DHParameters; |
| import org.bouncycastle.crypto.params.DSAParameters; |
| -import org.bouncycastle.crypto.params.ElGamalParameters; |
| -import org.bouncycastle.crypto.params.GOST3410Parameters; |
| -import org.bouncycastle.jce.spec.GOST3410ParameterSpec; |
| -import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.params.ElGamalParameters; |
| +// import org.bouncycastle.crypto.params.GOST3410Parameters; |
| +// import org.bouncycastle.jce.spec.GOST3410ParameterSpec; |
| +// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec; |
| +// END android-removed |
| |
| import javax.crypto.spec.DHGenParameterSpec; |
| import javax.crypto.spec.DHParameterSpec; |
| import javax.crypto.spec.IvParameterSpec; |
| -import javax.crypto.spec.RC2ParameterSpec; |
| +// BEGIN android-removed |
| +// import javax.crypto.spec.RC2ParameterSpec; |
| +// END android-removed |
| import java.security.AlgorithmParameterGeneratorSpi; |
| import java.security.AlgorithmParameters; |
| import java.security.InvalidAlgorithmParameterException; |
| @@ -144,196 +150,198 @@ |
| } |
| } |
| |
| - public static class GOST3410 |
| - extends JDKAlgorithmParameterGenerator |
| - { |
| - protected void engineInit( |
| - AlgorithmParameterSpec genParamSpec, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for GOST3410 parameter generation."); |
| - } |
| - |
| - protected AlgorithmParameters engineGenerateParameters() |
| - { |
| - GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator(); |
| - |
| - if (random != null) |
| - { |
| - pGen.init(strength, 2, random); |
| - } |
| - else |
| - { |
| - pGen.init(strength, 2, new SecureRandom()); |
| - } |
| - |
| - GOST3410Parameters p = pGen.generateParameters(); |
| - |
| - AlgorithmParameters params; |
| - |
| - try |
| - { |
| - params = AlgorithmParameters.getInstance("GOST3410", "BC"); |
| - params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA()))); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new RuntimeException(e.getMessage()); |
| - } |
| - |
| - return params; |
| - } |
| - } |
| - |
| - public static class ElGamal |
| - extends JDKAlgorithmParameterGenerator |
| - { |
| - private int l = 0; |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec genParamSpec, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - if (!(genParamSpec instanceof DHGenParameterSpec)) |
| - { |
| - throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); |
| - } |
| - DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; |
| - |
| - this.strength = spec.getPrimeSize(); |
| - this.l = spec.getExponentSize(); |
| - this.random = random; |
| - } |
| - |
| - protected AlgorithmParameters engineGenerateParameters() |
| - { |
| - ElGamalParametersGenerator pGen = new ElGamalParametersGenerator(); |
| - |
| - if (random != null) |
| - { |
| - pGen.init(strength, 20, random); |
| - } |
| - else |
| - { |
| - pGen.init(strength, 20, new SecureRandom()); |
| - } |
| - |
| - ElGamalParameters p = pGen.generateParameters(); |
| - |
| - AlgorithmParameters params; |
| - |
| - try |
| - { |
| - params = AlgorithmParameters.getInstance("ElGamal", "BC"); |
| - params.init(new DHParameterSpec(p.getP(), p.getG(), l)); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new RuntimeException(e.getMessage()); |
| - } |
| - |
| - return params; |
| - } |
| - } |
| - |
| - public static class DES |
| - extends JDKAlgorithmParameterGenerator |
| - { |
| - protected void engineInit( |
| - AlgorithmParameterSpec genParamSpec, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for DES parameter generation."); |
| - } |
| - |
| - protected AlgorithmParameters engineGenerateParameters() |
| - { |
| - byte[] iv = new byte[8]; |
| - |
| - if (random == null) |
| - { |
| - random = new SecureRandom(); |
| - } |
| - |
| - random.nextBytes(iv); |
| - |
| - AlgorithmParameters params; |
| - |
| - try |
| - { |
| - params = AlgorithmParameters.getInstance("DES", "BC"); |
| - params.init(new IvParameterSpec(iv)); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new RuntimeException(e.getMessage()); |
| - } |
| - |
| - return params; |
| - } |
| - } |
| - |
| - public static class RC2 |
| - extends JDKAlgorithmParameterGenerator |
| - { |
| - RC2ParameterSpec spec = null; |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec genParamSpec, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - if (genParamSpec instanceof RC2ParameterSpec) |
| - { |
| - spec = (RC2ParameterSpec)genParamSpec; |
| - return; |
| - } |
| - |
| - throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for RC2 parameter generation."); |
| - } |
| - |
| - protected AlgorithmParameters engineGenerateParameters() |
| - { |
| - AlgorithmParameters params; |
| - |
| - if (spec == null) |
| - { |
| - byte[] iv = new byte[8]; |
| - |
| - if (random == null) |
| - { |
| - random = new SecureRandom(); |
| - } |
| - |
| - random.nextBytes(iv); |
| - |
| - try |
| - { |
| - params = AlgorithmParameters.getInstance("RC2", "BC"); |
| - params.init(new IvParameterSpec(iv)); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new RuntimeException(e.getMessage()); |
| - } |
| - } |
| - else |
| - { |
| - try |
| - { |
| - params = AlgorithmParameters.getInstance("RC2", "BC"); |
| - params.init(spec); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new RuntimeException(e.getMessage()); |
| - } |
| - } |
| - |
| - return params; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class GOST3410 |
| + // extends JDKAlgorithmParameterGenerator |
| + // { |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec genParamSpec, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for GOST3410 parameter generation."); |
| + // } |
| + // |
| + // protected AlgorithmParameters engineGenerateParameters() |
| + // { |
| + // GOST3410ParametersGenerator pGen = new GOST3410ParametersGenerator(); |
| + // |
| + // if (random != null) |
| + // { |
| + // pGen.init(strength, 2, random); |
| + // } |
| + // else |
| + // { |
| + // pGen.init(strength, 2, new SecureRandom()); |
| + // } |
| + // |
| + // GOST3410Parameters p = pGen.generateParameters(); |
| + // |
| + // AlgorithmParameters params; |
| + // |
| + // try |
| + // { |
| + // params = AlgorithmParameters.getInstance("GOST3410", "BC"); |
| + // params.init(new GOST3410ParameterSpec(new GOST3410PublicKeyParameterSetSpec(p.getP(), p.getQ(), p.getA()))); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new RuntimeException(e.getMessage()); |
| + // } |
| + // |
| + // return params; |
| + // } |
| + // } |
| + // |
| + // public static class ElGamal |
| + // extends JDKAlgorithmParameterGenerator |
| + // { |
| + // private int l = 0; |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec genParamSpec, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // if (!(genParamSpec instanceof DHGenParameterSpec)) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("DH parameter generator requires a DHGenParameterSpec for initialisation"); |
| + // } |
| + // DHGenParameterSpec spec = (DHGenParameterSpec)genParamSpec; |
| + // |
| + // this.strength = spec.getPrimeSize(); |
| + // this.l = spec.getExponentSize(); |
| + // this.random = random; |
| + // } |
| + // |
| + // protected AlgorithmParameters engineGenerateParameters() |
| + // { |
| + // ElGamalParametersGenerator pGen = new ElGamalParametersGenerator(); |
| + // |
| + // if (random != null) |
| + // { |
| + // pGen.init(strength, 20, random); |
| + // } |
| + // else |
| + // { |
| + // pGen.init(strength, 20, new SecureRandom()); |
| + // } |
| + // |
| + // ElGamalParameters p = pGen.generateParameters(); |
| + // |
| + // AlgorithmParameters params; |
| + // |
| + // try |
| + // { |
| + // params = AlgorithmParameters.getInstance("ElGamal", "BC"); |
| + // params.init(new DHParameterSpec(p.getP(), p.getG(), l)); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new RuntimeException(e.getMessage()); |
| + // } |
| + // |
| + // return params; |
| + // } |
| + // } |
| + // |
| + // public static class DES |
| + // extends JDKAlgorithmParameterGenerator |
| + // { |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec genParamSpec, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for DES parameter generation."); |
| + // } |
| + // |
| + // protected AlgorithmParameters engineGenerateParameters() |
| + // { |
| + // byte[] iv = new byte[8]; |
| + // |
| + // if (random == null) |
| + // { |
| + // random = new SecureRandom(); |
| + // } |
| + // |
| + // random.nextBytes(iv); |
| + // |
| + // AlgorithmParameters params; |
| + // |
| + // try |
| + // { |
| + // params = AlgorithmParameters.getInstance("DES", "BC"); |
| + // params.init(new IvParameterSpec(iv)); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new RuntimeException(e.getMessage()); |
| + // } |
| + // |
| + // return params; |
| + // } |
| + // } |
| + // |
| + // public static class RC2 |
| + // extends JDKAlgorithmParameterGenerator |
| + // { |
| + // RC2ParameterSpec spec = null; |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec genParamSpec, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // if (genParamSpec instanceof RC2ParameterSpec) |
| + // { |
| + // spec = (RC2ParameterSpec)genParamSpec; |
| + // return; |
| + // } |
| + // |
| + // throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for RC2 parameter generation."); |
| + // } |
| + // |
| + // protected AlgorithmParameters engineGenerateParameters() |
| + // { |
| + // AlgorithmParameters params; |
| + // |
| + // if (spec == null) |
| + // { |
| + // byte[] iv = new byte[8]; |
| + // |
| + // if (random == null) |
| + // { |
| + // random = new SecureRandom(); |
| + // } |
| + // |
| + // random.nextBytes(iv); |
| + // |
| + // try |
| + // { |
| + // params = AlgorithmParameters.getInstance("RC2", "BC"); |
| + // params.init(new IvParameterSpec(iv)); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new RuntimeException(e.getMessage()); |
| + // } |
| + // } |
| + // else |
| + // { |
| + // try |
| + // { |
| + // params = AlgorithmParameters.getInstance("RC2", "BC"); |
| + // params.init(spec); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new RuntimeException(e.getMessage()); |
| + // } |
| + // } |
| + // |
| + // return params; |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKAlgorithmParameters.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -10,21 +10,27 @@ |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.DEROctetString; |
| import org.bouncycastle.asn1.DERSequence; |
| -import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters; |
| -import org.bouncycastle.asn1.oiw.ElGamalParameter; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.cryptopro.GOST3410PublicKeyAlgParameters; |
| +// import org.bouncycastle.asn1.oiw.ElGamalParameter; |
| +// END android-removed |
| import org.bouncycastle.asn1.pkcs.DHParameter; |
| import org.bouncycastle.asn1.pkcs.PKCS12PBEParams; |
| import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; |
| -import org.bouncycastle.asn1.pkcs.RC2CBCParameter; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.pkcs.RC2CBCParameter; |
| +// END android-removed |
| import org.bouncycastle.asn1.pkcs.RSAESOAEPparams; |
| import org.bouncycastle.asn1.pkcs.RSASSAPSSparams; |
| import org.bouncycastle.asn1.pkcs.PBKDF2Params; |
| import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
| import org.bouncycastle.asn1.x509.DSAParameter; |
| -import org.bouncycastle.jce.spec.ElGamalParameterSpec; |
| -import org.bouncycastle.jce.spec.GOST3410ParameterSpec; |
| -import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec; |
| -import org.bouncycastle.jce.spec.IESParameterSpec; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.spec.ElGamalParameterSpec; |
| +// import org.bouncycastle.jce.spec.GOST3410ParameterSpec; |
| +// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec; |
| +// import org.bouncycastle.jce.spec.IESParameterSpec; |
| +// END android-removed |
| import org.bouncycastle.util.Arrays; |
| |
| import javax.crypto.spec.DHParameterSpec; |
| @@ -32,7 +38,9 @@ |
| import javax.crypto.spec.OAEPParameterSpec; |
| import javax.crypto.spec.PBEParameterSpec; |
| import javax.crypto.spec.PSource; |
| -import javax.crypto.spec.RC2ParameterSpec; |
| +// BEGIN android-removed |
| +// import javax.crypto.spec.RC2ParameterSpec; |
| +// END android-removed |
| import java.io.IOException; |
| import java.security.AlgorithmParametersSpi; |
| import java.security.spec.AlgorithmParameterSpec; |
| @@ -68,13 +76,13 @@ |
| extends JDKAlgorithmParameters |
| { |
| private byte[] iv; |
| - |
| + |
| protected byte[] engineGetEncoded() |
| throws IOException |
| { |
| return engineGetEncoded("ASN.1"); |
| } |
| - |
| + |
| protected byte[] engineGetEncoded( |
| String format) |
| throws IOException |
| @@ -83,15 +91,15 @@ |
| { |
| return new DEROctetString(engineGetEncoded("RAW")).getEncoded(); |
| } |
| - |
| + |
| if (format.equals("RAW")) |
| { |
| return Arrays.clone(iv); |
| } |
| - |
| + |
| return null; |
| } |
| - |
| + |
| protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| Class paramSpec) |
| throws InvalidParameterSpecException |
| @@ -100,10 +108,10 @@ |
| { |
| return new IvParameterSpec(iv); |
| } |
| - |
| + |
| throw new InvalidParameterSpecException("unknown parameter spec passed to IV parameters object."); |
| } |
| - |
| + |
| protected void engineInit( |
| AlgorithmParameterSpec paramSpec) |
| throws InvalidParameterSpecException |
| @@ -112,10 +120,10 @@ |
| { |
| throw new InvalidParameterSpecException("IvParameterSpec required to initialise a IV parameters algorithm parameters object"); |
| } |
| - |
| + |
| this.iv = ((IvParameterSpec)paramSpec).getIV(); |
| } |
| - |
| + |
| protected void engineInit( |
| byte[] params) |
| throws IOException |
| @@ -127,13 +135,13 @@ |
| && params[0] == 0x04 && params[1] == params.length - 2) |
| { |
| ASN1OctetString oct = (ASN1OctetString)ASN1Object.fromByteArray(params); |
| - |
| + |
| params = oct.getOctets(); |
| } |
| - |
| + |
| this.iv = Arrays.clone(params); |
| } |
| - |
| + |
| protected void engineInit( |
| byte[] params, |
| String format) |
| @@ -144,204 +152,206 @@ |
| try |
| { |
| ASN1OctetString oct = (ASN1OctetString)ASN1Object.fromByteArray(params); |
| - |
| + |
| engineInit(oct.getOctets()); |
| } |
| catch (Exception e) |
| { |
| throw new IOException("Exception decoding: " + e); |
| } |
| - |
| + |
| return; |
| } |
| - |
| + |
| if (format.equals("RAW")) |
| { |
| engineInit(params); |
| return; |
| } |
| - |
| + |
| throw new IOException("Unknown parameters format in IV parameters object"); |
| } |
| - |
| + |
| protected String engineToString() |
| { |
| return "IV Parameters"; |
| } |
| } |
| - |
| - public static class RC2AlgorithmParameters |
| - extends JDKAlgorithmParameters |
| - { |
| - private static final short[] table = { |
| - 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, |
| - 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, |
| - 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, |
| - 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, |
| - 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, |
| - 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, |
| - 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, |
| - 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, |
| - 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, |
| - 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, |
| - 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, |
| - 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, |
| - 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, |
| - 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, |
| - 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, |
| - 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab |
| - }; |
| - |
| - private static final short[] ekb = { |
| - 0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d, 0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5, |
| - 0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47, 0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5, |
| - 0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c, 0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef, |
| - 0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89, 0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d, |
| - 0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8, 0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb, |
| - 0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab, 0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d, |
| - 0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46, 0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3, |
| - 0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87, 0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61, |
| - 0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6, 0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1, |
| - 0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7, 0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21, |
| - 0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0, 0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42, |
| - 0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a, 0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f, |
| - 0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5, 0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7, |
| - 0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90, 0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15, |
| - 0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b, 0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7, |
| - 0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18, 0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd |
| - }; |
| - |
| - private byte[] iv; |
| - private int parameterVersion = 58; |
| - |
| - protected byte[] engineGetEncoded() |
| - { |
| - return Arrays.clone(iv); |
| - } |
| - |
| - protected byte[] engineGetEncoded( |
| - String format) |
| - throws IOException |
| - { |
| - if (isASN1FormatString(format)) |
| - { |
| - if (parameterVersion == -1) |
| - { |
| - return new RC2CBCParameter(engineGetEncoded()).getEncoded(); |
| - } |
| - else |
| - { |
| - return new RC2CBCParameter(parameterVersion, engineGetEncoded()).getEncoded(); |
| - } |
| - } |
| - |
| - if (format.equals("RAW")) |
| - { |
| - return engineGetEncoded(); |
| - } |
| - |
| - return null; |
| - } |
| - |
| - protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| - Class paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (paramSpec == RC2ParameterSpec.class) |
| - { |
| - if (parameterVersion != -1) |
| - { |
| - if (parameterVersion < 256) |
| - { |
| - return new RC2ParameterSpec(ekb[parameterVersion], iv); |
| - } |
| - else |
| - { |
| - return new RC2ParameterSpec(parameterVersion, iv); |
| - } |
| - } |
| - } |
| - |
| - if (paramSpec == IvParameterSpec.class) |
| - { |
| - return new IvParameterSpec(iv); |
| - } |
| - |
| - throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object."); |
| - } |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (paramSpec instanceof IvParameterSpec) |
| - { |
| - this.iv = ((IvParameterSpec)paramSpec).getIV(); |
| - } |
| - else if (paramSpec instanceof RC2ParameterSpec) |
| - { |
| - int effKeyBits = ((RC2ParameterSpec)paramSpec).getEffectiveKeyBits(); |
| - if (effKeyBits != -1) |
| - { |
| - if (effKeyBits < 256) |
| - { |
| - parameterVersion = table[effKeyBits]; |
| - } |
| - else |
| - { |
| - parameterVersion = effKeyBits; |
| - } |
| - } |
| - |
| - this.iv = ((RC2ParameterSpec)paramSpec).getIV(); |
| - } |
| - else |
| - { |
| - throw new InvalidParameterSpecException("IvParameterSpec or RC2ParameterSpec required to initialise a RC2 parameters algorithm parameters object"); |
| - } |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params) |
| - throws IOException |
| - { |
| - this.iv = Arrays.clone(params); |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params, |
| - String format) |
| - throws IOException |
| - { |
| - if (isASN1FormatString(format)) |
| - { |
| - RC2CBCParameter p = RC2CBCParameter.getInstance(ASN1Object.fromByteArray(params)); |
| - |
| - if (p.getRC2ParameterVersion() != null) |
| - { |
| - parameterVersion = p.getRC2ParameterVersion().intValue(); |
| - } |
| - |
| - iv = p.getIV(); |
| - |
| - return; |
| - } |
| - |
| - if (format.equals("RAW")) |
| - { |
| - engineInit(params); |
| - return; |
| - } |
| - |
| - throw new IOException("Unknown parameters format in IV parameters object"); |
| - } |
| - |
| - protected String engineToString() |
| - { |
| - return "RC2 Parameters"; |
| - } |
| - } |
| - |
| + |
| + // BEGIN android-removed |
| + // public static class RC2AlgorithmParameters |
| + // extends JDKAlgorithmParameters |
| + // { |
| + // private static final short[] table = { |
| + // 0xbd, 0x56, 0xea, 0xf2, 0xa2, 0xf1, 0xac, 0x2a, 0xb0, 0x93, 0xd1, 0x9c, 0x1b, 0x33, 0xfd, 0xd0, |
| + // 0x30, 0x04, 0xb6, 0xdc, 0x7d, 0xdf, 0x32, 0x4b, 0xf7, 0xcb, 0x45, 0x9b, 0x31, 0xbb, 0x21, 0x5a, |
| + // 0x41, 0x9f, 0xe1, 0xd9, 0x4a, 0x4d, 0x9e, 0xda, 0xa0, 0x68, 0x2c, 0xc3, 0x27, 0x5f, 0x80, 0x36, |
| + // 0x3e, 0xee, 0xfb, 0x95, 0x1a, 0xfe, 0xce, 0xa8, 0x34, 0xa9, 0x13, 0xf0, 0xa6, 0x3f, 0xd8, 0x0c, |
| + // 0x78, 0x24, 0xaf, 0x23, 0x52, 0xc1, 0x67, 0x17, 0xf5, 0x66, 0x90, 0xe7, 0xe8, 0x07, 0xb8, 0x60, |
| + // 0x48, 0xe6, 0x1e, 0x53, 0xf3, 0x92, 0xa4, 0x72, 0x8c, 0x08, 0x15, 0x6e, 0x86, 0x00, 0x84, 0xfa, |
| + // 0xf4, 0x7f, 0x8a, 0x42, 0x19, 0xf6, 0xdb, 0xcd, 0x14, 0x8d, 0x50, 0x12, 0xba, 0x3c, 0x06, 0x4e, |
| + // 0xec, 0xb3, 0x35, 0x11, 0xa1, 0x88, 0x8e, 0x2b, 0x94, 0x99, 0xb7, 0x71, 0x74, 0xd3, 0xe4, 0xbf, |
| + // 0x3a, 0xde, 0x96, 0x0e, 0xbc, 0x0a, 0xed, 0x77, 0xfc, 0x37, 0x6b, 0x03, 0x79, 0x89, 0x62, 0xc6, |
| + // 0xd7, 0xc0, 0xd2, 0x7c, 0x6a, 0x8b, 0x22, 0xa3, 0x5b, 0x05, 0x5d, 0x02, 0x75, 0xd5, 0x61, 0xe3, |
| + // 0x18, 0x8f, 0x55, 0x51, 0xad, 0x1f, 0x0b, 0x5e, 0x85, 0xe5, 0xc2, 0x57, 0x63, 0xca, 0x3d, 0x6c, |
| + // 0xb4, 0xc5, 0xcc, 0x70, 0xb2, 0x91, 0x59, 0x0d, 0x47, 0x20, 0xc8, 0x4f, 0x58, 0xe0, 0x01, 0xe2, |
| + // 0x16, 0x38, 0xc4, 0x6f, 0x3b, 0x0f, 0x65, 0x46, 0xbe, 0x7e, 0x2d, 0x7b, 0x82, 0xf9, 0x40, 0xb5, |
| + // 0x1d, 0x73, 0xf8, 0xeb, 0x26, 0xc7, 0x87, 0x97, 0x25, 0x54, 0xb1, 0x28, 0xaa, 0x98, 0x9d, 0xa5, |
| + // 0x64, 0x6d, 0x7a, 0xd4, 0x10, 0x81, 0x44, 0xef, 0x49, 0xd6, 0xae, 0x2e, 0xdd, 0x76, 0x5c, 0x2f, |
| + // 0xa7, 0x1c, 0xc9, 0x09, 0x69, 0x9a, 0x83, 0xcf, 0x29, 0x39, 0xb9, 0xe9, 0x4c, 0xff, 0x43, 0xab |
| + // }; |
| + // |
| + // private static final short[] ekb = { |
| + // 0x5d, 0xbe, 0x9b, 0x8b, 0x11, 0x99, 0x6e, 0x4d, 0x59, 0xf3, 0x85, 0xa6, 0x3f, 0xb7, 0x83, 0xc5, |
| + // 0xe4, 0x73, 0x6b, 0x3a, 0x68, 0x5a, 0xc0, 0x47, 0xa0, 0x64, 0x34, 0x0c, 0xf1, 0xd0, 0x52, 0xa5, |
| + // 0xb9, 0x1e, 0x96, 0x43, 0x41, 0xd8, 0xd4, 0x2c, 0xdb, 0xf8, 0x07, 0x77, 0x2a, 0xca, 0xeb, 0xef, |
| + // 0x10, 0x1c, 0x16, 0x0d, 0x38, 0x72, 0x2f, 0x89, 0xc1, 0xf9, 0x80, 0xc4, 0x6d, 0xae, 0x30, 0x3d, |
| + // 0xce, 0x20, 0x63, 0xfe, 0xe6, 0x1a, 0xc7, 0xb8, 0x50, 0xe8, 0x24, 0x17, 0xfc, 0x25, 0x6f, 0xbb, |
| + // 0x6a, 0xa3, 0x44, 0x53, 0xd9, 0xa2, 0x01, 0xab, 0xbc, 0xb6, 0x1f, 0x98, 0xee, 0x9a, 0xa7, 0x2d, |
| + // 0x4f, 0x9e, 0x8e, 0xac, 0xe0, 0xc6, 0x49, 0x46, 0x29, 0xf4, 0x94, 0x8a, 0xaf, 0xe1, 0x5b, 0xc3, |
| + // 0xb3, 0x7b, 0x57, 0xd1, 0x7c, 0x9c, 0xed, 0x87, 0x40, 0x8c, 0xe2, 0xcb, 0x93, 0x14, 0xc9, 0x61, |
| + // 0x2e, 0xe5, 0xcc, 0xf6, 0x5e, 0xa8, 0x5c, 0xd6, 0x75, 0x8d, 0x62, 0x95, 0x58, 0x69, 0x76, 0xa1, |
| + // 0x4a, 0xb5, 0x55, 0x09, 0x78, 0x33, 0x82, 0xd7, 0xdd, 0x79, 0xf5, 0x1b, 0x0b, 0xde, 0x26, 0x21, |
| + // 0x28, 0x74, 0x04, 0x97, 0x56, 0xdf, 0x3c, 0xf0, 0x37, 0x39, 0xdc, 0xff, 0x06, 0xa4, 0xea, 0x42, |
| + // 0x08, 0xda, 0xb4, 0x71, 0xb0, 0xcf, 0x12, 0x7a, 0x4e, 0xfa, 0x6c, 0x1d, 0x84, 0x00, 0xc8, 0x7f, |
| + // 0x91, 0x45, 0xaa, 0x2b, 0xc2, 0xb1, 0x8f, 0xd5, 0xba, 0xf2, 0xad, 0x19, 0xb2, 0x67, 0x36, 0xf7, |
| + // 0x0f, 0x0a, 0x92, 0x7d, 0xe3, 0x9d, 0xe9, 0x90, 0x3e, 0x23, 0x27, 0x66, 0x13, 0xec, 0x81, 0x15, |
| + // 0xbd, 0x22, 0xbf, 0x9f, 0x7e, 0xa9, 0x51, 0x4b, 0x4c, 0xfb, 0x02, 0xd3, 0x70, 0x86, 0x31, 0xe7, |
| + // 0x3b, 0x05, 0x03, 0x54, 0x60, 0x48, 0x65, 0x18, 0xd2, 0xcd, 0x5f, 0x32, 0x88, 0x0e, 0x35, 0xfd |
| + // }; |
| + // |
| + // private byte[] iv; |
| + // private int parameterVersion = 58; |
| + // |
| + // protected byte[] engineGetEncoded() |
| + // { |
| + // return Arrays.clone(iv); |
| + // } |
| + // |
| + // protected byte[] engineGetEncoded( |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (isASN1FormatString(format)) |
| + // { |
| + // if (parameterVersion == -1) |
| + // { |
| + // return new RC2CBCParameter(engineGetEncoded()).getEncoded(); |
| + // } |
| + // else |
| + // { |
| + // return new RC2CBCParameter(parameterVersion, engineGetEncoded()).getEncoded(); |
| + // } |
| + // } |
| + // |
| + // if (format.equals("RAW")) |
| + // { |
| + // return engineGetEncoded(); |
| + // } |
| + // |
| + // return null; |
| + // } |
| + // |
| + // protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| + // Class paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (paramSpec == RC2ParameterSpec.class) |
| + // { |
| + // if (parameterVersion != -1) |
| + // { |
| + // if (parameterVersion < 256) |
| + // { |
| + // return new RC2ParameterSpec(ekb[parameterVersion], iv); |
| + // } |
| + // else |
| + // { |
| + // return new RC2ParameterSpec(parameterVersion, iv); |
| + // } |
| + // } |
| + // } |
| + // |
| + // if (paramSpec == IvParameterSpec.class) |
| + // { |
| + // return new IvParameterSpec(iv); |
| + // } |
| + // |
| + // throw new InvalidParameterSpecException("unknown parameter spec passed to RC2 parameters object."); |
| + // } |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (paramSpec instanceof IvParameterSpec) |
| + // { |
| + // this.iv = ((IvParameterSpec)paramSpec).getIV(); |
| + // } |
| + // else if (paramSpec instanceof RC2ParameterSpec) |
| + // { |
| + // int effKeyBits = ((RC2ParameterSpec)paramSpec).getEffectiveKeyBits(); |
| + // if (effKeyBits != -1) |
| + // { |
| + // if (effKeyBits < 256) |
| + // { |
| + // parameterVersion = table[effKeyBits]; |
| + // } |
| + // else |
| + // { |
| + // parameterVersion = effKeyBits; |
| + // } |
| + // } |
| + // |
| + // this.iv = ((RC2ParameterSpec)paramSpec).getIV(); |
| + // } |
| + // else |
| + // { |
| + // throw new InvalidParameterSpecException("IvParameterSpec or RC2ParameterSpec required to initialise a RC2 parameters algorithm parameters object"); |
| + // } |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params) |
| + // throws IOException |
| + // { |
| + // this.iv = Arrays.clone(params); |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params, |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (isASN1FormatString(format)) |
| + // { |
| + // RC2CBCParameter p = RC2CBCParameter.getInstance(ASN1Object.fromByteArray(params)); |
| + // |
| + // if (p.getRC2ParameterVersion() != null) |
| + // { |
| + // parameterVersion = p.getRC2ParameterVersion().intValue(); |
| + // } |
| + // |
| + // iv = p.getIV(); |
| + // |
| + // return; |
| + // } |
| + // |
| + // if (format.equals("RAW")) |
| + // { |
| + // engineInit(params); |
| + // return; |
| + // } |
| + // |
| + // throw new IOException("Unknown parameters format in IV parameters object"); |
| + // } |
| + // |
| + // protected String engineToString() |
| + // { |
| + // return "RC2 Parameters"; |
| + // } |
| + // } |
| + // END android-removed |
| + |
| public static class PBKDF2 |
| extends JDKAlgorithmParameters |
| { |
| @@ -429,7 +439,7 @@ |
| extends JDKAlgorithmParameters |
| { |
| PKCS12PBEParams params; |
| - |
| + |
| protected byte[] engineGetEncoded() |
| { |
| try |
| @@ -441,7 +451,7 @@ |
| throw new RuntimeException("Oooops! " + e.toString()); |
| } |
| } |
| - |
| + |
| protected byte[] engineGetEncoded( |
| String format) |
| { |
| @@ -449,10 +459,10 @@ |
| { |
| return engineGetEncoded(); |
| } |
| - |
| + |
| return null; |
| } |
| - |
| + |
| protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| Class paramSpec) |
| throws InvalidParameterSpecException |
| @@ -462,10 +472,10 @@ |
| return new PBEParameterSpec(params.getIV(), |
| params.getIterations().intValue()); |
| } |
| - |
| + |
| throw new InvalidParameterSpecException("unknown parameter spec passed to PKCS12 PBE parameters object."); |
| } |
| - |
| + |
| protected void engineInit( |
| AlgorithmParameterSpec paramSpec) |
| throws InvalidParameterSpecException |
| @@ -474,20 +484,20 @@ |
| { |
| throw new InvalidParameterSpecException("PBEParameterSpec required to initialise a PKCS12 PBE parameters algorithm parameters object"); |
| } |
| - |
| + |
| PBEParameterSpec pbeSpec = (PBEParameterSpec)paramSpec; |
| - |
| + |
| this.params = new PKCS12PBEParams(pbeSpec.getSalt(), |
| pbeSpec.getIterationCount()); |
| } |
| - |
| + |
| protected void engineInit( |
| byte[] params) |
| throws IOException |
| { |
| this.params = PKCS12PBEParams.getInstance(ASN1Object.fromByteArray(params)); |
| } |
| - |
| + |
| protected void engineInit( |
| byte[] params, |
| String format) |
| @@ -498,10 +508,10 @@ |
| engineInit(params); |
| return; |
| } |
| - |
| + |
| throw new IOException("Unknown parameters format in PKCS12 PBE parameters object"); |
| } |
| - |
| + |
| protected String engineToString() |
| { |
| return "PKCS12 PBE Parameters"; |
| @@ -725,334 +735,336 @@ |
| } |
| } |
| |
| - public static class GOST3410 |
| - extends JDKAlgorithmParameters |
| - { |
| - GOST3410ParameterSpec currentSpec; |
| - |
| - /** |
| - * Return the X.509 ASN.1 structure GOST3410Parameter. |
| - * <p> |
| - * <pre> |
| - * GOST3410Parameter ::= SEQUENCE { |
| - * prime INTEGER, -- p |
| - * subprime INTEGER, -- q |
| - * base INTEGER, -- a} |
| - * </pre> |
| - */ |
| - protected byte[] engineGetEncoded() |
| - { |
| - GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID())); |
| - |
| - try |
| - { |
| - return gost3410P.getEncoded(ASN1Encodable.DER); |
| - } |
| - catch (IOException e) |
| - { |
| - throw new RuntimeException("Error encoding GOST3410Parameters"); |
| - } |
| - } |
| - |
| - protected byte[] engineGetEncoded( |
| - String format) |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - return engineGetEncoded(); |
| - } |
| - |
| - return null; |
| - } |
| - |
| - protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| - Class paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (paramSpec == GOST3410PublicKeyParameterSetSpec.class) |
| - { |
| - return currentSpec; |
| - } |
| - |
| - throw new InvalidParameterSpecException("unknown parameter spec passed to GOST3410 parameters object."); |
| - } |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (!(paramSpec instanceof GOST3410ParameterSpec)) |
| - { |
| - throw new InvalidParameterSpecException("GOST3410ParameterSpec required to initialise a GOST3410 algorithm parameters object"); |
| - } |
| - |
| - this.currentSpec = (GOST3410ParameterSpec)paramSpec; |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params) |
| - throws IOException |
| - { |
| - try |
| - { |
| - ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params); |
| - |
| - this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg( |
| - new GOST3410PublicKeyAlgParameters(seq)); |
| - } |
| - catch (ClassCastException e) |
| - { |
| - throw new IOException("Not a valid GOST3410 Parameter encoding."); |
| - } |
| - catch (ArrayIndexOutOfBoundsException e) |
| - { |
| - throw new IOException("Not a valid GOST3410 Parameter encoding."); |
| - } |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params, |
| - String format) |
| - throws IOException |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - engineInit(params); |
| - } |
| - else |
| - { |
| - throw new IOException("Unknown parameter format " + format); |
| - } |
| - } |
| - |
| - protected String engineToString() |
| - { |
| - return "GOST3410 Parameters"; |
| - } |
| - } |
| - |
| - public static class ElGamal |
| - extends JDKAlgorithmParameters |
| - { |
| - ElGamalParameterSpec currentSpec; |
| - |
| - /** |
| - * Return the X.509 ASN.1 structure ElGamalParameter. |
| - * <p> |
| - * <pre> |
| - * ElGamalParameter ::= SEQUENCE { |
| - * prime INTEGER, -- p |
| - * base INTEGER, -- g} |
| - * </pre> |
| - */ |
| - protected byte[] engineGetEncoded() |
| - { |
| - ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG()); |
| - |
| - try |
| - { |
| - return elP.getEncoded(ASN1Encodable.DER); |
| - } |
| - catch (IOException e) |
| - { |
| - throw new RuntimeException("Error encoding ElGamalParameters"); |
| - } |
| - } |
| - |
| - protected byte[] engineGetEncoded( |
| - String format) |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - return engineGetEncoded(); |
| - } |
| - |
| - return null; |
| - } |
| - |
| - protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| - Class paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (paramSpec == ElGamalParameterSpec.class) |
| - { |
| - return currentSpec; |
| - } |
| - else if (paramSpec == DHParameterSpec.class) |
| - { |
| - return new DHParameterSpec(currentSpec.getP(), currentSpec.getG()); |
| - } |
| - |
| - throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object."); |
| - } |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec)) |
| - { |
| - throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object"); |
| - } |
| - |
| - if (paramSpec instanceof ElGamalParameterSpec) |
| - { |
| - this.currentSpec = (ElGamalParameterSpec)paramSpec; |
| - } |
| - else |
| - { |
| - DHParameterSpec s = (DHParameterSpec)paramSpec; |
| - |
| - this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG()); |
| - } |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params) |
| - throws IOException |
| - { |
| - try |
| - { |
| - ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params)); |
| - |
| - currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG()); |
| - } |
| - catch (ClassCastException e) |
| - { |
| - throw new IOException("Not a valid ElGamal Parameter encoding."); |
| - } |
| - catch (ArrayIndexOutOfBoundsException e) |
| - { |
| - throw new IOException("Not a valid ElGamal Parameter encoding."); |
| - } |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params, |
| - String format) |
| - throws IOException |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - engineInit(params); |
| - } |
| - else |
| - { |
| - throw new IOException("Unknown parameter format " + format); |
| - } |
| - } |
| - |
| - protected String engineToString() |
| - { |
| - return "ElGamal Parameters"; |
| - } |
| - } |
| - |
| - public static class IES |
| - extends JDKAlgorithmParameters |
| - { |
| - IESParameterSpec currentSpec; |
| - |
| - /** |
| - * in the absence of a standard way of doing it this will do for |
| - * now... |
| - */ |
| - protected byte[] engineGetEncoded() |
| - { |
| - try |
| - { |
| - ASN1EncodableVector v = new ASN1EncodableVector(); |
| - |
| - v.add(new DEROctetString(currentSpec.getDerivationV())); |
| - v.add(new DEROctetString(currentSpec.getEncodingV())); |
| - v.add(new DERInteger(currentSpec.getMacKeySize())); |
| - |
| - return new DERSequence(v).getEncoded(ASN1Encodable.DER); |
| - } |
| - catch (IOException e) |
| - { |
| - throw new RuntimeException("Error encoding IESParameters"); |
| - } |
| - } |
| - |
| - protected byte[] engineGetEncoded( |
| - String format) |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - return engineGetEncoded(); |
| - } |
| - |
| - return null; |
| - } |
| - |
| - protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| - Class paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (paramSpec == IESParameterSpec.class) |
| - { |
| - return currentSpec; |
| - } |
| - |
| - throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object."); |
| - } |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (!(paramSpec instanceof IESParameterSpec)) |
| - { |
| - throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object"); |
| - } |
| - |
| - this.currentSpec = (IESParameterSpec)paramSpec; |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params) |
| - throws IOException |
| - { |
| - try |
| - { |
| - ASN1Sequence s = (ASN1Sequence)ASN1Object.fromByteArray(params); |
| - |
| - this.currentSpec = new IESParameterSpec( |
| - ((ASN1OctetString)s.getObjectAt(0)).getOctets(), |
| - ((ASN1OctetString)s.getObjectAt(0)).getOctets(), |
| - ((DERInteger)s.getObjectAt(0)).getValue().intValue()); |
| - } |
| - catch (ClassCastException e) |
| - { |
| - throw new IOException("Not a valid IES Parameter encoding."); |
| - } |
| - catch (ArrayIndexOutOfBoundsException e) |
| - { |
| - throw new IOException("Not a valid IES Parameter encoding."); |
| - } |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params, |
| - String format) |
| - throws IOException |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - engineInit(params); |
| - } |
| - else |
| - { |
| - throw new IOException("Unknown parameter format " + format); |
| - } |
| - } |
| - |
| - protected String engineToString() |
| - { |
| - return "IES Parameters"; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class GOST3410 |
| + // extends JDKAlgorithmParameters |
| + // { |
| + // GOST3410ParameterSpec currentSpec; |
| + // |
| + // /** |
| + // * Return the X.509 ASN.1 structure GOST3410Parameter. |
| + // * <p> |
| + // * <pre> |
| + // * GOST3410Parameter ::= SEQUENCE { |
| + // * prime INTEGER, -- p |
| + // * subprime INTEGER, -- q |
| + // * base INTEGER, -- a} |
| + // * </pre> |
| + // */ |
| + // protected byte[] engineGetEncoded() |
| + // { |
| + // GOST3410PublicKeyAlgParameters gost3410P = new GOST3410PublicKeyAlgParameters(new DERObjectIdentifier(currentSpec.getPublicKeyParamSetOID()), new DERObjectIdentifier(currentSpec.getDigestParamSetOID()), new DERObjectIdentifier(currentSpec.getEncryptionParamSetOID())); |
| + // |
| + // try |
| + // { |
| + // return gost3410P.getEncoded(ASN1Encodable.DER); |
| + // } |
| + // catch (IOException e) |
| + // { |
| + // throw new RuntimeException("Error encoding GOST3410Parameters"); |
| + // } |
| + // } |
| + // |
| + // protected byte[] engineGetEncoded( |
| + // String format) |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // return engineGetEncoded(); |
| + // } |
| + // |
| + // return null; |
| + // } |
| + // |
| + // protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| + // Class paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (paramSpec == GOST3410PublicKeyParameterSetSpec.class) |
| + // { |
| + // return currentSpec; |
| + // } |
| + // |
| + // throw new InvalidParameterSpecException("unknown parameter spec passed to GOST3410 parameters object."); |
| + // } |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (!(paramSpec instanceof GOST3410ParameterSpec)) |
| + // { |
| + // throw new InvalidParameterSpecException("GOST3410ParameterSpec required to initialise a GOST3410 algorithm parameters object"); |
| + // } |
| + // |
| + // this.currentSpec = (GOST3410ParameterSpec)paramSpec; |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params) |
| + // throws IOException |
| + // { |
| + // try |
| + // { |
| + // ASN1Sequence seq = (ASN1Sequence) ASN1Object.fromByteArray(params); |
| + // |
| + // this.currentSpec = GOST3410ParameterSpec.fromPublicKeyAlg( |
| + // new GOST3410PublicKeyAlgParameters(seq)); |
| + // } |
| + // catch (ClassCastException e) |
| + // { |
| + // throw new IOException("Not a valid GOST3410 Parameter encoding."); |
| + // } |
| + // catch (ArrayIndexOutOfBoundsException e) |
| + // { |
| + // throw new IOException("Not a valid GOST3410 Parameter encoding."); |
| + // } |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params, |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // engineInit(params); |
| + // } |
| + // else |
| + // { |
| + // throw new IOException("Unknown parameter format " + format); |
| + // } |
| + // } |
| + // |
| + // protected String engineToString() |
| + // { |
| + // return "GOST3410 Parameters"; |
| + // } |
| + // } |
| + |
| + // public static class ElGamal |
| + // extends JDKAlgorithmParameters |
| + // { |
| + // ElGamalParameterSpec currentSpec; |
| + // |
| + // /** |
| + // * Return the X.509 ASN.1 structure ElGamalParameter. |
| + // * <p> |
| + // * <pre> |
| + // * ElGamalParameter ::= SEQUENCE { |
| + // * prime INTEGER, -- p |
| + // * base INTEGER, -- g} |
| + // * </pre> |
| + // */ |
| + // protected byte[] engineGetEncoded() |
| + // { |
| + // ElGamalParameter elP = new ElGamalParameter(currentSpec.getP(), currentSpec.getG()); |
| + // |
| + // try |
| + // { |
| + // return elP.getEncoded(ASN1Encodable.DER); |
| + // } |
| + // catch (IOException e) |
| + // { |
| + // throw new RuntimeException("Error encoding ElGamalParameters"); |
| + // } |
| + // } |
| + // |
| + // protected byte[] engineGetEncoded( |
| + // String format) |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // return engineGetEncoded(); |
| + // } |
| + // |
| + // return null; |
| + // } |
| + // |
| + // protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| + // Class paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (paramSpec == ElGamalParameterSpec.class) |
| + // { |
| + // return currentSpec; |
| + // } |
| + // else if (paramSpec == DHParameterSpec.class) |
| + // { |
| + // return new DHParameterSpec(currentSpec.getP(), currentSpec.getG()); |
| + // } |
| + // |
| + // throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object."); |
| + // } |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (!(paramSpec instanceof ElGamalParameterSpec) && !(paramSpec instanceof DHParameterSpec)) |
| + // { |
| + // throw new InvalidParameterSpecException("DHParameterSpec required to initialise a ElGamal algorithm parameters object"); |
| + // } |
| + // |
| + // if (paramSpec instanceof ElGamalParameterSpec) |
| + // { |
| + // this.currentSpec = (ElGamalParameterSpec)paramSpec; |
| + // } |
| + // else |
| + // { |
| + // DHParameterSpec s = (DHParameterSpec)paramSpec; |
| + // |
| + // this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG()); |
| + // } |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params) |
| + // throws IOException |
| + // { |
| + // try |
| + // { |
| + // ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Object.fromByteArray(params)); |
| + // |
| + // currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG()); |
| + // } |
| + // catch (ClassCastException e) |
| + // { |
| + // throw new IOException("Not a valid ElGamal Parameter encoding."); |
| + // } |
| + // catch (ArrayIndexOutOfBoundsException e) |
| + // { |
| + // throw new IOException("Not a valid ElGamal Parameter encoding."); |
| + // } |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params, |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // engineInit(params); |
| + // } |
| + // else |
| + // { |
| + // throw new IOException("Unknown parameter format " + format); |
| + // } |
| + // } |
| + // |
| + // protected String engineToString() |
| + // { |
| + // return "ElGamal Parameters"; |
| + // } |
| + // } |
| + // |
| + // public static class IES |
| + // extends JDKAlgorithmParameters |
| + // { |
| + // IESParameterSpec currentSpec; |
| + // |
| + // /** |
| + // * in the absence of a standard way of doing it this will do for |
| + // * now... |
| + // */ |
| + // protected byte[] engineGetEncoded() |
| + // { |
| + // try |
| + // { |
| + // ASN1EncodableVector v = new ASN1EncodableVector(); |
| + // |
| + // v.add(new DEROctetString(currentSpec.getDerivationV())); |
| + // v.add(new DEROctetString(currentSpec.getEncodingV())); |
| + // v.add(new DERInteger(currentSpec.getMacKeySize())); |
| + // |
| + // return new DERSequence(v).getEncoded(ASN1Encodable.DER); |
| + // } |
| + // catch (IOException e) |
| + // { |
| + // throw new RuntimeException("Error encoding IESParameters"); |
| + // } |
| + // } |
| + // |
| + // protected byte[] engineGetEncoded( |
| + // String format) |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // return engineGetEncoded(); |
| + // } |
| + // |
| + // return null; |
| + // } |
| + // |
| + // protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| + // Class paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (paramSpec == IESParameterSpec.class) |
| + // { |
| + // return currentSpec; |
| + // } |
| + // |
| + // throw new InvalidParameterSpecException("unknown parameter spec passed to ElGamal parameters object."); |
| + // } |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (!(paramSpec instanceof IESParameterSpec)) |
| + // { |
| + // throw new InvalidParameterSpecException("IESParameterSpec required to initialise a IES algorithm parameters object"); |
| + // } |
| + // |
| + // this.currentSpec = (IESParameterSpec)paramSpec; |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params) |
| + // throws IOException |
| + // { |
| + // try |
| + // { |
| + // ASN1Sequence s = (ASN1Sequence)ASN1Object.fromByteArray(params); |
| + // |
| + // this.currentSpec = new IESParameterSpec( |
| + // ((ASN1OctetString)s.getObjectAt(0)).getOctets(), |
| + // ((ASN1OctetString)s.getObjectAt(0)).getOctets(), |
| + // ((DERInteger)s.getObjectAt(0)).getValue().intValue()); |
| + // } |
| + // catch (ClassCastException e) |
| + // { |
| + // throw new IOException("Not a valid IES Parameter encoding."); |
| + // } |
| + // catch (ArrayIndexOutOfBoundsException e) |
| + // { |
| + // throw new IOException("Not a valid IES Parameter encoding."); |
| + // } |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params, |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // engineInit(params); |
| + // } |
| + // else |
| + // { |
| + // throw new IOException("Unknown parameter format " + format); |
| + // } |
| + // } |
| + // |
| + // protected String engineToString() |
| + // { |
| + // return "IES Parameters"; |
| + // } |
| + // } |
| + // END android-removed |
| |
| public static class OAEP |
| extends JDKAlgorithmParameters |
| @@ -1066,11 +1078,15 @@ |
| { |
| AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( |
| JCEDigestUtil.getOID(currentSpec.getDigestAlgorithm()), |
| - new DERNull()); |
| + // BEGIN android-changed |
| + DERNull.INSTANCE); |
| + // END android-changed |
| MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)currentSpec.getMGFParameters(); |
| AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( |
| PKCSObjectIdentifiers.id_mgf1, |
| - new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull())); |
| + // BEGIN android-changed |
| + new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); |
| + // END android-changed |
| PSource.PSpecified pSource = (PSource.PSpecified)currentSpec.getPSource(); |
| AlgorithmIdentifier pSourceAlgorithm = new AlgorithmIdentifier( |
| PKCSObjectIdentifiers.id_pSpecified, new DEROctetString(pSource.getValue())); |
| @@ -1167,110 +1183,116 @@ |
| } |
| } |
| |
| - public static class PSS |
| - extends JDKAlgorithmParameters |
| - { |
| - PSSParameterSpec currentSpec; |
| - |
| - /** |
| - * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. |
| - */ |
| - protected byte[] engineGetEncoded() |
| - throws IOException |
| - { |
| - PSSParameterSpec pssSpec = currentSpec; |
| - AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( |
| - JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()), |
| - new DERNull()); |
| - MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); |
| - AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( |
| - PKCSObjectIdentifiers.id_mgf1, |
| - new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), new DERNull())); |
| - RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField())); |
| - |
| - return pssP.getEncoded("DER"); |
| - } |
| - |
| - protected byte[] engineGetEncoded( |
| - String format) |
| - throws IOException |
| - { |
| - if (format.equalsIgnoreCase("X.509") |
| - || format.equalsIgnoreCase("ASN.1")) |
| - { |
| - return engineGetEncoded(); |
| - } |
| - |
| - return null; |
| - } |
| - |
| - protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| - Class paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (paramSpec == PSSParameterSpec.class && currentSpec != null) |
| - { |
| - return currentSpec; |
| - } |
| - |
| - throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object."); |
| - } |
| - |
| - protected void engineInit( |
| - AlgorithmParameterSpec paramSpec) |
| - throws InvalidParameterSpecException |
| - { |
| - if (!(paramSpec instanceof PSSParameterSpec)) |
| - { |
| - throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object"); |
| - } |
| - |
| - this.currentSpec = (PSSParameterSpec)paramSpec; |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params) |
| - throws IOException |
| - { |
| - try |
| - { |
| - RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params)); |
| - |
| - currentSpec = new PSSParameterSpec( |
| - pssP.getHashAlgorithm().getObjectId().getId(), |
| - pssP.getMaskGenAlgorithm().getObjectId().getId(), |
| - new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()), |
| - pssP.getSaltLength().getValue().intValue(), |
| - pssP.getTrailerField().getValue().intValue()); |
| - } |
| - catch (ClassCastException e) |
| - { |
| - throw new IOException("Not a valid PSS Parameter encoding."); |
| - } |
| - catch (ArrayIndexOutOfBoundsException e) |
| - { |
| - throw new IOException("Not a valid PSS Parameter encoding."); |
| - } |
| - } |
| - |
| - protected void engineInit( |
| - byte[] params, |
| - String format) |
| - throws IOException |
| - { |
| - if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| - { |
| - engineInit(params); |
| - } |
| - else |
| - { |
| - throw new IOException("Unknown parameter format " + format); |
| - } |
| - } |
| - |
| - protected String engineToString() |
| - { |
| - return "PSS Parameters"; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class PSS |
| + // extends JDKAlgorithmParameters |
| + // { |
| + // PSSParameterSpec currentSpec; |
| + // |
| + // /** |
| + // * Return the PKCS#1 ASN.1 structure RSASSA-PSS-params. |
| + // */ |
| + // protected byte[] engineGetEncoded() |
| + // throws IOException |
| + // { |
| + // PSSParameterSpec pssSpec = currentSpec; |
| + // AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier( |
| + // JCEDigestUtil.getOID(pssSpec.getDigestAlgorithm()), |
| + // // BEGIN android-changed |
| + // DERNull.INSTANCE); |
| + // // END android-changed |
| + // MGF1ParameterSpec mgfSpec = (MGF1ParameterSpec)pssSpec.getMGFParameters(); |
| + // AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier( |
| + // PKCSObjectIdentifiers.id_mgf1, |
| + // // BEGIN android-changed |
| + // new AlgorithmIdentifier(JCEDigestUtil.getOID(mgfSpec.getDigestAlgorithm()), DERNull.INSTANCE)); |
| + // // END android-changed |
| + // RSASSAPSSparams pssP = new RSASSAPSSparams(hashAlgorithm, maskGenAlgorithm, new DERInteger(pssSpec.getSaltLength()), new DERInteger(pssSpec.getTrailerField())); |
| + // |
| + // return pssP.getEncoded("DER"); |
| + // } |
| + // |
| + // protected byte[] engineGetEncoded( |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (format.equalsIgnoreCase("X.509") |
| + // || format.equalsIgnoreCase("ASN.1")) |
| + // { |
| + // return engineGetEncoded(); |
| + // } |
| + // |
| + // return null; |
| + // } |
| + // |
| + // protected AlgorithmParameterSpec localEngineGetParameterSpec( |
| + // Class paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (paramSpec == PSSParameterSpec.class && currentSpec != null) |
| + // { |
| + // return currentSpec; |
| + // } |
| + // |
| + // throw new InvalidParameterSpecException("unknown parameter spec passed to PSS parameters object."); |
| + // } |
| + // |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec paramSpec) |
| + // throws InvalidParameterSpecException |
| + // { |
| + // if (!(paramSpec instanceof PSSParameterSpec)) |
| + // { |
| + // throw new InvalidParameterSpecException("PSSParameterSpec required to initialise an PSS algorithm parameters object"); |
| + // } |
| + // |
| + // this.currentSpec = (PSSParameterSpec)paramSpec; |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params) |
| + // throws IOException |
| + // { |
| + // try |
| + // { |
| + // RSASSAPSSparams pssP = new RSASSAPSSparams((ASN1Sequence)ASN1Object.fromByteArray(params)); |
| + // |
| + // currentSpec = new PSSParameterSpec( |
| + // pssP.getHashAlgorithm().getObjectId().getId(), |
| + // pssP.getMaskGenAlgorithm().getObjectId().getId(), |
| + // new MGF1ParameterSpec(AlgorithmIdentifier.getInstance(pssP.getMaskGenAlgorithm().getParameters()).getObjectId().getId()), |
| + // pssP.getSaltLength().getValue().intValue(), |
| + // pssP.getTrailerField().getValue().intValue()); |
| + // } |
| + // catch (ClassCastException e) |
| + // { |
| + // throw new IOException("Not a valid PSS Parameter encoding."); |
| + // } |
| + // catch (ArrayIndexOutOfBoundsException e) |
| + // { |
| + // throw new IOException("Not a valid PSS Parameter encoding."); |
| + // } |
| + // } |
| + // |
| + // protected void engineInit( |
| + // byte[] params, |
| + // String format) |
| + // throws IOException |
| + // { |
| + // if (isASN1FormatString(format) || format.equalsIgnoreCase("X.509")) |
| + // { |
| + // engineInit(params); |
| + // } |
| + // else |
| + // { |
| + // throw new IOException("Unknown parameter format " + format); |
| + // } |
| + // } |
| + // |
| + // protected String engineToString() |
| + // { |
| + // return "PSS Parameters"; |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDSASigner.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDSASigner.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDSASigner.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDSASigner.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -22,13 +22,17 @@ |
| import org.bouncycastle.crypto.DSA; |
| import org.bouncycastle.crypto.Digest; |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| -import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA256Digest; |
| import org.bouncycastle.crypto.digests.SHA384Digest; |
| import org.bouncycastle.crypto.digests.SHA512Digest; |
| import org.bouncycastle.crypto.params.ParametersWithRandom; |
| import org.bouncycastle.crypto.signers.DSASigner; |
| -import org.bouncycastle.jce.interfaces.GOST3410Key; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.interfaces.GOST3410Key; |
| +// END android-removed |
| import org.bouncycastle.jce.provider.util.NullDigest; |
| |
| public class JDKDSASigner |
| @@ -53,11 +57,16 @@ |
| { |
| CipherParameters param; |
| |
| - if (publicKey instanceof GOST3410Key) |
| - { |
| - param = GOST3410Util.generatePublicKeyParameter(publicKey); |
| - } |
| - else if (publicKey instanceof DSAKey) |
| + // BEGIN android-removed |
| + // if (publicKey instanceof GOST3410Key) |
| + // { |
| + // param = GOST3410Util.generatePublicKeyParameter(publicKey); |
| + // } |
| + // else if (publicKey instanceof DSAKey) |
| + // END android-removed |
| + // BEGIN android-added |
| + if (publicKey instanceof DSAKey) |
| + // END android-added |
| { |
| param = DSAUtil.generatePublicKeyParameter(publicKey); |
| } |
| @@ -103,14 +112,18 @@ |
| { |
| CipherParameters param; |
| |
| - if (privateKey instanceof GOST3410Key) |
| - { |
| - param = GOST3410Util.generatePrivateKeyParameter(privateKey); |
| - } |
| - else |
| - { |
| + // BEGIN android-removed |
| + // if (privateKey instanceof GOST3410Key) |
| + // { |
| + // param = GOST3410Util.generatePrivateKeyParameter(privateKey); |
| + // } |
| + // else |
| + // { |
| + // END android-removed |
| param = DSAUtil.generatePrivateKeyParameter(privateKey); |
| - } |
| + // BEGIN android-removed |
| + // } |
| + // END android-removed |
| |
| if (random != null) |
| { |
| @@ -231,42 +244,44 @@ |
| super(new SHA1Digest(), new DSASigner()); |
| } |
| } |
| - |
| - static public class dsa224 |
| - extends JDKDSASigner |
| - { |
| - public dsa224() |
| - { |
| - super(new SHA224Digest(), new DSASigner()); |
| - } |
| - } |
| - |
| - static public class dsa256 |
| - extends JDKDSASigner |
| - { |
| - public dsa256() |
| - { |
| - super(new SHA256Digest(), new DSASigner()); |
| - } |
| - } |
| |
| - static public class dsa384 |
| - extends JDKDSASigner |
| - { |
| - public dsa384() |
| - { |
| - super(new SHA384Digest(), new DSASigner()); |
| - } |
| - } |
| - |
| - static public class dsa512 |
| - extends JDKDSASigner |
| - { |
| - public dsa512() |
| - { |
| - super(new SHA512Digest(), new DSASigner()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class dsa224 |
| + // extends JDKDSASigner |
| + // { |
| + // public dsa224() |
| + // { |
| + // super(new SHA224Digest(), new DSASigner()); |
| + // } |
| + // } |
| + // |
| + // static public class dsa256 |
| + // extends JDKDSASigner |
| + // { |
| + // public dsa256() |
| + // { |
| + // super(new SHA256Digest(), new DSASigner()); |
| + // } |
| + // } |
| + // |
| + // static public class dsa384 |
| + // extends JDKDSASigner |
| + // { |
| + // public dsa384() |
| + // { |
| + // super(new SHA384Digest(), new DSASigner()); |
| + // } |
| + // } |
| + // |
| + // static public class dsa512 |
| + // extends JDKDSASigner |
| + // { |
| + // public dsa512() |
| + // { |
| + // super(new SHA512Digest(), new DSASigner()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| static public class noneDSA |
| extends JDKDSASigner |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDigestSignature.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDigestSignature.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKDigestSignature.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKDigestSignature.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -23,14 +23,20 @@ |
| import org.bouncycastle.crypto.AsymmetricBlockCipher; |
| import org.bouncycastle.crypto.CipherParameters; |
| import org.bouncycastle.crypto.Digest; |
| -import org.bouncycastle.crypto.digests.MD2Digest; |
| -import org.bouncycastle.crypto.digests.MD4Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.MD2Digest; |
| +// import org.bouncycastle.crypto.digests.MD4Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.MD5Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD128Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD256Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.RIPEMD128Digest; |
| +// import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// import org.bouncycastle.crypto.digests.RIPEMD256Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| -import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA256Digest; |
| import org.bouncycastle.crypto.digests.SHA384Digest; |
| import org.bouncycastle.crypto.digests.SHA512Digest; |
| @@ -179,13 +185,13 @@ |
| } |
| } |
| } |
| - else if (sig.length == expected.length - 2) // NULL left out |
| + else if (expected.length == sig.length - 2) // NULL left out |
| { |
| int sigOffset = sig.length - hash.length - 2; |
| int expectedOffset = expected.length - hash.length - 2; |
| |
| - expected[1] -= 2; // adjust lengths |
| - expected[3] -= 2; |
| + sig[1] -= 2; // adjust lengths |
| + sig[3] -= 2; |
| |
| for (int i = 0; i < hash.length; i++) |
| { |
| @@ -195,7 +201,7 @@ |
| } |
| } |
| |
| - for (int i = 0; i < sigOffset; i++) |
| + for (int i = 0; i < expectedOffset; i++) |
| { |
| if (sig[i] != expected[i]) // check header less NULL |
| { |
| @@ -265,14 +271,16 @@ |
| } |
| } |
| |
| - static public class SHA224WithRSAEncryption |
| - extends JDKDigestSignature |
| - { |
| - public SHA224WithRSAEncryption() |
| - { |
| - super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class SHA224WithRSAEncryption |
| + // extends JDKDigestSignature |
| + // { |
| + // public SHA224WithRSAEncryption() |
| + // { |
| + // super(NISTObjectIdentifiers.id_sha224, new SHA224Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // END android-removed |
| |
| static public class SHA256WithRSAEncryption |
| extends JDKDigestSignature |
| @@ -301,23 +309,25 @@ |
| } |
| } |
| |
| - static public class MD2WithRSAEncryption |
| - extends JDKDigestSignature |
| - { |
| - public MD2WithRSAEncryption() |
| - { |
| - super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class MD4WithRSAEncryption |
| - extends JDKDigestSignature |
| - { |
| - public MD4WithRSAEncryption() |
| - { |
| - super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class MD2WithRSAEncryption |
| + // extends JDKDigestSignature |
| + // { |
| + // public MD2WithRSAEncryption() |
| + // { |
| + // super(PKCSObjectIdentifiers.md2, new MD2Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class MD4WithRSAEncryption |
| + // extends JDKDigestSignature |
| + // { |
| + // public MD4WithRSAEncryption() |
| + // { |
| + // super(PKCSObjectIdentifiers.md4, new MD4Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // END android-removed |
| |
| static public class MD5WithRSAEncryption |
| extends JDKDigestSignature |
| @@ -328,39 +338,41 @@ |
| } |
| } |
| |
| - static public class RIPEMD160WithRSAEncryption |
| - extends JDKDigestSignature |
| - { |
| - public RIPEMD160WithRSAEncryption() |
| - { |
| - super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class RIPEMD128WithRSAEncryption |
| - extends JDKDigestSignature |
| - { |
| - public RIPEMD128WithRSAEncryption() |
| - { |
| - super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class RIPEMD256WithRSAEncryption |
| - extends JDKDigestSignature |
| - { |
| - public RIPEMD256WithRSAEncryption() |
| - { |
| - super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| - |
| - static public class noneRSA |
| - extends JDKDigestSignature |
| - { |
| - public noneRSA() |
| - { |
| - super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine())); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class RIPEMD160WithRSAEncryption |
| + // extends JDKDigestSignature |
| + // { |
| + // public RIPEMD160WithRSAEncryption() |
| + // { |
| + // super(TeleTrusTObjectIdentifiers.ripemd160, new RIPEMD160Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class RIPEMD128WithRSAEncryption |
| + // extends JDKDigestSignature |
| + // { |
| + // public RIPEMD128WithRSAEncryption() |
| + // { |
| + // super(TeleTrusTObjectIdentifiers.ripemd128, new RIPEMD128Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class RIPEMD256WithRSAEncryption |
| + // extends JDKDigestSignature |
| + // { |
| + // public RIPEMD256WithRSAEncryption() |
| + // { |
| + // super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // |
| + // static public class noneRSA |
| + // extends JDKDigestSignature |
| + // { |
| + // public noneRSA() |
| + // { |
| + // super(new NullDigest(), new PKCS1Encoding(new RSABlindedEngine())); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyFactory.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyFactory.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyFactory.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyFactory.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -36,17 +36,21 @@ |
| import org.bouncycastle.asn1.pkcs.RSAPrivateKeyStructure; |
| import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; |
| import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; |
| -import org.bouncycastle.jce.interfaces.ElGamalPrivateKey; |
| -import org.bouncycastle.jce.interfaces.ElGamalPublicKey; |
| -import org.bouncycastle.jce.spec.ElGamalPrivateKeySpec; |
| -import org.bouncycastle.jce.spec.ElGamalPublicKeySpec; |
| -import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec; |
| -import org.bouncycastle.jce.spec.GOST3410PublicKeySpec; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.interfaces.ElGamalPrivateKey; |
| +// import org.bouncycastle.jce.interfaces.ElGamalPublicKey; |
| +// import org.bouncycastle.jce.spec.ElGamalPrivateKeySpec; |
| +// import org.bouncycastle.jce.spec.ElGamalPublicKeySpec; |
| +// import org.bouncycastle.jce.spec.GOST3410PrivateKeySpec; |
| +// import org.bouncycastle.jce.spec.GOST3410PublicKeySpec; |
| +// END android-removed |
| |
| public abstract class JDKKeyFactory |
| extends KeyFactorySpi |
| { |
| - protected boolean elGamalFactory = false; |
| + // BEGIN android-removed |
| + // protected boolean elGamalFactory = false; |
| + // END android-removed |
| |
| public JDKKeyFactory() |
| { |
| @@ -140,6 +144,20 @@ |
| |
| return new DHPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getG()); |
| } |
| + // BEGIN android-added |
| + else if (spec.isAssignableFrom(DSAPublicKeySpec.class) && key instanceof DSAPublicKey) |
| + { |
| + DSAPublicKey k = (DSAPublicKey)key; |
| + |
| + return new DSAPublicKeySpec(k.getY(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()); |
| + } |
| + else if (spec.isAssignableFrom(DSAPrivateKeySpec.class) && key instanceof DSAPrivateKey) |
| + { |
| + DSAPrivateKey k = (DSAPrivateKey)key; |
| + |
| + return new DSAPrivateKeySpec(k.getX(), k.getParams().getP(), k.getParams().getQ(), k.getParams().getG()); |
| + } |
| + // END android-added |
| |
| throw new RuntimeException("not implemented yet " + key + " " + spec); |
| } |
| @@ -162,25 +180,33 @@ |
| } |
| else if (key instanceof DHPublicKey) |
| { |
| - if (elGamalFactory) |
| - { |
| - return new JCEElGamalPublicKey((DHPublicKey)key); |
| - } |
| - else |
| - { |
| + // BEGIN android-removed |
| + // if (elGamalFactory) |
| + // { |
| + // return new JCEElGamalPublicKey((DHPublicKey)key); |
| + // } |
| + // else |
| + // { |
| + // END android-removed |
| return new JCEDHPublicKey((DHPublicKey)key); |
| - } |
| + // BEGIN android-removed |
| + // } |
| + // END android-removed |
| } |
| else if (key instanceof DHPrivateKey) |
| { |
| - if (elGamalFactory) |
| - { |
| - return new JCEElGamalPrivateKey((DHPrivateKey)key); |
| - } |
| - else |
| - { |
| + // BEGIN android-removed |
| + // if (elGamalFactory) |
| + // { |
| + // return new JCEElGamalPrivateKey((DHPrivateKey)key); |
| + // } |
| + // else |
| + // { |
| + // END android-removed |
| return new JCEDHPrivateKey((DHPrivateKey)key); |
| - } |
| + // BEGIN android-removed |
| + // } |
| + // END android-removed |
| } |
| else if (key instanceof DSAPublicKey) |
| { |
| @@ -190,14 +216,16 @@ |
| { |
| return new JDKDSAPrivateKey((DSAPrivateKey)key); |
| } |
| - else if (key instanceof ElGamalPublicKey) |
| - { |
| - return new JCEElGamalPublicKey((ElGamalPublicKey)key); |
| - } |
| - else if (key instanceof ElGamalPrivateKey) |
| - { |
| - return new JCEElGamalPrivateKey((ElGamalPrivateKey)key); |
| - } |
| + // BEGIN android-removed |
| + // else if (key instanceof ElGamalPublicKey) |
| + // { |
| + // return new JCEElGamalPublicKey((ElGamalPublicKey)key); |
| + // } |
| + // else if (key instanceof ElGamalPrivateKey) |
| + // { |
| + // return new JCEElGamalPrivateKey((ElGamalPrivateKey)key); |
| + // } |
| + // END android-removed |
| |
| throw new InvalidKeyException("key type unknown"); |
| } |
| @@ -233,10 +261,12 @@ |
| { |
| return new JCEDHPublicKey(info); |
| } |
| - else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| - { |
| - return new JCEElGamalPublicKey(info); |
| - } |
| + // BEGIN android-removed |
| + // else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| + // { |
| + // return new JCEElGamalPublicKey(info); |
| + // } |
| + // END android-removed |
| else if (algOid.equals(X9ObjectIdentifiers.id_dsa)) |
| { |
| return new JDKDSAPublicKey(info); |
| @@ -249,14 +279,15 @@ |
| { |
| return new JCEECPublicKey(info); |
| } |
| - else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94)) |
| - { |
| - return new JDKGOST3410PublicKey(info); |
| - } |
| - else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001)) |
| - { |
| - return new JCEECPublicKey(info); |
| - } |
| + // BEGIN android-removed |
| + // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94)) |
| + // { |
| + // return new JDKGOST3410PublicKey(info); |
| + // } |
| + // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001)) |
| + // { |
| + // return new JCEECPublicKey(info); |
| + // } |
| else |
| { |
| throw new RuntimeException("algorithm identifier " + algOid + " in key not recognised"); |
| @@ -290,10 +321,12 @@ |
| { |
| return new JCEDHPrivateKey(info); |
| } |
| - else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| - { |
| - return new JCEElGamalPrivateKey(info); |
| - } |
| + // BEGIN android-removed |
| + // else if (algOid.equals(OIWObjectIdentifiers.elGamalAlgorithm)) |
| + // { |
| + // return new JCEElGamalPrivateKey(info); |
| + // } |
| + // END android-removed |
| else if (algOid.equals(X9ObjectIdentifiers.id_dsa)) |
| { |
| return new JDKDSAPrivateKey(info); |
| @@ -302,14 +335,16 @@ |
| { |
| return new JCEECPrivateKey(info); |
| } |
| - else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94)) |
| - { |
| - return new JDKGOST3410PrivateKey(info); |
| - } |
| - else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001)) |
| - { |
| - return new JCEECPrivateKey(info); |
| - } |
| + // BEGIN android-removed |
| + // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_94)) |
| + // { |
| + // return new JDKGOST3410PrivateKey(info); |
| + // } |
| + // else if (algOid.equals(CryptoProObjectIdentifiers.gostR3410_2001)) |
| + // { |
| + // return new JCEECPrivateKey(info); |
| + // } |
| + // END android-removed |
| else |
| { |
| throw new RuntimeException("algorithm identifier " + algOid + " in key not recognised"); |
| @@ -440,89 +475,92 @@ |
| } |
| } |
| |
| - public static class GOST3410 |
| - extends JDKKeyFactory |
| - { |
| - public GOST3410() |
| - { |
| - } |
| - |
| - protected PrivateKey engineGeneratePrivate( |
| - KeySpec keySpec) |
| - throws InvalidKeySpecException |
| - { |
| - if (keySpec instanceof GOST3410PrivateKeySpec) |
| - { |
| - return new JDKGOST3410PrivateKey((GOST3410PrivateKeySpec)keySpec); |
| - } |
| - |
| - return super.engineGeneratePrivate(keySpec); |
| - } |
| - |
| - protected PublicKey engineGeneratePublic( |
| - KeySpec keySpec) |
| - throws InvalidKeySpecException |
| - { |
| - if (keySpec instanceof GOST3410PublicKeySpec) |
| - { |
| - return new JDKGOST3410PublicKey((GOST3410PublicKeySpec)keySpec); |
| - } |
| - |
| - return super.engineGeneratePublic(keySpec); |
| - } |
| - } |
| - |
| - public static class ElGamal |
| - extends JDKKeyFactory |
| - { |
| - public ElGamal() |
| - { |
| - elGamalFactory = true; |
| - } |
| - |
| - protected PrivateKey engineGeneratePrivate( |
| - KeySpec keySpec) |
| - throws InvalidKeySpecException |
| - { |
| - if (keySpec instanceof ElGamalPrivateKeySpec) |
| - { |
| - return new JCEElGamalPrivateKey((ElGamalPrivateKeySpec)keySpec); |
| - } |
| - else if (keySpec instanceof DHPrivateKeySpec) |
| - { |
| - return new JCEElGamalPrivateKey((DHPrivateKeySpec)keySpec); |
| - } |
| - |
| - return super.engineGeneratePrivate(keySpec); |
| - } |
| + // BEGIN android-removed |
| + // public static class GOST3410 |
| + // extends JDKKeyFactory |
| + // { |
| + // public GOST3410() |
| + // { |
| + // } |
| + // |
| + // protected PrivateKey engineGeneratePrivate( |
| + // KeySpec keySpec) |
| + // throws InvalidKeySpecException |
| + // { |
| + // if (keySpec instanceof GOST3410PrivateKeySpec) |
| + // { |
| + // return new JDKGOST3410PrivateKey((GOST3410PrivateKeySpec)keySpec); |
| + // } |
| + // |
| + // return super.engineGeneratePrivate(keySpec); |
| + // } |
| + // |
| + // protected PublicKey engineGeneratePublic( |
| + // KeySpec keySpec) |
| + // throws InvalidKeySpecException |
| + // { |
| + // if (keySpec instanceof GOST3410PublicKeySpec) |
| + // { |
| + // return new JDKGOST3410PublicKey((GOST3410PublicKeySpec)keySpec); |
| + // } |
| + // |
| + // return super.engineGeneratePublic(keySpec); |
| + // } |
| + // } |
| |
| - protected PublicKey engineGeneratePublic( |
| - KeySpec keySpec) |
| - throws InvalidKeySpecException |
| - { |
| - if (keySpec instanceof ElGamalPublicKeySpec) |
| - { |
| - return new JCEElGamalPublicKey((ElGamalPublicKeySpec)keySpec); |
| - } |
| - else if (keySpec instanceof DHPublicKeySpec) |
| - { |
| - return new JCEElGamalPublicKey((DHPublicKeySpec)keySpec); |
| - } |
| - |
| - return super.engineGeneratePublic(keySpec); |
| - } |
| - } |
| - |
| - |
| - /** |
| - * This isn't really correct, however the class path project API seems to think such |
| - * a key factory will exist. |
| - */ |
| - public static class X509 |
| - extends JDKKeyFactory |
| - { |
| - public X509() |
| - { |
| - } |
| - } |
| + // public static class ElGamal |
| + // extends JDKKeyFactory |
| + // { |
| + // public ElGamal() |
| + // { |
| + // elGamalFactory = true; |
| + // } |
| + // |
| + // protected PrivateKey engineGeneratePrivate( |
| + // KeySpec keySpec) |
| + // throws InvalidKeySpecException |
| + // { |
| + // if (keySpec instanceof ElGamalPrivateKeySpec) |
| + // { |
| + // return new JCEElGamalPrivateKey((ElGamalPrivateKeySpec)keySpec); |
| + // } |
| + // else if (keySpec instanceof DHPrivateKeySpec) |
| + // { |
| + // return new JCEElGamalPrivateKey((DHPrivateKeySpec)keySpec); |
| + // } |
| + // |
| + // return super.engineGeneratePrivate(keySpec); |
| + // } |
| + // |
| + // protected PublicKey engineGeneratePublic( |
| + // KeySpec keySpec) |
| + // throws InvalidKeySpecException |
| + // { |
| + // if (keySpec instanceof ElGamalPublicKeySpec) |
| + // { |
| + // return new JCEElGamalPublicKey((ElGamalPublicKeySpec)keySpec); |
| + // } |
| + // else if (keySpec instanceof DHPublicKeySpec) |
| + // { |
| + // return new JCEElGamalPublicKey((DHPublicKeySpec)keySpec); |
| + // } |
| + // |
| + // return super.engineGeneratePublic(keySpec); |
| + // } |
| + // } |
| + // |
| + // |
| + // |
| + // /** |
| + // * This isn't really correct, however the class path project API seems to think such |
| + // * a key factory will exist. |
| + // */ |
| + // public static class X509 |
| + // extends JDKKeyFactory |
| + // { |
| + // public X509() |
| + // { |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyPairGenerator.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -6,9 +6,11 @@ |
| import org.bouncycastle.crypto.generators.DHParametersGenerator; |
| import org.bouncycastle.crypto.generators.DSAKeyPairGenerator; |
| import org.bouncycastle.crypto.generators.DSAParametersGenerator; |
| -import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator; |
| -import org.bouncycastle.crypto.generators.ElGamalParametersGenerator; |
| -import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator; |
| +// import org.bouncycastle.crypto.generators.ElGamalParametersGenerator; |
| +// import org.bouncycastle.crypto.generators.GOST3410KeyPairGenerator; |
| +// END android-removed |
| import org.bouncycastle.crypto.generators.RSAKeyPairGenerator; |
| import org.bouncycastle.crypto.params.DHKeyGenerationParameters; |
| import org.bouncycastle.crypto.params.DHParameters; |
| @@ -18,20 +20,24 @@ |
| import org.bouncycastle.crypto.params.DSAParameters; |
| import org.bouncycastle.crypto.params.DSAPrivateKeyParameters; |
| import org.bouncycastle.crypto.params.DSAPublicKeyParameters; |
| -import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters; |
| -import org.bouncycastle.crypto.params.ElGamalParameters; |
| -import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; |
| -import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; |
| -import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters; |
| -import org.bouncycastle.crypto.params.GOST3410Parameters; |
| -import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters; |
| -import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters; |
| +// import org.bouncycastle.crypto.params.ElGamalParameters; |
| +// import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; |
| +// import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; |
| +// import org.bouncycastle.crypto.params.GOST3410KeyGenerationParameters; |
| +// import org.bouncycastle.crypto.params.GOST3410Parameters; |
| +// import org.bouncycastle.crypto.params.GOST3410PrivateKeyParameters; |
| +// import org.bouncycastle.crypto.params.GOST3410PublicKeyParameters; |
| +// END android-removed |
| import org.bouncycastle.crypto.params.RSAKeyGenerationParameters; |
| import org.bouncycastle.crypto.params.RSAKeyParameters; |
| import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters; |
| -import org.bouncycastle.jce.spec.ElGamalParameterSpec; |
| -import org.bouncycastle.jce.spec.GOST3410ParameterSpec; |
| -import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.spec.ElGamalParameterSpec; |
| +// import org.bouncycastle.jce.spec.GOST3410ParameterSpec; |
| +// import org.bouncycastle.jce.spec.GOST3410PublicKeyParameterSetSpec; |
| +// END android-removed |
| |
| import java.math.BigInteger; |
| import java.security.InvalidAlgorithmParameterException; |
| @@ -163,7 +169,9 @@ |
| { |
| if (!initialised) |
| { |
| - Integer paramStrength = new Integer(strength); |
| + // BEGIN android-changed |
| + Integer paramStrength = Integer.valueOf(strength); |
| + // END android-changed |
| |
| if (params.containsKey(paramStrength)) |
| { |
| @@ -260,139 +268,143 @@ |
| } |
| } |
| |
| - public static class ElGamal |
| - extends JDKKeyPairGenerator |
| - { |
| - ElGamalKeyGenerationParameters param; |
| - ElGamalKeyPairGenerator engine = new ElGamalKeyPairGenerator(); |
| - int strength = 1024; |
| - int certainty = 20; |
| - SecureRandom random = new SecureRandom(); |
| - boolean initialised = false; |
| - |
| - public ElGamal() |
| - { |
| - super("ElGamal"); |
| - } |
| - |
| - public void initialize( |
| - int strength, |
| - SecureRandom random) |
| - { |
| - this.strength = strength; |
| - this.random = random; |
| - } |
| - |
| - public void initialize( |
| - AlgorithmParameterSpec params, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec)) |
| - { |
| - throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec"); |
| - } |
| - |
| - if (params instanceof ElGamalParameterSpec) |
| - { |
| - ElGamalParameterSpec elParams = (ElGamalParameterSpec)params; |
| - |
| - param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG())); |
| - } |
| - else |
| - { |
| - DHParameterSpec dhParams = (DHParameterSpec)params; |
| - |
| - param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL())); |
| - } |
| - |
| - engine.init(param); |
| - initialised = true; |
| - } |
| - |
| - public KeyPair generateKeyPair() |
| - { |
| - if (!initialised) |
| - { |
| - ElGamalParametersGenerator pGen = new ElGamalParametersGenerator(); |
| - |
| - pGen.init(strength, certainty, random); |
| - param = new ElGamalKeyGenerationParameters(random, pGen.generateParameters()); |
| - engine.init(param); |
| - initialised = true; |
| - } |
| - |
| - AsymmetricCipherKeyPair pair = engine.generateKeyPair(); |
| - ElGamalPublicKeyParameters pub = (ElGamalPublicKeyParameters)pair.getPublic(); |
| - ElGamalPrivateKeyParameters priv = (ElGamalPrivateKeyParameters)pair.getPrivate(); |
| - |
| - return new KeyPair(new JCEElGamalPublicKey(pub), |
| - new JCEElGamalPrivateKey(priv)); |
| - } |
| - } |
| - |
| - public static class GOST3410 |
| - extends JDKKeyPairGenerator |
| - { |
| - GOST3410KeyGenerationParameters param; |
| - GOST3410KeyPairGenerator engine = new GOST3410KeyPairGenerator(); |
| - GOST3410ParameterSpec gost3410Params; |
| - int strength = 1024; |
| - SecureRandom random = null; |
| - boolean initialised = false; |
| - |
| - public GOST3410() |
| - { |
| - super("GOST3410"); |
| - } |
| - |
| - public void initialize( |
| - int strength, |
| - SecureRandom random) |
| - { |
| - this.strength = strength; |
| - this.random = random; |
| - } |
| - |
| - private void init( |
| - GOST3410ParameterSpec gParams, |
| - SecureRandom random) |
| - { |
| - GOST3410PublicKeyParameterSetSpec spec = gParams.getPublicKeyParameters(); |
| - |
| - param = new GOST3410KeyGenerationParameters(random, new GOST3410Parameters(spec.getP(), spec.getQ(), spec.getA())); |
| - |
| - engine.init(param); |
| - |
| - initialised = true; |
| - gost3410Params = gParams; |
| - } |
| - |
| - public void initialize( |
| - AlgorithmParameterSpec params, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - if (!(params instanceof GOST3410ParameterSpec)) |
| - { |
| - throw new InvalidAlgorithmParameterException("parameter object not a GOST3410ParameterSpec"); |
| - } |
| - |
| - init((GOST3410ParameterSpec)params, random); |
| - } |
| - |
| - public KeyPair generateKeyPair() |
| - { |
| - if (!initialised) |
| - { |
| - init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom()); |
| - } |
| - |
| - AsymmetricCipherKeyPair pair = engine.generateKeyPair(); |
| - GOST3410PublicKeyParameters pub = (GOST3410PublicKeyParameters)pair.getPublic(); |
| - GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate(); |
| - |
| - return new KeyPair(new JDKGOST3410PublicKey(pub, gost3410Params), new JDKGOST3410PrivateKey(priv, gost3410Params)); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class ElGamal |
| + // extends JDKKeyPairGenerator |
| + // { |
| + // ElGamalKeyGenerationParameters param; |
| + // ElGamalKeyPairGenerator engine = new ElGamalKeyPairGenerator(); |
| + // int strength = 1024; |
| + // int certainty = 20; |
| + // SecureRandom random = new SecureRandom(); |
| + // boolean initialised = false; |
| + // |
| + // public ElGamal() |
| + // { |
| + // super("ElGamal"); |
| + // } |
| + // |
| + // public void initialize( |
| + // int strength, |
| + // SecureRandom random) |
| + // { |
| + // this.strength = strength; |
| + // this.random = random; |
| + // } |
| + // |
| + // public void initialize( |
| + // AlgorithmParameterSpec params, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // if (!(params instanceof ElGamalParameterSpec) && !(params instanceof DHParameterSpec)) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec or an ElGamalParameterSpec"); |
| + // } |
| + // |
| + // if (params instanceof ElGamalParameterSpec) |
| + // { |
| + // ElGamalParameterSpec elParams = (ElGamalParameterSpec)params; |
| + |
| + // param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(elParams.getP(), elParams.getG())); |
| + // } |
| + // else |
| + // { |
| + // DHParameterSpec dhParams = (DHParameterSpec)params; |
| + // |
| + // param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL())); |
| + // } |
| + // |
| + // engine.init(param); |
| + // initialised = true; |
| + // } |
| + // |
| + // public KeyPair generateKeyPair() |
| + // { |
| + // if (!initialised) |
| + // { |
| + // ElGamalParametersGenerator pGen = new ElGamalParametersGenerator(); |
| + // |
| + // pGen.init(strength, certainty, random); |
| + // param = new ElGamalKeyGenerationParameters(random, pGen.generateParameters()); |
| + // engine.init(param); |
| + // initialised = true; |
| + // } |
| + // |
| + // AsymmetricCipherKeyPair pair = engine.generateKeyPair(); |
| + // ElGamalPublicKeyParameters pub = (ElGamalPublicKeyParameters)pair.getPublic(); |
| + // ElGamalPrivateKeyParameters priv = (ElGamalPrivateKeyParameters)pair.getPrivate(); |
| + // |
| + // return new KeyPair(new JCEElGamalPublicKey(pub), |
| + // new JCEElGamalPrivateKey(priv)); |
| + // } |
| + // } |
| + // END android-removed |
| + |
| + // BEGIN android-removed |
| + // public static class GOST3410 |
| + // extends JDKKeyPairGenerator |
| + // { |
| + // GOST3410KeyGenerationParameters param; |
| + // GOST3410KeyPairGenerator engine = new GOST3410KeyPairGenerator(); |
| + // GOST3410ParameterSpec gost3410Params; |
| + // int strength = 1024; |
| + // SecureRandom random = null; |
| + // boolean initialised = false; |
| + // |
| + // public GOST3410() |
| + // { |
| + // super("GOST3410"); |
| + // } |
| + // |
| + // public void initialize( |
| + // int strength, |
| + // SecureRandom random) |
| + // { |
| + // this.strength = strength; |
| + // this.random = random; |
| + // } |
| + // |
| + // private void init( |
| + // GOST3410ParameterSpec gParams, |
| + // SecureRandom random) |
| + // { |
| + // GOST3410PublicKeyParameterSetSpec spec = gParams.getPublicKeyParameters(); |
| + // |
| + // param = new GOST3410KeyGenerationParameters(random, new GOST3410Parameters(spec.getP(), spec.getQ(), spec.getA())); |
| + // |
| + // engine.init(param); |
| + // |
| + // initialised = true; |
| + // gost3410Params = gParams; |
| + // } |
| + // |
| + // public void initialize( |
| + // AlgorithmParameterSpec params, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // if (!(params instanceof GOST3410ParameterSpec)) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("parameter object not a GOST3410ParameterSpec"); |
| + // } |
| + // |
| + // init((GOST3410ParameterSpec)params, random); |
| + // } |
| + // |
| + // public KeyPair generateKeyPair() |
| + // { |
| + // if (!initialised) |
| + // { |
| + // init(new GOST3410ParameterSpec(CryptoProObjectIdentifiers.gostR3410_94_CryptoPro_A.getId()), new SecureRandom()); |
| + // } |
| + // |
| + // AsymmetricCipherKeyPair pair = engine.generateKeyPair(); |
| + // GOST3410PublicKeyParameters pub = (GOST3410PublicKeyParameters)pair.getPublic(); |
| + // GOST3410PrivateKeyParameters priv = (GOST3410PrivateKeyParameters)pair.getPrivate(); |
| + // |
| + // return new KeyPair(new JDKGOST3410PublicKey(pub, gost3410Params), new JDKGOST3410PrivateKey(priv, gost3410Params)); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyStore.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyStore.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKKeyStore.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKKeyStore.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -39,7 +39,12 @@ |
| import org.bouncycastle.crypto.CipherParameters; |
| import org.bouncycastle.crypto.Digest; |
| import org.bouncycastle.crypto.PBEParametersGenerator; |
| -import org.bouncycastle.crypto.digests.SHA1Digest; |
| +// BEGIN android-added |
| +import org.bouncycastle.crypto.digests.OpenSSLDigest; |
| +// END android-added |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.SHA1Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator; |
| import org.bouncycastle.crypto.io.DigestInputStream; |
| import org.bouncycastle.crypto.io.DigestOutputStream; |
| @@ -442,6 +447,7 @@ |
| } |
| catch (Exception e) |
| { |
| + |
| throw new IOException("Exception creating key: " + e.toString()); |
| } |
| } |
| @@ -497,7 +503,13 @@ |
| |
| if (entry == null) |
| { |
| - throw new KeyStoreException("no such entry as " + alias); |
| + // BEGIN android-removed |
| + // Only throw if there is a problem removing, not if missing |
| + // throw new KeyStoreException("no such entry as " + alias); |
| + // END android-removed |
| + // BEGIN android-added |
| + return; |
| + // END android-added |
| } |
| |
| table.remove(alias); |
| @@ -810,12 +822,16 @@ |
| // |
| // we only do an integrity check if the password is provided. |
| // |
| - HMac hMac = new HMac(new SHA1Digest()); |
| + // BEGIN android-changed |
| + HMac hMac = new HMac(new OpenSSLDigest.SHA1()); |
| + // END android-changed |
| if (password != null && password.length != 0) |
| { |
| byte[] passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password); |
| |
| - PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new SHA1Digest()); |
| + // BEGIN android-changed |
| + PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new OpenSSLDigest.SHA1()); |
| + // END android-changed |
| pbeGen.init(passKey, salt, iterationCount); |
| CipherParameters macParams = pbeGen.generateDerivedMacParameters(hMac.getMacSize()); |
| Arrays.fill(passKey, (byte)0); |
| @@ -866,9 +882,11 @@ |
| dOut.write(salt); |
| dOut.writeInt(iterationCount); |
| |
| - HMac hMac = new HMac(new SHA1Digest()); |
| + // BEGIN android-changed |
| + HMac hMac = new HMac(new OpenSSLDigest.SHA1()); |
| MacOutputStream mOut = new MacOutputStream(dOut, hMac); |
| - PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new SHA1Digest()); |
| + PBEParametersGenerator pbeGen = new PKCS12ParametersGenerator(new OpenSSLDigest.SHA1()); |
| + // END android-changed |
| byte[] passKey = PBEParametersGenerator.PKCS12PasswordToBytes(password); |
| |
| pbeGen.init(passKey, salt, iterationCount); |
| @@ -956,7 +974,9 @@ |
| Cipher cipher = this.makePBECipher(cipherAlg, Cipher.DECRYPT_MODE, password, salt, iterationCount); |
| CipherInputStream cIn = new CipherInputStream(dIn, cipher); |
| |
| - Digest dig = new SHA1Digest(); |
| + // BEGIN android-changed |
| + Digest dig = new OpenSSLDigest.SHA1(); |
| + // END android-changed |
| DigestInputStream dgIn = new DigestInputStream(cIn, dig); |
| |
| this.loadStore(dgIn); |
| @@ -996,8 +1016,9 @@ |
| cipher = this.makePBECipher(STORE_CIPHER, Cipher.ENCRYPT_MODE, password, salt, iterationCount); |
| |
| CipherOutputStream cOut = new CipherOutputStream(dOut, cipher); |
| - DigestOutputStream dgOut = new DigestOutputStream(cOut, new SHA1Digest()); |
| - |
| + // BEGIN android-changed |
| + DigestOutputStream dgOut = new DigestOutputStream(cOut, new OpenSSLDigest.SHA1()); |
| + // END android-changed |
| this.saveStore(dgOut); |
| |
| Digest dig = dgOut.getDigest(); |
| @@ -1009,5 +1030,5 @@ |
| |
| cOut.close(); |
| } |
| - } |
| + } |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKMessageDigest.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKMessageDigest.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKMessageDigest.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKMessageDigest.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -57,36 +57,38 @@ |
| { |
| super(new SHA1Digest()); |
| } |
| - |
| + |
| public Object clone() |
| throws CloneNotSupportedException |
| { |
| SHA1 d = (SHA1)super.clone(); |
| d.digest = new SHA1Digest((SHA1Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class SHA224 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public SHA224() |
| - { |
| - super(new SHA224Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - SHA224 d = (SHA224)super.clone(); |
| - d.digest = new SHA224Digest((SHA224Digest)digest); |
| - |
| + |
| return d; |
| } |
| } |
| - |
| + |
| + // BEGIN android-removed |
| + // static public class SHA224 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public SHA224() |
| + // { |
| + // super(new SHA224Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // SHA224 d = (SHA224)super.clone(); |
| + // d.digest = new SHA224Digest((SHA224Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // END android-removed |
| + |
| static public class SHA256 |
| extends JDKMessageDigest |
| implements Cloneable |
| @@ -95,13 +97,13 @@ |
| { |
| super(new SHA256Digest()); |
| } |
| - |
| + |
| public Object clone() |
| throws CloneNotSupportedException |
| { |
| SHA256 d = (SHA256)super.clone(); |
| d.digest = new SHA256Digest((SHA256Digest)digest); |
| - |
| + |
| return d; |
| } |
| } |
| @@ -144,43 +146,45 @@ |
| } |
| } |
| |
| - static public class MD2 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public MD2() |
| - { |
| - super(new MD2Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - MD2 d = (MD2)super.clone(); |
| - d.digest = new MD2Digest((MD2Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class MD4 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public MD4() |
| - { |
| - super(new MD4Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - MD4 d = (MD4)super.clone(); |
| - d.digest = new MD4Digest((MD4Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class MD2 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public MD2() |
| + // { |
| + // super(new MD2Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // MD2 d = (MD2)super.clone(); |
| + // d.digest = new MD2Digest((MD2Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class MD4 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public MD4() |
| + // { |
| + // super(new MD4Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // MD4 d = (MD4)super.clone(); |
| + // d.digest = new MD4Digest((MD4Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // END android-removed |
| |
| static public class MD5 |
| extends JDKMessageDigest |
| @@ -190,147 +194,149 @@ |
| { |
| super(new MD5Digest()); |
| } |
| - |
| + |
| public Object clone() |
| throws CloneNotSupportedException |
| { |
| MD5 d = (MD5)super.clone(); |
| d.digest = new MD5Digest((MD5Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class RIPEMD128 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public RIPEMD128() |
| - { |
| - super(new RIPEMD128Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - RIPEMD128 d = (RIPEMD128)super.clone(); |
| - d.digest = new RIPEMD128Digest((RIPEMD128Digest)digest); |
| - |
| + |
| return d; |
| } |
| } |
| |
| - static public class RIPEMD160 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public RIPEMD160() |
| - { |
| - super(new RIPEMD160Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - RIPEMD160 d = (RIPEMD160)super.clone(); |
| - d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class RIPEMD256 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public RIPEMD256() |
| - { |
| - super(new RIPEMD256Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - RIPEMD256 d = (RIPEMD256)super.clone(); |
| - d.digest = new RIPEMD256Digest((RIPEMD256Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class RIPEMD320 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public RIPEMD320() |
| - { |
| - super(new RIPEMD320Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - RIPEMD320 d = (RIPEMD320)super.clone(); |
| - d.digest = new RIPEMD320Digest((RIPEMD320Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class Tiger |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public Tiger() |
| - { |
| - super(new TigerDigest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - Tiger d = (Tiger)super.clone(); |
| - d.digest = new TigerDigest((TigerDigest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class GOST3411 |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public GOST3411() |
| - { |
| - super(new GOST3411Digest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - GOST3411 d = (GOST3411)super.clone(); |
| - d.digest = new GOST3411Digest((GOST3411Digest)digest); |
| - |
| - return d; |
| - } |
| - } |
| - |
| - static public class Whirlpool |
| - extends JDKMessageDigest |
| - implements Cloneable |
| - { |
| - public Whirlpool() |
| - { |
| - super(new WhirlpoolDigest()); |
| - } |
| - |
| - public Object clone() |
| - throws CloneNotSupportedException |
| - { |
| - Whirlpool d = (Whirlpool)super.clone(); |
| - d.digest = new WhirlpoolDigest((WhirlpoolDigest)digest); |
| - |
| - return d; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class RIPEMD128 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public RIPEMD128() |
| + // { |
| + // super(new RIPEMD128Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // RIPEMD128 d = (RIPEMD128)super.clone(); |
| + // d.digest = new RIPEMD128Digest((RIPEMD128Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class RIPEMD160 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public RIPEMD160() |
| + // { |
| + // super(new RIPEMD160Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // RIPEMD160 d = (RIPEMD160)super.clone(); |
| + // d.digest = new RIPEMD160Digest((RIPEMD160Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class RIPEMD256 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public RIPEMD256() |
| + // { |
| + // super(new RIPEMD256Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // RIPEMD256 d = (RIPEMD256)super.clone(); |
| + // d.digest = new RIPEMD256Digest((RIPEMD256Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class RIPEMD320 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public RIPEMD320() |
| + // { |
| + // super(new RIPEMD320Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // RIPEMD320 d = (RIPEMD320)super.clone(); |
| + // d.digest = new RIPEMD320Digest((RIPEMD320Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class Tiger |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public Tiger() |
| + // { |
| + // super(new TigerDigest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // Tiger d = (Tiger)super.clone(); |
| + // d.digest = new TigerDigest((TigerDigest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class GOST3411 |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public GOST3411() |
| + // { |
| + // super(new GOST3411Digest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // GOST3411 d = (GOST3411)super.clone(); |
| + // d.digest = new GOST3411Digest((GOST3411Digest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // |
| + // static public class Whirlpool |
| + // extends JDKMessageDigest |
| + // implements Cloneable |
| + // { |
| + // public Whirlpool() |
| + // { |
| + // super(new WhirlpoolDigest()); |
| + // } |
| + // |
| + // public Object clone() |
| + // throws CloneNotSupportedException |
| + // { |
| + // Whirlpool d = (Whirlpool)super.clone(); |
| + // d.digest = new WhirlpoolDigest((WhirlpoolDigest)digest); |
| + // |
| + // return d; |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/JDKPKCS12KeyStore.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -255,10 +255,13 @@ |
| } |
| } |
| |
| - if (c == null && k == null) |
| - { |
| - throw new KeyStoreException("no such entry as " + alias); |
| - } |
| + // BEGIN android-removed |
| + // Only throw if there is a problem removing, not if missing |
| + // if (c == null && k == null) |
| + // { |
| + // throw new KeyStoreException("no such entry as " + alias); |
| + // } |
| + // END android-removed |
| } |
| |
| /** |
| @@ -433,6 +436,14 @@ |
| |
| public Date engineGetCreationDate(String alias) |
| { |
| + // BEGIN android-added |
| + if (alias == null) { |
| + throw new NullPointerException("alias == null"); |
| + } |
| + if (keys.get(alias) == null && certs.get(alias) == null) { |
| + return null; |
| + } |
| + // END android-added |
| return new Date(); |
| } |
| |
| @@ -491,6 +502,11 @@ |
| Certificate[] chain) |
| throws KeyStoreException |
| { |
| + // BEGIN android-added |
| + if (!(key instanceof PrivateKey)) { |
| + throw new KeyStoreException("PKCS12 does not support non-PrivateKeys"); |
| + } |
| + // END android-added |
| if ((key instanceof PrivateKey) && (chain == null)) |
| { |
| throw new KeyStoreException("no certificate chain for private key"); |
| @@ -502,12 +518,18 @@ |
| } |
| |
| keys.put(alias, key); |
| + // BEGIN android-added |
| + if (chain != null) { |
| + // END android-added |
| certs.put(alias, chain[0]); |
| |
| for (int i = 0; i != chain.length; i++) |
| { |
| chainCerts.put(new CertId(chain[i].getPublicKey()), chain[i]); |
| } |
| + // BEGIN android-added |
| + } |
| + // END android-added |
| } |
| |
| public int engineSize() |
| @@ -1434,7 +1456,9 @@ |
| { |
| byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data); |
| |
| - AlgorithmIdentifier algId = new AlgorithmIdentifier(id_SHA1, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier algId = new AlgorithmIdentifier(id_SHA1, DERNull.INSTANCE); |
| + // END android-changed |
| DigestInfo dInfo = new DigestInfo(algId, res); |
| |
| mData = new MacData(dInfo, mSalt, itCount); |
| @@ -1484,32 +1508,34 @@ |
| } |
| } |
| |
| - public static class BCPKCS12KeyStore3DES |
| - extends JDKPKCS12KeyStore |
| - { |
| - public BCPKCS12KeyStore3DES() |
| - { |
| - super(bcProvider, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC); |
| - } |
| - } |
| - |
| - public static class DefPKCS12KeyStore |
| - extends JDKPKCS12KeyStore |
| - { |
| - public DefPKCS12KeyStore() |
| - { |
| - super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC); |
| - } |
| - } |
| - |
| - public static class DefPKCS12KeyStore3DES |
| - extends JDKPKCS12KeyStore |
| - { |
| - public DefPKCS12KeyStore3DES() |
| - { |
| - super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class BCPKCS12KeyStore3DES |
| + // extends JDKPKCS12KeyStore |
| + // { |
| + // public BCPKCS12KeyStore3DES() |
| + // { |
| + // super(bcProvider, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC); |
| + // } |
| + // } |
| + // |
| + // public static class DefPKCS12KeyStore |
| + // extends JDKPKCS12KeyStore |
| + // { |
| + // public DefPKCS12KeyStore() |
| + // { |
| + // super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbewithSHAAnd40BitRC2_CBC); |
| + // } |
| + // } |
| + // |
| + // public static class DefPKCS12KeyStore3DES |
| + // extends JDKPKCS12KeyStore |
| + // { |
| + // public DefPKCS12KeyStore3DES() |
| + // { |
| + // super(null, pbeWithSHAAnd3_KeyTripleDES_CBC, pbeWithSHAAnd3_KeyTripleDES_CBC); |
| + // } |
| + // } |
| + // END android-removed |
| |
| private static class IgnoresCaseHashtable |
| { |
| @@ -1518,7 +1544,7 @@ |
| |
| public void put(String key, Object value) |
| { |
| - String lower = Strings.toLowerCase(key); |
| + String lower = (key == null) ? null : Strings.toLowerCase(key); |
| String k = (String)keys.get(lower); |
| if (k != null) |
| { |
| @@ -1536,7 +1562,9 @@ |
| |
| public Object remove(String alias) |
| { |
| - String k = (String)keys.remove(Strings.toLowerCase(alias)); |
| + // BEGIN android-changed |
| + String k = (String)keys.remove(alias == null ? null : Strings.toLowerCase(alias)); |
| + // END android-changed |
| if (k == null) |
| { |
| return null; |
| @@ -1547,7 +1575,9 @@ |
| |
| public Object get(String alias) |
| { |
| - String k = (String)keys.get(Strings.toLowerCase(alias)); |
| + // BEGIN android-changed |
| + String k = (String)keys.get(alias == null ? null : Strings.toLowerCase(alias)); |
| + // END android-changed |
| if (k == null) |
| { |
| return null; |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PBE.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PBE.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PBE.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PBE.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -7,12 +7,18 @@ |
| |
| import org.bouncycastle.crypto.CipherParameters; |
| import org.bouncycastle.crypto.PBEParametersGenerator; |
| -import org.bouncycastle.crypto.digests.MD2Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.MD2Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.MD5Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| import org.bouncycastle.crypto.digests.SHA256Digest; |
| -import org.bouncycastle.crypto.digests.TigerDigest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.TigerDigest; |
| +// END android-removed |
| import org.bouncycastle.crypto.generators.OpenSSLPBEParametersGenerator; |
| import org.bouncycastle.crypto.generators.PKCS12ParametersGenerator; |
| import org.bouncycastle.crypto.generators.PKCS5S1ParametersGenerator; |
| @@ -53,9 +59,11 @@ |
| { |
| switch (hash) |
| { |
| - case MD2: |
| - generator = new PKCS5S1ParametersGenerator(new MD2Digest()); |
| - break; |
| + // BEGIN android-removed |
| + // case MD2: |
| + // generator = new PKCS5S1ParametersGenerator(new MD2Digest()); |
| + // break; |
| + // END android-removed |
| case MD5: |
| generator = new PKCS5S1ParametersGenerator(new MD5Digest()); |
| break; |
| @@ -74,21 +82,25 @@ |
| { |
| switch (hash) |
| { |
| - case MD2: |
| - generator = new PKCS12ParametersGenerator(new MD2Digest()); |
| - break; |
| + // BEGIN android-removed |
| + // case MD2: |
| + // generator = new PKCS12ParametersGenerator(new MD2Digest()); |
| + // break; |
| + // END android-removed |
| case MD5: |
| generator = new PKCS12ParametersGenerator(new MD5Digest()); |
| break; |
| case SHA1: |
| generator = new PKCS12ParametersGenerator(new SHA1Digest()); |
| break; |
| - case RIPEMD160: |
| - generator = new PKCS12ParametersGenerator(new RIPEMD160Digest()); |
| - break; |
| - case TIGER: |
| - generator = new PKCS12ParametersGenerator(new TigerDigest()); |
| - break; |
| + // BEGIN android-removed |
| + // case RIPEMD160: |
| + // generator = new PKCS12ParametersGenerator(new RIPEMD160Digest()); |
| + // break; |
| + // case TIGER: |
| + // generator = new PKCS12ParametersGenerator(new TigerDigest()); |
| + // break; |
| + // END android-removed |
| case SHA256: |
| generator = new PKCS12ParametersGenerator(new SHA256Digest()); |
| break; |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKCS12BagAttributeCarrierImpl.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -1,6 +1,9 @@ |
| package org.bouncycastle.jce.provider; |
| |
| import org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier; |
| +// BEGIN android-added |
| +import org.bouncycastle.asn1.OrderedTable; |
| +// END android-added |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.DEREncodable; |
| import org.bouncycastle.asn1.ASN1OutputStream; |
| @@ -17,65 +20,73 @@ |
| class PKCS12BagAttributeCarrierImpl |
| implements PKCS12BagAttributeCarrier |
| { |
| - private Hashtable pkcs12Attributes; |
| - private Vector pkcs12Ordering; |
| - |
| - PKCS12BagAttributeCarrierImpl(Hashtable attributes, Vector ordering) |
| - { |
| - this.pkcs12Attributes = attributes; |
| - this.pkcs12Ordering = ordering; |
| - } |
| + // BEGIN android-changed |
| + private OrderedTable pkcs12 = new OrderedTable(); |
| + // END android-changed |
| + |
| + // BEGIN android-removed |
| + // PKCS12BagAttributeCarrierImpl(Hashtable attributes, Vector ordering) |
| + // { |
| + // this.pkcs12Attributes = attributes; |
| + // this.pkcs12Ordering = ordering; |
| + // } |
| + // END android-removed |
| |
| public PKCS12BagAttributeCarrierImpl() |
| { |
| - this(new Hashtable(), new Vector()); |
| + // BEGIN android-removed |
| + // this(new Hashtable(), new Vector()); |
| + // END android-removed |
| } |
| |
| public void setBagAttribute( |
| DERObjectIdentifier oid, |
| DEREncodable attribute) |
| { |
| - if (pkcs12Attributes.containsKey(oid)) |
| - { // preserve original ordering |
| - pkcs12Attributes.put(oid, attribute); |
| - } |
| - else |
| - { |
| - pkcs12Attributes.put(oid, attribute); |
| - pkcs12Ordering.addElement(oid); |
| - } |
| + // BEGIN android-changed |
| + // preserve original ordering |
| + pkcs12.put(oid, attribute); |
| + // END android-changed |
| } |
| |
| public DEREncodable getBagAttribute( |
| DERObjectIdentifier oid) |
| { |
| - return (DEREncodable)pkcs12Attributes.get(oid); |
| + // BEGIN android-changed |
| + return (DEREncodable)pkcs12.get(oid); |
| + // END android-changed |
| } |
| |
| public Enumeration getBagAttributeKeys() |
| { |
| - return pkcs12Ordering.elements(); |
| + // BEGIN android-changed |
| + return pkcs12.getKeys(); |
| + // END android-changed |
| } |
| |
| int size() |
| { |
| - return pkcs12Ordering.size(); |
| - } |
| - |
| - Hashtable getAttributes() |
| - { |
| - return pkcs12Attributes; |
| - } |
| - |
| - Vector getOrdering() |
| - { |
| - return pkcs12Ordering; |
| - } |
| + // BEGIN android-changed |
| + return pkcs12.size(); |
| + // END android-changed |
| + } |
| + |
| + // BEGIN android-removed |
| + // Hashtable getAttributes() |
| + // { |
| + // return pkcs12Attributes; |
| + // } |
| + // |
| + // Vector getOrdering() |
| + // { |
| + // return pkcs12Ordering; |
| + // } |
| + // END android-removed |
| |
| public void writeObject(ObjectOutputStream out) |
| throws IOException |
| { |
| - if (pkcs12Ordering.size() == 0) |
| + if (pkcs12.size() == 0) |
| { |
| out.writeObject(new Hashtable()); |
| out.writeObject(new Vector()); |
| @@ -92,7 +103,7 @@ |
| DERObjectIdentifier oid = (DERObjectIdentifier)e.nextElement(); |
| |
| aOut.writeObject(oid); |
| - aOut.writeObject(pkcs12Attributes.get(oid)); |
| + aOut.writeObject(pkcs12.get(oid)); |
| } |
| |
| out.writeObject(bOut.toByteArray()); |
| @@ -106,8 +117,11 @@ |
| |
| if (obj instanceof Hashtable) |
| { |
| - this.pkcs12Attributes = (Hashtable)obj; |
| - this.pkcs12Ordering = (Vector)in.readObject(); |
| + // BEGIN android-changed |
| + // we only write out Hashtable/Vector in empty case |
| + in.readObject(); // consume empty Vector |
| + this.pkcs12 = new OrderedTable(); |
| + // END android-changed |
| } |
| else |
| { |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPath.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPath.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPath.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPath.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -33,7 +33,9 @@ |
| import org.bouncycastle.asn1.pkcs.ContentInfo; |
| import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; |
| import org.bouncycastle.asn1.pkcs.SignedData; |
| -import org.bouncycastle.openssl.PEMWriter; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.openssl.PEMWriter; |
| +// END android-removed |
| |
| /** |
| * CertPath implementation for X.509 certificates. |
| @@ -295,27 +297,29 @@ |
| return toDEREncoded(new ContentInfo( |
| PKCSObjectIdentifiers.signedData, sd)); |
| } |
| - else if (encoding.equalsIgnoreCase("PEM")) |
| - { |
| - ByteArrayOutputStream bOut = new ByteArrayOutputStream(); |
| - PEMWriter pWrt = new PEMWriter(new OutputStreamWriter(bOut)); |
| - |
| - try |
| - { |
| - for (int i = 0; i != certificates.size(); i++) |
| - { |
| - pWrt.writeObject(certificates.get(i)); |
| - } |
| - |
| - pWrt.close(); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new CertificateEncodingException("can't encode certificate for PEM encoded path"); |
| - } |
| - |
| - return bOut.toByteArray(); |
| - } |
| + // BEGIN android-removed |
| + // else if (encoding.equalsIgnoreCase("PEM")) |
| + // { |
| + // ByteArrayOutputStream bOut = new ByteArrayOutputStream(); |
| + // PEMWriter pWrt = new PEMWriter(new OutputStreamWriter(bOut)); |
| + // |
| + // try |
| + // { |
| + // for (int i = 0; i != certificates.size(); i++) |
| + // { |
| + // pWrt.writeObject(certificates.get(i)); |
| + // } |
| + // |
| + // pWrt.close(); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new CertificateEncodingException("can't encode certificate for PEM encoded path"); |
| + // } |
| + // |
| + // return bOut.toByteArray(); |
| + // } |
| + // END android-removed |
| else |
| { |
| throw new CertificateEncodingException("unsupported encoding: " + encoding); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathBuilderSpi.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -172,8 +172,9 @@ |
| try |
| { |
| // check whether the issuer of <tbvCert> is a TrustAnchor |
| - if (CertPathValidatorUtilities.findTrustAnchor(tbvCert, pkixParams.getTrustAnchors(), |
| - pkixParams.getSigProvider()) != null) |
| + // BEGIN android-changed |
| + if (CertPathValidatorUtilities.findTrustAnchor(tbvCert, pkixParams) != null) |
| + // END android-changed |
| { |
| // exception message from possibly later tried certification |
| // chains |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXCertPathValidatorSpi.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -1,5 +1,8 @@ |
| package org.bouncycastle.jce.provider; |
| |
| +// BEGIN android-added |
| +import java.math.BigInteger; |
| +// END android-added |
| import java.security.InvalidAlgorithmParameterException; |
| import java.security.PublicKey; |
| import java.security.cert.CertPath; |
| @@ -13,6 +16,7 @@ |
| import java.security.cert.TrustAnchor; |
| import java.security.cert.X509Certificate; |
| import java.util.ArrayList; |
| +import java.util.Arrays; |
| import java.util.HashSet; |
| import java.util.Iterator; |
| import java.util.List; |
| @@ -20,9 +24,17 @@ |
| |
| import javax.security.auth.x500.X500Principal; |
| |
| +// BEGIN android-added |
| +import org.apache.harmony.xnet.provider.jsse.IndexedPKIXParameters; |
| + |
| +// END android-added |
| import org.bouncycastle.asn1.DEREncodable; |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.x509.AlgorithmIdentifier; |
| +// BEGIN android-added |
| +import org.bouncycastle.crypto.Digest; |
| +import org.bouncycastle.crypto.digests.OpenSSLDigest; |
| +// END android-added |
| import org.bouncycastle.jce.exception.ExtCertPathValidatorException; |
| import org.bouncycastle.x509.ExtendedPKIXParameters; |
| |
| @@ -33,6 +45,63 @@ |
| public class PKIXCertPathValidatorSpi |
| extends CertPathValidatorSpi |
| { |
| + // BEGIN android-added |
| + |
| + // From http://src.chromium.org/viewvc/chrome/trunk/src/net/base/x509_certificate.cc?revision=78748&view=markup |
| + private static final Set<BigInteger> SERIAL_BLACKLIST = new HashSet<BigInteger>(Arrays.asList( |
| + // Not a real certificate. For testing only. |
| + 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}), |
| + |
| + 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}), |
| + 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}), |
| + 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}), |
| + 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}), |
| + 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}), |
| + 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}), |
| + 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}), |
| + 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}), |
| + 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}) |
| + )); |
| + |
| + // From http://src.chromium.org/viewvc/chrome/branches/782/src/net/base/x509_certificate.cc?r1=98750&r2=98749&pathrev=98750 |
| + private static final byte[][] PUBLIC_KEY_SHA1_BLACKLIST = { |
| + // C=NL, O=DigiNotar, CN=DigiNotar Root CA/emailAddress=info@diginotar.nl |
| + {(byte)0x41, (byte)0x0f, (byte)0x36, (byte)0x36, (byte)0x32, (byte)0x58, (byte)0xf3, (byte)0x0b, (byte)0x34, (byte)0x7d, |
| + (byte)0x12, (byte)0xce, (byte)0x48, (byte)0x63, (byte)0xe4, (byte)0x33, (byte)0x43, (byte)0x78, (byte)0x06, (byte)0xa8}, |
| + // Subject: CN=DigiNotar Cyber CA |
| + // Issuer: CN=GTE CyberTrust Global Root |
| + {(byte)0xba, (byte)0x3e, (byte)0x7b, (byte)0xd3, (byte)0x8c, (byte)0xd7, (byte)0xe1, (byte)0xe6, (byte)0xb9, (byte)0xcd, |
| + (byte)0x4c, (byte)0x21, (byte)0x99, (byte)0x62, (byte)0xe5, (byte)0x9d, (byte)0x7a, (byte)0x2f, (byte)0x4e, (byte)0x37}, |
| + // Subject: CN=DigiNotar Services 1024 CA |
| + // Issuer: CN=Entrust.net |
| + {(byte)0xe2, (byte)0x3b, (byte)0x8d, (byte)0x10, (byte)0x5f, (byte)0x87, (byte)0x71, (byte)0x0a, (byte)0x68, (byte)0xd9, |
| + (byte)0x24, (byte)0x80, (byte)0x50, (byte)0xeb, (byte)0xef, (byte)0xc6, (byte)0x27, (byte)0xbe, (byte)0x4c, (byte)0xa6}, |
| + // Subject: CN=DigiNotar PKIoverheid CA Organisatie - G2 |
| + // Issuer: CN=Staat der Nederlanden Organisatie CA - G2 |
| + {(byte)0x7b, (byte)0x2e, (byte)0x16, (byte)0xbc, (byte)0x39, (byte)0xbc, (byte)0xd7, (byte)0x2b, (byte)0x45, (byte)0x6e, |
| + (byte)0x9f, (byte)0x05, (byte)0x5d, (byte)0x1d, (byte)0xe6, (byte)0x15, (byte)0xb7, (byte)0x49, (byte)0x45, (byte)0xdb}, |
| + // Subject: CN=DigiNotar PKIoverheid CA Overheid en Bedrijven |
| + // Issuer: CN=Staat der Nederlanden Overheid CA |
| + {(byte)0xe8, (byte)0xf9, (byte)0x12, (byte)0x00, (byte)0xc6, (byte)0x5c, (byte)0xee, (byte)0x16, (byte)0xe0, (byte)0x39, |
| + (byte)0xb9, (byte)0xf8, (byte)0x83, (byte)0x84, (byte)0x16, (byte)0x61, (byte)0x63, (byte)0x5f, (byte)0x81, (byte)0xc5}, |
| + }; |
| + |
| + private static boolean isPublicKeyBlackListed(PublicKey publicKey) { |
| + byte[] encoded = publicKey.getEncoded(); |
| + Digest digest = new OpenSSLDigest.SHA1(); |
| + digest.update(encoded, 0, encoded.length); |
| + byte[] out = new byte[digest.getDigestSize()]; |
| + digest.doFinal(out, 0); |
| + |
| + for (byte[] sha1 : PUBLIC_KEY_SHA1_BLACKLIST) { |
| + if (Arrays.equals(out, sha1)) { |
| + return true; |
| + } |
| + } |
| + return false; |
| + } |
| + |
| + // END android-added |
| |
| public CertPathValidatorResult engineValidate( |
| CertPath certPath, |
| @@ -46,6 +115,18 @@ |
| + " instance."); |
| } |
| |
| + // BEGIN android-added |
| + IndexedPKIXParameters indexedParams; |
| + if (params instanceof IndexedPKIXParameters) |
| + { |
| + indexedParams = (IndexedPKIXParameters)params; |
| + } |
| + else |
| + { |
| + indexedParams = null; |
| + } |
| + |
| + // END android-added |
| ExtendedPKIXParameters paramsPKIX; |
| if (params instanceof ExtendedPKIXParameters) |
| { |
| @@ -75,6 +156,22 @@ |
| { |
| throw new CertPathValidatorException("Certification path is empty.", null, certPath, 0); |
| } |
| + // BEGIN android-added |
| + { |
| + X509Certificate cert = (X509Certificate) certs.get(0); |
| + |
| + if (cert != null) { |
| + BigInteger serial = cert.getSerialNumber(); |
| + if (serial != null && SERIAL_BLACKLIST.contains(serial)) { |
| + // emulate CRL exception message in RFC3280CertPathUtilities.checkCRLs |
| + String message = "Certificate revocation of serial 0x" + serial.toString(16); |
| + System.out.println(message); |
| + AnnotatedException e = new AnnotatedException(message); |
| + throw new CertPathValidatorException(e.getMessage(), e, certPath, 0); |
| + } |
| + } |
| + } |
| + // END android-added |
| |
| // |
| // (b) |
| @@ -92,8 +189,10 @@ |
| TrustAnchor trust; |
| try |
| { |
| + // BEGIN android-changed |
| trust = CertPathValidatorUtilities.findTrustAnchor((X509Certificate) certs.get(certs.size() - 1), |
| - paramsPKIX.getTrustAnchors(), paramsPKIX.getSigProvider()); |
| + indexedParams != null ? indexedParams : paramsPKIX); |
| + // END android-changed |
| } |
| catch (AnnotatedException e) |
| { |
| @@ -251,6 +350,15 @@ |
| |
| for (index = certs.size() - 1; index >= 0; index--) |
| { |
| + // BEGIN android-added |
| + if (isPublicKeyBlackListed(workingPublicKey)) { |
| + // emulate CRL exception message in RFC3280CertPathUtilities.checkCRLs |
| + String message = "Certificate revocation of public key " + workingPublicKey; |
| + System.out.println(message); |
| + AnnotatedException e = new AnnotatedException(message); |
| + throw new CertPathValidatorException(e.getMessage(), e, certPath, index); |
| + } |
| + // END android-added |
| // try |
| // { |
| // |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/PKIXNameConstraintValidator.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -1533,7 +1533,9 @@ |
| for (Enumeration e = permitted.getObjects(); e.hasMoreElements();) |
| { |
| GeneralSubtree subtree = GeneralSubtree.getInstance(e.nextElement()); |
| - Integer tagNo = new Integer(subtree.getBase().getTagNo()); |
| + // BEGIN android-changed |
| + Integer tagNo = Integer.valueOf(subtree.getBase().getTagNo()); |
| + // END android-changed |
| if (subtreesMap.get(tagNo) == null) |
| { |
| subtreesMap.put(tagNo, new HashSet()); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/WrapCipherSpi.java bcprov-jdk16-145/org/bouncycastle/jce/provider/WrapCipherSpi.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/WrapCipherSpi.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/WrapCipherSpi.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -12,8 +12,10 @@ |
| import org.bouncycastle.crypto.Wrapper; |
| import org.bouncycastle.crypto.engines.DESedeEngine; |
| import org.bouncycastle.crypto.engines.DESedeWrapEngine; |
| -import org.bouncycastle.crypto.engines.RC2WrapEngine; |
| -import org.bouncycastle.crypto.engines.RFC3211WrapEngine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.RC2WrapEngine; |
| +// import org.bouncycastle.crypto.engines.RFC3211WrapEngine; |
| +// END android-removed |
| import org.bouncycastle.crypto.params.KeyParameter; |
| import org.bouncycastle.crypto.params.ParametersWithIV; |
| |
| @@ -25,8 +27,10 @@ |
| import javax.crypto.ShortBufferException; |
| import javax.crypto.spec.IvParameterSpec; |
| import javax.crypto.spec.PBEParameterSpec; |
| -import javax.crypto.spec.RC2ParameterSpec; |
| -import javax.crypto.spec.RC5ParameterSpec; |
| +// BEGIN android-removed |
| +// import javax.crypto.spec.RC2ParameterSpec; |
| +// import javax.crypto.spec.RC5ParameterSpec; |
| +// END android-removed |
| import javax.crypto.spec.SecretKeySpec; |
| import java.security.AlgorithmParameters; |
| import java.security.InvalidAlgorithmParameterException; |
| @@ -52,8 +56,10 @@ |
| { |
| IvParameterSpec.class, |
| PBEParameterSpec.class, |
| - RC2ParameterSpec.class, |
| - RC5ParameterSpec.class |
| + // BEGIN android-removed |
| + // RC2ParameterSpec.class, |
| + // RC5ParameterSpec.class |
| + // END android-removed |
| }; |
| |
| protected int pbeType = PKCS12; |
| @@ -265,16 +271,19 @@ |
| return null; |
| } |
| |
| + // BEGIN android-changed |
| + // added ShortBufferException to throws statement |
| protected int engineDoFinal( |
| byte[] input, |
| int inputOffset, |
| int inputLen, |
| byte[] output, |
| int outputOffset) |
| - throws IllegalBlockSizeException, BadPaddingException |
| + throws IllegalBlockSizeException, BadPaddingException, ShortBufferException |
| { |
| return 0; |
| } |
| + // END android-changed |
| |
| protected byte[] engineWrap( |
| Key key) |
| @@ -307,7 +316,12 @@ |
| byte[] wrappedKey, |
| String wrappedKeyAlgorithm, |
| int wrappedKeyType) |
| - throws InvalidKeyException |
| + // BEGIN android-removed |
| + // throws InvalidKeyException |
| + // END android-removed |
| + // BEGIN android-added |
| + throws InvalidKeyException, NoSuchAlgorithmException |
| + // END android-added |
| { |
| byte[] encoded; |
| try |
| @@ -358,10 +372,12 @@ |
| { |
| privKey = new JCEECPrivateKey(in); |
| } |
| - else if (oid.equals(CryptoProObjectIdentifiers.gostR3410_94)) |
| - { |
| - privKey = new JDKGOST3410PrivateKey(in); |
| - } |
| + // BEGIN android-removed |
| + // else if (oid.equals(CryptoProObjectIdentifiers.gostR3410_94)) |
| + // { |
| + // privKey = new JDKGOST3410PrivateKey(in); |
| + // } |
| + // END android-removed |
| else if (oid.equals(X9ObjectIdentifiers.id_dsa)) |
| { |
| privKey = new JDKDSAPrivateKey(in); |
| @@ -405,10 +421,12 @@ |
| { |
| throw new InvalidKeyException("Unknown key type " + e.getMessage()); |
| } |
| - catch (NoSuchAlgorithmException e) |
| - { |
| - throw new InvalidKeyException("Unknown key type " + e.getMessage()); |
| - } |
| + // BEGIN android-removed |
| + // catch (NoSuchAlgorithmException e) |
| + // { |
| + // throw new InvalidKeyException("Unknown key type " + e.getMessage()); |
| + // } |
| + // END android-removed |
| catch (InvalidKeySpecException e2) |
| { |
| throw new InvalidKeyException("Unknown key type " + e2.getMessage()); |
| @@ -433,21 +451,23 @@ |
| } |
| } |
| |
| - public static class RC2Wrap |
| - extends WrapCipherSpi |
| - { |
| - public RC2Wrap() |
| - { |
| - super(new RC2WrapEngine()); |
| - } |
| - } |
| - |
| - public static class RFC3211DESedeWrap |
| - extends WrapCipherSpi |
| - { |
| - public RFC3211DESedeWrap() |
| - { |
| - super(new RFC3211WrapEngine(new DESedeEngine()), 8); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class RC2Wrap |
| + // extends WrapCipherSpi |
| + // { |
| + // public RC2Wrap() |
| + // { |
| + // super(new RC2WrapEngine()); |
| + // } |
| + // } |
| + // |
| + // public static class RFC3211DESedeWrap |
| + // extends WrapCipherSpi |
| + // { |
| + // public RFC3211DESedeWrap() |
| + // { |
| + // super(new RFC3211WrapEngine(new DESedeEngine()), 8); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509CertificateObject.java bcprov-jdk16-145/org/bouncycastle/jce/provider/X509CertificateObject.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509CertificateObject.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/X509CertificateObject.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -518,12 +518,20 @@ |
| return JDKKeyFactory.createPublicKeyFromPublicKeyInfo(c.getSubjectPublicKeyInfo()); |
| } |
| |
| + // BEGIN android-changed |
| + private byte[] encoded; |
| + // END android-changed |
| public byte[] getEncoded() |
| throws CertificateEncodingException |
| { |
| try |
| { |
| - return c.getEncoded(ASN1Encodable.DER); |
| + // BEGIN android-changed |
| + if (encoded == null) { |
| + encoded = c.getEncoded(ASN1Encodable.DER); |
| + } |
| + return encoded; |
| + // END android-changed |
| } |
| catch (IOException e) |
| { |
| @@ -703,7 +711,7 @@ |
| { |
| Signature signature; |
| String sigName = X509SignatureUtil.getSignatureName(c.getSignatureAlgorithm()); |
| - |
| + |
| try |
| { |
| signature = Signature.getInstance(sigName, "BC"); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509SignatureUtil.java bcprov-jdk16-145/org/bouncycastle/jce/provider/X509SignatureUtil.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/X509SignatureUtil.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/X509SignatureUtil.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -25,7 +25,9 @@ |
| |
| class X509SignatureUtil |
| { |
| - private static final ASN1Null derNull = new DERNull(); |
| + // BEGIN android-changed |
| + private static final ASN1Null derNull = DERNull.INSTANCE; |
| + // END android-changed |
| |
| static void setSignatureParameters( |
| Signature signature, |
| @@ -66,12 +68,14 @@ |
| |
| if (params != null && !derNull.equals(params)) |
| { |
| - if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) |
| - { |
| - RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params); |
| - |
| - return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1"; |
| - } |
| + // BEGIN android-removed |
| + // if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) |
| + // { |
| + // RSASSAPSSparams rsaParams = RSASSAPSSparams.getInstance(params); |
| + // |
| + // return getDigestAlgName(rsaParams.getHashAlgorithm().getObjectId()) + "withRSAandMGF1"; |
| + // } |
| + // END android-removed |
| if (sigAlgId.getObjectId().equals(X9ObjectIdentifiers.ecdsa_with_SHA2)) |
| { |
| ASN1Sequence ecDsaParams = ASN1Sequence.getInstance(params); |
| @@ -98,10 +102,12 @@ |
| { |
| return "SHA1"; |
| } |
| - else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID)) |
| - { |
| - return "SHA224"; |
| - } |
| + // BEGIN android-removed |
| + // else if (NISTObjectIdentifiers.id_sha224.equals(digestAlgOID)) |
| + // { |
| + // return "SHA224"; |
| + // } |
| + // END android-removed |
| else if (NISTObjectIdentifiers.id_sha256.equals(digestAlgOID)) |
| { |
| return "SHA256"; |
| @@ -114,22 +120,24 @@ |
| { |
| return "SHA512"; |
| } |
| - else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID)) |
| - { |
| - return "RIPEMD128"; |
| - } |
| - else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID)) |
| - { |
| - return "RIPEMD160"; |
| - } |
| - else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID)) |
| - { |
| - return "RIPEMD256"; |
| - } |
| - else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID)) |
| - { |
| - return "GOST3411"; |
| - } |
| + // BEGIN android-removed |
| + // else if (TeleTrusTObjectIdentifiers.ripemd128.equals(digestAlgOID)) |
| + // { |
| + // return "RIPEMD128"; |
| + // } |
| + // else if (TeleTrusTObjectIdentifiers.ripemd160.equals(digestAlgOID)) |
| + // { |
| + // return "RIPEMD160"; |
| + // } |
| + // else if (TeleTrusTObjectIdentifiers.ripemd256.equals(digestAlgOID)) |
| + // { |
| + // return "RIPEMD256"; |
| + // } |
| + // else if (CryptoProObjectIdentifiers.gostR3411.equals(digestAlgOID)) |
| + // { |
| + // return "GOST3411"; |
| + // } |
| + // END android-removed |
| else |
| { |
| return digestAlgOID.getId(); |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ECMappings.java bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ECMappings.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ECMappings.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ECMappings.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -4,8 +4,10 @@ |
| |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| import org.bouncycastle.asn1.cryptopro.CryptoProObjectIdentifiers; |
| -import org.bouncycastle.asn1.eac.EACObjectIdentifiers; |
| -import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.eac.EACObjectIdentifiers; |
| +// import org.bouncycastle.asn1.teletrust.TeleTrusTObjectIdentifiers; |
| +// END android-removed |
| import org.bouncycastle.asn1.x9.X9ObjectIdentifiers; |
| |
| public class ECMappings |
| @@ -14,39 +16,49 @@ |
| public ECMappings() |
| { |
| put("KeyAgreement.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DH"); |
| - put("KeyAgreement.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHC"); |
| - put("KeyAgreement.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQV"); |
| - put("KeyAgreement." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHwithSHA1KDF"); |
| - put("KeyAgreement." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQVwithSHA1KDF"); |
| + // BEGIN android-removed |
| + // put("KeyAgreement.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHC"); |
| + // put("KeyAgreement.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQV"); |
| + // put("KeyAgreement." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$DHwithSHA1KDF"); |
| + // put("KeyAgreement." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "org.bouncycastle.jce.provider.asymmetric.ec.KeyAgreement$MQVwithSHA1KDF"); |
| + // END android-removed |
| |
| put("KeyFactory.EC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$EC"); |
| - put("KeyFactory.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDSA"); |
| - put("KeyFactory.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDH"); |
| - put("KeyFactory.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDHC"); |
| - put("KeyFactory.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECMQV"); |
| + // BEGIN android-removed |
| + // put("KeyFactory.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDSA"); |
| + // put("KeyFactory.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDH"); |
| + // put("KeyFactory.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECDHC"); |
| + // put("KeyFactory.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECMQV"); |
| + // END android-removed |
| put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.id_ecPublicKey, "EC"); |
| // TODO Should this be an alias for ECDH? |
| put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "EC"); |
| - put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.KeyFactory." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV"); |
| |
| - put("KeyFactory.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECGOST3410"); |
| - put("Alg.Alias.KeyFactory.GOST-3410-2001", "ECGOST3410"); |
| - put("Alg.Alias.KeyFactory.ECGOST-3410", "ECGOST3410"); |
| - put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_2001, "ECGOST3410"); |
| + // put("KeyFactory.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyFactory$ECGOST3410"); |
| + // put("Alg.Alias.KeyFactory.GOST-3410-2001", "ECGOST3410"); |
| + // put("Alg.Alias.KeyFactory.ECGOST-3410", "ECGOST3410"); |
| + // put("Alg.Alias.KeyFactory." + CryptoProObjectIdentifiers.gostR3410_2001, "ECGOST3410"); |
| + // END android-removed |
| |
| put("KeyPairGenerator.EC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$EC"); |
| - put("KeyPairGenerator.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDSA"); |
| - put("KeyPairGenerator.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH"); |
| - put("KeyPairGenerator.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDHC"); |
| - put("KeyPairGenerator.ECIES", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH"); |
| - put("KeyPairGenerator.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECMQV"); |
| + // BEGIN android-removed |
| + // put("KeyPairGenerator.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDSA"); |
| + // put("KeyPairGenerator.ECDH", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH"); |
| + // put("KeyPairGenerator.ECDHC", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDHC"); |
| + // put("KeyPairGenerator.ECIES", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECDH"); |
| + // put("KeyPairGenerator.ECMQV", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECMQV"); |
| + // END android-removed |
| // TODO Should this be an alias for ECDH? |
| put("Alg.Alias.KeyPairGenerator." + X9ObjectIdentifiers.dhSinglePass_stdDH_sha1kdf_scheme, "EC"); |
| - put("Alg.Alias.KeyPairGenerator." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.KeyPairGenerator." + X9ObjectIdentifiers.mqvSinglePass_sha1kdf_scheme, "ECMQV"); |
| |
| - put("KeyPairGenerator.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECGOST3410"); |
| - put("Alg.Alias.KeyPairGenerator.ECGOST-3410", "ECGOST3410"); |
| - put("Alg.Alias.KeyPairGenerator.GOST-3410-2001", "ECGOST3410"); |
| + // put("KeyPairGenerator.ECGOST3410", "org.bouncycastle.jce.provider.asymmetric.ec.KeyPairGenerator$ECGOST3410"); |
| + // put("Alg.Alias.KeyPairGenerator.ECGOST-3410", "ECGOST3410"); |
| + // put("Alg.Alias.KeyPairGenerator.GOST-3410-2001", "ECGOST3410"); |
| + // END android-removed |
| |
| put("Signature.ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA"); |
| put("Signature.NONEwithECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSAnone"); |
| @@ -58,23 +70,27 @@ |
| put("Alg.Alias.Signature.SHA1WithECDSA", "ECDSA"); |
| put("Alg.Alias.Signature.ECDSAWithSHA1", "ECDSA"); |
| put("Alg.Alias.Signature.1.2.840.10045.4.1", "ECDSA"); |
| - put("Alg.Alias.Signature." + TeleTrusTObjectIdentifiers.ecSignWithSha1, "ECDSA"); |
| + // BEGIN android-removed |
| + // put("Alg.Alias.Signature." + TeleTrusTObjectIdentifiers.ecSignWithSha1, "ECDSA"); |
| |
| - addSignatureAlgorithm("SHA224", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA224", X9ObjectIdentifiers.ecdsa_with_SHA224); |
| + // addSignatureAlgorithm("SHA224", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA224", X9ObjectIdentifiers.ecdsa_with_SHA224); |
| + // END android-removed |
| addSignatureAlgorithm("SHA256", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA256", X9ObjectIdentifiers.ecdsa_with_SHA256); |
| addSignatureAlgorithm("SHA384", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA384", X9ObjectIdentifiers.ecdsa_with_SHA384); |
| addSignatureAlgorithm("SHA512", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSA512", X9ObjectIdentifiers.ecdsa_with_SHA512); |
| - addSignatureAlgorithm("RIPEMD160", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSARipeMD160",TeleTrusTObjectIdentifiers.ecSignWithRipemd160); |
| + // BEGIN android-removed |
| + // addSignatureAlgorithm("RIPEMD160", "ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecDSARipeMD160",TeleTrusTObjectIdentifiers.ecSignWithRipemd160); |
| |
| - put("Signature.SHA1WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR"); |
| - put("Signature.SHA224WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR224"); |
| - put("Signature.SHA256WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR256"); |
| - put("Signature.SHA384WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR384"); |
| - put("Signature.SHA512WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR512"); |
| - |
| - addSignatureAlgorithm("SHA1", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_1); |
| - addSignatureAlgorithm("SHA224", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA224", EACObjectIdentifiers.id_TA_ECDSA_SHA_224); |
| - addSignatureAlgorithm("SHA256", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA256", EACObjectIdentifiers.id_TA_ECDSA_SHA_256); |
| + // put("Signature.SHA1WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR"); |
| + // put("Signature.SHA224WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR224"); |
| + // put("Signature.SHA256WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR256"); |
| + // put("Signature.SHA384WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR384"); |
| + // put("Signature.SHA512WITHECNR", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecNR512"); |
| + |
| + // addSignatureAlgorithm("SHA1", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA", EACObjectIdentifiers.id_TA_ECDSA_SHA_1); |
| + // addSignatureAlgorithm("SHA224", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA224", EACObjectIdentifiers.id_TA_ECDSA_SHA_224); |
| + // addSignatureAlgorithm("SHA256", "CVC-ECDSA", "org.bouncycastle.jce.provider.asymmetric.ec.Signature$ecCVCDSA256", EACObjectIdentifiers.id_TA_ECDSA_SHA_256); |
| + // END android-removed |
| } |
| |
| private void addSignatureAlgorithm( |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/ECUtil.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -1,10 +1,14 @@ |
| package org.bouncycastle.jce.provider.asymmetric.ec; |
| |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| -import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.nist.NISTNamedCurves; |
| import org.bouncycastle.asn1.sec.SECNamedCurves; |
| -import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.x9.X962NamedCurves; |
| import org.bouncycastle.asn1.x9.X9ECParameters; |
| import org.bouncycastle.crypto.params.AsymmetricKeyParameter; |
| @@ -167,14 +171,16 @@ |
| { |
| oid = NISTNamedCurves.getOID(name); |
| } |
| - if (oid == null) |
| - { |
| - oid = TeleTrusTNamedCurves.getOID(name); |
| - } |
| - if (oid == null) |
| - { |
| - oid = ECGOST3410NamedCurves.getOID(name); |
| - } |
| + // BEGIN android-removed |
| + // if (oid == null) |
| + // { |
| + // oid = TeleTrusTNamedCurves.getOID(name); |
| + // } |
| + // if (oid == null) |
| + // { |
| + // oid = ECGOST3410NamedCurves.getOID(name); |
| + // } |
| + // END android-removed |
| } |
| |
| return oid; |
| @@ -192,10 +198,12 @@ |
| { |
| params = NISTNamedCurves.getByOID(oid); |
| } |
| - if (params == null) |
| - { |
| - params = TeleTrusTNamedCurves.getByOID(oid); |
| - } |
| + // BEGIN android-removed |
| + // if (params == null) |
| + // { |
| + // params = TeleTrusTNamedCurves.getByOID(oid); |
| + // } |
| + // END android-removed |
| } |
| |
| return params; |
| @@ -213,14 +221,16 @@ |
| { |
| name = NISTNamedCurves.getName(oid); |
| } |
| - if (name == null) |
| - { |
| - name = TeleTrusTNamedCurves.getName(oid); |
| - } |
| - if (name == null) |
| - { |
| - name = ECGOST3410NamedCurves.getName(oid); |
| - } |
| + // BEGIN android-removed |
| + // if (name == null) |
| + // { |
| + // name = TeleTrusTNamedCurves.getName(oid); |
| + // } |
| + // if (name == null) |
| + // { |
| + // name = ECGOST3410NamedCurves.getName(oid); |
| + // } |
| + // END android-removed |
| } |
| |
| return name; |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/KeyAgreement.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -24,20 +24,26 @@ |
| import org.bouncycastle.crypto.CipherParameters; |
| import org.bouncycastle.crypto.DerivationFunction; |
| import org.bouncycastle.crypto.agreement.ECDHBasicAgreement; |
| -import org.bouncycastle.crypto.agreement.ECDHCBasicAgreement; |
| -import org.bouncycastle.crypto.agreement.ECMQVBasicAgreement; |
| -import org.bouncycastle.crypto.agreement.kdf.DHKDFParameters; |
| -import org.bouncycastle.crypto.agreement.kdf.ECDHKEKGenerator; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.agreement.ECDHCBasicAgreement; |
| +// import org.bouncycastle.crypto.agreement.ECMQVBasicAgreement; |
| +// import org.bouncycastle.crypto.agreement.kdf.DHKDFParameters; |
| +// import org.bouncycastle.crypto.agreement.kdf.ECDHKEKGenerator; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| import org.bouncycastle.crypto.params.ECDomainParameters; |
| import org.bouncycastle.crypto.params.ECPrivateKeyParameters; |
| import org.bouncycastle.crypto.params.ECPublicKeyParameters; |
| -import org.bouncycastle.crypto.params.MQVPrivateParameters; |
| -import org.bouncycastle.crypto.params.MQVPublicParameters; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.params.MQVPrivateParameters; |
| +// import org.bouncycastle.crypto.params.MQVPublicParameters; |
| +// END android-removed |
| import org.bouncycastle.jce.interfaces.ECPrivateKey; |
| import org.bouncycastle.jce.interfaces.ECPublicKey; |
| -import org.bouncycastle.jce.interfaces.MQVPrivateKey; |
| -import org.bouncycastle.jce.interfaces.MQVPublicKey; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.jce.interfaces.MQVPrivateKey; |
| +// import org.bouncycastle.jce.interfaces.MQVPublicKey; |
| +// END android-removed |
| |
| /** |
| * Diffie-Hellman key agreement using elliptic curve keys, ala IEEE P1363 |
| @@ -70,7 +76,9 @@ |
| private BigInteger result; |
| private ECDomainParameters parameters; |
| private BasicAgreement agreement; |
| - private DerivationFunction kdf; |
| + // BEGIN android-removed |
| + // private DerivationFunction kdf; |
| + // END android-removed |
| |
| private byte[] bigIntToBytes( |
| BigInteger r) |
| @@ -85,7 +93,9 @@ |
| { |
| this.kaAlgorithm = kaAlgorithm; |
| this.agreement = agreement; |
| - this.kdf = kdf; |
| + // BEGIN android-removed |
| + // this.kdf = kdf; |
| + // END android-removed |
| } |
| |
| protected Key engineDoPhase( |
| @@ -104,25 +114,27 @@ |
| } |
| |
| CipherParameters pubKey; |
| - if (agreement instanceof ECMQVBasicAgreement) |
| - { |
| - if (!(key instanceof MQVPublicKey)) |
| - { |
| - throw new InvalidKeyException(kaAlgorithm + " key agreement requires " |
| - + getSimpleName(MQVPublicKey.class) + " for doPhase"); |
| - } |
| - |
| - MQVPublicKey mqvPubKey = (MQVPublicKey)key; |
| - ECPublicKeyParameters staticKey = (ECPublicKeyParameters) |
| - ECUtil.generatePublicKeyParameter(mqvPubKey.getStaticKey()); |
| - ECPublicKeyParameters ephemKey = (ECPublicKeyParameters) |
| - ECUtil.generatePublicKeyParameter(mqvPubKey.getEphemeralKey()); |
| - |
| - pubKey = new MQVPublicParameters(staticKey, ephemKey); |
| - |
| - // TODO Validate that all the keys are using the same parameters? |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (agreement instanceof ECMQVBasicAgreement) |
| + // { |
| + // if (!(key instanceof MQVPublicKey)) |
| + // { |
| + // throw new InvalidKeyException(kaAlgorithm + " key agreement requires " |
| + // + getSimpleName(MQVPublicKey.class) + " for doPhase"); |
| + // } |
| + // |
| + // MQVPublicKey mqvPubKey = (MQVPublicKey)key; |
| + // ECPublicKeyParameters staticKey = (ECPublicKeyParameters) |
| + // ECUtil.generatePublicKeyParameter(mqvPubKey.getStaticKey()); |
| + // ECPublicKeyParameters ephemKey = (ECPublicKeyParameters) |
| + // ECUtil.generatePublicKeyParameter(mqvPubKey.getEphemeralKey()); |
| + // |
| + // pubKey = new MQVPublicParameters(staticKey, ephemKey); |
| + // |
| + // // TODO Validate that all the keys are using the same parameters? |
| + // } |
| + // else |
| + // END android-removed |
| { |
| if (!(key instanceof ECPublicKey)) |
| { |
| @@ -143,11 +155,13 @@ |
| protected byte[] engineGenerateSecret() |
| throws IllegalStateException |
| { |
| - if (kdf != null) |
| - { |
| - throw new UnsupportedOperationException( |
| - "KDF can only be used when algorithm is known"); |
| - } |
| + // BEGIN android-removed |
| + // if (kdf != null) |
| + // { |
| + // throw new UnsupportedOperationException( |
| + // "KDF can only be used when algorithm is known"); |
| + // } |
| + // END android-removed |
| |
| return bigIntToBytes(result); |
| } |
| @@ -175,23 +189,25 @@ |
| { |
| byte[] secret = bigIntToBytes(result); |
| |
| - if (kdf != null) |
| - { |
| - if (!algorithms.containsKey(algorithm)) |
| - { |
| - throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm); |
| - } |
| - |
| - int keySize = ((Integer)algorithms.get(algorithm)).intValue(); |
| - |
| - DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret); |
| - |
| - byte[] keyBytes = new byte[keySize / 8]; |
| - kdf.init(params); |
| - kdf.generateBytes(keyBytes, 0, keyBytes.length); |
| - secret = keyBytes; |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (kdf != null) |
| + // { |
| + // if (!algorithms.containsKey(algorithm)) |
| + // { |
| + // throw new NoSuchAlgorithmException("unknown algorithm encountered: " + algorithm); |
| + // } |
| + // |
| + // int keySize = ((Integer)algorithms.get(algorithm)).intValue(); |
| + // |
| + // DHKDFParameters params = new DHKDFParameters(new DERObjectIdentifier(algorithm), keySize, secret); |
| + // |
| + // byte[] keyBytes = new byte[keySize / 8]; |
| + // kdf.init(params); |
| + // kdf.generateBytes(keyBytes, 0, keyBytes.length); |
| + // secret = keyBytes; |
| + // } |
| + // else |
| + // END android-removed |
| { |
| // TODO Should we be ensuring the key is the right length? |
| } |
| @@ -219,35 +235,37 @@ |
| private void initFromKey(Key key) |
| throws InvalidKeyException |
| { |
| - if (agreement instanceof ECMQVBasicAgreement) |
| - { |
| - if (!(key instanceof MQVPrivateKey)) |
| - { |
| - throw new InvalidKeyException(kaAlgorithm + " key agreement requires " |
| - + getSimpleName(MQVPrivateKey.class) + " for initialisation"); |
| - } |
| - |
| - MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key; |
| - ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters) |
| - ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey()); |
| - ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters) |
| - ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey()); |
| - |
| - ECPublicKeyParameters ephemPubKey = null; |
| - if (mqvPrivKey.getEphemeralPublicKey() != null) |
| - { |
| - ephemPubKey = (ECPublicKeyParameters) |
| - ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey()); |
| - } |
| - |
| - MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey); |
| - this.parameters = staticPrivKey.getParameters(); |
| - |
| - // TODO Validate that all the keys are using the same parameters? |
| - |
| - agreement.init(localParams); |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (agreement instanceof ECMQVBasicAgreement) |
| + // { |
| + // if (!(key instanceof MQVPrivateKey)) |
| + // { |
| + // throw new InvalidKeyException(kaAlgorithm + " key agreement requires " |
| + // + getSimpleName(MQVPrivateKey.class) + " for initialisation"); |
| + // } |
| + // |
| + // MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key; |
| + // ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters) |
| + // ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey()); |
| + // ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters) |
| + // ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey()); |
| + // |
| + // ECPublicKeyParameters ephemPubKey = null; |
| + // if (mqvPrivKey.getEphemeralPublicKey() != null) |
| + // { |
| + // ephemPubKey = (ECPublicKeyParameters) |
| + // ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey()); |
| + // } |
| + // |
| + // MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey); |
| + // this.parameters = staticPrivKey.getParameters(); |
| + // |
| + // // TODO Validate that all the keys are using the same parameters? |
| + // |
| + // agreement.init(localParams); |
| + // } |
| + // else |
| + // END android-removed |
| { |
| if (!(key instanceof ECPrivateKey)) |
| { |
| @@ -278,39 +296,41 @@ |
| } |
| } |
| |
| - public static class DHC |
| - extends KeyAgreement |
| - { |
| - public DHC() |
| - { |
| - super("ECDHC", new ECDHCBasicAgreement(), null); |
| - } |
| - } |
| - |
| - public static class MQV |
| - extends KeyAgreement |
| - { |
| - public MQV() |
| - { |
| - super("ECMQV", new ECMQVBasicAgreement(), null); |
| - } |
| - } |
| - |
| - public static class DHwithSHA1KDF |
| - extends KeyAgreement |
| - { |
| - public DHwithSHA1KDF() |
| - { |
| - super("ECDHwithSHA1KDF", new ECDHBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest())); |
| - } |
| - } |
| - |
| - public static class MQVwithSHA1KDF |
| - extends KeyAgreement |
| - { |
| - public MQVwithSHA1KDF() |
| - { |
| - super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest())); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class DHC |
| + // extends KeyAgreement |
| + // { |
| + // public DHC() |
| + // { |
| + // super("ECDHC", new ECDHCBasicAgreement(), null); |
| + // } |
| + // } |
| + // |
| + // public static class MQV |
| + // extends KeyAgreement |
| + // { |
| + // public MQV() |
| + // { |
| + // super("ECMQV", new ECMQVBasicAgreement(), null); |
| + // } |
| + // } |
| + // |
| + // public static class DHwithSHA1KDF |
| + // extends KeyAgreement |
| + // { |
| + // public DHwithSHA1KDF() |
| + // { |
| + // super("ECDHwithSHA1KDF", new ECDHBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest())); |
| + // } |
| + // } |
| + // |
| + // public static class MQVwithSHA1KDF |
| + // extends KeyAgreement |
| + // { |
| + // public MQVwithSHA1KDF() |
| + // { |
| + // super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest())); |
| + // } |
| + // } |
| + // END android-removed |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/KeyPairGenerator.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -10,10 +10,14 @@ |
| import java.util.Hashtable; |
| |
| import org.bouncycastle.asn1.DERObjectIdentifier; |
| -import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.cryptopro.ECGOST3410NamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.nist.NISTNamedCurves; |
| import org.bouncycastle.asn1.sec.SECNamedCurves; |
| -import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.asn1.teletrust.TeleTrusTNamedCurves; |
| +// END android-removed |
| import org.bouncycastle.asn1.x9.X962NamedCurves; |
| import org.bouncycastle.asn1.x9.X9ECParameters; |
| import org.bouncycastle.crypto.AsymmetricCipherKeyPair; |
| @@ -83,7 +87,13 @@ |
| SecureRandom random) |
| { |
| this.strength = strength; |
| + // BEGIN android-added |
| + if (random != null) { |
| + // END android-added |
| this.random = random; |
| + // BEGIN android-added |
| + } |
| + // END android-added |
| this.ecParams = ecParameters.get(new Integer(strength)); |
| |
| if (ecParams != null) |
| @@ -108,6 +118,11 @@ |
| SecureRandom random) |
| throws InvalidAlgorithmParameterException |
| { |
| + // BEGIN android-added |
| + if (random == null) { |
| + random = this.random; |
| + } |
| + // END android-added |
| if (params instanceof ECParameterSpec) |
| { |
| ECParameterSpec p = (ECParameterSpec)params; |
| @@ -135,23 +150,25 @@ |
| { |
| final String curveName = ((ECGenParameterSpec)params).getName(); |
| |
| - if (this.algorithm.equals("ECGOST3410")) |
| - { |
| - ECDomainParameters ecP = ECGOST3410NamedCurves.getByName(curveName); |
| - if (ecP == null) |
| - { |
| - throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName); |
| - } |
| - |
| - this.ecParams = new ECNamedCurveSpec( |
| - curveName, |
| - ecP.getCurve(), |
| - ecP.getG(), |
| - ecP.getN(), |
| - ecP.getH(), |
| - ecP.getSeed()); |
| - } |
| - else |
| + // BEGIN android-removed |
| + // if (this.algorithm.equals("ECGOST3410")) |
| + // { |
| + // ECDomainParameters ecP = ECGOST3410NamedCurves.getByName(curveName); |
| + // if (ecP == null) |
| + // { |
| + // throw new InvalidAlgorithmParameterException("unknown curve name: " + curveName); |
| + // } |
| + // |
| + // this.ecParams = new ECNamedCurveSpec( |
| + // curveName, |
| + // ecP.getCurve(), |
| + // ecP.getG(), |
| + // ecP.getN(), |
| + // ecP.getH(), |
| + // ecP.getSeed()); |
| + // } |
| + // else |
| + // END android-removed |
| { |
| X9ECParameters ecP = X962NamedCurves.getByName(curveName); |
| if (ecP == null) |
| @@ -161,10 +178,12 @@ |
| { |
| ecP = NISTNamedCurves.getByName(curveName); |
| } |
| - if (ecP == null) |
| - { |
| - ecP = TeleTrusTNamedCurves.getByName(curveName); |
| - } |
| + // BEGIN android-removed |
| + // if (ecP == null) |
| + // { |
| + // ecP = TeleTrusTNamedCurves.getByName(curveName); |
| + // } |
| + // END android-removed |
| if (ecP == null) |
| { |
| // See if it's actually an OID string (SunJSSE ServerHandshaker setupEphemeralECDHKeys bug) |
| @@ -180,10 +199,12 @@ |
| { |
| ecP = NISTNamedCurves.getByOID(oid); |
| } |
| - if (ecP == null) |
| - { |
| - ecP = TeleTrusTNamedCurves.getByOID(oid); |
| - } |
| + // BEGIN android-removed |
| + // if (ecP == null) |
| + // { |
| + // ecP = TeleTrusTNamedCurves.getByOID(oid); |
| + // } |
| + // END android-removed |
| if (ecP == null) |
| { |
| throw new InvalidAlgorithmParameterException("unknown curve OID: " + curveName); |
| @@ -239,7 +260,15 @@ |
| { |
| if (!initialised) |
| { |
| - throw new IllegalStateException("EC Key Pair Generator not initialised"); |
| + // BEGIN android-removed |
| + // throw new IllegalStateException("EC Key Pair Generator not initialised"); |
| + // END android-removed |
| + // BEGIN android-added |
| + /* |
| + * KeyPairGenerator documentation says that a default initialization must be provided |
| + */ |
| + initialize(192, random); |
| + // END android-added |
| } |
| |
| AsymmetricCipherKeyPair pair = engine.generateKeyPair(); |
| @@ -279,14 +308,16 @@ |
| } |
| } |
| |
| - public static class ECGOST3410 |
| - extends EC |
| - { |
| - public ECGOST3410() |
| - { |
| - super("ECGOST3410"); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class ECGOST3410 |
| + // extends EC |
| + // { |
| + // public ECGOST3410() |
| + // { |
| + // super("ECGOST3410"); |
| + // } |
| + // } |
| + // END android-removed |
| |
| public static class ECDH |
| extends EC |
| @@ -314,4 +345,4 @@ |
| super("ECMQV"); |
| } |
| } |
| -} |
| \ No newline at end of file |
| +} |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/asymmetric/ec/Signature.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -18,15 +18,21 @@ |
| import org.bouncycastle.crypto.CipherParameters; |
| import org.bouncycastle.crypto.DSA; |
| import org.bouncycastle.crypto.Digest; |
| -import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.RIPEMD160Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA1Digest; |
| -import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.digests.SHA224Digest; |
| +// END android-removed |
| import org.bouncycastle.crypto.digests.SHA256Digest; |
| import org.bouncycastle.crypto.digests.SHA384Digest; |
| import org.bouncycastle.crypto.digests.SHA512Digest; |
| import org.bouncycastle.crypto.params.ParametersWithRandom; |
| import org.bouncycastle.crypto.signers.ECDSASigner; |
| -import org.bouncycastle.crypto.signers.ECNRSigner; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.signers.ECNRSigner; |
| +// END android-removed |
| import org.bouncycastle.jce.interfaces.ECKey; |
| import org.bouncycastle.jce.provider.DSABase; |
| import org.bouncycastle.jce.provider.DSAEncoder; |
| @@ -123,14 +129,16 @@ |
| } |
| } |
| |
| - static public class ecDSA224 |
| - extends Signature |
| - { |
| - public ecDSA224() |
| - { |
| - super(new SHA224Digest(), new ECDSASigner(), new StdDSAEncoder()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class ecDSA224 |
| + // extends Signature |
| + // { |
| + // public ecDSA224() |
| + // { |
| + // super(new SHA224Digest(), new ECDSASigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| static public class ecDSA256 |
| extends Signature |
| @@ -159,86 +167,88 @@ |
| } |
| } |
| |
| - static public class ecDSARipeMD160 |
| - extends Signature |
| - { |
| - public ecDSARipeMD160() |
| - { |
| - super(new RIPEMD160Digest(), new ECDSASigner(), new StdDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecNR |
| - extends Signature |
| - { |
| - public ecNR() |
| - { |
| - super(new SHA1Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecNR224 |
| - extends Signature |
| - { |
| - public ecNR224() |
| - { |
| - super(new SHA224Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecNR256 |
| - extends Signature |
| - { |
| - public ecNR256() |
| - { |
| - super(new SHA256Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecNR384 |
| - extends Signature |
| - { |
| - public ecNR384() |
| - { |
| - super(new SHA384Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecNR512 |
| - extends Signature |
| - { |
| - public ecNR512() |
| - { |
| - super(new SHA512Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecCVCDSA |
| - extends Signature |
| - { |
| - public ecCVCDSA() |
| - { |
| - super(new SHA1Digest(), new ECDSASigner(), new CVCDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecCVCDSA224 |
| - extends Signature |
| - { |
| - public ecCVCDSA224() |
| - { |
| - super(new SHA224Digest(), new ECDSASigner(), new CVCDSAEncoder()); |
| - } |
| - } |
| - |
| - static public class ecCVCDSA256 |
| - extends Signature |
| - { |
| - public ecCVCDSA256() |
| - { |
| - super(new SHA256Digest(), new ECDSASigner(), new CVCDSAEncoder()); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // static public class ecDSARipeMD160 |
| + // extends Signature |
| + // { |
| + // public ecDSARipeMD160() |
| + // { |
| + // super(new RIPEMD160Digest(), new ECDSASigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecNR |
| + // extends Signature |
| + // { |
| + // public ecNR() |
| + // { |
| + // super(new SHA1Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecNR224 |
| + // extends Signature |
| + // { |
| + // public ecNR224() |
| + // { |
| + // super(new SHA224Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecNR256 |
| + // extends Signature |
| + // { |
| + // public ecNR256() |
| + // { |
| + // super(new SHA256Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecNR384 |
| + // extends Signature |
| + // { |
| + // public ecNR384() |
| + // { |
| + // super(new SHA384Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecNR512 |
| + // extends Signature |
| + // { |
| + // public ecNR512() |
| + // { |
| + // super(new SHA512Digest(), new ECNRSigner(), new StdDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecCVCDSA |
| + // extends Signature |
| + // { |
| + // public ecCVCDSA() |
| + // { |
| + // super(new SHA1Digest(), new ECDSASigner(), new CVCDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecCVCDSA224 |
| + // extends Signature |
| + // { |
| + // public ecCVCDSA224() |
| + // { |
| + // super(new SHA224Digest(), new ECDSASigner(), new CVCDSAEncoder()); |
| + // } |
| + // } |
| + // |
| + // static public class ecCVCDSA256 |
| + // extends Signature |
| + // { |
| + // public ecCVCDSA256() |
| + // { |
| + // super(new SHA256Digest(), new ECDSASigner(), new CVCDSAEncoder()); |
| + // } |
| + // } |
| + // END android-removed |
| |
| private static class StdDSAEncoder |
| implements DSAEncoder |
| @@ -332,4 +342,4 @@ |
| return sig; |
| } |
| } |
| -} |
| \ No newline at end of file |
| +} |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AES.java bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AES.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AES.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AES.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -5,7 +5,9 @@ |
| import org.bouncycastle.crypto.engines.AESEngine; |
| import org.bouncycastle.crypto.engines.AESFastEngine; |
| import org.bouncycastle.crypto.engines.AESWrapEngine; |
| -import org.bouncycastle.crypto.engines.RFC3211WrapEngine; |
| +// BEGIN android-removed |
| +// import org.bouncycastle.crypto.engines.RFC3211WrapEngine; |
| +// END android-removed |
| import org.bouncycastle.crypto.modes.CBCBlockCipher; |
| import org.bouncycastle.crypto.modes.CFBBlockCipher; |
| import org.bouncycastle.crypto.modes.OFBBlockCipher; |
| @@ -36,32 +38,34 @@ |
| } |
| } |
| |
| - public static class CBC |
| - extends JCEBlockCipher |
| - { |
| - public CBC() |
| - { |
| - super(new CBCBlockCipher(new AESFastEngine()), 128); |
| - } |
| - } |
| - |
| - static public class CFB |
| - extends JCEBlockCipher |
| - { |
| - public CFB() |
| - { |
| - super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128); |
| - } |
| - } |
| - |
| - static public class OFB |
| - extends JCEBlockCipher |
| - { |
| - public OFB() |
| - { |
| - super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class CBC |
| + // extends JCEBlockCipher |
| + // { |
| + // public CBC() |
| + // { |
| + // super(new CBCBlockCipher(new AESFastEngine()), 128); |
| + // } |
| + // } |
| + // |
| + // static public class CFB |
| + // extends JCEBlockCipher |
| + // { |
| + // public CFB() |
| + // { |
| + // super(new BufferedBlockCipher(new CFBBlockCipher(new AESFastEngine(), 128)), 128); |
| + // } |
| + // } |
| + // |
| + // static public class OFB |
| + // extends JCEBlockCipher |
| + // { |
| + // public OFB() |
| + // { |
| + // super(new BufferedBlockCipher(new OFBBlockCipher(new AESFastEngine(), 128)), 128); |
| + // } |
| + // } |
| + // END android-removed |
| |
| static public class Wrap |
| extends WrapCipherSpi |
| @@ -72,14 +76,16 @@ |
| } |
| } |
| |
| - public static class RFC3211Wrap |
| - extends WrapCipherSpi |
| - { |
| - public RFC3211Wrap() |
| - { |
| - super(new RFC3211WrapEngine(new AESEngine()), 16); |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class RFC3211Wrap |
| + // extends WrapCipherSpi |
| + // { |
| + // public RFC3211Wrap() |
| + // { |
| + // super(new RFC3211WrapEngine(new AESEngine()), 16); |
| + // } |
| + // } |
| + // END android-removed |
| |
| public static class KeyGen |
| extends JCEKeyGenerator |
| @@ -95,70 +101,72 @@ |
| } |
| } |
| |
| - public static class KeyGen128 |
| - extends KeyGen |
| - { |
| - public KeyGen128() |
| - { |
| - super(128); |
| - } |
| - } |
| - |
| - public static class KeyGen192 |
| - extends KeyGen |
| - { |
| - public KeyGen192() |
| - { |
| - super(192); |
| - } |
| - } |
| - |
| - public static class KeyGen256 |
| - extends KeyGen |
| - { |
| - public KeyGen256() |
| - { |
| - super(256); |
| - } |
| - } |
| - |
| - public static class AlgParamGen |
| - extends JDKAlgorithmParameterGenerator |
| - { |
| - protected void engineInit( |
| - AlgorithmParameterSpec genParamSpec, |
| - SecureRandom random) |
| - throws InvalidAlgorithmParameterException |
| - { |
| - throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation."); |
| - } |
| - |
| - protected AlgorithmParameters engineGenerateParameters() |
| - { |
| - byte[] iv = new byte[16]; |
| - |
| - if (random == null) |
| - { |
| - random = new SecureRandom(); |
| - } |
| - |
| - random.nextBytes(iv); |
| - |
| - AlgorithmParameters params; |
| - |
| - try |
| - { |
| - params = AlgorithmParameters.getInstance("AES", "BC"); |
| - params.init(new IvParameterSpec(iv)); |
| - } |
| - catch (Exception e) |
| - { |
| - throw new RuntimeException(e.getMessage()); |
| - } |
| - |
| - return params; |
| - } |
| - } |
| + // BEGIN android-removed |
| + // public static class KeyGen128 |
| + // extends KeyGen |
| + // { |
| + // public KeyGen128() |
| + // { |
| + // super(128); |
| + // } |
| + // } |
| + // |
| + // public static class KeyGen192 |
| + // extends KeyGen |
| + // { |
| + // public KeyGen192() |
| + // { |
| + // super(192); |
| + // } |
| + // } |
| + // |
| + // public static class KeyGen256 |
| + // extends KeyGen |
| + // { |
| + // public KeyGen256() |
| + // { |
| + // super(256); |
| + // } |
| + // } |
| + // |
| + // public static class AlgParamGen |
| + // extends JDKAlgorithmParameterGenerator |
| + // { |
| + // protected void engineInit( |
| + // AlgorithmParameterSpec genParamSpec, |
| + // SecureRandom random) |
| + // throws InvalidAlgorithmParameterException |
| + // { |
| + // throw new InvalidAlgorithmParameterException("No supported AlgorithmParameterSpec for AES parameter generation."); |
| + // } |
| + // |
| + // protected AlgorithmParameters engineGenerateParameters() |
| + // { |
| + // byte[] iv = new byte[16]; |
| + // |
| + // if (random == null) |
| + // { |
| + // random = new SecureRandom(); |
| + // } |
| + // |
| + // random.nextBytes(iv); |
| + // |
| + // AlgorithmParameters params; |
| + // |
| + // try |
| + // { |
| + // params = AlgorithmParameters.getInstance("AES", "BC"); |
| + // params.init(new IvParameterSpec(iv)); |
| + // } |
| + // catch (Exception e) |
| + // { |
| + // throw new RuntimeException(e.getMessage()); |
| + // } |
| + // |
| + // return params; |
| + // } |
| + // } |
| + // END android-removed |
| |
| public static class AlgParams |
| extends JDKAlgorithmParameters.IVAlgorithmParameters |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AESMappings.java bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AESMappings.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/jce/provider/symmetric/AESMappings.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/jce/provider/symmetric/AESMappings.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -26,55 +26,63 @@ |
| put("Alg.Alias.AlgorithmParameters." + NISTObjectIdentifiers.id_aes192_CBC, "AES"); |
| put("Alg.Alias.AlgorithmParameters." + NISTObjectIdentifiers.id_aes256_CBC, "AES"); |
| |
| - put("AlgorithmParameterGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$AlgParamGen"); |
| - put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES128, "AES"); |
| - put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES192, "AES"); |
| - put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES256, "AES"); |
| - put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "AES"); |
| - put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "AES"); |
| - put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "AES"); |
| + // BEGIN android-removed |
| + // put("AlgorithmParameterGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$AlgParamGen"); |
| + // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES128, "AES"); |
| + // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES192, "AES"); |
| + // put("Alg.Alias.AlgorithmParameterGenerator." + wrongAES256, "AES"); |
| + // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "AES"); |
| + // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "AES"); |
| + // put("Alg.Alias.AlgorithmParameterGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "AES"); |
| + // END android-removed |
| |
| put("Cipher.AES", "org.bouncycastle.jce.provider.symmetric.AES$ECB"); |
| put("Alg.Alias.Cipher." + wrongAES128, "AES"); |
| put("Alg.Alias.Cipher." + wrongAES192, "AES"); |
| put("Alg.Alias.Cipher." + wrongAES256, "AES"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$ECB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$CBC"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$OFB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB"); |
| - put("Cipher." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$CFB"); |
| + // BEGIN android-changed |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_ECB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_ECB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_ECB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_CBC, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_CBC, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_CBC, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_OFB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_OFB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_OFB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_CFB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_CFB, "AES"); |
| + put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_CFB, "AES"); |
| + // END android-changed |
| put("Cipher.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$Wrap"); |
| put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes128_wrap, "AESWRAP"); |
| put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes192_wrap, "AESWRAP"); |
| put("Alg.Alias.Cipher." + NISTObjectIdentifiers.id_aes256_wrap, "AESWRAP"); |
| - put("Cipher.AESRFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.AES$RFC3211Wrap"); |
| + // BEGIN android-removed |
| + // put("Cipher.AESRFC3211WRAP", "org.bouncycastle.jce.provider.symmetric.AES$RFC3211Wrap"); |
| + // END android-removed |
| |
| put("KeyGenerator.AES", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen"); |
| - put("KeyGenerator.2.16.840.1.101.3.4.2", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| - put("KeyGenerator.2.16.840.1.101.3.4.22", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| - put("KeyGenerator.2.16.840.1.101.3.4.42", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| - put("KeyGenerator.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| - put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // BEGIN android-removed |
| + // put("KeyGenerator.2.16.840.1.101.3.4.2", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| + // put("KeyGenerator.2.16.840.1.101.3.4.22", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| + // put("KeyGenerator.2.16.840.1.101.3.4.42", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_ECB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CBC, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_OFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_CFB, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // put("KeyGenerator.AESWRAP", "org.bouncycastle.jce.provider.symmetric.AES$KeyGen"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes128_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen128"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes192_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen192"); |
| + // put("KeyGenerator." + NISTObjectIdentifiers.id_aes256_wrap, "org.bouncycastle.jce.provider.symmetric.AES$KeyGen256"); |
| + // END android-removed |
| } |
| } |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/x509/X509Util.java bcprov-jdk16-145/org/bouncycastle/x509/X509Util.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/x509/X509Util.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/x509/X509Util.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -43,8 +43,10 @@ |
| |
| static |
| { |
| - algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption); |
| - algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption); |
| + // BEGIN android-removed |
| + // algorithms.put("MD2WITHRSAENCRYPTION", PKCSObjectIdentifiers.md2WithRSAEncryption); |
| + // algorithms.put("MD2WITHRSA", PKCSObjectIdentifiers.md2WithRSAEncryption); |
| + // END android-removed |
| algorithms.put("MD5WITHRSAENCRYPTION", PKCSObjectIdentifiers.md5WithRSAEncryption); |
| algorithms.put("MD5WITHRSA", PKCSObjectIdentifiers.md5WithRSAEncryption); |
| algorithms.put("SHA1WITHRSAENCRYPTION", PKCSObjectIdentifiers.sha1WithRSAEncryption); |
| @@ -106,19 +108,29 @@ |
| // |
| // explicit params |
| // |
| - AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA1WITHRSAANDMGF1", creatPSSParams(sha1AlgId, 20)); |
| |
| - AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha224, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA224WITHRSAANDMGF1", creatPSSParams(sha224AlgId, 28)); |
| |
| - AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA256WITHRSAANDMGF1", creatPSSParams(sha256AlgId, 32)); |
| |
| - AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha384, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA384WITHRSAANDMGF1", creatPSSParams(sha384AlgId, 48)); |
| |
| - AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, new DERNull()); |
| + // BEGIN android-changed |
| + AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha512, DERNull.INSTANCE); |
| + // END android-changed |
| params.put("SHA512WITHRSAANDMGF1", creatPSSParams(sha512AlgId, 64)); |
| } |
| |
| @@ -161,7 +173,9 @@ |
| } |
| else |
| { |
| - return new AlgorithmIdentifier(sigOid, new DERNull()); |
| + // BEGIN android-changed |
| + return new AlgorithmIdentifier(sigOid, DERNull.INSTANCE); |
| + // END android-changed |
| } |
| } |
| |
| diff -Naur bcprov-jdk16-145.orig/org/bouncycastle/x509/extension/X509ExtensionUtil.java bcprov-jdk16-145/org/bouncycastle/x509/extension/X509ExtensionUtil.java |
| --- bcprov-jdk16-145.orig/org/bouncycastle/x509/extension/X509ExtensionUtil.java 2010-01-11 21:46:14.000000000 +0000 |
| +++ bcprov-jdk16-145/org/bouncycastle/x509/extension/X509ExtensionUtil.java 2011-09-03 18:25:17.000000000 +0000 |
| @@ -62,7 +62,9 @@ |
| { |
| GeneralName genName = GeneralName.getInstance(it.nextElement()); |
| List list = new ArrayList(); |
| - list.add(new Integer(genName.getTagNo())); |
| + // BEGIN android-changed |
| + list.add(Integer.valueOf(genName.getTagNo())); |
| + // END android-changed |
| switch (genName.getTagNo()) |
| { |
| case GeneralName.ediPartyName: |