blob: 1d98b4427ba8b5a381994db3f80aa2509a807759 [file] [log] [blame]
[email protected]38409aec2014-07-19 00:54:511// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
erg56f12322015-04-17 00:51:485#include "components/webcrypto/algorithm_implementation.h"
[email protected]38409aec2014-07-19 00:54:516
erg56f12322015-04-17 00:51:487#include "components/webcrypto/status.h"
[email protected]38409aec2014-07-19 00:54:518
9namespace webcrypto {
10
11AlgorithmImplementation::~AlgorithmImplementation() {
12}
13
14Status AlgorithmImplementation::Encrypt(
15 const blink::WebCryptoAlgorithm& algorithm,
16 const blink::WebCryptoKey& key,
17 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3818 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5119 return Status::ErrorUnsupported();
20}
21
22Status AlgorithmImplementation::Decrypt(
23 const blink::WebCryptoAlgorithm& algorithm,
24 const blink::WebCryptoKey& key,
25 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3826 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5127 return Status::ErrorUnsupported();
28}
29
30Status AlgorithmImplementation::Sign(const blink::WebCryptoAlgorithm& algorithm,
31 const blink::WebCryptoKey& key,
32 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3833 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5134 return Status::ErrorUnsupported();
35}
36
37Status AlgorithmImplementation::Verify(
38 const blink::WebCryptoAlgorithm& algorithm,
39 const blink::WebCryptoKey& key,
40 const CryptoData& signature,
41 const CryptoData& data,
42 bool* signature_match) const {
43 return Status::ErrorUnsupported();
44}
45
46Status AlgorithmImplementation::Digest(
47 const blink::WebCryptoAlgorithm& algorithm,
48 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3849 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5150 return Status::ErrorUnsupported();
51}
52
eroman9b747eaf2014-10-18 22:03:2853Status AlgorithmImplementation::GenerateKey(
[email protected]38409aec2014-07-19 00:54:5154 const blink::WebCryptoAlgorithm& algorithm,
55 bool extractable,
eroman0e1d34e2014-10-21 19:13:3156 blink::WebCryptoKeyUsageMask usages,
eroman9b747eaf2014-10-18 22:03:2857 GenerateKeyResult* result) const {
[email protected]38409aec2014-07-19 00:54:5158 return Status::ErrorUnsupported();
59}
60
eroman1499b4942014-11-26 19:59:5361Status AlgorithmImplementation::DeriveBits(
62 const blink::WebCryptoAlgorithm& algorithm,
63 const blink::WebCryptoKey& base_key,
eroman20bf4c3c2014-12-12 17:22:3764 bool has_optional_length_bits,
65 unsigned int optional_length_bits,
eroman1499b4942014-11-26 19:59:5366 std::vector<uint8_t>* derived_bytes) const {
67 return Status::ErrorUnsupported();
68}
69
eromanf93fd5b2014-12-11 00:21:0670Status AlgorithmImplementation::GetKeyLength(
71 const blink::WebCryptoAlgorithm& key_length_algorithm,
72 bool* has_length_bits,
73 unsigned int* length_bits) const {
74 return Status::ErrorUnsupported();
75}
76
[email protected]38409aec2014-07-19 00:54:5177Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey(
78 blink::WebCryptoKeyFormat format,
eroman0e1d34e2014-10-21 19:13:3179 blink::WebCryptoKeyUsageMask usages) const {
[email protected]38409aec2014-07-19 00:54:5180 return Status::ErrorUnsupportedImportKeyFormat();
81}
82
eromana22536b22014-12-12 03:29:2883Status AlgorithmImplementation::ImportKey(
84 blink::WebCryptoKeyFormat format,
85 const CryptoData& key_data,
86 const blink::WebCryptoAlgorithm& algorithm,
87 bool extractable,
88 blink::WebCryptoKeyUsageMask usages,
89 blink::WebCryptoKey* key) const {
90 switch (format) {
91 case blink::WebCryptoKeyFormatRaw:
92 return ImportKeyRaw(key_data, algorithm, extractable, usages, key);
93 case blink::WebCryptoKeyFormatSpki:
94 return ImportKeySpki(key_data, algorithm, extractable, usages, key);
95 case blink::WebCryptoKeyFormatPkcs8:
96 return ImportKeyPkcs8(key_data, algorithm, extractable, usages, key);
97 case blink::WebCryptoKeyFormatJwk:
98 return ImportKeyJwk(key_data, algorithm, extractable, usages, key);
99 default:
100 return Status::ErrorUnsupported();
101 }
102}
103
[email protected]38409aec2014-07-19 00:54:51104Status AlgorithmImplementation::ImportKeyRaw(
105 const CryptoData& key_data,
106 const blink::WebCryptoAlgorithm& algorithm,
107 bool extractable,
eroman0e1d34e2014-10-21 19:13:31108 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51109 blink::WebCryptoKey* key) const {
110 return Status::ErrorUnsupportedImportKeyFormat();
111}
112
113Status AlgorithmImplementation::ImportKeyPkcs8(
114 const CryptoData& key_data,
115 const blink::WebCryptoAlgorithm& algorithm,
116 bool extractable,
eroman0e1d34e2014-10-21 19:13:31117 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51118 blink::WebCryptoKey* key) const {
119 return Status::ErrorUnsupportedImportKeyFormat();
120}
121
122Status AlgorithmImplementation::ImportKeySpki(
123 const CryptoData& key_data,
124 const blink::WebCryptoAlgorithm& algorithm,
125 bool extractable,
eroman0e1d34e2014-10-21 19:13:31126 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51127 blink::WebCryptoKey* key) const {
128 return Status::ErrorUnsupportedImportKeyFormat();
129}
130
131Status AlgorithmImplementation::ImportKeyJwk(
132 const CryptoData& key_data,
133 const blink::WebCryptoAlgorithm& algorithm,
134 bool extractable,
eroman0e1d34e2014-10-21 19:13:31135 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51136 blink::WebCryptoKey* key) const {
137 return Status::ErrorUnsupportedImportKeyFormat();
138}
139
eromana22536b22014-12-12 03:29:28140Status AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format,
141 const blink::WebCryptoKey& key,
142 std::vector<uint8_t>* buffer) const {
143 switch (format) {
144 case blink::WebCryptoKeyFormatRaw:
145 return ExportKeyRaw(key, buffer);
146 case blink::WebCryptoKeyFormatSpki:
147 return ExportKeySpki(key, buffer);
148 case blink::WebCryptoKeyFormatPkcs8:
149 return ExportKeyPkcs8(key, buffer);
150 case blink::WebCryptoKeyFormatJwk:
151 return ExportKeyJwk(key, buffer);
152 default:
153 return Status::ErrorUnsupported();
154 }
155}
156
[email protected]53b6c9d22014-07-19 05:08:38157Status AlgorithmImplementation::ExportKeyRaw(
158 const blink::WebCryptoKey& key,
159 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51160 return Status::ErrorUnsupportedExportKeyFormat();
161}
162
163Status AlgorithmImplementation::ExportKeyPkcs8(
164 const blink::WebCryptoKey& key,
[email protected]53b6c9d22014-07-19 05:08:38165 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51166 return Status::ErrorUnsupportedExportKeyFormat();
167}
168
169Status AlgorithmImplementation::ExportKeySpki(
170 const blink::WebCryptoKey& key,
[email protected]53b6c9d22014-07-19 05:08:38171 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51172 return Status::ErrorUnsupportedExportKeyFormat();
173}
174
[email protected]53b6c9d22014-07-19 05:08:38175Status AlgorithmImplementation::ExportKeyJwk(
176 const blink::WebCryptoKey& key,
177 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51178 return Status::ErrorUnsupportedExportKeyFormat();
179}
180
eromana895fed2014-11-08 03:10:25181Status AlgorithmImplementation::SerializeKeyForClone(
182 const blink::WebCryptoKey& key,
183 blink::WebVector<uint8_t>* key_data) const {
184 return Status::ErrorUnsupported();
185}
186
187Status AlgorithmImplementation::DeserializeKeyForClone(
188 const blink::WebCryptoKeyAlgorithm& algorithm,
189 blink::WebCryptoKeyType type,
190 bool extractable,
191 blink::WebCryptoKeyUsageMask usages,
192 const CryptoData& key_data,
193 blink::WebCryptoKey* key) const {
194 return Status::ErrorUnsupported();
195}
196
[email protected]38409aec2014-07-19 00:54:51197} // namespace webcrypto