| OLD | NEW |
| (Empty) |
| 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, | |
| 20 std::vector<uint8_t>* buffer) const { | |
| 21 return Status::ErrorUnsupported(); | |
| 22 } | |
| 23 | |
| 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(); | |
| 30 } | |
| 31 | |
| 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(); | |
| 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, | |
| 51 std::vector<uint8_t>* buffer) const { | |
| 52 return Status::ErrorUnsupported(); | |
| 53 } | |
| 54 | |
| 55 Status AlgorithmImplementation::GenerateKey( | |
| 56 const blink::WebCryptoAlgorithm& algorithm, | |
| 57 bool extractable, | |
| 58 blink::WebCryptoKeyUsageMask usages, | |
| 59 GenerateKeyResult* result) const { | |
| 60 return Status::ErrorUnsupported(); | |
| 61 } | |
| 62 | |
| 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(); | |
| 70 } | |
| 71 | |
| 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 | |
| 79 Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey( | |
| 80 blink::WebCryptoKeyFormat format, | |
| 81 blink::WebCryptoKeyUsageMask usages) const { | |
| 82 return Status::ErrorUnsupportedImportKeyFormat(); | |
| 83 } | |
| 84 | |
| 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 | |
| 106 Status AlgorithmImplementation::ImportKeyRaw( | |
| 107 const CryptoData& key_data, | |
| 108 const blink::WebCryptoAlgorithm& algorithm, | |
| 109 bool extractable, | |
| 110 blink::WebCryptoKeyUsageMask usages, | |
| 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, | |
| 119 blink::WebCryptoKeyUsageMask usages, | |
| 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, | |
| 128 blink::WebCryptoKeyUsageMask usages, | |
| 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, | |
| 137 blink::WebCryptoKeyUsageMask usages, | |
| 138 blink::WebCryptoKey* key) const { | |
| 139 return Status::ErrorUnsupportedImportKeyFormat(); | |
| 140 } | |
| 141 | |
| 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 | |
| 159 Status AlgorithmImplementation::ExportKeyRaw( | |
| 160 const blink::WebCryptoKey& key, | |
| 161 std::vector<uint8_t>* buffer) const { | |
| 162 return Status::ErrorUnsupportedExportKeyFormat(); | |
| 163 } | |
| 164 | |
| 165 Status AlgorithmImplementation::ExportKeyPkcs8( | |
| 166 const blink::WebCryptoKey& key, | |
| 167 std::vector<uint8_t>* buffer) const { | |
| 168 return Status::ErrorUnsupportedExportKeyFormat(); | |
| 169 } | |
| 170 | |
| 171 Status AlgorithmImplementation::ExportKeySpki( | |
| 172 const blink::WebCryptoKey& key, | |
| 173 std::vector<uint8_t>* buffer) const { | |
| 174 return Status::ErrorUnsupportedExportKeyFormat(); | |
| 175 } | |
| 176 | |
| 177 Status AlgorithmImplementation::ExportKeyJwk( | |
| 178 const blink::WebCryptoKey& key, | |
| 179 std::vector<uint8_t>* buffer) const { | |
| 180 return Status::ErrorUnsupportedExportKeyFormat(); | |
| 181 } | |
| 182 | |
| 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 | |
| 199 } // namespace webcrypto | |
| 200 | |
| 201 } // namespace content | |
| OLD | NEW |