OLD | NEW |
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 "components/webcrypto/algorithms/test_helpers.h" | 5 #include "components/webcrypto/algorithms/test_helpers.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 if (curve_str == "P-384") | 638 if (curve_str == "P-384") |
639 return blink::WebCryptoNamedCurveP384; | 639 return blink::WebCryptoNamedCurveP384; |
640 if (curve_str == "P-521") | 640 if (curve_str == "P-521") |
641 return blink::WebCryptoNamedCurveP521; | 641 return blink::WebCryptoNamedCurveP521; |
642 else | 642 else |
643 ADD_FAILURE() << "Unrecognized curve name: " << curve_str; | 643 ADD_FAILURE() << "Unrecognized curve name: " << curve_str; |
644 | 644 |
645 return blink::WebCryptoNamedCurveP384; | 645 return blink::WebCryptoNamedCurveP384; |
646 } | 646 } |
647 | 647 |
| 648 blink::WebCryptoAlgorithm CreateHmacImportAlgorithm( |
| 649 blink::WebCryptoAlgorithmId hash_id, |
| 650 unsigned int length_bits) { |
| 651 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id)); |
| 652 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
| 653 blink::WebCryptoAlgorithmIdHmac, |
| 654 new blink::WebCryptoHmacImportParams(CreateAlgorithm(hash_id), true, |
| 655 length_bits)); |
| 656 } |
| 657 |
| 658 blink::WebCryptoAlgorithm CreateHmacImportAlgorithmNoLength( |
| 659 blink::WebCryptoAlgorithmId hash_id) { |
| 660 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id)); |
| 661 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
| 662 blink::WebCryptoAlgorithmIdHmac, |
| 663 new blink::WebCryptoHmacImportParams(CreateAlgorithm(hash_id), false, 0)); |
| 664 } |
| 665 |
648 } // namespace webcrypto | 666 } // namespace webcrypto |
OLD | NEW |