Don't preload rarely seen large images
[chromium-blink-merge.git] / components / webcrypto / openssl / rsa_hashed_algorithm_openssl.h
blob4c0d44b810da1e5194826a3c44dc0cb661e59673
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 COMPONENTS_WEBCRYPTO_OPENSSL_RSA_HASHED_ALGORITHM_OPENSSL_H_
6 #define COMPONENTS_WEBCRYPTO_OPENSSL_RSA_HASHED_ALGORITHM_OPENSSL_H_
8 #include "components/webcrypto/algorithm_implementation.h"
10 namespace webcrypto {
12 // Base class for an RSA algorithm whose keys additionaly have a hash parameter
13 // bound to them. Provides functionality for generating, importing, and
14 // exporting keys.
15 class RsaHashedAlgorithm : public AlgorithmImplementation {
16 public:
17 // |all_public_key_usages| and |all_private_key_usages| are the set of
18 // WebCrypto key usages that are valid for created keys (public and private
19 // respectively).
21 // For instance if public keys support encryption and wrapping, and private
22 // keys support decryption and unwrapping callers should set:
23 // all_public_key_usages = UsageEncrypt | UsageWrap
24 // all_private_key_usages = UsageDecrypt | UsageUnwrap
25 // This information is used when importing or generating keys, to enforce
26 // that valid key usages are allowed.
27 RsaHashedAlgorithm(blink::WebCryptoKeyUsageMask all_public_key_usages,
28 blink::WebCryptoKeyUsageMask all_private_key_usages)
29 : all_public_key_usages_(all_public_key_usages),
30 all_private_key_usages_(all_private_key_usages) {}
32 // For instance "RSA-OAEP-256".
33 virtual const char* GetJwkAlgorithm(
34 const blink::WebCryptoAlgorithmId hash) const = 0;
36 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
37 bool extractable,
38 blink::WebCryptoKeyUsageMask usages,
39 GenerateKeyResult* result) const override;
41 Status VerifyKeyUsagesBeforeImportKey(
42 blink::WebCryptoKeyFormat format,
43 blink::WebCryptoKeyUsageMask usages) const override;
45 Status ImportKeyPkcs8(const CryptoData& key_data,
46 const blink::WebCryptoAlgorithm& algorithm,
47 bool extractable,
48 blink::WebCryptoKeyUsageMask usages,
49 blink::WebCryptoKey* key) const override;
51 Status ImportKeySpki(const CryptoData& key_data,
52 const blink::WebCryptoAlgorithm& algorithm,
53 bool extractable,
54 blink::WebCryptoKeyUsageMask usages,
55 blink::WebCryptoKey* key) const override;
57 Status ImportKeyJwk(const CryptoData& key_data,
58 const blink::WebCryptoAlgorithm& algorithm,
59 bool extractable,
60 blink::WebCryptoKeyUsageMask usages,
61 blink::WebCryptoKey* key) const override;
63 Status ExportKeyPkcs8(const blink::WebCryptoKey& key,
64 std::vector<uint8_t>* buffer) const override;
66 Status ExportKeySpki(const blink::WebCryptoKey& key,
67 std::vector<uint8_t>* buffer) const override;
69 Status ExportKeyJwk(const blink::WebCryptoKey& key,
70 std::vector<uint8_t>* buffer) const override;
72 Status SerializeKeyForClone(
73 const blink::WebCryptoKey& key,
74 blink::WebVector<uint8_t>* key_data) const override;
76 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
77 blink::WebCryptoKeyType type,
78 bool extractable,
79 blink::WebCryptoKeyUsageMask usages,
80 const CryptoData& key_data,
81 blink::WebCryptoKey* key) const override;
83 private:
84 const blink::WebCryptoKeyUsageMask all_public_key_usages_;
85 const blink::WebCryptoKeyUsageMask all_private_key_usages_;
88 } // namespace webcrypto
90 #endif // COMPONENTS_WEBCRYPTO_OPENSSL_RSA_HASHED_ALGORITHM_OPENSSL_H_