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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 13 matching lines...) Expand all Loading... |
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "modules/crypto/SubtleCrypto.h" | 31 #include "modules/crypto/SubtleCrypto.h" |
32 | 32 |
33 #include "core/dom/ExceptionCode.h" | 33 #include "core/dom/ExceptionCode.h" |
| 34 #include "modules/crypto/CryptoOperation.h" |
| 35 #include "modules/crypto/NormalizeAlgorithm.h" |
| 36 #include "wtf/ArrayBuffer.h" |
34 #include "wtf/ArrayBufferView.h" | 37 #include "wtf/ArrayBufferView.h" |
35 | 38 |
36 namespace WebCore { | 39 namespace WebCore { |
37 | 40 |
38 SubtleCrypto::SubtleCrypto() | 41 SubtleCrypto::SubtleCrypto() |
39 { | 42 { |
40 ScriptWrappable::init(this); | 43 ScriptWrappable::init(this); |
41 } | 44 } |
42 | 45 |
| 46 PassRefPtr<CryptoOperation> SubtleCrypto::encrypt(const Dictionary& rawAlgorithm
, ExceptionCode& ec) |
| 47 { |
| 48 WebKit::WebCryptoAlgorithm algorithm; |
| 49 if (!normalizeAlgorithm(rawAlgorithm, Encrypt, algorithm, ec)) |
| 50 return 0; |
| 51 return CryptoOperation::create(algorithm); |
43 } | 52 } |
| 53 |
| 54 PassRefPtr<CryptoOperation> SubtleCrypto::decrypt(const Dictionary& rawAlgorithm
, ExceptionCode& ec) |
| 55 { |
| 56 WebKit::WebCryptoAlgorithm algorithm; |
| 57 if (!normalizeAlgorithm(rawAlgorithm, Decrypt, algorithm, ec)) |
| 58 return 0; |
| 59 return CryptoOperation::create(algorithm); |
| 60 } |
| 61 |
| 62 PassRefPtr<CryptoOperation> SubtleCrypto::sign(const Dictionary& rawAlgorithm, E
xceptionCode& ec) |
| 63 { |
| 64 WebKit::WebCryptoAlgorithm algorithm; |
| 65 if (!normalizeAlgorithm(rawAlgorithm, Sign, algorithm, ec)) |
| 66 return 0; |
| 67 return CryptoOperation::create(algorithm); |
| 68 } |
| 69 |
| 70 PassRefPtr<CryptoOperation> SubtleCrypto::verify(const Dictionary& rawAlgorithm,
ExceptionCode& ec) |
| 71 { |
| 72 WebKit::WebCryptoAlgorithm algorithm; |
| 73 if (!normalizeAlgorithm(rawAlgorithm, Verify, algorithm, ec)) |
| 74 return 0; |
| 75 return CryptoOperation::create(algorithm); |
| 76 } |
| 77 |
| 78 PassRefPtr<CryptoOperation> SubtleCrypto::digest(const Dictionary& rawAlgorithm,
ExceptionCode& ec) |
| 79 { |
| 80 WebKit::WebCryptoAlgorithm algorithm; |
| 81 if (!normalizeAlgorithm(rawAlgorithm, Digest, algorithm, ec)) |
| 82 return 0; |
| 83 return CryptoOperation::create(algorithm); |
| 84 } |
| 85 |
| 86 } // namespace WebCore |
OLD | NEW |