merge in jb-mr0-release history after reset to jb-dev
diff --git a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
index 687c57e..b11e30a 100644
--- a/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
+++ b/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
@@ -2698,6 +2698,10 @@
         JNI_TRACE("ssl=%p SSL_use_OpenSSL_PrivateKey => error", ssl);
         return;
     }
+    // SSL_use_PrivateKey expects to take ownership of the EVP_PKEY,
+    // but we have an external reference from the caller such as an
+    // OpenSSLKey, so we manually increment the reference count here.
+    CRYPTO_add(&pkey->references,+1,CRYPTO_LOCK_EVP_PKEY);
 
     JNI_TRACE("ssl=%p SSL_use_OpenSSL_PrivateKey => ok", ssl);
 }
diff --git a/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java b/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
index 39423ee..7886e3e 100644
--- a/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
+++ b/luni/src/test/java/org/apache/harmony/security/tests/java/security/Signature2Test.java
@@ -37,6 +37,7 @@
 import java.security.spec.DSAParameterSpec;
 import java.util.HashSet;
 import java.util.Set;
+import libcore.java.security.StandardNames;
 
 public class Signature2Test extends junit.framework.TestCase {
 
@@ -467,10 +468,17 @@
         } catch (IllegalArgumentException expected) {
         }
 
-        try {
-            sig.verify(signature, signature.length, 0);
-            fail();
-        } catch (SignatureException expected) {
+        if (StandardNames.IS_RI) {
+            try {
+                sig.verify(signature, signature.length, 0);
+                fail();
+            } catch (SignatureException expected) {
+            }
+        } else {
+            // Calling Signature.verify a second time should not throw
+            // http://code.google.com/p/android/issues/detail?id=34933
+            boolean verified = sig.verify(signature, signature.length, 0);
+            assertFalse(verified);
         }
 
         try {