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

Side by Side Diff: components/webcrypto/algorithm_implementation.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
« no previous file with comments | « components/webcrypto/algorithm_implementation.h ('k') | components/webcrypto/algorithms/aes.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 "components/webcrypto/algorithm_implementation.h" 5 #include "components/webcrypto/algorithm_implementation.h"
6 6
7 #include "components/webcrypto/blink_key_handle.h" 7 #include "components/webcrypto/blink_key_handle.h"
8 #include "components/webcrypto/status.h" 8 #include "components/webcrypto/status.h"
9 9
10 namespace webcrypto { 10 namespace webcrypto {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return Status::ErrorUnsupported(); 68 return Status::ErrorUnsupported();
69 } 69 }
70 70
71 Status AlgorithmImplementation::GetKeyLength( 71 Status AlgorithmImplementation::GetKeyLength(
72 const blink::WebCryptoAlgorithm& key_length_algorithm, 72 const blink::WebCryptoAlgorithm& key_length_algorithm,
73 bool* has_length_bits, 73 bool* has_length_bits,
74 unsigned int* length_bits) const { 74 unsigned int* length_bits) const {
75 return Status::ErrorUnsupported(); 75 return Status::ErrorUnsupported();
76 } 76 }
77 77
78 Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey(
79 blink::WebCryptoKeyFormat format,
80 blink::WebCryptoKeyUsageMask usages) const {
81 return Status::ErrorUnsupportedImportKeyFormat();
82 }
83
84 Status AlgorithmImplementation::ImportKey( 78 Status AlgorithmImplementation::ImportKey(
85 blink::WebCryptoKeyFormat format, 79 blink::WebCryptoKeyFormat format,
86 const CryptoData& key_data, 80 const CryptoData& key_data,
87 const blink::WebCryptoAlgorithm& algorithm, 81 const blink::WebCryptoAlgorithm& algorithm,
88 bool extractable, 82 bool extractable,
89 blink::WebCryptoKeyUsageMask usages, 83 blink::WebCryptoKeyUsageMask usages,
90 blink::WebCryptoKey* key) const { 84 blink::WebCryptoKey* key) const {
91 switch (format) { 85 return Status::ErrorUnsupported();
92 case blink::WebCryptoKeyFormatRaw:
93 return ImportKeyRaw(key_data, algorithm, extractable, usages, key);
94 case blink::WebCryptoKeyFormatSpki:
95 return ImportKeySpki(key_data, algorithm, extractable, usages, key);
96 case blink::WebCryptoKeyFormatPkcs8:
97 return ImportKeyPkcs8(key_data, algorithm, extractable, usages, key);
98 case blink::WebCryptoKeyFormatJwk:
99 return ImportKeyJwk(key_data, algorithm, extractable, usages, key);
100 default:
101 return Status::ErrorUnsupported();
102 }
103 }
104
105 Status AlgorithmImplementation::ImportKeyRaw(
106 const CryptoData& key_data,
107 const blink::WebCryptoAlgorithm& algorithm,
108 bool extractable,
109 blink::WebCryptoKeyUsageMask usages,
110 blink::WebCryptoKey* key) const {
111 return Status::ErrorUnsupportedImportKeyFormat();
112 }
113
114 Status AlgorithmImplementation::ImportKeyPkcs8(
115 const CryptoData& key_data,
116 const blink::WebCryptoAlgorithm& algorithm,
117 bool extractable,
118 blink::WebCryptoKeyUsageMask usages,
119 blink::WebCryptoKey* key) const {
120 return Status::ErrorUnsupportedImportKeyFormat();
121 }
122
123 Status AlgorithmImplementation::ImportKeySpki(
124 const CryptoData& key_data,
125 const blink::WebCryptoAlgorithm& algorithm,
126 bool extractable,
127 blink::WebCryptoKeyUsageMask usages,
128 blink::WebCryptoKey* key) const {
129 return Status::ErrorUnsupportedImportKeyFormat();
130 }
131
132 Status AlgorithmImplementation::ImportKeyJwk(
133 const CryptoData& key_data,
134 const blink::WebCryptoAlgorithm& algorithm,
135 bool extractable,
136 blink::WebCryptoKeyUsageMask usages,
137 blink::WebCryptoKey* key) const {
138 return Status::ErrorUnsupportedImportKeyFormat();
139 } 86 }
140 87
141 Status AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format, 88 Status AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format,
142 const blink::WebCryptoKey& key, 89 const blink::WebCryptoKey& key,
143 std::vector<uint8_t>* buffer) const { 90 std::vector<uint8_t>* buffer) const {
144 switch (format) { 91 return Status::ErrorUnsupported();
145 case blink::WebCryptoKeyFormatRaw:
146 return ExportKeyRaw(key, buffer);
147 case blink::WebCryptoKeyFormatSpki:
148 return ExportKeySpki(key, buffer);
149 case blink::WebCryptoKeyFormatPkcs8:
150 return ExportKeyPkcs8(key, buffer);
151 case blink::WebCryptoKeyFormatJwk:
152 return ExportKeyJwk(key, buffer);
153 default:
154 return Status::ErrorUnsupported();
155 }
156 }
157
158 Status AlgorithmImplementation::ExportKeyRaw(
159 const blink::WebCryptoKey& key,
160 std::vector<uint8_t>* buffer) const {
161 return Status::ErrorUnsupportedExportKeyFormat();
162 }
163
164 Status AlgorithmImplementation::ExportKeyPkcs8(
165 const blink::WebCryptoKey& key,
166 std::vector<uint8_t>* buffer) const {
167 return Status::ErrorUnsupportedExportKeyFormat();
168 }
169
170 Status AlgorithmImplementation::ExportKeySpki(
171 const blink::WebCryptoKey& key,
172 std::vector<uint8_t>* buffer) const {
173 return Status::ErrorUnsupportedExportKeyFormat();
174 }
175
176 Status AlgorithmImplementation::ExportKeyJwk(
177 const blink::WebCryptoKey& key,
178 std::vector<uint8_t>* buffer) const {
179 return Status::ErrorUnsupportedExportKeyFormat();
180 } 92 }
181 93
182 Status AlgorithmImplementation::SerializeKeyForClone( 94 Status AlgorithmImplementation::SerializeKeyForClone(
183 const blink::WebCryptoKey& key, 95 const blink::WebCryptoKey& key,
184 blink::WebVector<uint8_t>* key_data) const { 96 blink::WebVector<uint8_t>* key_data) const {
185 *key_data = GetSerializedKeyData(key); 97 *key_data = GetSerializedKeyData(key);
186 return Status::Success(); 98 return Status::Success();
187 } 99 }
188 100
189 Status AlgorithmImplementation::DeserializeKeyForClone( 101 Status AlgorithmImplementation::DeserializeKeyForClone(
190 const blink::WebCryptoKeyAlgorithm& algorithm, 102 const blink::WebCryptoKeyAlgorithm& algorithm,
191 blink::WebCryptoKeyType type, 103 blink::WebCryptoKeyType type,
192 bool extractable, 104 bool extractable,
193 blink::WebCryptoKeyUsageMask usages, 105 blink::WebCryptoKeyUsageMask usages,
194 const CryptoData& key_data, 106 const CryptoData& key_data,
195 blink::WebCryptoKey* key) const { 107 blink::WebCryptoKey* key) const {
196 return Status::ErrorUnsupported(); 108 return Status::ErrorUnsupported();
197 } 109 }
198 110
199 } // namespace webcrypto 111 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/webcrypto/algorithm_implementation.h ('k') | components/webcrypto/algorithms/aes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698