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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore
::CryptoResult>&); | 88 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore
::CryptoResult>&); |
89 #endif | 89 #endif |
90 | 90 |
91 private: | 91 private: |
92 BLINK_PLATFORM_EXPORT void reset(); | 92 BLINK_PLATFORM_EXPORT void reset(); |
93 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); | 93 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); |
94 | 94 |
95 WebPrivatePtr<WebCore::CryptoResult> m_impl; | 95 WebPrivatePtr<WebCore::CryptoResult> m_impl; |
96 }; | 96 }; |
97 | 97 |
| 98 class WebCryptoDigestor { |
| 99 public: |
| 100 virtual ~WebCryptoDigestor() { } |
| 101 |
| 102 // consume() will return |true| on the successful addition of data to the |
| 103 // partially generated digest. It will return |false| when that fails. After |
| 104 // a return of |false|, consume() should not be called again (nor should |
| 105 // finish() be called). |
| 106 virtual bool consume(const unsigned char* data, unsigned dataSize) { return
false; } |
| 107 |
| 108 // finish() will return |true| if the digest has been successfully computed |
| 109 // and put into the result buffer, otherwise it will return |false|. In |
| 110 // either case, neither finish() nor consume() should be called again after |
| 111 // a call to finish(). resultData is valid until the WebCrytpoDigestor |
| 112 // object is destroyed. |
| 113 virtual bool finish(unsigned char*& resultData, unsigned& resultDataSize) {
return false; } |
| 114 |
| 115 protected: |
| 116 WebCryptoDigestor() { } |
| 117 }; |
| 118 |
98 class WebCrypto { | 119 class WebCrypto { |
99 public: | 120 public: |
100 // WebCrypto is the interface for starting one-shot cryptographic | 121 // WebCrypto is the interface for starting one-shot cryptographic |
101 // operations. | 122 // operations. |
102 // | 123 // |
103 // ----------------------- | 124 // ----------------------- |
104 // Completing the request | 125 // Completing the request |
105 // ----------------------- | 126 // ----------------------- |
106 // | 127 // |
107 // Implementations signal completion by calling one of the methods on | 128 // Implementations signal completion by calling one of the methods on |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u
nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete
WithError(); } | 190 virtual void decrypt(const WebCryptoAlgorithm&, const WebCryptoKey&, const u
nsigned char* data, unsigned dataSize, WebCryptoResult result) { result.complete
WithError(); } |
170 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi
gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit
hError(); } | 191 virtual void sign(const WebCryptoAlgorithm&, const WebCryptoKey&, const unsi
gned char* data, unsigned dataSize, WebCryptoResult result) { result.completeWit
hError(); } |
171 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&,
const unsigned char* signature, unsigned signatureSize, const unsigned char* da
ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } | 192 virtual void verifySignature(const WebCryptoAlgorithm&, const WebCryptoKey&,
const unsigned char* signature, unsigned signatureSize, const unsigned char* da
ta, unsigned dataSize, WebCryptoResult result) { result.completeWithError(); } |
172 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un
signed dataSize, WebCryptoResult result) { result.completeWithError(); } | 193 virtual void digest(const WebCryptoAlgorithm&, const unsigned char* data, un
signed dataSize, WebCryptoResult result) { result.completeWithError(); } |
173 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry
ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } | 194 virtual void generateKey(const WebCryptoAlgorithm&, bool extractable, WebCry
ptoKeyUsageMask, WebCryptoResult result) { result.completeWithError(); } |
174 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns
igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag
eMask, WebCryptoResult result) { result.completeWithError(); } | 195 virtual void importKey(WebCryptoKeyFormat, const unsigned char* keyData, uns
igned keyDataSize, const WebCryptoAlgorithm&, bool extractable, WebCryptoKeyUsag
eMask, WebCryptoResult result) { result.completeWithError(); } |
175 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes
ult result) { result.completeWithError(); } | 196 virtual void exportKey(WebCryptoKeyFormat, const WebCryptoKey&, WebCryptoRes
ult result) { result.completeWithError(); } |
176 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC
ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu
lt.completeWithError(); } | 197 virtual void wrapKey(WebCryptoKeyFormat, const WebCryptoKey& key, const WebC
ryptoKey& wrappingKey, const WebCryptoAlgorithm&, WebCryptoResult result) { resu
lt.completeWithError(); } |
177 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(); } | 198 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(); } |
178 | 199 |
179 // This is the one exception to the "Completing the request" guarantees | 200 // This is the exception to the "Completing the request" guarantees |
180 // outlined above. digestSynchronous must provide the result into result | 201 // outlined above. This is useful for Blink internal crypto and is not part |
181 // synchronously. It must return |true| on successful calculation of the | 202 // of the WebCrypto standard. digestSynchronous returns |true| if the |
182 // digest and |false| otherwise. This is useful for Blink internal crypto | 203 // digest was successfully computed and put into result. Otherwise, returns |
183 // and is not part of the WebCrypto standard. | 204 // |false|. It must compute the digest or fail synchronously. |
| 205 // createDigestor must provide the result via the WebCryptoDigestor object |
| 206 // synchronously. createDigestor may return 0 if it fails to create a |
| 207 // WebCryptoDigestor. If it succeeds, the WebCryptoDigestor returned by |
| 208 // createDigestor must be freed by the caller. |
184 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const
unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false;
} | 209 virtual bool digestSynchronous(const WebCryptoAlgorithmId algorithmId, const
unsigned char* data, unsigned dataSize, WebArrayBuffer& result) { return false;
} |
| 210 virtual WebCryptoDigestor* createDigestor(WebCryptoAlgorithmId algorithmId)
{ return 0; } |
185 | 211 |
186 // ----------------------- | 212 // ----------------------- |
187 // Structured clone | 213 // Structured clone |
188 // ----------------------- | 214 // ----------------------- |
189 // | 215 // |
190 // deserializeKeyForClone() and serializeKeyForClone() are used for | 216 // deserializeKeyForClone() and serializeKeyForClone() are used for |
191 // implementing structured cloning of WebCryptoKey. | 217 // implementing structured cloning of WebCryptoKey. |
192 // | 218 // |
193 // Blink is responsible for saving and restoring all of the attributes of | 219 // Blink is responsible for saving and restoring all of the attributes of |
194 // WebCryptoKey EXCEPT for the actual key data: | 220 // WebCryptoKey EXCEPT for the actual key data: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // Returns true on success. | 257 // Returns true on success. |
232 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch
ar>&) { return false; } | 258 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch
ar>&) { return false; } |
233 | 259 |
234 protected: | 260 protected: |
235 virtual ~WebCrypto() { } | 261 virtual ~WebCrypto() { } |
236 }; | 262 }; |
237 | 263 |
238 } // namespace blink | 264 } // namespace blink |
239 | 265 |
240 #endif | 266 #endif |
OLD | NEW |