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

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

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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/webcrypto/algorithms/secret_key_util.h" 5 #include "components/webcrypto/algorithms/secret_key_util.h"
6 6
7 #include <openssl/rand.h> 7 #include <openssl/rand.h>
8 8
9 #include "components/webcrypto/algorithms/util.h" 9 #include "components/webcrypto/algorithms/util.h"
10 #include "components/webcrypto/blink_key_handle.h" 10 #include "components/webcrypto/blink_key_handle.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const blink::WebCryptoKeyAlgorithm& algorithm, 43 const blink::WebCryptoKeyAlgorithm& algorithm,
44 bool extractable, 44 bool extractable,
45 blink::WebCryptoKeyUsageMask usages, 45 blink::WebCryptoKeyUsageMask usages,
46 blink::WebCryptoKey* key) { 46 blink::WebCryptoKey* key) {
47 *key = blink::WebCryptoKey::create(CreateSymmetricKeyHandle(key_data), 47 *key = blink::WebCryptoKey::create(CreateSymmetricKeyHandle(key_data),
48 blink::WebCryptoKeyTypeSecret, extractable, 48 blink::WebCryptoKeyTypeSecret, extractable,
49 algorithm, usages); 49 algorithm, usages);
50 return Status::Success(); 50 return Status::Success();
51 } 51 }
52 52
53 Status CheckSecretKeyCreationUsages(
54 blink::WebCryptoKeyUsageMask all_possible_usages,
55 blink::WebCryptoKeyUsageMask actual_usages) {
56 return CheckKeyCreationUsages(all_possible_usages, actual_usages,
57 EmptyUsagePolicy::REJECT_EMPTY);
58 }
59
60 void WriteSecretKeyJwk(const CryptoData& raw_key_data, 53 void WriteSecretKeyJwk(const CryptoData& raw_key_data,
61 const std::string& algorithm, 54 const std::string& algorithm,
62 bool extractable, 55 bool extractable,
63 blink::WebCryptoKeyUsageMask usages, 56 blink::WebCryptoKeyUsageMask usages,
64 std::vector<uint8_t>* jwk_key_data) { 57 std::vector<uint8_t>* jwk_key_data) {
65 JwkWriter writer(algorithm, extractable, usages, "oct"); 58 JwkWriter writer(algorithm, extractable, usages, "oct");
66 writer.SetBytes("k", raw_key_data); 59 writer.SetBytes("k", raw_key_data);
67 writer.ToJson(jwk_key_data); 60 writer.ToJson(jwk_key_data);
68 } 61 }
69 62
(...skipping 11 matching lines...) Expand all
81 std::string jwk_k_value; 74 std::string jwk_k_value;
82 status = jwk->GetBytes("k", &jwk_k_value); 75 status = jwk->GetBytes("k", &jwk_k_value);
83 if (status.IsError()) 76 if (status.IsError())
84 return status; 77 return status;
85 raw_key_data->assign(jwk_k_value.begin(), jwk_k_value.end()); 78 raw_key_data->assign(jwk_k_value.begin(), jwk_k_value.end());
86 79
87 return Status::Success(); 80 return Status::Success();
88 } 81 }
89 82
90 } // namespace webcrypto 83 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithms/secret_key_util.h ('k') | components/webcrypto/algorithms/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698