Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / webcrypto / openssl / ec_algorithm_openssl.h
blob9771f3d6142b67b660c33bf3354fac9bfe6356e2
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_EC_ALGORITHM_OPENSSL_H_
6 #define COMPONENTS_WEBCRYPTO_OPENSSL_EC_ALGORITHM_OPENSSL_H_
8 #include "components/webcrypto/algorithm_implementation.h"
10 namespace webcrypto {
12 // Base class for an EC algorithm. Provides functionality for generating,
13 // importing, and exporting keys.
14 class EcAlgorithm : public AlgorithmImplementation {
15 public:
16 // |all_public_key_usages| and |all_private_key_usages| are the set of
17 // WebCrypto key usages that are valid for created keys (public and private
18 // respectively).
19 EcAlgorithm(blink::WebCryptoKeyUsageMask all_public_key_usages,
20 blink::WebCryptoKeyUsageMask all_private_key_usages)
21 : all_public_key_usages_(all_public_key_usages),
22 all_private_key_usages_(all_private_key_usages) {}
24 // For instance "ES256".
25 virtual const char* GetJwkAlgorithm(
26 const blink::WebCryptoNamedCurve curve) const = 0;
28 Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
29 bool extractable,
30 blink::WebCryptoKeyUsageMask usages,
31 GenerateKeyResult* result) const override;
33 Status VerifyKeyUsagesBeforeImportKey(
34 blink::WebCryptoKeyFormat format,
35 blink::WebCryptoKeyUsageMask usages) const override;
37 Status ImportKeyPkcs8(const CryptoData& key_data,
38 const blink::WebCryptoAlgorithm& algorithm,
39 bool extractable,
40 blink::WebCryptoKeyUsageMask usages,
41 blink::WebCryptoKey* key) const override;
43 Status ImportKeySpki(const CryptoData& key_data,
44 const blink::WebCryptoAlgorithm& algorithm,
45 bool extractable,
46 blink::WebCryptoKeyUsageMask usages,
47 blink::WebCryptoKey* key) const override;
49 Status ImportKeyJwk(const CryptoData& key_data,
50 const blink::WebCryptoAlgorithm& algorithm,
51 bool extractable,
52 blink::WebCryptoKeyUsageMask usages,
53 blink::WebCryptoKey* key) const override;
55 Status ExportKeyPkcs8(const blink::WebCryptoKey& key,
56 std::vector<uint8_t>* buffer) const override;
58 Status ExportKeySpki(const blink::WebCryptoKey& key,
59 std::vector<uint8_t>* buffer) const override;
61 Status ExportKeyJwk(const blink::WebCryptoKey& key,
62 std::vector<uint8_t>* buffer) const override;
64 Status SerializeKeyForClone(
65 const blink::WebCryptoKey& key,
66 blink::WebVector<uint8_t>* key_data) const override;
68 Status DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm,
69 blink::WebCryptoKeyType type,
70 bool extractable,
71 blink::WebCryptoKeyUsageMask usages,
72 const CryptoData& key_data,
73 blink::WebCryptoKey* key) const override;
75 private:
76 const blink::WebCryptoKeyUsageMask all_public_key_usages_;
77 const blink::WebCryptoKeyUsageMask all_private_key_usages_;
80 } // namespace webcrypto
82 #endif // COMPONENTS_WEBCRYPTO_OPENSSL_EC_ALGORITHM_OPENSSL_H_