Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: content/renderer/webcrypto/webcrypto_util.cc

Issue 100593002: [webcrypto] Add symmetric key export for NSS and OpenSSL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjusted #ifdef to fix android (openssl) build Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_util.h" 5 #include "content/renderer/webcrypto/webcrypto_util.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 9 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 if (new_size == buffer->byteLength()) 44 if (new_size == buffer->byteLength())
45 return; 45 return;
46 46
47 blink::WebArrayBuffer new_buffer = blink::WebArrayBuffer::create(new_size, 1); 47 blink::WebArrayBuffer new_buffer = blink::WebArrayBuffer::create(new_size, 1);
48 DCHECK(!new_buffer.isNull()); 48 DCHECK(!new_buffer.isNull());
49 memcpy(new_buffer.data(), buffer->data(), new_size); 49 memcpy(new_buffer.data(), buffer->data(), new_size);
50 *buffer = new_buffer; 50 *buffer = new_buffer;
51 } 51 }
52 52
53 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data, unsigned data_size) {
54 blink::WebArrayBuffer buffer = blink::WebArrayBuffer::create(data_size, 1);
55 DCHECK(!buffer.isNull());
56 if (data_size) // data_size == 0 might mean the data pointer is invalid
57 memcpy(buffer.data(), data, data_size);
58 return buffer;
59 }
60
53 // This function decodes unpadded 'base64url' encoded data, as described in 61 // This function decodes unpadded 'base64url' encoded data, as described in
54 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first 62 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first
55 // change the incoming data to 'base64' encoding by applying the appropriate 63 // change the incoming data to 'base64' encoding by applying the appropriate
56 // transformation including adding padding if required, and then call a base64 64 // transformation including adding padding if required, and then call a base64
57 // decoder. 65 // decoder.
58 bool Base64DecodeUrlSafe(const std::string& input, std::string* output) { 66 bool Base64DecodeUrlSafe(const std::string& input, std::string* output) {
59 std::string base64EncodedText(input); 67 std::string base64EncodedText(input);
60 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+'); 68 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+');
61 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/'); 69 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/');
62 base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '='); 70 base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '=');
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 196
189 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( 197 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(
190 unsigned short key_length_bits) { 198 unsigned short key_length_bits) {
191 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, 199 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm,
192 key_length_bits); 200 key_length_bits);
193 } 201 }
194 202
195 } // namespace webcrypto 203 } // namespace webcrypto
196 204
197 } // namespace content 205 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698