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

Side by Side Diff: components/webcrypto/jwk.cc

Issue 1077273002: html_viewer: Move webcrypto to a place where html_viewer can use it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to ToT Created 5 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 | « components/webcrypto/jwk.h ('k') | components/webcrypto/nss/aes_algorithm_nss.h » ('j') | 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/jwk.h" 5 #include "components/webcrypto/jwk.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "content/child/webcrypto/crypto_data.h" 15 #include "components/webcrypto/crypto_data.h"
16 #include "content/child/webcrypto/status.h" 16 #include "components/webcrypto/status.h"
17 #include "content/child/webcrypto/webcrypto_util.h" 17 #include "components/webcrypto/webcrypto_util.h"
18 18
19 // TODO(eroman): The algorithm-specific logic in this file for AES and RSA 19 // TODO(eroman): The algorithm-specific logic in this file for AES and RSA
20 // should be moved into the corresponding AlgorithmImplementation file. It 20 // should be moved into the corresponding AlgorithmImplementation file. It
21 // exists in this file to avoid duplication between OpenSSL and NSS 21 // exists in this file to avoid duplication between OpenSSL and NSS
22 // implementations. 22 // implementations.
23 23
24 // JSON Web Key Format (JWK) is defined by: 24 // JSON Web Key Format (JWK) is defined by:
25 // http://tools.ietf.org/html/draft-ietf-jose-json-web-key 25 // http://tools.ietf.org/html/draft-ietf-jose-json-web-key
26 // 26 //
27 // A JWK is a simple JSON dictionary with the following members: 27 // A JWK is a simple JSON dictionary with the following members:
28 // - "kty" (Key Type) Parameter, REQUIRED 28 // - "kty" (Key Type) Parameter, REQUIRED
29 // - <kty-specific parameters, see below>, REQUIRED 29 // - <kty-specific parameters, see below>, REQUIRED
30 // - "use" (Key Use) OPTIONAL 30 // - "use" (Key Use) OPTIONAL
31 // - "key_ops" (Key Operations) OPTIONAL 31 // - "key_ops" (Key Operations) OPTIONAL
32 // - "alg" (Algorithm) OPTIONAL 32 // - "alg" (Algorithm) OPTIONAL
33 // - "ext" (Key Exportability), OPTIONAL 33 // - "ext" (Key Exportability), OPTIONAL
34 // (all other entries are ignored) 34 // (all other entries are ignored)
35 // 35 //
36 // The <kty-specific parameters> are defined by the JWA spec: 36 // The <kty-specific parameters> are defined by the JWA spec:
37 // http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms 37 // http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms
38 38
39 namespace content {
40
41 namespace webcrypto { 39 namespace webcrypto {
42 40
43 namespace { 41 namespace {
44 42
45 // Web Crypto equivalent usage mask for JWK 'use' = 'enc'. 43 // Web Crypto equivalent usage mask for JWK 'use' = 'enc'.
46 const blink::WebCryptoKeyUsageMask kJwkEncUsage = 44 const blink::WebCryptoKeyUsageMask kJwkEncUsage =
47 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt | 45 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt |
48 blink::WebCryptoKeyUsageWrapKey | blink::WebCryptoKeyUsageUnwrapKey; 46 blink::WebCryptoKeyUsageWrapKey | blink::WebCryptoKeyUsageUnwrapKey;
49 // Web Crypto equivalent usage mask for JWK 'use' = 'sig'. 47 // Web Crypto equivalent usage mask for JWK 'use' = 'sig'.
50 const blink::WebCryptoKeyUsageMask kJwkSigUsage = 48 const blink::WebCryptoKeyUsageMask kJwkSigUsage =
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return Base64EncodeUrlSafe(string_piece); 609 return Base64EncodeUrlSafe(string_piece);
612 } 610 }
613 611
614 Status GetWebCryptoUsagesFromJwkKeyOpsForTest( 612 Status GetWebCryptoUsagesFromJwkKeyOpsForTest(
615 const base::ListValue* key_ops, 613 const base::ListValue* key_ops,
616 blink::WebCryptoKeyUsageMask* usages) { 614 blink::WebCryptoKeyUsageMask* usages) {
617 return GetWebCryptoUsagesFromJwkKeyOps(key_ops, usages); 615 return GetWebCryptoUsagesFromJwkKeyOps(key_ops, usages);
618 } 616 }
619 617
620 } // namespace webcrypto 618 } // namespace webcrypto
621
622 } // namespace content
OLDNEW
« no previous file with comments | « components/webcrypto/jwk.h ('k') | components/webcrypto/nss/aes_algorithm_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698