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

Side by Side Diff: content/child/webcrypto/openssl/rsa_key_openssl.cc

Issue 444793003: [style] Replace various "X() != 1" checks with "!X()". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/child/webcrypto/openssl/rsa_oaep_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/webcrypto/openssl/rsa_key_openssl.h" 5 #include "content/child/webcrypto/openssl/rsa_key_openssl.h"
6 6
7 #include <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/pkcs12.h> 8 #include <openssl/pkcs12.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 rsa->dmq1 = CreateBIGNUM(params.dq); 176 rsa->dmq1 = CreateBIGNUM(params.dq);
177 rsa->iqmp = CreateBIGNUM(params.qi); 177 rsa->iqmp = CreateBIGNUM(params.qi);
178 178
179 if (!rsa->n || !rsa->e || !rsa->d || !rsa->p || !rsa->q || !rsa->dmp1 || 179 if (!rsa->n || !rsa->e || !rsa->d || !rsa->p || !rsa->q || !rsa->dmp1 ||
180 !rsa->dmq1 || !rsa->iqmp) { 180 !rsa->dmq1 || !rsa->iqmp) {
181 return Status::OperationError(); 181 return Status::OperationError();
182 } 182 }
183 183
184 // TODO(eroman): This should really be a DataError, however for compatibility 184 // TODO(eroman): This should really be a DataError, however for compatibility
185 // with NSS it is an OperationError. 185 // with NSS it is an OperationError.
186 if (1 != RSA_check_key(rsa.get())) 186 if (!RSA_check_key(rsa.get()))
187 return Status::OperationError(); 187 return Status::OperationError();
188 188
189 // Create a corresponding EVP_PKEY. 189 // Create a corresponding EVP_PKEY.
190 crypto::ScopedEVP_PKEY pkey(EVP_PKEY_new()); 190 crypto::ScopedEVP_PKEY pkey(EVP_PKEY_new());
191 if (!pkey || !EVP_PKEY_set1_RSA(pkey.get(), rsa.get())) 191 if (!pkey || !EVP_PKEY_set1_RSA(pkey.get(), rsa.get()))
192 return Status::OperationError(); 192 return Status::OperationError();
193 193
194 return CreateWebCryptoPrivateKey(pkey.Pass(), 194 return CreateWebCryptoPrivateKey(pkey.Pass(),
195 algorithm.id(), 195 algorithm.id(),
196 algorithm.rsaHashedImportParams()->hash(), 196 algorithm.rsaHashedImportParams()->hash(),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return Status::DataError(); 352 return Status::DataError();
353 353
354 if (EVP_PKEY_id(private_key.get()) != EVP_PKEY_RSA) 354 if (EVP_PKEY_id(private_key.get()) != EVP_PKEY_RSA)
355 return Status::DataError(); // Data did not define an RSA key. 355 return Status::DataError(); // Data did not define an RSA key.
356 356
357 // Verify the parameters of the key (because EVP_PKCS82PKEY() happily imports 357 // Verify the parameters of the key (because EVP_PKCS82PKEY() happily imports
358 // invalid keys). 358 // invalid keys).
359 crypto::ScopedRSA rsa(EVP_PKEY_get1_RSA(private_key.get())); 359 crypto::ScopedRSA rsa(EVP_PKEY_get1_RSA(private_key.get()));
360 if (!rsa.get()) 360 if (!rsa.get())
361 return Status::ErrorUnexpected(); 361 return Status::ErrorUnexpected();
362 if (1 != RSA_check_key(rsa.get())) 362 if (!RSA_check_key(rsa.get()))
363 return Status::DataError(); 363 return Status::DataError();
364 364
365 // TODO(eroman): Validate the algorithm OID against the webcrypto provided 365 // TODO(eroman): Validate the algorithm OID against the webcrypto provided
366 // hash. http://crbug.com/389400 366 // hash. http://crbug.com/389400
367 367
368 return CreateWebCryptoPrivateKey(private_key.Pass(), 368 return CreateWebCryptoPrivateKey(private_key.Pass(),
369 algorithm.id(), 369 algorithm.id(),
370 algorithm.rsaHashedImportParams()->hash(), 370 algorithm.rsaHashedImportParams()->hash(),
371 extractable, 371 extractable,
372 usage_mask, 372 usage_mask,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 return Status::Success(); 495 return Status::Success();
496 496
497 default: 497 default:
498 return Status::ErrorUnexpected(); 498 return Status::ErrorUnexpected();
499 } 499 }
500 } 500 }
501 501
502 } // namespace webcrypto 502 } // namespace webcrypto
503 503
504 } // namespace content 504 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/openssl/rsa_oaep_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698