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

Side by Side Diff: public/platform/WebCrypto.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/SubtleCrypto.cpp ('k') | no next file » | 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 26 matching lines...) Expand all
37 37
38 namespace WebCore { class CryptoResult; } 38 namespace WebCore { class CryptoResult; }
39 39
40 #if BLINK_IMPLEMENTATION 40 #if BLINK_IMPLEMENTATION
41 namespace WTF { template <typename T> class PassRefPtr; } 41 namespace WTF { template <typename T> class PassRefPtr; }
42 #endif 42 #endif
43 43
44 namespace blink { 44 namespace blink {
45 45
46 class WebArrayBuffer; 46 class WebArrayBuffer;
47 class WebString;
47 48
48 class WebCryptoResult { 49 class WebCryptoResult {
49 public: 50 public:
50 WebCryptoResult(const WebCryptoResult& o) 51 WebCryptoResult(const WebCryptoResult& o)
51 { 52 {
52 assign(o); 53 assign(o);
53 } 54 }
54 55
55 ~WebCryptoResult() 56 ~WebCryptoResult()
56 { 57 {
57 reset(); 58 reset();
58 } 59 }
59 60
60 WebCryptoResult& operator=(const WebCryptoResult& o) 61 WebCryptoResult& operator=(const WebCryptoResult& o)
61 { 62 {
62 assign(o); 63 assign(o);
63 return *this; 64 return *this;
64 } 65 }
65 66
66 BLINK_EXPORT void completeWithError(); 67 BLINK_EXPORT void completeWithError();
68
69 // Note that WebString is NOT safe to pass across threads.
70 //
71 // Error details are intended to be displayed to developers for debugging.
72 // They MUST NEVER reveal any secret information such as bytes of the key
73 // or plain text. An appropriate error would be something like:
74 // "iv must be 16 bytes long".
75 BLINK_EXPORT void completeWithError(const WebString&);
76
67 // Note that WebArrayBuffer is NOT safe to create from another thread. 77 // Note that WebArrayBuffer is NOT safe to create from another thread.
68 BLINK_EXPORT void completeWithBuffer(const WebArrayBuffer&); 78 BLINK_EXPORT void completeWithBuffer(const WebArrayBuffer&);
69 // Makes a copy of the input data given as a pointer and byte length. 79 // Makes a copy of the input data given as a pointer and byte length.
70 BLINK_EXPORT void completeWithBuffer(const void*, unsigned); 80 BLINK_EXPORT void completeWithBuffer(const void*, unsigned);
71 BLINK_EXPORT void completeWithBoolean(bool); 81 BLINK_EXPORT void completeWithBoolean(bool);
72 BLINK_EXPORT void completeWithKey(const WebCryptoKey&); 82 BLINK_EXPORT void completeWithKey(const WebCryptoKey&);
73 BLINK_EXPORT void completeWithKeyPair(const WebCryptoKey& publicKey, const W ebCryptoKey& privateKey); 83 BLINK_EXPORT void completeWithKeyPair(const WebCryptoKey& publicKey, const W ebCryptoKey& privateKey);
74 84
75 #if BLINK_IMPLEMENTATION 85 #if BLINK_IMPLEMENTATION
76 explicit WebCryptoResult(const WTF::PassRefPtr<WebCore::CryptoResult>&); 86 explicit WebCryptoResult(const WTF::PassRefPtr<WebCore::CryptoResult>&);
77 #endif 87 #endif
78 88
79 private: 89 private:
80 BLINK_EXPORT void reset(); 90 BLINK_EXPORT void reset();
81 BLINK_EXPORT void assign(const WebCryptoResult&); 91 BLINK_EXPORT void assign(const WebCryptoResult&);
82 92
83 WebPrivatePtr<WebCore::CryptoResult> m_impl; 93 WebPrivatePtr<WebCore::CryptoResult> m_impl;
84 }; 94 };
85 95
86 class WebCrypto { 96 class WebCrypto {
87 public: 97 public:
88 // WebCrypto is the interface for starting one-shot cryptographic operations . 98 // WebCrypto is the interface for starting one-shot cryptographic
99 // operations.
89 // 100 //
90 // ----------------------- 101 // -----------------------
91 // Completing the request 102 // Completing the request
92 // ----------------------- 103 // -----------------------
93 // 104 //
94 // Implementations signal completion by calling one of the methods on 105 // Implementations signal completion by calling one of the methods on
95 // "result". Only a single result/error should be set for the request. 106 // "result". Only a single result/error should be set for the request.
96 // Different operations expect different result types based on the 107 // Different operations expect different result types based on the
97 // algorithm parameters; see the Web Crypto standard for details. 108 // algorithm parameters; see the Web Crypto standard for details.
98 // 109 //
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // It is possible that unwrappedKeyAlgorithm.isNull() 178 // It is possible that unwrappedKeyAlgorithm.isNull()
168 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } 179 virtual void unwrapKey(WebCryptoKeyFormat, const unsigned char* wrappedKey, unsigned wrappedKeySize, const WebCryptoKey&, const WebCryptoAlgorithm& unwrapAl gorithm, const WebCryptoAlgorithm& unwrappedKeyAlgorithm, bool extractable, WebC ryptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); }
169 180
170 protected: 181 protected:
171 virtual ~WebCrypto() { } 182 virtual ~WebCrypto() { }
172 }; 183 };
173 184
174 } // namespace blink 185 } // namespace blink
175 186
176 #endif 187 #endif
OLDNEW
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698