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

Issue 11571059: Add net/android/keystore.h (Closed)

Created:
8 years ago by digit1
Modified:
7 years, 10 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org
Base URL:
http://git.chromium.org/chromium/src.git@master
Visibility:
Public.

Description

This patch adds some Android-support code to allow the network stack to use platform-specific private key objects to perform signing in the context of SSL handshakes which require a client certificate. More specifically: - Add net/android/keystore.h, which provides native functions to operate on JNI references pointing to java.security.PrivateKey objects provided by the platform. I.e.: net::android::GetPrivateKeyType() net::android::SignWithPrivateKey() Also provide a function that can get the system's own EVP_PKEY* handle corresponding to a given PrivateKey object. This uses reflection and should *only* be used for RSA private keys when running on Android 4.0 and 4.1, in order to route around a platform bug that was only fixed in 4.2. net::android::GetOpenSSLSytstemHandleForPrivateKey() See the comments in this source file for mode details: net/android/java/org/chromium/net/AndroidKeyStore.java - Add net/android/keystore_openssl.h, which provides a function that can wrap an existing PrivateKey JNI reference around an OpenSSL EVP_PKEY object which uses custom DSA/RSA/ECDSA methods to perform signing as expected to handle client certificates. net::android::GetOpenSSLPrivateKeyWrapper() - Add relevant unit tests for the new functions. Note that the unit test comes with its own Java helper function, which is used to create a platform PrivateKey object from encoded PKCS#8 private key data. This is called from the native unit test, but does not constitute a new Java test (AndroidKeyStoreTestUtil.java). - Add corresponding new test key files under net/data/ssl/certificates/, and their generation script in net/data/ssl/scripts/. - Add net/android/private_key_type_list.h which is used both from C++ and Java to define the list of supported private key types used by this code. - Minor improvements: Add a "release()" method to crypto::ScopedOpenSSL, add missing BASE_EXPORT to one base/android/jni_array.h function declaration. BUG=166642 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=181741

Patch Set 1 #

Patch Set 2 : new version with simpler signing support #

Total comments: 22

Patch Set 3 : fix small issues only #

Total comments: 1

Patch Set 4 : First real implementation - RSA only #

Total comments: 1

Patch Set 5 : Add DSA + ECDSA test keys and signing tests #

Total comments: 30

Patch Set 6 : Add DSA/ECDSA methods + reflection hack for Android 4.0-4.1 #

Patch Set 7 : Appease the angry 'findbugs' gods. #

Total comments: 46

Patch Set 8 : PEM data files + RSA_size() / DSA_size() support. #

Total comments: 7

Patch Set 9 : Add ECDSA_size() support + fix checks against DSA_size() + ECDSA_size() #

Patch Set 10 : Fix bad include #

Patch Set 11 : Simple rebase #

Patch Set 12 : fix typo #

Total comments: 6

Patch Set 13 : removed non-const references #

Total comments: 69

Patch Set 14 : addressing ryan's remarks. #

Total comments: 8

Patch Set 15 : addressing style issues #

Total comments: 5

Patch Set 16 : git cl try #

Total comments: 18

Patch Set 17 : address marcus' nits. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2325 lines, -2 lines) Patch
M base/android/jni_array.h View 1 1 chunk +1 line, -1 line 0 comments Download
M crypto/openssl_util.h View 1 2 3 4 5 2 chunks +6 lines, -1 line 0 comments Download
A net/android/java/PrivateKeyType.template View 1 2 3 4 5 1 chunk +10 lines, -0 lines 0 comments Download
A net/android/java/src/org/chromium/net/AndroidKeyStore.java View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +308 lines, -0 lines 0 comments Download
A net/android/javatests/src/org/chromium/net/AndroidKeyStoreTestUtil.java View 1 2 3 4 5 6 1 chunk +67 lines, -0 lines 0 comments Download
A net/android/keystore.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +117 lines, -0 lines 0 comments Download
A net/android/keystore.cc View 1 2 3 4 5 6 7 8 1 chunk +130 lines, -0 lines 0 comments Download
A net/android/keystore_openssl.h View 1 2 3 4 5 6 7 1 chunk +48 lines, -0 lines 0 comments Download
A net/android/keystore_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +699 lines, -0 lines 0 comments Download
A net/android/keystore_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +725 lines, -0 lines 0 comments Download
M net/android/net_jni_registrar.cc View 1 2 chunks +2 lines, -0 lines 0 comments Download
A net/android/private_key_type_list.h View 1 2 3 4 5 6 7 1 chunk +12 lines, -0 lines 0 comments Download
M net/base/openssl_private_key_store.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M net/data/ssl/certificates/README View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +9 lines, -0 lines 0 comments Download
A net/data/ssl/certificates/android-test-key-dsa.pem View 1 2 3 4 5 6 7 1 chunk +20 lines, -0 lines 0 comments Download
A net/data/ssl/certificates/android-test-key-dsa-public.pem View 1 2 3 4 5 6 7 1 chunk +20 lines, -0 lines 0 comments Download
A net/data/ssl/certificates/android-test-key-ecdsa.pem View 1 2 3 4 5 6 7 1 chunk +8 lines, -0 lines 0 comments Download
A net/data/ssl/certificates/android-test-key-ecdsa-public.pem View 1 2 3 4 5 6 7 1 chunk +4 lines, -0 lines 0 comments Download
A net/data/ssl/certificates/android-test-key-rsa.pem View 1 2 3 4 5 6 7 1 chunk +27 lines, -0 lines 0 comments Download
A net/data/ssl/scripts/generate-android-test-keys.sh View 1 2 3 4 5 6 7 1 chunk +56 lines, -0 lines 0 comments Download
M net/net.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 9 chunks +50 lines, -0 lines 0 comments Download
M net/socket/ssl_client_socket_openssl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 37 (0 generated)
digit1
8 years ago (2012-12-19 14:22:31 UTC) #1
digit1
I've updated the CL description, and added Ryan as a reviewer to get his initial ...
7 years, 11 months ago (2013-01-18 15:17:08 UTC) #2
Ryan Sleevi
I am not really comfortable with this approach. 1) net/ should not have any UI-facing ...
7 years, 11 months ago (2013-01-18 20:05:47 UTC) #3
palmer
Everybody loves a drive-by review on Friday afternoon, right? :) https://chromiumcodereview.appspot.com/11571059/diff/3001/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://chromiumcodereview.appspot.com/11571059/diff/3001/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode53 ...
7 years, 11 months ago (2013-01-19 01:43:11 UTC) #4
digit1
I've uploaded a second patch that fixes the minor issues. I'm now preparing a new ...
7 years, 11 months ago (2013-01-21 13:35:35 UTC) #5
Ryan Sleevi
Like I said, I'm not really comfortable with this approach. This definitely seems like it ...
7 years, 11 months ago (2013-01-22 22:03:45 UTC) #6
digit1
At last, patch set 4 contains the first working version of signing support through the ...
7 years, 11 months ago (2013-01-25 14:22:11 UTC) #7
digit1
https://chromiumcodereview.appspot.com/11571059/diff/10007/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://chromiumcodereview.appspot.com/11571059/diff/10007/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode110 net/android/java/src/org/chromium/net/AndroidKeyStore.java:110: // throw NoSuchAlgorithmException on Android 4.2.1. Fixed in 4.2 ...
7 years, 11 months ago (2013-01-25 14:23:41 UTC) #8
digit1
Patch set 5 adds test DSA and ECDSA key pairs, and corresponding signing tests. Except ...
7 years, 11 months ago (2013-01-25 16:56:03 UTC) #9
Ryan Sleevi
https://chromiumcodereview.appspot.com/11571059/diff/16001/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://chromiumcodereview.appspot.com/11571059/diff/16001/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode31 net/android/java/src/org/chromium/net/AndroidKeyStore.java:31: * PrivateKey object. Comment is wrong. It's not just ...
7 years, 11 months ago (2013-01-26 01:51:57 UTC) #10
palmer
https://chromiumcodereview.appspot.com/11571059/diff/16001/crypto/openssl_util.h File crypto/openssl_util.h (right): https://chromiumcodereview.appspot.com/11571059/diff/16001/crypto/openssl_util.h#newcode14 crypto/openssl_util.h:14: // A helper class that takes care of destroying ...
7 years, 11 months ago (2013-01-26 02:14:20 UTC) #11
digit1
https://chromiumcodereview.appspot.com/11571059/diff/16001/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://chromiumcodereview.appspot.com/11571059/diff/16001/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode32 net/android/java/src/org/chromium/net/AndroidKeyStore.java:32: * Assumes that initSignatureForKey() was called previously on the ...
7 years, 10 months ago (2013-01-28 10:16:30 UTC) #12
ppi
Minor remarks below - great to see the EVP_PKEY wrapper working! https://chromiumcodereview.appspot.com/11571059/diff/16001/net/android/keystore_unittest.cc File net/android/keystore_unittest.cc (right): ...
7 years, 10 months ago (2013-01-29 17:57:10 UTC) #13
digit1
Patch set 6 finally looks like something acceptable, compared to the previous version: - The ...
7 years, 10 months ago (2013-01-29 23:17:39 UTC) #14
agl
LGTM I'm sorry that you had to see that side of OpenSSL :) Currently I ...
7 years, 10 months ago (2013-01-30 14:28:53 UTC) #15
digit1
On 2013/01/30 14:28:53, agl wrote: > LGTM > > I'm sorry that you had to ...
7 years, 10 months ago (2013-01-30 16:50:29 UTC) #16
digit1
By the way, testing shows that the reflection hack fails on some Android 4.0 devices. ...
7 years, 10 months ago (2013-01-30 16:55:01 UTC) #17
Ryan Sleevi
https://chromiumcodereview.appspot.com/11571059/diff/20004/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://chromiumcodereview.appspot.com/11571059/diff/20004/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode46 net/android/java/src/org/chromium/net/AndroidKeyStore.java:46: public static byte[] signWithPrivateKey(PrivateKey privateKey, perhaps name this "rawSignWithPrivateKey", ...
7 years, 10 months ago (2013-01-31 03:09:53 UTC) #18
digit1
https://chromiumcodereview.appspot.com/11571059/diff/20004/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://chromiumcodereview.appspot.com/11571059/diff/20004/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode46 net/android/java/src/org/chromium/net/AndroidKeyStore.java:46: public static byte[] signWithPrivateKey(PrivateKey privateKey, On 2013/01/31 03:09:53, Ryan ...
7 years, 10 months ago (2013-01-31 17:44:29 UTC) #19
digit1
Note that the latest patch also adds a new hack for Android 4.0 -> 4.0.3. ...
7 years, 10 months ago (2013-01-31 17:48:28 UTC) #20
palmer
https://chromiumcodereview.appspot.com/11571059/diff/35002/net/android/keystore.cc File net/android/keystore.cc (right): https://chromiumcodereview.appspot.com/11571059/diff/35002/net/android/keystore.cc#newcode106 net/android/keystore.cc:106: // ported to 64-bit environments, if ever). OK. Does ...
7 years, 10 months ago (2013-02-01 00:27:12 UTC) #21
Ryan Sleevi
I haven't reviewed the test changes. Just responding to your ECC question https://chromiumcodereview.appspot.com/11571059/diff/20004/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc ...
7 years, 10 months ago (2013-02-01 00:51:29 UTC) #22
digit1
Latest version fixes ECDSA_size() support. I also fixed the signature size checks for DSA and ...
7 years, 10 months ago (2013-02-01 21:44:36 UTC) #23
Ryan Sleevi
Comments on the diff from patchset 8, which mostly LG. I will make a full ...
7 years, 10 months ago (2013-02-01 21:50:58 UTC) #24
digit1
https://chromiumcodereview.appspot.com/11571059/diff/30019/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc (right): https://chromiumcodereview.appspot.com/11571059/diff/30019/net/android/keystore_openssl.cc#newcode231 net/android/keystore_openssl.cc:231: bool CopyBigNumFromBytes(BIGNUM& num, ok, I've fixed that. Thanks for ...
7 years, 10 months ago (2013-02-01 22:50:17 UTC) #25
Ryan Sleevi
A lot of style issues this time around, a few TODOs, and some questions below. ...
7 years, 10 months ago (2013-02-04 22:53:27 UTC) #26
digit1
https://codereview.chromium.org/11571059/diff/51001/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://codereview.chromium.org/11571059/diff/51001/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode112 net/android/java/src/org/chromium/net/AndroidKeyStore.java:112: * PrivateKey object for client certificate support. I've updated ...
7 years, 10 months ago (2013-02-05 14:31:58 UTC) #27
Ryan Sleevi
https://codereview.chromium.org/11571059/diff/51001/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc (right): https://codereview.chromium.org/11571059/diff/51001/net/android/keystore_openssl.cc#newcode506 net/android/keystore_openssl.cc:506: return s_ecdsa_ex_data_index; On 2013/02/05 14:31:58, digit1 wrote: > On ...
7 years, 10 months ago (2013-02-06 22:48:02 UTC) #28
digit1
https://codereview.chromium.org/11571059/diff/59001/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc (right): https://codereview.chromium.org/11571059/diff/59001/net/android/keystore_openssl.cc#newcode196 net/android/keystore_openssl.cc:196: private_key, message_piece, &result)) { On 2013/02/06 22:48:02, Ryan Sleevi ...
7 years, 10 months ago (2013-02-07 17:05:51 UTC) #29
digit1
https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc (right): https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_openssl.cc#newcode230 net/android/keystore_openssl.cc:230: /* .flags = */ RSA_METHOD_FLAG_NO_CHECK, Fyi, this issue was ...
7 years, 10 months ago (2013-02-07 17:29:02 UTC) #30
Ryan Sleevi
LGTM, mod nit https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc (right): https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_openssl.cc#newcode369 net/android/keystore_openssl.cc:369: &signature)) { style nit: still wrong ...
7 years, 10 months ago (2013-02-08 22:43:32 UTC) #31
digit1
https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_openssl.cc File net/android/keystore_openssl.cc (right): https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_openssl.cc#newcode369 net/android/keystore_openssl.cc:369: &signature)) { Oh damn, done. thanks. https://codereview.chromium.org/11571059/diff/61005/net/android/keystore_unittest.cc File net/android/keystore_unittest.cc ...
7 years, 10 months ago (2013-02-11 09:05:56 UTC) #32
digit1
I just added bulach and yfriedman as reviewers, since they are base/android OWNERS. Guys, can ...
7 years, 10 months ago (2013-02-11 09:07:14 UTC) #33
bulach
lgtm, thanks digit! just some drive-by suggestions below: https://codereview.chromium.org/11571059/diff/73016/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://codereview.chromium.org/11571059/diff/73016/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode31 net/android/java/src/org/chromium/net/AndroidKeyStore.java:31: private ...
7 years, 10 months ago (2013-02-11 11:59:05 UTC) #34
digit1
https://codereview.chromium.org/11571059/diff/73016/net/android/java/src/org/chromium/net/AndroidKeyStore.java File net/android/java/src/org/chromium/net/AndroidKeyStore.java (right): https://codereview.chromium.org/11571059/diff/73016/net/android/java/src/org/chromium/net/AndroidKeyStore.java#newcode31 net/android/java/src/org/chromium/net/AndroidKeyStore.java:31: private static final String TAG = AndroidKeyStore.class.getName(); On 2013/02/11 ...
7 years, 10 months ago (2013-02-11 14:03:45 UTC) #35
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/digit@chromium.org/11571059/64006
7 years, 10 months ago (2013-02-11 17:08:29 UTC) #36
commit-bot: I haz the power
7 years, 10 months ago (2013-02-11 20:13:46 UTC) #37
Message was sent while issue was closed.
Change committed as 181741

Powered by Google App Engine
This is Rietveld 408576698