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

Side by Side Diff: net/android/keystore_openssl.cc

Issue 652953002: Fix typos in a comment and log messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/android/keystore_openssl.h" 5 #include "net/android/keystore_openssl.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <openssl/bn.h> 8 #include <openssl/bn.h>
9 #include <openssl/dsa.h> 9 #include <openssl/dsa.h>
10 #include <openssl/ec.h> 10 #include <openssl/ec.h>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 int ExDataDup(CRYPTO_EX_DATA* to, 88 int ExDataDup(CRYPTO_EX_DATA* to,
89 const CRYPTO_EX_DATA* from, 89 const CRYPTO_EX_DATA* from,
90 void** from_d, 90 void** from_d,
91 int index, 91 int index,
92 long argl, 92 long argl,
93 void* argp) { 93 void* argp) {
94 CHECK_EQ((void*)NULL, *from_d); 94 CHECK_EQ((void*)NULL, *from_d);
95 return 0; 95 return 0;
96 } 96 }
97 97
98 // ExDataFree is called when one of the RSA, DSA or EC_KEY object is freed. 98 // ExDataFree is called when one of the RSA, DSA or EC_KEY objects is freed.
99 void ExDataFree(void* parent, 99 void ExDataFree(void* parent,
100 void* ptr, 100 void* ptr,
101 CRYPTO_EX_DATA* ad, 101 CRYPTO_EX_DATA* ad,
102 int index, 102 int index,
103 long argl, 103 long argl,
104 void* argp) { 104 void* argp) {
105 // Ensure the global JNI reference created with this wrapper is 105 // Ensure the global JNI reference created with this wrapper is
106 // properly destroyed with it. 106 // properly destroyed with it.
107 KeyExData *ex_data = reinterpret_cast<KeyExData*>(ptr); 107 KeyExData *ex_data = reinterpret_cast<KeyExData*>(ptr);
108 if (ex_data != NULL) { 108 if (ex_data != NULL) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // the same Android version as the "NONEwithRSA" 197 // the same Android version as the "NONEwithRSA"
198 // java.security.Signature algorithm, so the same version checks 198 // java.security.Signature algorithm, so the same version checks
199 // for GetRsaLegacyKey should work. 199 // for GetRsaLegacyKey should work.
200 OPENSSL_PUT_ERROR(RSA, sign_raw, RSA_R_UNKNOWN_PADDING_TYPE); 200 OPENSSL_PUT_ERROR(RSA, sign_raw, RSA_R_UNKNOWN_PADDING_TYPE);
201 return 0; 201 return 0;
202 } 202 }
203 203
204 // Retrieve private key JNI reference. 204 // Retrieve private key JNI reference.
205 const KeyExData *ex_data = RsaGetExData(rsa); 205 const KeyExData *ex_data = RsaGetExData(rsa);
206 if (!ex_data || !ex_data->private_key) { 206 if (!ex_data || !ex_data->private_key) {
207 LOG(WARNING) << "Null JNI reference passed to RsaMethodPrivEnc!"; 207 LOG(WARNING) << "Null JNI reference passed to RsaMethodSignRaw!";
208 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR); 208 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR);
209 return 0; 209 return 0;
210 } 210 }
211 211
212 // Pre-4.2 legacy codepath. 212 // Pre-4.2 legacy codepath.
213 if (ex_data->legacy_rsa) { 213 if (ex_data->legacy_rsa) {
214 int ret = ex_data->legacy_rsa->meth->rsa_priv_enc( 214 int ret = ex_data->legacy_rsa->meth->rsa_priv_enc(
215 in_len, in, out, ex_data->legacy_rsa, ANDROID_RSA_PKCS1_PADDING); 215 in_len, in, out, ex_data->legacy_rsa, ANDROID_RSA_PKCS1_PADDING);
216 if (ret < 0) { 216 if (ret < 0) {
217 LOG(WARNING) << "Could not sign message in RsaMethodPrivEnc!"; 217 LOG(WARNING) << "Could not sign message in RsaMethodSignRaw!";
218 // System OpenSSL will use a separate error queue, so it is still 218 // System OpenSSL will use a separate error queue, so it is still
219 // necessary to push a new error. 219 // necessary to push a new error.
220 // 220 //
221 // TODO(davidben): It would be good to also clear the system error queue 221 // TODO(davidben): It would be good to also clear the system error queue
222 // if there were some way to convince Java to do it. (Without going 222 // if there were some way to convince Java to do it. (Without going
223 // through Java, it's difficult to get a handle on a system OpenSSL 223 // through Java, it's difficult to get a handle on a system OpenSSL
224 // function; dlopen loads a second copy.) 224 // function; dlopen loads a second copy.)
225 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR); 225 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR);
226 return 0; 226 return 0;
227 } 227 }
228 *out_len = ret; 228 *out_len = ret;
229 return 1; 229 return 1;
230 } 230 }
231 231
232 base::StringPiece from_piece(reinterpret_cast<const char*>(in), in_len); 232 base::StringPiece from_piece(reinterpret_cast<const char*>(in), in_len);
233 std::vector<uint8> result; 233 std::vector<uint8> result;
234 // For RSA keys, this function behaves as RSA_private_encrypt with 234 // For RSA keys, this function behaves as RSA_private_encrypt with
235 // PKCS#1 padding. 235 // PKCS#1 padding.
236 if (!RawSignDigestWithPrivateKey(ex_data->private_key, from_piece, &result)) { 236 if (!RawSignDigestWithPrivateKey(ex_data->private_key, from_piece, &result)) {
237 LOG(WARNING) << "Could not sign message in RsaMethodPrivEnc!"; 237 LOG(WARNING) << "Could not sign message in RsaMethodSignRaw!";
238 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR); 238 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR);
239 return 0; 239 return 0;
240 } 240 }
241 241
242 size_t expected_size = static_cast<size_t>(RSA_size(rsa)); 242 size_t expected_size = static_cast<size_t>(RSA_size(rsa));
243 if (result.size() > expected_size) { 243 if (result.size() > expected_size) {
244 LOG(ERROR) << "RSA Signature size mismatch, actual: " 244 LOG(ERROR) << "RSA Signature size mismatch, actual: "
245 << result.size() << ", expected <= " << expected_size; 245 << result.size() << ", expected <= " << expected_size;
246 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR); 246 OPENSSL_PUT_ERROR(RSA, sign_raw, ERR_R_INTERNAL_ERROR);
247 return 0; 247 return 0;
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 return GetEcdsaPkeyWrapper(private_key); 574 return GetEcdsaPkeyWrapper(private_key);
575 default: 575 default:
576 LOG(WARNING) 576 LOG(WARNING)
577 << "GetOpenSSLPrivateKeyWrapper() called with invalid key type"; 577 << "GetOpenSSLPrivateKeyWrapper() called with invalid key type";
578 return crypto::ScopedEVP_PKEY(); 578 return crypto::ScopedEVP_PKEY();
579 } 579 }
580 } 580 }
581 581
582 } // namespace android 582 } // namespace android
583 } // namespace net 583 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698