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