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

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

Issue 205913002: [webcrypto] Add JWK RSA public key export for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 8 months 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/child/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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/child/webcrypto/webcrypto_util.h" 5 #include "content/child/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 "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "content/child/webcrypto/status.h" 10 #include "content/child/webcrypto/status.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // inverse of the process above. 60 // inverse of the process above.
61 std::string Base64EncodeUrlSafe(const base::StringPiece& input) { 61 std::string Base64EncodeUrlSafe(const base::StringPiece& input) {
62 std::string output; 62 std::string output;
63 base::Base64Encode(input, &output); 63 base::Base64Encode(input, &output);
64 std::replace(output.begin(), output.end(), '+', '-'); 64 std::replace(output.begin(), output.end(), '+', '-');
65 std::replace(output.begin(), output.end(), '/', '_'); 65 std::replace(output.begin(), output.end(), '/', '_');
66 output.erase(std::remove(output.begin(), output.end(), '='), output.end()); 66 output.erase(std::remove(output.begin(), output.end(), '='), output.end());
67 return output; 67 return output;
68 } 68 }
69 69
70 std::string Base64EncodeUrlSafe(const std::vector<uint8>& input) {
71 const base::StringPiece string_piece(
72 reinterpret_cast<const char*>(Uint8VectorStart(input)), input.size());
73 return Base64EncodeUrlSafe(string_piece);
74 }
75
70 struct JwkToWebCryptoUsage { 76 struct JwkToWebCryptoUsage {
71 const char* const jwk_key_op; 77 const char* const jwk_key_op;
72 const blink::WebCryptoKeyUsage webcrypto_usage; 78 const blink::WebCryptoKeyUsage webcrypto_usage;
73 }; 79 };
74 80
75 const JwkToWebCryptoUsage kJwkWebCryptoUsageMap[] = { 81 const JwkToWebCryptoUsage kJwkWebCryptoUsageMap[] = {
76 {"encrypt", blink::WebCryptoKeyUsageEncrypt}, 82 {"encrypt", blink::WebCryptoKeyUsageEncrypt},
77 {"decrypt", blink::WebCryptoKeyUsageDecrypt}, 83 {"decrypt", blink::WebCryptoKeyUsageDecrypt},
78 {"deriveKey", blink::WebCryptoKeyUsageDeriveKey}, 84 {"deriveKey", blink::WebCryptoKeyUsageDeriveKey},
79 // TODO(padolph): Add 'deriveBits' once supported by Blink. 85 // TODO(padolph): Add 'deriveBits' once supported by Blink.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 algorithm.id(), keylen_bytes * 8); 223 algorithm.id(), keylen_bytes * 8);
218 return true; 224 return true;
219 default: 225 default:
220 return false; 226 return false;
221 } 227 }
222 } 228 }
223 229
224 } // namespace webcrypto 230 } // namespace webcrypto
225 231
226 } // namespace content 232 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698