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
3 // found in the LICENSE file.
5 #include "content/child/webcrypto/algorithm_implementation.h"
7 #include "content/child/webcrypto/status.h"
13 AlgorithmImplementation::~AlgorithmImplementation() {
16 Status
AlgorithmImplementation::Encrypt(
17 const blink::WebCryptoAlgorithm
& algorithm
,
18 const blink::WebCryptoKey
& key
,
19 const CryptoData
& data
,
20 std::vector
<uint8_t>* buffer
) const {
21 return Status::ErrorUnsupported();
24 Status
AlgorithmImplementation::Decrypt(
25 const blink::WebCryptoAlgorithm
& algorithm
,
26 const blink::WebCryptoKey
& key
,
27 const CryptoData
& data
,
28 std::vector
<uint8_t>* buffer
) const {
29 return Status::ErrorUnsupported();
32 Status
AlgorithmImplementation::Sign(const blink::WebCryptoAlgorithm
& algorithm
,
33 const blink::WebCryptoKey
& key
,
34 const CryptoData
& data
,
35 std::vector
<uint8_t>* buffer
) const {
36 return Status::ErrorUnsupported();
39 Status
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();
48 Status
AlgorithmImplementation::Digest(
49 const blink::WebCryptoAlgorithm
& algorithm
,
50 const CryptoData
& data
,
51 std::vector
<uint8_t>* buffer
) const {
52 return Status::ErrorUnsupported();
55 Status
AlgorithmImplementation::GenerateKey(
56 const blink::WebCryptoAlgorithm
& algorithm
,
58 blink::WebCryptoKeyUsageMask usages
,
59 GenerateKeyResult
* result
) const {
60 return Status::ErrorUnsupported();
63 Status
AlgorithmImplementation::DeriveBits(
64 const blink::WebCryptoAlgorithm
& algorithm
,
65 const blink::WebCryptoKey
& base_key
,
66 bool has_optional_length_bits
,
67 unsigned int optional_length_bits
,
68 std::vector
<uint8_t>* derived_bytes
) const {
69 return Status::ErrorUnsupported();
72 Status
AlgorithmImplementation::GetKeyLength(
73 const blink::WebCryptoAlgorithm
& key_length_algorithm
,
74 bool* has_length_bits
,
75 unsigned int* length_bits
) const {
76 return Status::ErrorUnsupported();
79 Status
AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey(
80 blink::WebCryptoKeyFormat format
,
81 blink::WebCryptoKeyUsageMask usages
) const {
82 return Status::ErrorUnsupportedImportKeyFormat();
85 Status
AlgorithmImplementation::ImportKey(
86 blink::WebCryptoKeyFormat format
,
87 const CryptoData
& key_data
,
88 const blink::WebCryptoAlgorithm
& algorithm
,
90 blink::WebCryptoKeyUsageMask usages
,
91 blink::WebCryptoKey
* key
) const {
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
);
102 return Status::ErrorUnsupported();
106 Status
AlgorithmImplementation::ImportKeyRaw(
107 const CryptoData
& key_data
,
108 const blink::WebCryptoAlgorithm
& algorithm
,
110 blink::WebCryptoKeyUsageMask usages
,
111 blink::WebCryptoKey
* key
) const {
112 return Status::ErrorUnsupportedImportKeyFormat();
115 Status
AlgorithmImplementation::ImportKeyPkcs8(
116 const CryptoData
& key_data
,
117 const blink::WebCryptoAlgorithm
& algorithm
,
119 blink::WebCryptoKeyUsageMask usages
,
120 blink::WebCryptoKey
* key
) const {
121 return Status::ErrorUnsupportedImportKeyFormat();
124 Status
AlgorithmImplementation::ImportKeySpki(
125 const CryptoData
& key_data
,
126 const blink::WebCryptoAlgorithm
& algorithm
,
128 blink::WebCryptoKeyUsageMask usages
,
129 blink::WebCryptoKey
* key
) const {
130 return Status::ErrorUnsupportedImportKeyFormat();
133 Status
AlgorithmImplementation::ImportKeyJwk(
134 const CryptoData
& key_data
,
135 const blink::WebCryptoAlgorithm
& algorithm
,
137 blink::WebCryptoKeyUsageMask usages
,
138 blink::WebCryptoKey
* key
) const {
139 return Status::ErrorUnsupportedImportKeyFormat();
142 Status
AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format
,
143 const blink::WebCryptoKey
& key
,
144 std::vector
<uint8_t>* buffer
) const {
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
);
155 return Status::ErrorUnsupported();
159 Status
AlgorithmImplementation::ExportKeyRaw(
160 const blink::WebCryptoKey
& key
,
161 std::vector
<uint8_t>* buffer
) const {
162 return Status::ErrorUnsupportedExportKeyFormat();
165 Status
AlgorithmImplementation::ExportKeyPkcs8(
166 const blink::WebCryptoKey
& key
,
167 std::vector
<uint8_t>* buffer
) const {
168 return Status::ErrorUnsupportedExportKeyFormat();
171 Status
AlgorithmImplementation::ExportKeySpki(
172 const blink::WebCryptoKey
& key
,
173 std::vector
<uint8_t>* buffer
) const {
174 return Status::ErrorUnsupportedExportKeyFormat();
177 Status
AlgorithmImplementation::ExportKeyJwk(
178 const blink::WebCryptoKey
& key
,
179 std::vector
<uint8_t>* buffer
) const {
180 return Status::ErrorUnsupportedExportKeyFormat();
183 Status
AlgorithmImplementation::SerializeKeyForClone(
184 const blink::WebCryptoKey
& key
,
185 blink::WebVector
<uint8_t>* key_data
) const {
186 return Status::ErrorUnsupported();
189 Status
AlgorithmImplementation::DeserializeKeyForClone(
190 const blink::WebCryptoKeyAlgorithm
& algorithm
,
191 blink::WebCryptoKeyType type
,
193 blink::WebCryptoKeyUsageMask usages
,
194 const CryptoData
& key_data
,
195 blink::WebCryptoKey
* key
) const {
196 return Status::ErrorUnsupported();
199 } // namespace webcrypto
201 } // namespace content