blob: 2bbdcdc3f0ec8580da1a6ed338712053481142eb [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
5#include "content/child/webcrypto/algorithm_implementation.h"
6
7#include "content/child/webcrypto/status.h"
8
9namespace content {
10
11namespace webcrypto {
12
13AlgorithmImplementation::~AlgorithmImplementation() {
14}
15
16Status AlgorithmImplementation::Encrypt(
17 const blink::WebCryptoAlgorithm& algorithm,
18 const blink::WebCryptoKey& key,
19 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3820 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5121 return Status::ErrorUnsupported();
22}
23
24Status AlgorithmImplementation::Decrypt(
25 const blink::WebCryptoAlgorithm& algorithm,
26 const blink::WebCryptoKey& key,
27 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3828 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5129 return Status::ErrorUnsupported();
30}
31
32Status AlgorithmImplementation::Sign(const blink::WebCryptoAlgorithm& algorithm,
33 const blink::WebCryptoKey& key,
34 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3835 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5136 return Status::ErrorUnsupported();
37}
38
39Status AlgorithmImplementation::Verify(
40 const blink::WebCryptoAlgorithm& algorithm,
41 const blink::WebCryptoKey& key,
42 const CryptoData& signature,
43 const CryptoData& data,
44 bool* signature_match) const {
45 return Status::ErrorUnsupported();
46}
47
48Status AlgorithmImplementation::Digest(
49 const blink::WebCryptoAlgorithm& algorithm,
50 const CryptoData& data,
[email protected]53b6c9d22014-07-19 05:08:3851 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:5152 return Status::ErrorUnsupported();
53}
54
eroman9b747eaf2014-10-18 22:03:2855Status AlgorithmImplementation::GenerateKey(
[email protected]38409aec2014-07-19 00:54:5156 const blink::WebCryptoAlgorithm& algorithm,
57 bool extractable,
eroman0e1d34e2014-10-21 19:13:3158 blink::WebCryptoKeyUsageMask usages,
eroman9b747eaf2014-10-18 22:03:2859 GenerateKeyResult* result) const {
[email protected]38409aec2014-07-19 00:54:5160 return Status::ErrorUnsupported();
61}
62
eroman1499b4942014-11-26 19:59:5363Status AlgorithmImplementation::DeriveBits(
64 const blink::WebCryptoAlgorithm& algorithm,
65 const blink::WebCryptoKey& base_key,
eroman20bf4c3c2014-12-12 17:22:3766 bool has_optional_length_bits,
67 unsigned int optional_length_bits,
eroman1499b4942014-11-26 19:59:5368 std::vector<uint8_t>* derived_bytes) const {
69 return Status::ErrorUnsupported();
70}
71
eromanf93fd5b2014-12-11 00:21:0672Status AlgorithmImplementation::GetKeyLength(
73 const blink::WebCryptoAlgorithm& key_length_algorithm,
74 bool* has_length_bits,
75 unsigned int* length_bits) const {
76 return Status::ErrorUnsupported();
77}
78
[email protected]38409aec2014-07-19 00:54:5179Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey(
80 blink::WebCryptoKeyFormat format,
eroman0e1d34e2014-10-21 19:13:3181 blink::WebCryptoKeyUsageMask usages) const {
[email protected]38409aec2014-07-19 00:54:5182 return Status::ErrorUnsupportedImportKeyFormat();
83}
84
eromana22536b22014-12-12 03:29:2885Status AlgorithmImplementation::ImportKey(
86 blink::WebCryptoKeyFormat format,
87 const CryptoData& key_data,
88 const blink::WebCryptoAlgorithm& algorithm,
89 bool extractable,
90 blink::WebCryptoKeyUsageMask usages,
91 blink::WebCryptoKey* key) const {
92 switch (format) {
93 case blink::WebCryptoKeyFormatRaw:
94 return ImportKeyRaw(key_data, algorithm, extractable, usages, key);
95 case blink::WebCryptoKeyFormatSpki:
96 return ImportKeySpki(key_data, algorithm, extractable, usages, key);
97 case blink::WebCryptoKeyFormatPkcs8:
98 return ImportKeyPkcs8(key_data, algorithm, extractable, usages, key);
99 case blink::WebCryptoKeyFormatJwk:
100 return ImportKeyJwk(key_data, algorithm, extractable, usages, key);
101 default:
102 return Status::ErrorUnsupported();
103 }
104}
105
[email protected]38409aec2014-07-19 00:54:51106Status AlgorithmImplementation::ImportKeyRaw(
107 const CryptoData& key_data,
108 const blink::WebCryptoAlgorithm& algorithm,
109 bool extractable,
eroman0e1d34e2014-10-21 19:13:31110 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51111 blink::WebCryptoKey* key) const {
112 return Status::ErrorUnsupportedImportKeyFormat();
113}
114
115Status AlgorithmImplementation::ImportKeyPkcs8(
116 const CryptoData& key_data,
117 const blink::WebCryptoAlgorithm& algorithm,
118 bool extractable,
eroman0e1d34e2014-10-21 19:13:31119 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51120 blink::WebCryptoKey* key) const {
121 return Status::ErrorUnsupportedImportKeyFormat();
122}
123
124Status AlgorithmImplementation::ImportKeySpki(
125 const CryptoData& key_data,
126 const blink::WebCryptoAlgorithm& algorithm,
127 bool extractable,
eroman0e1d34e2014-10-21 19:13:31128 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51129 blink::WebCryptoKey* key) const {
130 return Status::ErrorUnsupportedImportKeyFormat();
131}
132
133Status AlgorithmImplementation::ImportKeyJwk(
134 const CryptoData& key_data,
135 const blink::WebCryptoAlgorithm& algorithm,
136 bool extractable,
eroman0e1d34e2014-10-21 19:13:31137 blink::WebCryptoKeyUsageMask usages,
[email protected]38409aec2014-07-19 00:54:51138 blink::WebCryptoKey* key) const {
139 return Status::ErrorUnsupportedImportKeyFormat();
140}
141
eromana22536b22014-12-12 03:29:28142Status AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format,
143 const blink::WebCryptoKey& key,
144 std::vector<uint8_t>* buffer) const {
145 switch (format) {
146 case blink::WebCryptoKeyFormatRaw:
147 return ExportKeyRaw(key, buffer);
148 case blink::WebCryptoKeyFormatSpki:
149 return ExportKeySpki(key, buffer);
150 case blink::WebCryptoKeyFormatPkcs8:
151 return ExportKeyPkcs8(key, buffer);
152 case blink::WebCryptoKeyFormatJwk:
153 return ExportKeyJwk(key, buffer);
154 default:
155 return Status::ErrorUnsupported();
156 }
157}
158
[email protected]53b6c9d22014-07-19 05:08:38159Status AlgorithmImplementation::ExportKeyRaw(
160 const blink::WebCryptoKey& key,
161 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51162 return Status::ErrorUnsupportedExportKeyFormat();
163}
164
165Status AlgorithmImplementation::ExportKeyPkcs8(
166 const blink::WebCryptoKey& key,
[email protected]53b6c9d22014-07-19 05:08:38167 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51168 return Status::ErrorUnsupportedExportKeyFormat();
169}
170
171Status AlgorithmImplementation::ExportKeySpki(
172 const blink::WebCryptoKey& key,
[email protected]53b6c9d22014-07-19 05:08:38173 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51174 return Status::ErrorUnsupportedExportKeyFormat();
175}
176
[email protected]53b6c9d22014-07-19 05:08:38177Status AlgorithmImplementation::ExportKeyJwk(
178 const blink::WebCryptoKey& key,
179 std::vector<uint8_t>* buffer) const {
[email protected]38409aec2014-07-19 00:54:51180 return Status::ErrorUnsupportedExportKeyFormat();
181}
182
eromana895fed2014-11-08 03:10:25183Status AlgorithmImplementation::SerializeKeyForClone(
184 const blink::WebCryptoKey& key,
185 blink::WebVector<uint8_t>* key_data) const {
186 return Status::ErrorUnsupported();
187}
188
189Status AlgorithmImplementation::DeserializeKeyForClone(
190 const blink::WebCryptoKeyAlgorithm& algorithm,
191 blink::WebCryptoKeyType type,
192 bool extractable,
193 blink::WebCryptoKeyUsageMask usages,
194 const CryptoData& key_data,
195 blink::WebCryptoKey* key) const {
196 return Status::ErrorUnsupported();
197}
198
[email protected]38409aec2014-07-19 00:54:51199} // namespace webcrypto
200
201} // namespace content