| 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 #ifndef COMPONENTS_WEBCRYPTO_OPENSSL_AES_ALGORITHM_OPENSSL_H_ | |
| 6 #define COMPONENTS_WEBCRYPTO_OPENSSL_AES_ALGORITHM_OPENSSL_H_ | |
| 7 | |
| 8 #include "components/webcrypto/algorithm_implementation.h" | |
| 9 | |
| 10 namespace webcrypto { | |
| 11 | |
| 12 // Base class for AES algorithms that provides the implementation for key | |
| 13 // creation and export. | |
| 14 class AesAlgorithm : public AlgorithmImplementation { | |
| 15 public: | |
| 16 // |all_key_usages| is the set of all WebCrypto key usages that are | |
| 17 // allowed for imported or generated keys. |jwk_suffix| is the suffix | |
| 18 // used when constructing JWK names for the algorithm. For instance A128CBC | |
| 19 // is the JWK name for 128-bit AES-CBC. The |jwk_suffix| in this case would | |
| 20 // be "CBC". | |
| 21 AesAlgorithm(blink::WebCryptoKeyUsageMask all_key_usages, | |
| 22 const std::string& jwk_suffix); | |
| 23 | |
| 24 // This is the same as the other AesAlgorithm constructor where | |
| 25 // |all_key_usages| is pre-filled to values for encryption/decryption | |
| 26 // algorithms (supports usages for: encrypt, decrypt, wrap, unwrap). | |
| 27 explicit AesAlgorithm(const std::string& jwk_suffix); | |
| 28 | |
| 29 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, | |
| 30 bool extractable, | |
| 31 blink::WebCryptoKeyUsageMask usages, | |
| 32 GenerateKeyResult* result) const override; | |
| 33 | |
| 34 Status VerifyKeyUsagesBeforeImportKey( | |
| 35 blink::WebCryptoKeyFormat format, | |
| 36 blink::WebCryptoKeyUsageMask usages) const override; | |
| 37 | |
| 38 Status ImportKeyRaw(const CryptoData& key_data, | |
| 39 const blink::WebCryptoAlgorithm& algorithm, | |
| 40 bool extractable, | |
| 41 blink::WebCryptoKeyUsageMask usages, | |
| 42 blink::WebCryptoKey* key) const override; | |
| 43 | |
| 44 Status ImportKeyJwk(const CryptoData& key_data, | |
| 45 const blink::WebCryptoAlgorithm& algorithm, | |
| 46 bool extractable, | |
| 47 blink::WebCryptoKeyUsageMask usages, | |
| 48 blink::WebCryptoKey* key) const override; | |
| 49 | |
| 50 Status ExportKeyRaw(const blink::WebCryptoKey& key, | |
| 51 std::vector<uint8_t>* buffer) const override; | |
| 52 | |
| 53 Status ExportKeyJwk(const blink::WebCryptoKey& key, | |
| 54 std::vector<uint8_t>* buffer) const override; | |
| 55 | |
| 56 Status SerializeKeyForClone( | |
| 57 const blink::WebCryptoKey& key, | |
| 58 blink::WebVector<uint8_t>* key_data) const override; | |
| 59 | |
| 60 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, | |
| 61 blink::WebCryptoKeyType type, | |
| 62 bool extractable, | |
| 63 blink::WebCryptoKeyUsageMask usages, | |
| 64 const CryptoData& key_data, | |
| 65 blink::WebCryptoKey* key) const override; | |
| 66 | |
| 67 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, | |
| 68 bool* has_length_bits, | |
| 69 unsigned int* length_bits) const override; | |
| 70 | |
| 71 private: | |
| 72 const blink::WebCryptoKeyUsageMask all_key_usages_; | |
| 73 const std::string jwk_suffix_; | |
| 74 }; | |
| 75 | |
| 76 } // namespace webcrypto | |
| 77 | |
| 78 #endif // COMPONENTS_WEBCRYPTO_OPENSSL_AES_ALGORITHM_OPENSSL_H_ | |
| OLD | NEW |