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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 }; | 101 }; |
102 | 102 |
103 } // namespace | 103 } // namespace |
104 | 104 |
105 MockWebCrypto* MockWebCrypto::get() | 105 MockWebCrypto* MockWebCrypto::get() |
106 { | 106 { |
107 static MockWebCrypto crypto; | 107 static MockWebCrypto crypto; |
108 return &crypto; | 108 return &crypto; |
109 } | 109 } |
110 | 110 |
| 111 void MockWebCrypto::encrypt(const WebKit::WebCryptoAlgorithm& algorithm, const W
ebKit::WebCryptoKey& key, WebKit::WebCryptoOperationResult& result) |
| 112 { |
| 113 result.initializationSucceeded(new MockCryptoOperation(algorithm, result)); |
| 114 } |
| 115 |
| 116 void MockWebCrypto::decrypt(const WebKit::WebCryptoAlgorithm& algorithm, const W
ebKit::WebCryptoKey& key, WebKit::WebCryptoOperationResult& result) |
| 117 { |
| 118 result.initializationSucceeded(new MockCryptoOperation(algorithm, result)); |
| 119 } |
| 120 |
| 121 void MockWebCrypto::sign(const WebKit::WebCryptoAlgorithm& algorithm, const WebK
it::WebCryptoKey& key, WebKit::WebCryptoOperationResult& result) |
| 122 { |
| 123 result.initializationSucceeded(new MockCryptoOperation(algorithm, result)); |
| 124 } |
| 125 |
111 void MockWebCrypto::digest(const WebKit::WebCryptoAlgorithm& algorithm, WebKit::
WebCryptoOperationResult& result) | 126 void MockWebCrypto::digest(const WebKit::WebCryptoAlgorithm& algorithm, WebKit::
WebCryptoOperationResult& result) |
112 { | 127 { |
113 result.initializationSucceeded(new MockCryptoOperation(algorithm, result)); | 128 result.initializationSucceeded(new MockCryptoOperation(algorithm, result)); |
114 } | 129 } |
115 | 130 |
116 void MockWebCrypto::importKey(WebKit::WebCryptoKeyFormat, const unsigned char* k
eyData, size_t keyDataSize, const WebKit::WebCryptoAlgorithm& algorithm, bool ex
tractable, WebKit::WebCryptoKeyUsageMask usages, WebKit::WebCryptoKeyOperationRe
sult& result) | 131 void MockWebCrypto::importKey(WebKit::WebCryptoKeyFormat, const unsigned char* k
eyData, size_t keyDataSize, const WebKit::WebCryptoAlgorithm& algorithm, bool ex
tractable, WebKit::WebCryptoKeyUsageMask usages, WebKit::WebCryptoKeyOperationRe
sult& result) |
117 { | 132 { |
118 std::string keyDataString(reinterpret_cast<const char*>(keyData), keyDataSiz
e); | 133 std::string keyDataString(reinterpret_cast<const char*>(keyData), keyDataSiz
e); |
119 | 134 |
120 if (keyDataString == "reject") { | 135 if (keyDataString == "reject") { |
121 result.completeWithError(); | 136 result.completeWithError(); |
122 } else if (keyDataString == "throw") { | 137 } else if (keyDataString == "throw") { |
123 result.initializationFailed(); | 138 result.initializationFailed(); |
124 } else { | 139 } else { |
125 WebKit::WebCryptoKeyType type = WebKit::WebCryptoKeyTypePrivate; | 140 WebKit::WebCryptoKeyType type = WebKit::WebCryptoKeyTypePrivate; |
126 if (keyDataString == "public") | 141 if (keyDataString == "public") |
127 type = WebKit::WebCryptoKeyTypePublic; | 142 type = WebKit::WebCryptoKeyTypePublic; |
128 result.completeWithKey(WebKit::WebCryptoKey::create(0, type, extractable
, algorithm, usages)); | 143 result.completeWithKey(WebKit::WebCryptoKey::create(0, type, extractable
, algorithm, usages)); |
129 } | 144 } |
130 } | 145 } |
131 | 146 |
132 } // namespace WebTestRunner | 147 } // namespace WebTestRunner |
OLD | NEW |