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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 WebKit::WebCryptoAlgorithm algorithm; | 70 WebKit::WebCryptoAlgorithm algorithm; |
71 if (!normalizeAlgorithm(rawAlgorithm, operationType, algorithm, es)) | 71 if (!normalizeAlgorithm(rawAlgorithm, operationType, algorithm, es)) |
72 return ScriptPromise(); | 72 return ScriptPromise(); |
73 | 73 |
74 if (requiresKey && !key->canBeUsedForAlgorithm(algorithm, operationType, es)
) | 74 if (requiresKey && !key->canBeUsedForAlgorithm(algorithm, operationType, es)
) |
75 return ScriptPromise(); | 75 return ScriptPromise(); |
76 | 76 |
77 const unsigned char* data = static_cast<const unsigned char*>(dataBuffer->ba
seAddress()); | 77 const unsigned char* data = static_cast<const unsigned char*>(dataBuffer->ba
seAddress()); |
78 size_t dataSize = dataBuffer->byteLength(); | 78 unsigned dataSize = dataBuffer->byteLength(); |
79 | 79 |
80 RefPtr<CryptoResult> result = CryptoResult::create(); | 80 RefPtr<CryptoResult> result = CryptoResult::create(); |
81 | 81 |
82 switch (operationType) { | 82 switch (operationType) { |
83 case Encrypt: | 83 case Encrypt: |
84 WebKit::Platform::current()->crypto()->encrypt(algorithm, key->key(), da
ta, dataSize, result->result()); | 84 WebKit::Platform::current()->crypto()->encrypt(algorithm, key->key(), da
ta, dataSize, result->result()); |
85 break; | 85 break; |
86 case Decrypt: | 86 case Decrypt: |
87 WebKit::Platform::current()->crypto()->decrypt(algorithm, key->key(), da
ta, dataSize, result->result()); | 87 WebKit::Platform::current()->crypto()->decrypt(algorithm, key->key(), da
ta, dataSize, result->result()); |
88 break; | 88 break; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 es.throwDOMException(NotSupportedError, "key is not extractable"); | 191 es.throwDOMException(NotSupportedError, "key is not extractable"); |
192 return ScriptPromise(); | 192 return ScriptPromise(); |
193 } | 193 } |
194 | 194 |
195 RefPtr<CryptoResult> result = CryptoResult::create(); | 195 RefPtr<CryptoResult> result = CryptoResult::create(); |
196 WebKit::Platform::current()->crypto()->exportKey(format, key->key(), result-
>result()); | 196 WebKit::Platform::current()->crypto()->exportKey(format, key->key(), result-
>result()); |
197 return result->promise(); | 197 return result->promise(); |
198 } | 198 } |
199 | 199 |
200 } // namespace WebCore | 200 } // namespace WebCore |
OLD | NEW |