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

Side by Side Diff: content/child/webcrypto/algorithm_implementation.h

Issue 794873002: Refactor: Remove switch statements on key format from algorithm_dispatch.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 CONTENT_CHILD_WEBCRYPTO_ALGORITHM_IMPLEMENTATION_H_ 5 #ifndef CONTENT_CHILD_WEBCRYPTO_ALGORITHM_IMPLEMENTATION_H_
6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_IMPLEMENTATION_H_ 6 #define CONTENT_CHILD_WEBCRYPTO_ALGORITHM_IMPLEMENTATION_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // For instance, importing an RSA-SSA key with 'spki' format and Sign usage 100 // For instance, importing an RSA-SSA key with 'spki' format and Sign usage
101 // is invalid. The 'spki' format implies it will be a public key, and public 101 // is invalid. The 'spki' format implies it will be a public key, and public
102 // keys do not support signing. 102 // keys do not support signing.
103 // 103 //
104 // When called with format=JWK the key type may be unknown. The 104 // When called with format=JWK the key type may be unknown. The
105 // ImportKeyJwk() must do the final usage check. 105 // ImportKeyJwk() must do the final usage check.
106 virtual Status VerifyKeyUsagesBeforeImportKey( 106 virtual Status VerifyKeyUsagesBeforeImportKey(
107 blink::WebCryptoKeyFormat format, 107 blink::WebCryptoKeyFormat format,
108 blink::WebCryptoKeyUsageMask usages) const; 108 blink::WebCryptoKeyUsageMask usages) const;
109 109
110 // Dispatches to the format-specific ImportKey* method.
111 Status ImportKey(blink::WebCryptoKeyFormat format,
112 const CryptoData& key_data,
113 const blink::WebCryptoAlgorithm& algorithm,
114 bool extractable,
115 blink::WebCryptoKeyUsageMask usages,
116 blink::WebCryptoKey* key) const;
117
110 // This method corresponds to Web Crypto's 118 // This method corresponds to Web Crypto's
111 // crypto.subtle.importKey(format='raw'). 119 // crypto.subtle.importKey(format='raw').
112 virtual Status ImportKeyRaw(const CryptoData& key_data, 120 virtual Status ImportKeyRaw(const CryptoData& key_data,
113 const blink::WebCryptoAlgorithm& algorithm, 121 const blink::WebCryptoAlgorithm& algorithm,
114 bool extractable, 122 bool extractable,
115 blink::WebCryptoKeyUsageMask usages, 123 blink::WebCryptoKeyUsageMask usages,
116 blink::WebCryptoKey* key) const; 124 blink::WebCryptoKey* key) const;
117 125
118 // This method corresponds to Web Crypto's 126 // This method corresponds to Web Crypto's
119 // crypto.subtle.importKey(format='pkcs8'). 127 // crypto.subtle.importKey(format='pkcs8').
(...skipping 16 matching lines...) Expand all
136 virtual Status ImportKeyJwk(const CryptoData& key_data, 144 virtual Status ImportKeyJwk(const CryptoData& key_data,
137 const blink::WebCryptoAlgorithm& algorithm, 145 const blink::WebCryptoAlgorithm& algorithm,
138 bool extractable, 146 bool extractable,
139 blink::WebCryptoKeyUsageMask usages, 147 blink::WebCryptoKeyUsageMask usages,
140 blink::WebCryptoKey* key) const; 148 blink::WebCryptoKey* key) const;
141 149
142 // ----------------------------------------------- 150 // -----------------------------------------------
143 // Key export 151 // Key export
144 // ----------------------------------------------- 152 // -----------------------------------------------
145 153
154 // Dispatches to the format-specific ExportKey* method.
155 Status ExportKey(blink::WebCryptoKeyFormat format,
156 const blink::WebCryptoKey& key,
157 std::vector<uint8_t>* buffer) const;
158
146 virtual Status ExportKeyRaw(const blink::WebCryptoKey& key, 159 virtual Status ExportKeyRaw(const blink::WebCryptoKey& key,
147 std::vector<uint8_t>* buffer) const; 160 std::vector<uint8_t>* buffer) const;
148 161
149 virtual Status ExportKeyPkcs8(const blink::WebCryptoKey& key, 162 virtual Status ExportKeyPkcs8(const blink::WebCryptoKey& key,
150 std::vector<uint8_t>* buffer) const; 163 std::vector<uint8_t>* buffer) const;
151 164
152 virtual Status ExportKeySpki(const blink::WebCryptoKey& key, 165 virtual Status ExportKeySpki(const blink::WebCryptoKey& key,
153 std::vector<uint8_t>* buffer) const; 166 std::vector<uint8_t>* buffer) const;
154 167
155 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, 168 virtual Status ExportKeyJwk(const blink::WebCryptoKey& key,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 blink::WebCryptoKeyUsageMask usages, 201 blink::WebCryptoKeyUsageMask usages,
189 const CryptoData& key_data, 202 const CryptoData& key_data,
190 blink::WebCryptoKey* key) const; 203 blink::WebCryptoKey* key) const;
191 }; 204 };
192 205
193 } // namespace webcrypto 206 } // namespace webcrypto
194 207
195 } // namespace content 208 } // namespace content
196 209
197 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_IMPLEMENTATION_H_ 210 #endif // CONTENT_CHILD_WEBCRYPTO_ALGORITHM_IMPLEMENTATION_H_
OLDNEW
« no previous file with comments | « content/child/webcrypto/algorithm_dispatch.cc ('k') | content/child/webcrypto/algorithm_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698