[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "content/child/webcrypto/algorithm_implementation.h" |
| 6 | |
| 7 | #include "content/child/webcrypto/status.h" |
| 8 | |
| 9 | namespace content { |
| 10 | |
| 11 | namespace webcrypto { |
| 12 | |
| 13 | AlgorithmImplementation::~AlgorithmImplementation() { |
| 14 | } |
| 15 | |
| 16 | Status AlgorithmImplementation::Encrypt( |
| 17 | const blink::WebCryptoAlgorithm& algorithm, |
| 18 | const blink::WebCryptoKey& key, |
| 19 | const CryptoData& data, |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 20 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 21 | return Status::ErrorUnsupported(); |
| 22 | } |
| 23 | |
| 24 | Status AlgorithmImplementation::Decrypt( |
| 25 | const blink::WebCryptoAlgorithm& algorithm, |
| 26 | const blink::WebCryptoKey& key, |
| 27 | const CryptoData& data, |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 28 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 29 | return Status::ErrorUnsupported(); |
| 30 | } |
| 31 | |
| 32 | Status AlgorithmImplementation::Sign(const blink::WebCryptoAlgorithm& algorithm, |
| 33 | const blink::WebCryptoKey& key, |
| 34 | const CryptoData& data, |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 35 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 36 | return Status::ErrorUnsupported(); |
| 37 | } |
| 38 | |
| 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(); |
| 46 | } |
| 47 | |
| 48 | Status AlgorithmImplementation::Digest( |
| 49 | const blink::WebCryptoAlgorithm& algorithm, |
| 50 | const CryptoData& data, |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 51 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 52 | return Status::ErrorUnsupported(); |
| 53 | } |
| 54 | |
eroman | 9b747eaf | 2014-10-18 22:03:28 | [diff] [blame] | 55 | Status AlgorithmImplementation::GenerateKey( |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 56 | const blink::WebCryptoAlgorithm& algorithm, |
| 57 | bool extractable, |
eroman | 0e1d34e | 2014-10-21 19:13:31 | [diff] [blame] | 58 | blink::WebCryptoKeyUsageMask usages, |
eroman | 9b747eaf | 2014-10-18 22:03:28 | [diff] [blame] | 59 | GenerateKeyResult* result) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 60 | return Status::ErrorUnsupported(); |
| 61 | } |
| 62 | |
eroman | 1499b494 | 2014-11-26 19:59:53 | [diff] [blame] | 63 | Status AlgorithmImplementation::DeriveBits( |
| 64 | const blink::WebCryptoAlgorithm& algorithm, |
| 65 | const blink::WebCryptoKey& base_key, |
eroman | 20bf4c3c | 2014-12-12 17:22:37 | [diff] [blame^] | 66 | bool has_optional_length_bits, |
| 67 | unsigned int optional_length_bits, |
eroman | 1499b494 | 2014-11-26 19:59:53 | [diff] [blame] | 68 | std::vector<uint8_t>* derived_bytes) const { |
| 69 | return Status::ErrorUnsupported(); |
| 70 | } |
| 71 | |
eroman | f93fd5b | 2014-12-11 00:21:06 | [diff] [blame] | 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(); |
| 77 | } |
| 78 | |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 79 | Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey( |
| 80 | blink::WebCryptoKeyFormat format, |
eroman | 0e1d34e | 2014-10-21 19:13:31 | [diff] [blame] | 81 | blink::WebCryptoKeyUsageMask usages) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 82 | return Status::ErrorUnsupportedImportKeyFormat(); |
| 83 | } |
| 84 | |
eroman | a22536b2 | 2014-12-12 03:29:28 | [diff] [blame] | 85 | Status 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] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 106 | Status AlgorithmImplementation::ImportKeyRaw( |
| 107 | const CryptoData& key_data, |
| 108 | const blink::WebCryptoAlgorithm& algorithm, |
| 109 | bool extractable, |
eroman | 0e1d34e | 2014-10-21 19:13:31 | [diff] [blame] | 110 | blink::WebCryptoKeyUsageMask usages, |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 111 | blink::WebCryptoKey* key) const { |
| 112 | return Status::ErrorUnsupportedImportKeyFormat(); |
| 113 | } |
| 114 | |
| 115 | Status AlgorithmImplementation::ImportKeyPkcs8( |
| 116 | const CryptoData& key_data, |
| 117 | const blink::WebCryptoAlgorithm& algorithm, |
| 118 | bool extractable, |
eroman | 0e1d34e | 2014-10-21 19:13:31 | [diff] [blame] | 119 | blink::WebCryptoKeyUsageMask usages, |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 120 | blink::WebCryptoKey* key) const { |
| 121 | return Status::ErrorUnsupportedImportKeyFormat(); |
| 122 | } |
| 123 | |
| 124 | Status AlgorithmImplementation::ImportKeySpki( |
| 125 | const CryptoData& key_data, |
| 126 | const blink::WebCryptoAlgorithm& algorithm, |
| 127 | bool extractable, |
eroman | 0e1d34e | 2014-10-21 19:13:31 | [diff] [blame] | 128 | blink::WebCryptoKeyUsageMask usages, |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 129 | blink::WebCryptoKey* key) const { |
| 130 | return Status::ErrorUnsupportedImportKeyFormat(); |
| 131 | } |
| 132 | |
| 133 | Status AlgorithmImplementation::ImportKeyJwk( |
| 134 | const CryptoData& key_data, |
| 135 | const blink::WebCryptoAlgorithm& algorithm, |
| 136 | bool extractable, |
eroman | 0e1d34e | 2014-10-21 19:13:31 | [diff] [blame] | 137 | blink::WebCryptoKeyUsageMask usages, |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 138 | blink::WebCryptoKey* key) const { |
| 139 | return Status::ErrorUnsupportedImportKeyFormat(); |
| 140 | } |
| 141 | |
eroman | a22536b2 | 2014-12-12 03:29:28 | [diff] [blame] | 142 | Status 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] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 159 | Status AlgorithmImplementation::ExportKeyRaw( |
| 160 | const blink::WebCryptoKey& key, |
| 161 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 162 | return Status::ErrorUnsupportedExportKeyFormat(); |
| 163 | } |
| 164 | |
| 165 | Status AlgorithmImplementation::ExportKeyPkcs8( |
| 166 | const blink::WebCryptoKey& key, |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 167 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 168 | return Status::ErrorUnsupportedExportKeyFormat(); |
| 169 | } |
| 170 | |
| 171 | Status AlgorithmImplementation::ExportKeySpki( |
| 172 | const blink::WebCryptoKey& key, |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 173 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 174 | return Status::ErrorUnsupportedExportKeyFormat(); |
| 175 | } |
| 176 | |
[email protected] | 53b6c9d2 | 2014-07-19 05:08:38 | [diff] [blame] | 177 | Status AlgorithmImplementation::ExportKeyJwk( |
| 178 | const blink::WebCryptoKey& key, |
| 179 | std::vector<uint8_t>* buffer) const { |
[email protected] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 180 | return Status::ErrorUnsupportedExportKeyFormat(); |
| 181 | } |
| 182 | |
eroman | a895fed | 2014-11-08 03:10:25 | [diff] [blame] | 183 | Status AlgorithmImplementation::SerializeKeyForClone( |
| 184 | const blink::WebCryptoKey& key, |
| 185 | blink::WebVector<uint8_t>* key_data) const { |
| 186 | return Status::ErrorUnsupported(); |
| 187 | } |
| 188 | |
| 189 | Status 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] | 38409aec | 2014-07-19 00:54:51 | [diff] [blame] | 199 | } // namespace webcrypto |
| 200 | |
| 201 | } // namespace content |