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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef NormalizeAlgorithm_h | 31 #ifndef NormalizeAlgorithm_h |
32 #define NormalizeAlgorithm_h | 32 #define NormalizeAlgorithm_h |
33 | 33 |
| 34 #include "public/platform/WebCrypto.h" |
34 #include "public/platform/WebCryptoAlgorithm.h" | 35 #include "public/platform/WebCryptoAlgorithm.h" |
| 36 #include "public/platform/WebCryptoAlgorithmOperation.h" |
| 37 #include "public/platform/WebString.h" |
35 #include "wtf/Assertions.h" | 38 #include "wtf/Assertions.h" |
36 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
37 | 40 |
38 namespace blink { class WebCryptoAlgorithm; } | 41 namespace blink { class WebCryptoAlgorithm; } |
39 | 42 |
40 namespace WebCore { | 43 namespace WebCore { |
41 | 44 |
42 class CryptoResult; | |
43 class Dictionary; | 45 class Dictionary; |
44 | 46 |
45 enum AlgorithmOperation { | 47 struct AlgorithmError { |
46 Encrypt, | 48 blink::WebCryptoErrorType errorType; |
47 Decrypt, | 49 blink::WebString errorDetails; |
48 Sign, | |
49 Verify, | |
50 Digest, | |
51 GenerateKey, | |
52 ImportKey, | |
53 DeriveKey, | |
54 DeriveBits, | |
55 WrapKey, | |
56 UnwrapKey, | |
57 // <---- End of list (keep this up-to-date) | |
58 LastAlgorithmOperation = UnwrapKey, | |
59 }; | 50 }; |
60 | 51 |
61 // Converts a javascript Dictionary to a WebCryptoAlgorithm object. | 52 // Converts a javascript Dictionary to a WebCryptoAlgorithm object. |
62 // | 53 // |
63 // This corresponds with "normalizing" [1] the algorithm, and then validating | 54 // This corresponds with "normalizing" [1] the algorithm, and then validating |
64 // the expected parameters for the algorithm/operation combination. | 55 // the expected parameters for the algorithm/operation combination. |
65 // | 56 // |
66 // On success returns true and sets the WebCryptoAlgorithm. | 57 // On success returns true and sets the WebCryptoAlgorithm. |
67 // | 58 // |
68 // On failure parseAlgorithm returns false and completes the CryptoResult | 59 // On failure normalizeAlgorithm returns false and sets the AlgorithmError with |
69 // with a (non-localized) debug string. | 60 // a error type and a (non-localized) debug string. |
70 // | 61 // |
71 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules | 62 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules |
72 bool parseAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoAlgor
ithm&, CryptoResult*) WARN_UNUSED_RETURN; | 63 bool normalizeAlgorithm(const Dictionary&, blink::AlgorithmOperation, blink::Web
CryptoAlgorithm&, AlgorithmError*) WARN_UNUSED_RETURN; |
73 | 64 |
74 // Returns a null-terminated C-string literal. Caller can assume the pointer | 65 // Returns a null-terminated C-string literal. Caller can assume the pointer |
75 // will be valid for the program's entire runtime. | 66 // will be valid for the program's entire runtime. |
76 const char* algorithmIdToName(blink::WebCryptoAlgorithmId); | 67 const char* algorithmIdToName(blink::WebCryptoAlgorithmId); |
77 | 68 |
78 } // namespace WebCore | 69 } // namespace WebCore |
79 | 70 |
80 #endif | 71 #endif |
OLD | NEW |