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_ALGORITHM_OPENSSL_H_ | |
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_AES_ALGORITHM_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 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, | |
32 bool extractable, | |
33 blink::WebCryptoKeyUsageMask usages, | |
34 GenerateKeyResult* result) const override; | |
35 | |
36 Status VerifyKeyUsagesBeforeImportKey( | |
37 blink::WebCryptoKeyFormat format, | |
38 blink::WebCryptoKeyUsageMask usages) const override; | |
39 | |
40 Status ImportKeyRaw(const CryptoData& key_data, | |
41 const blink::WebCryptoAlgorithm& algorithm, | |
42 bool extractable, | |
43 blink::WebCryptoKeyUsageMask usages, | |
44 blink::WebCryptoKey* key) const override; | |
45 | |
46 Status ImportKeyJwk(const CryptoData& key_data, | |
47 const blink::WebCryptoAlgorithm& algorithm, | |
48 bool extractable, | |
49 blink::WebCryptoKeyUsageMask usages, | |
50 blink::WebCryptoKey* key) const override; | |
51 | |
52 Status ExportKeyRaw(const blink::WebCryptoKey& key, | |
53 std::vector<uint8_t>* buffer) const override; | |
54 | |
55 Status ExportKeyJwk(const blink::WebCryptoKey& key, | |
56 std::vector<uint8_t>* buffer) const override; | |
57 | |
58 Status SerializeKeyForClone( | |
59 const blink::WebCryptoKey& key, | |
60 blink::WebVector<uint8_t>* key_data) const override; | |
61 | |
62 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, | |
63 blink::WebCryptoKeyType type, | |
64 bool extractable, | |
65 blink::WebCryptoKeyUsageMask usages, | |
66 const CryptoData& key_data, | |
67 blink::WebCryptoKey* key) const override; | |
68 | |
69 Status GetKeyLength(const blink::WebCryptoAlgorithm& key_length_algorithm, | |
70 bool* has_length_bits, | |
71 unsigned int* length_bits) const override; | |
72 | |
73 private: | |
74 const blink::WebCryptoKeyUsageMask all_key_usages_; | |
75 const std::string jwk_suffix_; | |
76 }; | |
77 | |
78 } // namespace webcrypto | |
79 | |
80 } // namespace content | |
81 | |
82 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_AES_ALGORITHM_OPENSSL_H_ | |
OLD | NEW |