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

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

Issue 877783005: Fix a style issue: Add braces around a multi-line if statement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/numerics/safe_math.h" 5 #include "base/numerics/safe_math.h"
6 #include "content/child/webcrypto/algorithm_implementation.h" 6 #include "content/child/webcrypto/algorithm_implementation.h"
7 #include "content/child/webcrypto/crypto_data.h" 7 #include "content/child/webcrypto/crypto_data.h"
8 #include "content/child/webcrypto/openssl/key_openssl.h" 8 #include "content/child/webcrypto/openssl/key_openssl.h"
9 #include "content/child/webcrypto/openssl/util_openssl.h" 9 #include "content/child/webcrypto/openssl/util_openssl.h"
10 #include "content/child/webcrypto/status.h" 10 #include "content/child/webcrypto/status.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // TODO(xun.sun): Empty password would derive random keys with 79 // TODO(xun.sun): Empty password would derive random keys with
80 // PKCS5_PBKDF2_HMAC(). 80 // PKCS5_PBKDF2_HMAC().
81 // https://code.google.com/p/chromium/issues/detail?id=449409 81 // https://code.google.com/p/chromium/issues/detail?id=449409
82 // 82 //
83 // Rejecting them until it is addressed in BoringSSL. 83 // Rejecting them until it is addressed in BoringSSL.
84 if (password.empty()) 84 if (password.empty())
85 return Status::ErrorPbkdf2EmptyPassword(); 85 return Status::ErrorPbkdf2EmptyPassword();
86 86
87 // Prevent underflowing password.size() - BoringSSL expects the size as an 87 // Prevent underflowing password.size() - BoringSSL expects the size as an
88 // signed int, and will interpret the data as a C-String if it is -1. 88 // signed int, and will interpret the data as a C-String if it is -1.
89 base::CheckedNumeric<int> password_size = password.size(); 89 base::CheckedNumeric<int> password_size = password.size();
davidben 2015/01/26 22:57:23 We can probably get rid of this now too, right? I
eroman 2015/01/26 23:06:55 Done
90 if (!password_size.IsValid()) 90 if (!password_size.IsValid())
91 return Status::ErrorDataTooLarge(); 91 return Status::ErrorDataTooLarge();
92 92
93 if (keylen_bytes == 0) 93 if (keylen_bytes == 0)
94 return Status::Success(); 94 return Status::Success();
95 95
96 const char* password_ptr = 96 const char* password_ptr =
97 password.empty() ? NULL : reinterpret_cast<const char*>(&password[0]); 97 password.empty() ? NULL : reinterpret_cast<const char*>(&password[0]);
98 98
99 if (!PKCS5_PBKDF2_HMAC(password_ptr, password_size.ValueOrDie(), 99 if (!PKCS5_PBKDF2_HMAC(password_ptr, password_size.ValueOrDie(),
100 params->salt().data(), params->salt().size(), 100 params->salt().data(), params->salt().size(),
101 params->iterations(), digest_algorithm, keylen_bytes, 101 params->iterations(), digest_algorithm, keylen_bytes,
102 &derived_bytes->front())) 102 &derived_bytes->front())) {
103 return Status::OperationError(); 103 return Status::OperationError();
104 }
104 return Status::Success(); 105 return Status::Success();
105 } 106 }
106 107
107 Status SerializeKeyForClone( 108 Status SerializeKeyForClone(
108 const blink::WebCryptoKey& key, 109 const blink::WebCryptoKey& key,
109 blink::WebVector<uint8_t>* key_data) const override { 110 blink::WebVector<uint8_t>* key_data) const override {
110 key_data->assign(SymKeyOpenSsl::Cast(key)->serialized_key_data()); 111 key_data->assign(SymKeyOpenSsl::Cast(key)->serialized_key_data());
111 return Status::Success(); 112 return Status::Success();
112 } 113 }
113 114
(...skipping 17 matching lines...) Expand all
131 132
132 } // namespace 133 } // namespace
133 134
134 AlgorithmImplementation* CreatePlatformPbkdf2Implementation() { 135 AlgorithmImplementation* CreatePlatformPbkdf2Implementation() {
135 return new Pbkdf2Implementation; 136 return new Pbkdf2Implementation;
136 } 137 }
137 138
138 } // namespace webcrypto 139 } // namespace webcrypto
139 140
140 } // namespace content 141 } // namespace content
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