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

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

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
« no previous file with comments | « content/child/webcrypto/algorithm_implementation.h ('k') | no next file » | 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/algorithm_implementation.h" 5 #include "content/child/webcrypto/algorithm_implementation.h"
6 6
7 #include "content/child/webcrypto/status.h" 7 #include "content/child/webcrypto/status.h"
8 8
9 namespace content { 9 namespace content {
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 std::vector<uint8_t>* derived_bytes) const { 67 std::vector<uint8_t>* derived_bytes) const {
68 return Status::ErrorUnsupported(); 68 return Status::ErrorUnsupported();
69 } 69 }
70 70
71 Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey( 71 Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey(
72 blink::WebCryptoKeyFormat format, 72 blink::WebCryptoKeyFormat format,
73 blink::WebCryptoKeyUsageMask usages) const { 73 blink::WebCryptoKeyUsageMask usages) const {
74 return Status::ErrorUnsupportedImportKeyFormat(); 74 return Status::ErrorUnsupportedImportKeyFormat();
75 } 75 }
76 76
77 Status AlgorithmImplementation::ImportKey(
78 blink::WebCryptoKeyFormat format,
79 const CryptoData& key_data,
80 const blink::WebCryptoAlgorithm& algorithm,
81 bool extractable,
82 blink::WebCryptoKeyUsageMask usages,
83 blink::WebCryptoKey* key) const {
84 switch (format) {
85 case blink::WebCryptoKeyFormatRaw:
86 return ImportKeyRaw(key_data, algorithm, extractable, usages, key);
87 case blink::WebCryptoKeyFormatSpki:
88 return ImportKeySpki(key_data, algorithm, extractable, usages, key);
89 case blink::WebCryptoKeyFormatPkcs8:
90 return ImportKeyPkcs8(key_data, algorithm, extractable, usages, key);
91 case blink::WebCryptoKeyFormatJwk:
92 return ImportKeyJwk(key_data, algorithm, extractable, usages, key);
93 default:
94 return Status::ErrorUnsupported();
95 }
96 }
97
77 Status AlgorithmImplementation::ImportKeyRaw( 98 Status AlgorithmImplementation::ImportKeyRaw(
78 const CryptoData& key_data, 99 const CryptoData& key_data,
79 const blink::WebCryptoAlgorithm& algorithm, 100 const blink::WebCryptoAlgorithm& algorithm,
80 bool extractable, 101 bool extractable,
81 blink::WebCryptoKeyUsageMask usages, 102 blink::WebCryptoKeyUsageMask usages,
82 blink::WebCryptoKey* key) const { 103 blink::WebCryptoKey* key) const {
83 return Status::ErrorUnsupportedImportKeyFormat(); 104 return Status::ErrorUnsupportedImportKeyFormat();
84 } 105 }
85 106
86 Status AlgorithmImplementation::ImportKeyPkcs8( 107 Status AlgorithmImplementation::ImportKeyPkcs8(
(...skipping 16 matching lines...) Expand all
103 124
104 Status AlgorithmImplementation::ImportKeyJwk( 125 Status AlgorithmImplementation::ImportKeyJwk(
105 const CryptoData& key_data, 126 const CryptoData& key_data,
106 const blink::WebCryptoAlgorithm& algorithm, 127 const blink::WebCryptoAlgorithm& algorithm,
107 bool extractable, 128 bool extractable,
108 blink::WebCryptoKeyUsageMask usages, 129 blink::WebCryptoKeyUsageMask usages,
109 blink::WebCryptoKey* key) const { 130 blink::WebCryptoKey* key) const {
110 return Status::ErrorUnsupportedImportKeyFormat(); 131 return Status::ErrorUnsupportedImportKeyFormat();
111 } 132 }
112 133
134 Status AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format,
135 const blink::WebCryptoKey& key,
136 std::vector<uint8_t>* buffer) const {
137 switch (format) {
138 case blink::WebCryptoKeyFormatRaw:
139 return ExportKeyRaw(key, buffer);
140 case blink::WebCryptoKeyFormatSpki:
141 return ExportKeySpki(key, buffer);
142 case blink::WebCryptoKeyFormatPkcs8:
143 return ExportKeyPkcs8(key, buffer);
144 case blink::WebCryptoKeyFormatJwk:
145 return ExportKeyJwk(key, buffer);
146 default:
147 return Status::ErrorUnsupported();
148 }
149 }
150
113 Status AlgorithmImplementation::ExportKeyRaw( 151 Status AlgorithmImplementation::ExportKeyRaw(
114 const blink::WebCryptoKey& key, 152 const blink::WebCryptoKey& key,
115 std::vector<uint8_t>* buffer) const { 153 std::vector<uint8_t>* buffer) const {
116 return Status::ErrorUnsupportedExportKeyFormat(); 154 return Status::ErrorUnsupportedExportKeyFormat();
117 } 155 }
118 156
119 Status AlgorithmImplementation::ExportKeyPkcs8( 157 Status AlgorithmImplementation::ExportKeyPkcs8(
120 const blink::WebCryptoKey& key, 158 const blink::WebCryptoKey& key,
121 std::vector<uint8_t>* buffer) const { 159 std::vector<uint8_t>* buffer) const {
122 return Status::ErrorUnsupportedExportKeyFormat(); 160 return Status::ErrorUnsupportedExportKeyFormat();
(...skipping 23 matching lines...) Expand all
146 bool extractable, 184 bool extractable,
147 blink::WebCryptoKeyUsageMask usages, 185 blink::WebCryptoKeyUsageMask usages,
148 const CryptoData& key_data, 186 const CryptoData& key_data,
149 blink::WebCryptoKey* key) const { 187 blink::WebCryptoKey* key) const {
150 return Status::ErrorUnsupported(); 188 return Status::ErrorUnsupported();
151 } 189 }
152 190
153 } // namespace webcrypto 191 } // namespace webcrypto
154 192
155 } // namespace content 193 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/algorithm_implementation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698