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

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

Issue 76363006: [webcrypto] Add JWK import of RSA public key for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjusted #ifdef to make android (openssl) build pass 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 // 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
55 // change the incoming data to 'base64' encoding by applying the appropriate
56 // transformation including adding padding if required, and then call a base64
57 // decoder.
53 bool Base64DecodeUrlSafe(const std::string& input, std::string* output) { 58 bool Base64DecodeUrlSafe(const std::string& input, std::string* output) {
54 std::string base64EncodedText(input); 59 std::string base64EncodedText(input);
55 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+'); 60 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+');
56 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/'); 61 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/');
57 base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '='); 62 base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '=');
58 return base::Base64Decode(base64EncodedText, output); 63 return base::Base64Decode(base64EncodedText, output);
59 } 64 }
60 65
61 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( 66 blink::WebCryptoAlgorithm GetInnerHashAlgorithm(
62 const blink::WebCryptoAlgorithm& algorithm) { 67 const blink::WebCryptoAlgorithm& algorithm) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 188
184 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( 189 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(
185 unsigned short key_length_bits) { 190 unsigned short key_length_bits) {
186 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, 191 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm,
187 key_length_bits); 192 key_length_bits);
188 } 193 }
189 194
190 } // namespace webcrypto 195 } // namespace webcrypto
191 196
192 } // namespace content 197 } // 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