Remove a workaround for an openssl bug that's been fixed upstream.

The >= versus > bug was fixed in openssl somewhere between .98g and .98k (we
don't have _all_ versions conveniently lying around), and our removal of
the disjunct was irrelevant. Call the now-correct upstream code instead of
manually inlining and hacking it.

Also rename BN_lshift to BN_shift, since it handles both left and right shifts.
diff --git a/libcore/math/src/main/java/java/math/BigInt.java b/libcore/math/src/main/java/java/math/BigInt.java
index 3ba1da2..4d1e18e 100644
--- a/libcore/math/src/main/java/java/math/BigInt.java
+++ b/libcore/math/src/main/java/java/math/BigInt.java
@@ -256,12 +256,12 @@
     // n > 0: shift left (multiply)
     public static BigInt shift(BigInt a, int n) {
         BigInt r = newBigInt();
-        Check(NativeBN.BN_lshift(r.bignum, a.bignum, n));
+        Check(NativeBN.BN_shift(r.bignum, a.bignum, n));
         return r;
     }
 
     public void shift(int n) {
-        Check(NativeBN.BN_lshift(this.bignum, this.bignum, n));
+        Check(NativeBN.BN_shift(this.bignum, this.bignum, n));
     }
 
     public void addPositiveInt(int w) {
diff --git a/libcore/openssl/src/main/java/org/openssl/NativeBN.java b/libcore/openssl/src/main/java/org/openssl/NativeBN.java
index fd796f8..9691204 100644
--- a/libcore/openssl/src/main/java/org/openssl/NativeBN.java
+++ b/libcore/openssl/src/main/java/org/openssl/NativeBN.java
@@ -96,11 +96,8 @@
     // op: 0 = reset; 1 = set; -1 = flip
     // uses BN_set_bit(), BN_clear_bit() and BN_is_bit_set()
 
-    public static native boolean BN_lshift(int r, int a, int n);
-    // int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
-//    public static native int BN_rshift(BigInteger r, BigInteger a, int n);
-    // int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
-
+    public static native boolean BN_shift(int r, int a, int n);
+    // int BN_shift(BIGNUM *r, const BIGNUM *a, int n);
 
     public static native boolean BN_add_word(int a, int w);
     // ATTENTION: w is treated as unsigned.
diff --git a/libcore/openssl/src/main/native/BNInterface.c b/libcore/openssl/src/main/native/BNInterface.c
index ff2a2ae..8ac2395 100644
--- a/libcore/openssl/src/main/native/BNInterface.c
+++ b/libcore/openssl/src/main/native/BNInterface.c
@@ -509,72 +509,13 @@
 }
 
 /**
- * public static native int BN_lshift(int, int, int)
+ * public static native int BN_shift(int, int, int)
  */
-static jboolean NativeBN_BN_lshift(JNIEnv* env, jclass cls, BIGNUM* r, BIGNUM* a, int n) {
-// LOGD("NativeBN_BN_lshift %p %p %d", r, a, n);
+static jboolean NativeBN_BN_shift(JNIEnv* env, jclass cls, BIGNUM* r, BIGNUM* a, int n) {
     if (!twoValidHandles(env, r, a)) return FALSE;
-    if (n >= 0) return BN_lshift(r, a, n);
-
-    n = -n;
-//    return BN_rshift(r, a, n);
-// Following code insourced from bn_shift.c in order to have bug fixed:
-// FIXME: Should report to openssl team!!!
-
-	int i,j,nw,lb,rb;
-	BN_ULONG *t,*f;
-	BN_ULONG l,tmp;
-
-	bn_check_top(r);
-	bn_check_top(a);
-
-	nw=n/BN_BITS2;
-	rb=n%BN_BITS2;
-	lb=BN_BITS2-rb;
-// Changed "nw > a->top || a->top == 0" to nw >= a->top" as considering this a bug:
-	if (nw >= a->top)
-		{
-		BN_zero(r);
-		return(1);
-		}
-	if (r != a)
-		{
-		r->neg=a->neg;
-		if (bn_wexpand(r,a->top-nw+1) == NULL) return(0);
-		}
-	else
-		{
-		if (n == 0)
-			return 1; /* or the copying loop will go berserk */
-		}
-
-	f= &(a->d[nw]);
-	t=r->d;
-	j=a->top-nw;
-	r->top=j;
-
-	if (rb == 0)
-		{
-		for (i=j; i != 0; i--)
-			*(t++)= *(f++);
-		}
-	else
-		{
-		l= *(f++);
-		for (i=j-1; i != 0; i--)
-			{
-			tmp =(l>>rb)&BN_MASK2;
-			l= *(f++);
-			*(t++) =(tmp|(l<<lb))&BN_MASK2;
-			}
-		*(t++) =(l>>rb)&BN_MASK2;
-		}
-	bn_correct_top(r);
-	bn_check_top(r);
-	return(1);
+    return (n >= 0) ? BN_lshift(r, a, n) : BN_rshift(r, a, -n);
 }
 
-
 /**
  * public static native boolean BN_add_word(int, int)
  */
@@ -698,7 +639,7 @@
 static jboolean NativeBN_BN_generate_prime_ex(JNIEnv* env, jclass cls, BIGNUM* ret, int bits, jboolean safe,
         BIGNUM* add, BIGNUM* rem, jint cb) {
     if (!oneValidHandle(env, ret)) return FALSE;
-    return BN_generate_prime_ex(ret, bits, safe, add, rem, cb);
+    return BN_generate_prime_ex(ret, bits, safe, add, rem, (BN_GENCB*) cb);
 }
 
 /**
@@ -706,7 +647,7 @@
  */
 static jboolean NativeBN_BN_is_prime_ex(JNIEnv* env, jclass cls, BIGNUM* p, int nchecks, BN_CTX* ctx, jint cb) {
     if (!oneValidHandle(env, p)) return FALSE;
-    return BN_is_prime_ex(p, nchecks, ctx, cb);
+    return BN_is_prime_ex(p, nchecks, ctx, (BN_GENCB*) cb);
 }
 
 
@@ -740,7 +681,7 @@
    { "bitLength", "(I)I", (void*)NativeBN_bitLength },
    { "BN_is_bit_set", "(II)Z", (void*)NativeBN_BN_is_bit_set },
    { "modifyBit", "(III)Z", (void*)NativeBN_modifyBit },
-   { "BN_lshift", "(III)Z", (void*)NativeBN_BN_lshift },
+   { "BN_shift", "(III)Z", (void*)NativeBN_BN_shift },
    { "BN_add_word", "(II)Z", (void*)NativeBN_BN_add_word },
    { "BN_sub_word", "(II)Z", (void*)NativeBN_BN_sub_word },
    { "BN_mul_word", "(II)Z", (void*)NativeBN_BN_mul_word },