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

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: Created 7 years, 1 month 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
OLDNEW
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_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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 if (new_size == buffer->byteLength()) 42 if (new_size == buffer->byteLength())
43 return; 43 return;
44 44
45 blink::WebArrayBuffer new_buffer = 45 blink::WebArrayBuffer new_buffer =
46 blink::WebArrayBuffer::create(new_size, 1); 46 blink::WebArrayBuffer::create(new_size, 1);
47 DCHECK(!new_buffer.isNull()); 47 DCHECK(!new_buffer.isNull());
48 memcpy(new_buffer.data(), buffer->data(), new_size); 48 memcpy(new_buffer.data(), buffer->data(), new_size);
49 *buffer = new_buffer; 49 *buffer = new_buffer;
50 } 50 }
51 51
52 // This function decodes unpadded 'base64url' encoded data, as described in
53 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first
54 // change the incoming data to 'base64' encoding by applying the appropriate
55 // transformation including adding padding if required, and then call a base64
56 // decoder.
52 bool Base64DecodeUrlSafe(const std::string& input, std::string* output) { 57 bool Base64DecodeUrlSafe(const std::string& input, std::string* output) {
53 std::string base64EncodedText(input); 58 std::string base64EncodedText(input);
54 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+'); 59 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '-', '+');
55 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/'); 60 std::replace(base64EncodedText.begin(), base64EncodedText.end(), '_', '/');
56 base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '='); 61 base64EncodedText.append((4 - base64EncodedText.size() % 4) % 4, '=');
57 return base::Base64Decode(base64EncodedText, output); 62 return base::Base64Decode(base64EncodedText, output);
58 } 63 }
59 64
60 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( 65 blink::WebCryptoAlgorithm GetInnerHashAlgorithm(
61 const blink::WebCryptoAlgorithm& algorithm) { 66 const blink::WebCryptoAlgorithm& algorithm) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 key_length_bits); 170 key_length_bits);
166 } 171 }
167 172
168 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( 173 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(
169 unsigned short key_length_bits) { 174 unsigned short key_length_bits) {
170 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm, 175 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesGcm,
171 key_length_bits); 176 key_length_bits);
172 } 177 }
173 178
174 } // namespace content 179 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698