OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 if (id_int >= WTF_ARRAY_LENGTH(kAlgorithmIdToInfo)) | 344 if (id_int >= WTF_ARRAY_LENGTH(kAlgorithmIdToInfo)) |
345 return 0; | 345 return 0; |
346 return &kAlgorithmIdToInfo[id]; | 346 return &kAlgorithmIdToInfo[id]; |
347 } | 347 } |
348 | 348 |
349 bool WebCryptoAlgorithm::IsNull() const { | 349 bool WebCryptoAlgorithm::IsNull() const { |
350 return private_.IsNull(); | 350 return private_.IsNull(); |
351 } | 351 } |
352 | 352 |
353 WebCryptoAlgorithmId WebCryptoAlgorithm::Id() const { | 353 WebCryptoAlgorithmId WebCryptoAlgorithm::Id() const { |
354 ASSERT(!IsNull()); | 354 DCHECK(!IsNull()); |
355 return private_->id; | 355 return private_->id; |
356 } | 356 } |
357 | 357 |
358 WebCryptoAlgorithmParamsType WebCryptoAlgorithm::ParamsType() const { | 358 WebCryptoAlgorithmParamsType WebCryptoAlgorithm::ParamsType() const { |
359 ASSERT(!IsNull()); | 359 DCHECK(!IsNull()); |
360 if (!private_->params) | 360 if (!private_->params) |
361 return kWebCryptoAlgorithmParamsTypeNone; | 361 return kWebCryptoAlgorithmParamsTypeNone; |
362 return private_->params->GetType(); | 362 return private_->params->GetType(); |
363 } | 363 } |
364 | 364 |
365 const WebCryptoAesCbcParams* WebCryptoAlgorithm::AesCbcParams() const { | 365 const WebCryptoAesCbcParams* WebCryptoAlgorithm::AesCbcParams() const { |
366 ASSERT(!IsNull()); | 366 DCHECK(!IsNull()); |
367 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesCbcParams) | 367 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesCbcParams) |
368 return static_cast<WebCryptoAesCbcParams*>(private_->params.get()); | 368 return static_cast<WebCryptoAesCbcParams*>(private_->params.get()); |
369 return 0; | 369 return 0; |
370 } | 370 } |
371 | 371 |
372 const WebCryptoAesCtrParams* WebCryptoAlgorithm::AesCtrParams() const { | 372 const WebCryptoAesCtrParams* WebCryptoAlgorithm::AesCtrParams() const { |
373 ASSERT(!IsNull()); | 373 DCHECK(!IsNull()); |
374 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesCtrParams) | 374 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesCtrParams) |
375 return static_cast<WebCryptoAesCtrParams*>(private_->params.get()); | 375 return static_cast<WebCryptoAesCtrParams*>(private_->params.get()); |
376 return 0; | 376 return 0; |
377 } | 377 } |
378 | 378 |
379 const WebCryptoAesKeyGenParams* WebCryptoAlgorithm::AesKeyGenParams() const { | 379 const WebCryptoAesKeyGenParams* WebCryptoAlgorithm::AesKeyGenParams() const { |
380 ASSERT(!IsNull()); | 380 DCHECK(!IsNull()); |
381 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesKeyGenParams) | 381 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesKeyGenParams) |
382 return static_cast<WebCryptoAesKeyGenParams*>(private_->params.get()); | 382 return static_cast<WebCryptoAesKeyGenParams*>(private_->params.get()); |
383 return 0; | 383 return 0; |
384 } | 384 } |
385 | 385 |
386 const WebCryptoHmacImportParams* WebCryptoAlgorithm::HmacImportParams() const { | 386 const WebCryptoHmacImportParams* WebCryptoAlgorithm::HmacImportParams() const { |
387 ASSERT(!IsNull()); | 387 DCHECK(!IsNull()); |
388 if (ParamsType() == kWebCryptoAlgorithmParamsTypeHmacImportParams) | 388 if (ParamsType() == kWebCryptoAlgorithmParamsTypeHmacImportParams) |
389 return static_cast<WebCryptoHmacImportParams*>(private_->params.get()); | 389 return static_cast<WebCryptoHmacImportParams*>(private_->params.get()); |
390 return 0; | 390 return 0; |
391 } | 391 } |
392 | 392 |
393 const WebCryptoHmacKeyGenParams* WebCryptoAlgorithm::HmacKeyGenParams() const { | 393 const WebCryptoHmacKeyGenParams* WebCryptoAlgorithm::HmacKeyGenParams() const { |
394 ASSERT(!IsNull()); | 394 DCHECK(!IsNull()); |
395 if (ParamsType() == kWebCryptoAlgorithmParamsTypeHmacKeyGenParams) | 395 if (ParamsType() == kWebCryptoAlgorithmParamsTypeHmacKeyGenParams) |
396 return static_cast<WebCryptoHmacKeyGenParams*>(private_->params.get()); | 396 return static_cast<WebCryptoHmacKeyGenParams*>(private_->params.get()); |
397 return 0; | 397 return 0; |
398 } | 398 } |
399 | 399 |
400 const WebCryptoAesGcmParams* WebCryptoAlgorithm::AesGcmParams() const { | 400 const WebCryptoAesGcmParams* WebCryptoAlgorithm::AesGcmParams() const { |
401 ASSERT(!IsNull()); | 401 DCHECK(!IsNull()); |
402 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesGcmParams) | 402 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesGcmParams) |
403 return static_cast<WebCryptoAesGcmParams*>(private_->params.get()); | 403 return static_cast<WebCryptoAesGcmParams*>(private_->params.get()); |
404 return 0; | 404 return 0; |
405 } | 405 } |
406 | 406 |
407 const WebCryptoRsaOaepParams* WebCryptoAlgorithm::RsaOaepParams() const { | 407 const WebCryptoRsaOaepParams* WebCryptoAlgorithm::RsaOaepParams() const { |
408 ASSERT(!IsNull()); | 408 DCHECK(!IsNull()); |
409 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaOaepParams) | 409 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaOaepParams) |
410 return static_cast<WebCryptoRsaOaepParams*>(private_->params.get()); | 410 return static_cast<WebCryptoRsaOaepParams*>(private_->params.get()); |
411 return 0; | 411 return 0; |
412 } | 412 } |
413 | 413 |
414 const WebCryptoRsaHashedImportParams* | 414 const WebCryptoRsaHashedImportParams* |
415 WebCryptoAlgorithm::RsaHashedImportParams() const { | 415 WebCryptoAlgorithm::RsaHashedImportParams() const { |
416 ASSERT(!IsNull()); | 416 DCHECK(!IsNull()); |
417 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaHashedImportParams) | 417 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaHashedImportParams) |
418 return static_cast<WebCryptoRsaHashedImportParams*>(private_->params.get()); | 418 return static_cast<WebCryptoRsaHashedImportParams*>(private_->params.get()); |
419 return 0; | 419 return 0; |
420 } | 420 } |
421 | 421 |
422 const WebCryptoRsaHashedKeyGenParams* | 422 const WebCryptoRsaHashedKeyGenParams* |
423 WebCryptoAlgorithm::RsaHashedKeyGenParams() const { | 423 WebCryptoAlgorithm::RsaHashedKeyGenParams() const { |
424 ASSERT(!IsNull()); | 424 DCHECK(!IsNull()); |
425 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams) | 425 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaHashedKeyGenParams) |
426 return static_cast<WebCryptoRsaHashedKeyGenParams*>(private_->params.get()); | 426 return static_cast<WebCryptoRsaHashedKeyGenParams*>(private_->params.get()); |
427 return 0; | 427 return 0; |
428 } | 428 } |
429 | 429 |
430 const WebCryptoRsaPssParams* WebCryptoAlgorithm::RsaPssParams() const { | 430 const WebCryptoRsaPssParams* WebCryptoAlgorithm::RsaPssParams() const { |
431 ASSERT(!IsNull()); | 431 DCHECK(!IsNull()); |
432 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaPssParams) | 432 if (ParamsType() == kWebCryptoAlgorithmParamsTypeRsaPssParams) |
433 return static_cast<WebCryptoRsaPssParams*>(private_->params.get()); | 433 return static_cast<WebCryptoRsaPssParams*>(private_->params.get()); |
434 return 0; | 434 return 0; |
435 } | 435 } |
436 | 436 |
437 const WebCryptoEcdsaParams* WebCryptoAlgorithm::EcdsaParams() const { | 437 const WebCryptoEcdsaParams* WebCryptoAlgorithm::EcdsaParams() const { |
438 ASSERT(!IsNull()); | 438 DCHECK(!IsNull()); |
439 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcdsaParams) | 439 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcdsaParams) |
440 return static_cast<WebCryptoEcdsaParams*>(private_->params.get()); | 440 return static_cast<WebCryptoEcdsaParams*>(private_->params.get()); |
441 return 0; | 441 return 0; |
442 } | 442 } |
443 | 443 |
444 const WebCryptoEcKeyGenParams* WebCryptoAlgorithm::EcKeyGenParams() const { | 444 const WebCryptoEcKeyGenParams* WebCryptoAlgorithm::EcKeyGenParams() const { |
445 ASSERT(!IsNull()); | 445 DCHECK(!IsNull()); |
446 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcKeyGenParams) | 446 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcKeyGenParams) |
447 return static_cast<WebCryptoEcKeyGenParams*>(private_->params.get()); | 447 return static_cast<WebCryptoEcKeyGenParams*>(private_->params.get()); |
448 return 0; | 448 return 0; |
449 } | 449 } |
450 | 450 |
451 const WebCryptoEcKeyImportParams* WebCryptoAlgorithm::EcKeyImportParams() | 451 const WebCryptoEcKeyImportParams* WebCryptoAlgorithm::EcKeyImportParams() |
452 const { | 452 const { |
453 ASSERT(!IsNull()); | 453 DCHECK(!IsNull()); |
454 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcKeyImportParams) | 454 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcKeyImportParams) |
455 return static_cast<WebCryptoEcKeyImportParams*>(private_->params.get()); | 455 return static_cast<WebCryptoEcKeyImportParams*>(private_->params.get()); |
456 return 0; | 456 return 0; |
457 } | 457 } |
458 | 458 |
459 const WebCryptoEcdhKeyDeriveParams* WebCryptoAlgorithm::EcdhKeyDeriveParams() | 459 const WebCryptoEcdhKeyDeriveParams* WebCryptoAlgorithm::EcdhKeyDeriveParams() |
460 const { | 460 const { |
461 ASSERT(!IsNull()); | 461 DCHECK(!IsNull()); |
462 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcdhKeyDeriveParams) | 462 if (ParamsType() == kWebCryptoAlgorithmParamsTypeEcdhKeyDeriveParams) |
463 return static_cast<WebCryptoEcdhKeyDeriveParams*>(private_->params.get()); | 463 return static_cast<WebCryptoEcdhKeyDeriveParams*>(private_->params.get()); |
464 return 0; | 464 return 0; |
465 } | 465 } |
466 | 466 |
467 const WebCryptoAesDerivedKeyParams* WebCryptoAlgorithm::AesDerivedKeyParams() | 467 const WebCryptoAesDerivedKeyParams* WebCryptoAlgorithm::AesDerivedKeyParams() |
468 const { | 468 const { |
469 ASSERT(!IsNull()); | 469 DCHECK(!IsNull()); |
470 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesDerivedKeyParams) | 470 if (ParamsType() == kWebCryptoAlgorithmParamsTypeAesDerivedKeyParams) |
471 return static_cast<WebCryptoAesDerivedKeyParams*>(private_->params.get()); | 471 return static_cast<WebCryptoAesDerivedKeyParams*>(private_->params.get()); |
472 return 0; | 472 return 0; |
473 } | 473 } |
474 | 474 |
475 const WebCryptoHkdfParams* WebCryptoAlgorithm::HkdfParams() const { | 475 const WebCryptoHkdfParams* WebCryptoAlgorithm::HkdfParams() const { |
476 ASSERT(!IsNull()); | 476 DCHECK(!IsNull()); |
477 if (ParamsType() == kWebCryptoAlgorithmParamsTypeHkdfParams) | 477 if (ParamsType() == kWebCryptoAlgorithmParamsTypeHkdfParams) |
478 return static_cast<WebCryptoHkdfParams*>(private_->params.get()); | 478 return static_cast<WebCryptoHkdfParams*>(private_->params.get()); |
479 return 0; | 479 return 0; |
480 } | 480 } |
481 | 481 |
482 const WebCryptoPbkdf2Params* WebCryptoAlgorithm::Pbkdf2Params() const { | 482 const WebCryptoPbkdf2Params* WebCryptoAlgorithm::Pbkdf2Params() const { |
483 ASSERT(!IsNull()); | 483 DCHECK(!IsNull()); |
484 if (ParamsType() == kWebCryptoAlgorithmParamsTypePbkdf2Params) | 484 if (ParamsType() == kWebCryptoAlgorithmParamsTypePbkdf2Params) |
485 return static_cast<WebCryptoPbkdf2Params*>(private_->params.get()); | 485 return static_cast<WebCryptoPbkdf2Params*>(private_->params.get()); |
486 return 0; | 486 return 0; |
487 } | 487 } |
488 | 488 |
489 bool WebCryptoAlgorithm::IsHash(WebCryptoAlgorithmId id) { | 489 bool WebCryptoAlgorithm::IsHash(WebCryptoAlgorithmId id) { |
490 switch (id) { | 490 switch (id) { |
491 case kWebCryptoAlgorithmIdSha1: | 491 case kWebCryptoAlgorithmIdSha1: |
492 case kWebCryptoAlgorithmIdSha256: | 492 case kWebCryptoAlgorithmIdSha256: |
493 case kWebCryptoAlgorithmIdSha384: | 493 case kWebCryptoAlgorithmIdSha384: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 536 |
537 void WebCryptoAlgorithm::Assign(const WebCryptoAlgorithm& other) { | 537 void WebCryptoAlgorithm::Assign(const WebCryptoAlgorithm& other) { |
538 private_ = other.private_; | 538 private_ = other.private_; |
539 } | 539 } |
540 | 540 |
541 void WebCryptoAlgorithm::Reset() { | 541 void WebCryptoAlgorithm::Reset() { |
542 private_.Reset(); | 542 private_.Reset(); |
543 } | 543 } |
544 | 544 |
545 } // namespace blink | 545 } // namespace blink |
OLD | NEW |