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

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

Issue 295423004: Expose WebCrypto's algorithm normalization. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comments. Created 6 years, 6 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
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 13 matching lines...) Expand all
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/WebString.h"
35 #include "wtf/Assertions.h" 37 #include "wtf/Assertions.h"
36 #include "wtf/Forward.h" 38 #include "wtf/Forward.h"
37 39
38 namespace blink { class WebCryptoAlgorithm; } 40 namespace blink { class WebCryptoAlgorithm; }
39 41
40 namespace WebCore { 42 namespace WebCore {
41 43
42 class CryptoResult;
43 class Dictionary; 44 class Dictionary;
44 45
45 enum AlgorithmOperation { 46 struct AlgorithmError {
46 Encrypt, 47 blink::WebCryptoErrorType errorType;
47 Decrypt, 48 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 }; 49 };
60 50
61 // Converts a javascript Dictionary to a WebCryptoAlgorithm object. 51 // Converts a javascript Dictionary to a WebCryptoAlgorithm object.
62 // 52 //
63 // This corresponds with "normalizing" [1] the algorithm, and then validating 53 // This corresponds with "normalizing" [1] the algorithm, and then validating
64 // the expected parameters for the algorithm/operation combination. 54 // the expected parameters for the algorithm/operation combination.
65 // 55 //
66 // On success returns true and sets the WebCryptoAlgorithm. 56 // On success returns true and sets the WebCryptoAlgorithm.
67 // 57 //
68 // On failure parseAlgorithm returns false and completes the CryptoResult 58 // On failure normalizeAlgorithm returns false and sets the AlgorithmError with
69 // with a (non-localized) debug string. 59 // a error type and a (non-localized) debug string.
70 // 60 //
71 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules 61 // [1] http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules
72 bool parseAlgorithm(const Dictionary&, AlgorithmOperation, blink::WebCryptoAlgor ithm&, CryptoResult*) WARN_UNUSED_RETURN; 62 bool normalizeAlgorithm(const Dictionary&, blink::WebCryptoOperation, blink::Web CryptoAlgorithm&, AlgorithmError*) WARN_UNUSED_RETURN;
73 63
74 // Returns a null-terminated C-string literal. Caller can assume the pointer 64 // Returns a null-terminated C-string literal. Caller can assume the pointer
75 // will be valid for the program's entire runtime. 65 // will be valid for the program's entire runtime.
76 const char* algorithmIdToName(blink::WebCryptoAlgorithmId); 66 const char* algorithmIdToName(blink::WebCryptoAlgorithmId);
77 67
78 } // namespace WebCore 68 } // namespace WebCore
79 69
80 #endif 70 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698