OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/webcrypto/webcrypto_impl.h" | 5 #include "content/renderer/webcrypto/webcrypto_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 9 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 if (new_size == buffer->byteLength()) | 39 if (new_size == buffer->byteLength()) |
40 return; | 40 return; |
41 | 41 |
42 WebKit::WebArrayBuffer new_buffer = | 42 WebKit::WebArrayBuffer new_buffer = |
43 WebKit::WebArrayBuffer::create(new_size, 1); | 43 WebKit::WebArrayBuffer::create(new_size, 1); |
44 DCHECK(!new_buffer.isNull()); | 44 DCHECK(!new_buffer.isNull()); |
45 memcpy(new_buffer.data(), buffer->data(), new_size); | 45 memcpy(new_buffer.data(), buffer->data(), new_size); |
46 *buffer = new_buffer; | 46 *buffer = new_buffer; |
47 } | 47 } |
48 | 48 |
49 // static | |
50 // TODO(eroman): Expose functionality in Blink instead. | |
51 WebKit::WebCryptoKey WebCryptoImpl::NullKey() { | |
52 // Needs a non-null algorithm to succeed. | |
53 return WebKit::WebCryptoKey::create( | |
54 NULL, WebKit::WebCryptoKeyTypeSecret, false, | |
55 WebKit::WebCryptoAlgorithm::adoptParamsAndCreate( | |
56 WebKit::WebCryptoAlgorithmIdAesGcm, NULL), 0); | |
57 } | |
58 | |
59 void WebCryptoImpl::encrypt( | 49 void WebCryptoImpl::encrypt( |
60 const WebKit::WebCryptoAlgorithm& algorithm, | 50 const WebKit::WebCryptoAlgorithm& algorithm, |
61 const WebKit::WebCryptoKey& key, | 51 const WebKit::WebCryptoKey& key, |
62 const unsigned char* data, | 52 const unsigned char* data, |
63 unsigned data_size, | 53 unsigned data_size, |
64 WebKit::WebCryptoResult result) { | 54 WebKit::WebCryptoResult result) { |
65 DCHECK(!algorithm.isNull()); | 55 DCHECK(!algorithm.isNull()); |
66 WebKit::WebArrayBuffer buffer; | 56 WebKit::WebArrayBuffer buffer; |
67 if (!EncryptInternal(algorithm, key, data, data_size, &buffer)) { | 57 if (!EncryptInternal(algorithm, key, data, data_size, &buffer)) { |
68 result.completeWithError(); | 58 result.completeWithError(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 data, | 188 data, |
199 data_size, | 189 data_size, |
200 &signature_match)) { | 190 &signature_match)) { |
201 result.completeWithError(); | 191 result.completeWithError(); |
202 } else { | 192 } else { |
203 result.completeWithBoolean(signature_match); | 193 result.completeWithBoolean(signature_match); |
204 } | 194 } |
205 } | 195 } |
206 | 196 |
207 } // namespace content | 197 } // namespace content |
OLD | NEW |