Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1796)

Unified Diff: net/android/keystore_unittest.cc

Issue 2301553002: Pass JavaRef to Java methods in net. (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/android/keystore_openssl.cc ('k') | net/android/network_library.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/android/keystore_unittest.cc
diff --git a/net/android/keystore_unittest.cc b/net/android/keystore_unittest.cc
index 3213731484fbd6b7d38377eb0a358906f0bc08c7..677e59aaa5c55ce93a038458f451f1ea1b3a674e 100644
--- a/net/android/keystore_unittest.cc
+++ b/net/android/keystore_unittest.cc
@@ -51,6 +51,8 @@
// Finally, it also checks that using the EVP_PKEY generated with
// GetOpenSSLPrivateKeyWrapper() works correctly.
+using base::android::JavaRef;
+
namespace net {
namespace android {
@@ -355,7 +357,7 @@ bool CompareSignatureWithOpenSSL(const base::StringPiece& message,
// same key content.
// |message| is a message.
// |result| will receive the result.
-void DoKeySigning(jobject android_key,
+void DoKeySigning(const JavaRef<jobject>& android_key,
EVP_PKEY* openssl_key,
const base::StringPiece& message,
std::string* result) {
@@ -413,7 +415,7 @@ TEST(AndroidKeyStore, GetRSAKeyModulus) {
// Retrieve the corresponding modulus through JNI
std::vector<uint8_t> modulus_java;
- ASSERT_TRUE(GetRSAKeyModulus(key_java.obj(), &modulus_java));
+ ASSERT_TRUE(GetRSAKeyModulus(key_java, &modulus_java));
// Create an OpenSSL BIGNUM from it.
crypto::ScopedBIGNUM bn(
@@ -434,8 +436,7 @@ TEST(AndroidKeyStore,GetPrivateKeyTypeRSA) {
ScopedJava rsa_key = GetRSATestKeyJava();
ASSERT_FALSE(rsa_key.is_null());
- EXPECT_EQ(PRIVATE_KEY_TYPE_RSA,
- GetPrivateKeyType(rsa_key.obj()));
+ EXPECT_EQ(PRIVATE_KEY_TYPE_RSA, GetPrivateKeyType(rsa_key));
}
TEST(AndroidKeyStore,SignWithPrivateKeyRSA) {
@@ -454,7 +455,7 @@ TEST(AndroidKeyStore,SignWithPrivateKeyRSA) {
ASSERT_EQ(36U, message.size());
std::string signature;
- DoKeySigning(rsa_key.obj(), openssl_key.get(), message, &signature);
+ DoKeySigning(rsa_key, openssl_key.get(), message, &signature);
ASSERT_TRUE(
CompareSignatureWithOpenSSL(message, signature, openssl_key.get()));
// All good.
@@ -466,8 +467,7 @@ TEST(AndroidKeyStore,SignWithWrapperKeyRSA) {
ScopedJava rsa_key = GetRSATestKeyJava();
ASSERT_FALSE(rsa_key.is_null());
- crypto::ScopedEVP_PKEY wrapper_key(
- GetOpenSSLPrivateKeyWrapper(rsa_key.obj()));
+ crypto::ScopedEVP_PKEY wrapper_key(GetOpenSSLPrivateKeyWrapper(rsa_key));
ASSERT_TRUE(wrapper_key.get() != NULL);
crypto::ScopedEVP_PKEY openssl_key(ImportPrivateKeyFile(kTestRsaKeyFile));
@@ -496,8 +496,7 @@ TEST(AndroidKeyStore,GetPrivateKeyTypeECDSA) {
ScopedJava ecdsa_key = GetECDSATestKeyJava();
ASSERT_FALSE(ecdsa_key.is_null());
- EXPECT_EQ(PRIVATE_KEY_TYPE_ECDSA,
- GetPrivateKeyType(ecdsa_key.obj()));
+ EXPECT_EQ(PRIVATE_KEY_TYPE_ECDSA, GetPrivateKeyType(ecdsa_key));
}
TEST(AndroidKeyStore,SignWithPrivateKeyECDSA) {
@@ -509,7 +508,7 @@ TEST(AndroidKeyStore,SignWithPrivateKeyECDSA) {
std::string message = kTestEcdsaHash;
std::string signature;
- DoKeySigning(ecdsa_key.obj(), openssl_key.get(), message, &signature);
+ DoKeySigning(ecdsa_key, openssl_key.get(), message, &signature);
ASSERT_TRUE(VerifyTestECDSASignature(message, signature));
}
@@ -519,8 +518,7 @@ TEST(AndroidKeyStore, SignWithWrapperKeyECDSA) {
ScopedJava ecdsa_key = GetECDSATestKeyJava();
ASSERT_FALSE(ecdsa_key.is_null());
- crypto::ScopedEVP_PKEY wrapper_key(
- GetOpenSSLPrivateKeyWrapper(ecdsa_key.obj()));
+ crypto::ScopedEVP_PKEY wrapper_key(GetOpenSSLPrivateKeyWrapper(ecdsa_key));
ASSERT_TRUE(wrapper_key.get());
crypto::ScopedEVP_PKEY openssl_key(ImportPrivateKeyFile(kTestEcdsaKeyFile));
« no previous file with comments | « net/android/keystore_openssl.cc ('k') | net/android/network_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698