Mark some members const.
[chromium-blink-merge.git] / content / child / webcrypto / openssl / rsa_hashed_algorithm_openssl.h
blobfe0b15f69148e5bda0dba50f7ad3004fdf7a5edd
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_RSA_HASHED_ALGORITHM_OPENSSL_H_
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_RSA_HASHED_ALGORITHM_OPENSSL_H_
8 #include "content/child/webcrypto/algorithm_implementation.h"
10 namespace content {
12 namespace webcrypto {
14 // Base class for an RSA algorithm whose keys additionaly have a hash parameter
15 // bound to them. Provides functionality for generating, importing, and
16 // exporting keys.
17 class RsaHashedAlgorithm : public AlgorithmImplementation {
18 public:
19 // |all_public_key_usages| and |all_private_key_usages| are the set of
20 // WebCrypto key usages that are valid for created keys (public and private
21 // respectively).
23 // For instance if public keys support encryption and wrapping, and private
24 // keys support decryption and unwrapping callers should set:
25 // all_public_key_usages = UsageEncrypt | UsageWrap
26 // all_private_key_usages = UsageDecrypt | UsageUnwrap
27 // This information is used when importing or generating keys, to enforce
28 // that valid key usages are allowed.
29 RsaHashedAlgorithm(blink::WebCryptoKeyUsageMask all_public_key_usages,
30 blink::WebCryptoKeyUsageMask all_private_key_usages)
31 : all_public_key_usages_(all_public_key_usages),
32 all_private_key_usages_(all_private_key_usages) {}
34 // For instance "RSA-OAEP-256".
35 virtual const char* GetJwkAlgorithm(
36 const blink::WebCryptoAlgorithmId hash) const = 0;
38 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
39 bool extractable,
40 blink::WebCryptoKeyUsageMask usages,
41 GenerateKeyResult* result) const override;
43 Status VerifyKeyUsagesBeforeImportKey(
44 blink::WebCryptoKeyFormat format,
45 blink::WebCryptoKeyUsageMask usages) const override;
47 Status ImportKeyPkcs8(const CryptoData& key_data,
48 const blink::WebCryptoAlgorithm& algorithm,
49 bool extractable,
50 blink::WebCryptoKeyUsageMask usages,
51 blink::WebCryptoKey* key) const override;
53 Status ImportKeySpki(const CryptoData& key_data,
54 const blink::WebCryptoAlgorithm& algorithm,
55 bool extractable,
56 blink::WebCryptoKeyUsageMask usages,
57 blink::WebCryptoKey* key) const override;
59 Status ImportKeyJwk(const CryptoData& key_data,
60 const blink::WebCryptoAlgorithm& algorithm,
61 bool extractable,
62 blink::WebCryptoKeyUsageMask usages,
63 blink::WebCryptoKey* key) const override;
65 Status ExportKeyPkcs8(const blink::WebCryptoKey& key,
66 std::vector<uint8_t>* buffer) const override;
68 Status ExportKeySpki(const blink::WebCryptoKey& key,
69 std::vector<uint8_t>* buffer) const override;
71 Status ExportKeyJwk(const blink::WebCryptoKey& key,
72 std::vector<uint8_t>* buffer) const override;
74 Status SerializeKeyForClone(
75 const blink::WebCryptoKey& key,
76 blink::WebVector<uint8_t>* key_data) const override;
78 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
79 blink::WebCryptoKeyType type,
80 bool extractable,
81 blink::WebCryptoKeyUsageMask usages,
82 const CryptoData& key_data,
83 blink::WebCryptoKey* key) const override;
85 private:
86 const blink::WebCryptoKeyUsageMask all_public_key_usages_;
87 const blink::WebCryptoKeyUsageMask all_private_key_usages_;
90 } // namespace webcrypto
92 } // namespace content
94 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_RSA_HASHED_ALGORITHM_OPENSSL_H_