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

Side by Side Diff: Source/modules/crypto/NormalizeAlgorithm.h

Issue 141413003: [webcrypto] Match the error handling defined by the spec. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 11 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 | « Source/modules/crypto/Key.cpp ('k') | Source/modules/crypto/NormalizeAlgorithm.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
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/WebCryptoAlgorithm.h" 34 #include "public/platform/WebCryptoAlgorithm.h"
35 #include "wtf/Assertions.h" 35 #include "wtf/Assertions.h"
36 #include "wtf/Forward.h"
36 37
37 namespace blink { class WebCryptoAlgorithm; } 38 namespace blink { class WebCryptoAlgorithm; }
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 class Dictionary; 42 class Dictionary;
42 class ExceptionState; 43 class ExceptionState;
43 44
44 enum AlgorithmOperation { 45 enum AlgorithmOperation {
45 Encrypt, 46 Encrypt,
46 Decrypt, 47 Decrypt,
47 Sign, 48 Sign,
48 Verify, 49 Verify,
49 Digest, 50 Digest,
50 GenerateKey, 51 GenerateKey,
51 ImportKey, 52 ImportKey,
52 DeriveKey, 53 DeriveKey,
53 WrapKey, 54 WrapKey,
54 UnwrapKey, 55 UnwrapKey,
55 // <---- End of list (keep this up-to-date) 56 // <---- End of list (keep this up-to-date)
56 LastAlgorithmOperation = UnwrapKey, 57 LastAlgorithmOperation = UnwrapKey,
57 }; 58 };
58 59
59 // Normalizes an algorithm identifier (dictionary) into a WebCryptoAlgorithm. If 60 // Converts a javascript Dictionary to a WebCryptoAlgorithm object.
60 // normalization fails then returns false and sets the ExceptionState. 61 //
61 bool normalizeAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoA lgorithm&, ExceptionState&) WARN_UNUSED_RETURN; 62 // This corresponds with "normalizing" [1] the algorithm, and then validating
63 // the expected parameters for the algorithm/operation combination.
64 //
65 // On success returns true and sets the WebCryptoAlgorithm.
66 //
67 // On failure parseAlgorithm returns false. errorDetails will be filled
68 // with a (non-localized) debug string. Additionally the ExceptionState *may*
69 // be set (the web crypto spec only defines a handeful of errors as resulting
70 // in exceptions).
71 //
72 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules
73 bool parseAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoAlgor ithm&, String& errorDetails, ExceptionState&) WARN_UNUSED_RETURN;
62 74
63 // Returns a null-terminated C-string literal. Caller can assume the pointer 75 // Returns a null-terminated C-string literal. Caller can assume the pointer
64 // will be valid for the program's entire runtime. 76 // will be valid for the program's entire runtime.
65 const char* algorithmIdToName(blink::WebCryptoAlgorithmId); 77 const char* algorithmIdToName(blink::WebCryptoAlgorithmId);
66 78
67 } // namespace WebCore 79 } // namespace WebCore
68 80
69 #endif 81 #endif
OLDNEW
« no previous file with comments | « Source/modules/crypto/Key.cpp ('k') | Source/modules/crypto/NormalizeAlgorithm.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698