| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 SubtleCrypto_h | 31 #ifndef KeyOperation_h |
| 32 #define SubtleCrypto_h | 32 #define KeyOperation_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptWrappable.h" | 34 #include "bindings/v8/ScriptObject.h" |
| 35 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
| 36 #include "wtf/PassRefPtr.h" | 36 #include "wtf/PassRefPtr.h" |
| 37 #include "wtf/RefCounted.h" | 37 #include "wtf/RefPtr.h" |
| 38 #include "wtf/ThreadSafeRefCounted.h" |
| 39 |
| 40 namespace WebKit { |
| 41 class WebCryptoKeyOperation; |
| 42 class WebCryptoKey; |
| 43 } |
| 38 | 44 |
| 39 namespace WebCore { | 45 namespace WebCore { |
| 40 | 46 |
| 41 class CryptoOperation; | 47 typedef int ExceptionCode; |
| 42 class Dictionary; | 48 class ScriptPromiseResolver; |
| 43 | 49 |
| 44 typedef int ExceptionCode; | 50 // todo: m_exceptionCode |
| 51 // create the promise resolver. |
| 45 | 52 |
| 46 class SubtleCrypto : public ScriptWrappable, public RefCounted<SubtleCrypto> { | 53 class KeyOperation : public ThreadSafeRefCounted<KeyOperation> { |
| 47 public: | 54 public: |
| 48 static PassRefPtr<SubtleCrypto> create() { return adoptRef(new SubtleCrypto(
)); } | 55 KeyOperation(); |
| 56 ~KeyOperation(); |
| 49 | 57 |
| 50 PassRefPtr<CryptoOperation> encrypt(const Dictionary&, ExceptionCode&); | 58 // Implementation of WebKit::WebCryptoKeyOperationResult. |
| 51 PassRefPtr<CryptoOperation> decrypt(const Dictionary&, ExceptionCode&); | 59 void initializationFailed(); |
| 52 PassRefPtr<CryptoOperation> sign(const Dictionary&, ExceptionCode&); | 60 void initializationSucceeded(WebKit::WebCryptoKeyOperation*); |
| 53 // Note that this is not named "verify" because when compiling on Mac that e
xpands to a macro and breaks. | 61 void completeWithError(); |
| 54 PassRefPtr<CryptoOperation> verifySignature(const Dictionary&, ExceptionCode
&); | 62 void completeWithKey(const WebKit::WebCryptoKey&); |
| 55 PassRefPtr<CryptoOperation> digest(const Dictionary&, ExceptionCode&); | 63 |
| 64 ScriptObject returnValue(ExceptionCode&); |
| 56 | 65 |
| 57 private: | 66 private: |
| 58 SubtleCrypto(); | 67 enum State { |
| 68 Initializing, |
| 69 InProgress, |
| 70 Done, |
| 71 }; |
| 72 |
| 73 ScriptPromiseResolver* promiseResolver(); |
| 74 |
| 75 State m_state; |
| 76 WebKit::WebCryptoKeyOperation* m_impl; |
| 77 ExceptionCode m_exceptionCode; |
| 78 RefPtr<ScriptPromiseResolver> m_promiseResolver; |
| 59 }; | 79 }; |
| 60 | 80 |
| 61 } // namespace WebCore | 81 } // namespace WebCore |
| 62 | 82 |
| 63 #endif | 83 #endif |
| OLD | NEW |