cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / child / webcrypto / openssl / aes_key_openssl.h
blob206a1e2bcfc5ed02929ee77c57289c7c0c40d188
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.
5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_AES_OPENSSL_H_
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_AES_OPENSSL_H_
8 #include "content/child/webcrypto/algorithm_implementation.h"
10 namespace content {
12 namespace webcrypto {
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);
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);
31 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
32 bool extractable,
33 blink::WebCryptoKeyUsageMask usages,
34 GenerateKeyResult* result) const override;
36 Status VerifyKeyUsagesBeforeImportKey(
37 blink::WebCryptoKeyFormat format,
38 blink::WebCryptoKeyUsageMask usages) const override;
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;
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;
52 Status ExportKeyRaw(const blink::WebCryptoKey& key,
53 std::vector<uint8_t>* buffer) const override;
55 Status ExportKeyJwk(const blink::WebCryptoKey& key,
56 std::vector<uint8_t>* buffer) const override;
58 private:
59 const blink::WebCryptoKeyUsageMask all_key_usages_;
60 const std::string jwk_suffix_;
63 } // namespace webcrypto
65 } // namespace content
67 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_AES_OPENSSL_H_