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

Side by Side Diff: components/webcrypto/algorithms/secret_key_util.h

Issue 2163053002: [webcrypto] Check for empty key usages *after* key creation rather than before, to match the spec's… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
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 #ifndef COMPONENTS_WEBCRYPTO_ALGORITHMS_SECRET_KEY_UTIL_ 5 #ifndef COMPONENTS_WEBCRYPTO_ALGORITHMS_SECRET_KEY_UTIL_
6 #define COMPONENTS_WEBCRYPTO_ALGORITHMS_SECRET_KEY_UTIL_ 6 #define COMPONENTS_WEBCRYPTO_ALGORITHMS_SECRET_KEY_UTIL_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 23 matching lines...) Expand all
34 34
35 // Creates a WebCrypto secret key given the raw data. The provided |key_data| 35 // Creates a WebCrypto secret key given the raw data. The provided |key_data|
36 // will be copied into the new key. This function does not do any validation 36 // will be copied into the new key. This function does not do any validation
37 // checks for the provided parameters. 37 // checks for the provided parameters.
38 Status CreateWebCryptoSecretKey(const CryptoData& key_data, 38 Status CreateWebCryptoSecretKey(const CryptoData& key_data,
39 const blink::WebCryptoKeyAlgorithm& algorithm, 39 const blink::WebCryptoKeyAlgorithm& algorithm,
40 bool extractable, 40 bool extractable,
41 blink::WebCryptoKeyUsageMask usages, 41 blink::WebCryptoKeyUsageMask usages,
42 blink::WebCryptoKey* key); 42 blink::WebCryptoKey* key);
43 43
44 // Checks that |actual_usages| is a non-empty subset of |all_possible_usages|.
45 Status CheckSecretKeyCreationUsages(
46 blink::WebCryptoKeyUsageMask all_possible_usages,
47 blink::WebCryptoKeyUsageMask actual_usages);
48
49 // Writes a JWK-formatted symmetric key to |jwk_key_data|. 44 // Writes a JWK-formatted symmetric key to |jwk_key_data|.
50 // * raw_key_data: The actual key data 45 // * raw_key_data: The actual key data
51 // * algorithm: The JWK algorithm name (i.e. "alg") 46 // * algorithm: The JWK algorithm name (i.e. "alg")
52 // * extractable: The JWK extractability (i.e. "ext") 47 // * extractable: The JWK extractability (i.e. "ext")
53 // * usages: The JWK usages (i.e. "key_ops") 48 // * usages: The JWK usages (i.e. "key_ops")
54 void WriteSecretKeyJwk(const CryptoData& raw_key_data, 49 void WriteSecretKeyJwk(const CryptoData& raw_key_data,
55 const std::string& algorithm, 50 const std::string& algorithm,
56 bool extractable, 51 bool extractable,
57 blink::WebCryptoKeyUsageMask usages, 52 blink::WebCryptoKeyUsageMask usages,
58 std::vector<uint8_t>* jwk_key_data); 53 std::vector<uint8_t>* jwk_key_data);
59 54
60 // Parses a UTF-8 encoded JWK (key_data), and extracts the key material to 55 // Parses a UTF-8 encoded JWK (key_data), and extracts the key material to
61 // |*raw_key_data|. Returns Status::Success() on success, otherwise an error. 56 // |*raw_key_data|. Returns Status::Success() on success, otherwise an error.
62 // In order for this to succeed: 57 // In order for this to succeed:
63 // * expected_extractable must be consistent with the JWK's "ext", if 58 // * expected_extractable must be consistent with the JWK's "ext", if
64 // present. 59 // present.
65 // * expected_usages must be a subset of the JWK's "key_ops" if present. 60 // * expected_usages must be a subset of the JWK's "key_ops" if present.
66 Status ReadSecretKeyNoExpectedAlgJwk( 61 Status ReadSecretKeyNoExpectedAlgJwk(
67 const CryptoData& key_data, 62 const CryptoData& key_data,
68 bool expected_extractable, 63 bool expected_extractable,
69 blink::WebCryptoKeyUsageMask expected_usages, 64 blink::WebCryptoKeyUsageMask expected_usages,
70 std::vector<uint8_t>* raw_key_data, 65 std::vector<uint8_t>* raw_key_data,
71 JwkReader* jwk); 66 JwkReader* jwk);
72 67
73 } // namespace webcrypto 68 } // namespace webcrypto
74 69
75 #endif // COMPONENTS_WEBCRYPTO_ALGORITHMS_SECRET_KEY_UTIL_ 70 #endif // COMPONENTS_WEBCRYPTO_ALGORITHMS_SECRET_KEY_UTIL_
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/rsa_ssa_unittest.cc ('k') | components/webcrypto/algorithms/secret_key_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698