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

Side by Side Diff: content/renderer/webcrypto/webcrypto_impl.cc

Issue 138953016: [style] Remove braces from single-line if statements for style consistency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/renderer/webcrypto/webcrypto_impl_nss.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 (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 "content/renderer/webcrypto/webcrypto_impl.h" 5 #include "content/renderer/webcrypto/webcrypto_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 void WebCryptoImpl::encrypt( 178 void WebCryptoImpl::encrypt(
179 const blink::WebCryptoAlgorithm& algorithm, 179 const blink::WebCryptoAlgorithm& algorithm,
180 const blink::WebCryptoKey& key, 180 const blink::WebCryptoKey& key,
181 const unsigned char* data, 181 const unsigned char* data,
182 unsigned data_size, 182 unsigned data_size,
183 blink::WebCryptoResult result) { 183 blink::WebCryptoResult result) {
184 DCHECK(!algorithm.isNull()); 184 DCHECK(!algorithm.isNull());
185 blink::WebArrayBuffer buffer; 185 blink::WebArrayBuffer buffer;
186 Status status = EncryptInternal(algorithm, key, data, data_size, &buffer); 186 Status status = EncryptInternal(algorithm, key, data, data_size, &buffer);
187 if (status.IsError()) { 187 if (status.IsError())
188 CompleteWithError(status, &result); 188 CompleteWithError(status, &result);
189 } else { 189 else
190 result.completeWithBuffer(buffer); 190 result.completeWithBuffer(buffer);
191 }
192 } 191 }
193 192
194 void WebCryptoImpl::decrypt( 193 void WebCryptoImpl::decrypt(
195 const blink::WebCryptoAlgorithm& algorithm, 194 const blink::WebCryptoAlgorithm& algorithm,
196 const blink::WebCryptoKey& key, 195 const blink::WebCryptoKey& key,
197 const unsigned char* data, 196 const unsigned char* data,
198 unsigned data_size, 197 unsigned data_size,
199 blink::WebCryptoResult result) { 198 blink::WebCryptoResult result) {
200 DCHECK(!algorithm.isNull()); 199 DCHECK(!algorithm.isNull());
201 blink::WebArrayBuffer buffer; 200 blink::WebArrayBuffer buffer;
202 Status status = DecryptInternal(algorithm, key, data, data_size, &buffer); 201 Status status = DecryptInternal(algorithm, key, data, data_size, &buffer);
203 if (status.IsError()) { 202 if (status.IsError())
204 CompleteWithError(status, &result); 203 CompleteWithError(status, &result);
205 } else { 204 else
206 result.completeWithBuffer(buffer); 205 result.completeWithBuffer(buffer);
207 }
208 } 206 }
209 207
210 void WebCryptoImpl::digest( 208 void WebCryptoImpl::digest(
211 const blink::WebCryptoAlgorithm& algorithm, 209 const blink::WebCryptoAlgorithm& algorithm,
212 const unsigned char* data, 210 const unsigned char* data,
213 unsigned data_size, 211 unsigned data_size,
214 blink::WebCryptoResult result) { 212 blink::WebCryptoResult result) {
215 DCHECK(!algorithm.isNull()); 213 DCHECK(!algorithm.isNull());
216 blink::WebArrayBuffer buffer; 214 blink::WebArrayBuffer buffer;
217 Status status = DigestInternal(algorithm, data, data_size, &buffer); 215 Status status = DigestInternal(algorithm, data, data_size, &buffer);
218 if (status.IsError()) { 216 if (status.IsError())
219 CompleteWithError(status, &result); 217 CompleteWithError(status, &result);
220 } else { 218 else
221 result.completeWithBuffer(buffer); 219 result.completeWithBuffer(buffer);
222 }
223 } 220 }
224 221
225 void WebCryptoImpl::generateKey( 222 void WebCryptoImpl::generateKey(
226 const blink::WebCryptoAlgorithm& algorithm, 223 const blink::WebCryptoAlgorithm& algorithm,
227 bool extractable, 224 bool extractable,
228 blink::WebCryptoKeyUsageMask usage_mask, 225 blink::WebCryptoKeyUsageMask usage_mask,
229 blink::WebCryptoResult result) { 226 blink::WebCryptoResult result) {
230 DCHECK(!algorithm.isNull()); 227 DCHECK(!algorithm.isNull());
231 if (IsAlgorithmAsymmetric(algorithm)) { 228 if (IsAlgorithmAsymmetric(algorithm)) {
232 blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull(); 229 blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 result.completeWithKey(key); 294 result.completeWithKey(key);
298 } 295 }
299 } 296 }
300 297
301 void WebCryptoImpl::exportKey( 298 void WebCryptoImpl::exportKey(
302 blink::WebCryptoKeyFormat format, 299 blink::WebCryptoKeyFormat format,
303 const blink::WebCryptoKey& key, 300 const blink::WebCryptoKey& key,
304 blink::WebCryptoResult result) { 301 blink::WebCryptoResult result) {
305 blink::WebArrayBuffer buffer; 302 blink::WebArrayBuffer buffer;
306 Status status = ExportKeyInternal(format, key, &buffer); 303 Status status = ExportKeyInternal(format, key, &buffer);
307 if (status.IsError()) { 304 if (status.IsError())
308 CompleteWithError(status, &result); 305 CompleteWithError(status, &result);
309 } else { 306 else
310 result.completeWithBuffer(buffer); 307 result.completeWithBuffer(buffer);
311 }
312 } 308 }
313 309
314 void WebCryptoImpl::sign( 310 void WebCryptoImpl::sign(
315 const blink::WebCryptoAlgorithm& algorithm, 311 const blink::WebCryptoAlgorithm& algorithm,
316 const blink::WebCryptoKey& key, 312 const blink::WebCryptoKey& key,
317 const unsigned char* data, 313 const unsigned char* data,
318 unsigned data_size, 314 unsigned data_size,
319 blink::WebCryptoResult result) { 315 blink::WebCryptoResult result) {
320 DCHECK(!algorithm.isNull()); 316 DCHECK(!algorithm.isNull());
321 blink::WebArrayBuffer buffer; 317 blink::WebArrayBuffer buffer;
322 Status status = SignInternal(algorithm, key, data, data_size, &buffer); 318 Status status = SignInternal(algorithm, key, data, data_size, &buffer);
323 if (status.IsError()) { 319 if (status.IsError())
324 CompleteWithError(status, &result); 320 CompleteWithError(status, &result);
325 } else { 321 else
326 result.completeWithBuffer(buffer); 322 result.completeWithBuffer(buffer);
327 }
328 } 323 }
329 324
330 void WebCryptoImpl::verifySignature( 325 void WebCryptoImpl::verifySignature(
331 const blink::WebCryptoAlgorithm& algorithm, 326 const blink::WebCryptoAlgorithm& algorithm,
332 const blink::WebCryptoKey& key, 327 const blink::WebCryptoKey& key,
333 const unsigned char* signature, 328 const unsigned char* signature,
334 unsigned signature_size, 329 unsigned signature_size,
335 const unsigned char* data, 330 const unsigned char* data,
336 unsigned data_size, 331 unsigned data_size,
337 blink::WebCryptoResult result) { 332 blink::WebCryptoResult result) {
338 DCHECK(!algorithm.isNull()); 333 DCHECK(!algorithm.isNull());
339 bool signature_match = false; 334 bool signature_match = false;
340 Status status = VerifySignatureInternal(algorithm, 335 Status status = VerifySignatureInternal(algorithm,
341 key, 336 key,
342 signature, 337 signature,
343 signature_size, 338 signature_size,
344 data, 339 data,
345 data_size, 340 data_size,
346 &signature_match); 341 &signature_match);
347 if (status.IsError()) { 342 if (status.IsError())
348 CompleteWithError(status, &result); 343 CompleteWithError(status, &result);
349 } else { 344 else
350 result.completeWithBoolean(signature_match); 345 result.completeWithBoolean(signature_match);
351 }
352 } 346 }
353 347
354 Status WebCryptoImpl::ImportKeyJwk( 348 Status WebCryptoImpl::ImportKeyJwk(
355 const unsigned char* key_data, 349 const unsigned char* key_data,
356 unsigned key_data_size, 350 unsigned key_data_size,
357 const blink::WebCryptoAlgorithm& algorithm_or_null, 351 const blink::WebCryptoAlgorithm& algorithm_or_null,
358 bool extractable, 352 bool extractable,
359 blink::WebCryptoKeyUsageMask usage_mask, 353 blink::WebCryptoKeyUsageMask usage_mask,
360 blink::WebCryptoKey* key) { 354 blink::WebCryptoKey* key) {
361 355
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 key); 636 key);
643 637
644 } else { 638 } else {
645 return Status::ErrorJwkUnrecognizedKty(); 639 return Status::ErrorJwkUnrecognizedKty();
646 } 640 }
647 641
648 return Status::Success(); 642 return Status::Success();
649 } 643 }
650 644
651 } // namespace content 645 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/webcrypto/webcrypto_impl_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698