ExtensionInstallDialogView: fix scrolling behavior on Views (Win,Linux)
[chromium-blink-merge.git] / components / webcrypto / openssl / key_openssl.h
blob8b5d6551569d3db1e8bc17b64243ffb35a9cde76
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_KEY_OPENSSL_H_
6 #define COMPONENTS_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_
8 #include <openssl/ossl_typ.h>
9 #include <stdint.h>
10 #include <vector>
12 #include "base/macros.h"
13 #include "crypto/scoped_openssl_types.h"
14 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
16 namespace webcrypto {
18 class CryptoData;
19 class AsymKeyOpenSsl;
20 class SymKeyOpenSsl;
22 // Base key class for all OpenSSL keys, used to safely cast between types. Each
23 // key maintains a copy of its serialized form in either 'raw', 'pkcs8', or
24 // 'spki' format. This is to allow structured cloning of keys synchronously from
25 // the target Blink thread without having to lock access to the key.
26 class KeyOpenSsl : public blink::WebCryptoKeyHandle {
27 public:
28 explicit KeyOpenSsl(const CryptoData& serialized_key_data);
29 ~KeyOpenSsl() override;
31 virtual SymKeyOpenSsl* AsSymKey();
32 virtual AsymKeyOpenSsl* AsAsymKey();
34 const std::vector<uint8_t>& serialized_key_data() const {
35 return serialized_key_data_;
38 private:
39 const std::vector<uint8_t> serialized_key_data_;
42 class SymKeyOpenSsl : public KeyOpenSsl {
43 public:
44 ~SymKeyOpenSsl() override;
45 explicit SymKeyOpenSsl(const CryptoData& raw_key_data);
47 static SymKeyOpenSsl* Cast(const blink::WebCryptoKey& key);
49 SymKeyOpenSsl* AsSymKey() override;
51 const std::vector<uint8_t>& raw_key_data() const {
52 return serialized_key_data();
55 private:
56 DISALLOW_COPY_AND_ASSIGN(SymKeyOpenSsl);
59 class AsymKeyOpenSsl : public KeyOpenSsl {
60 public:
61 ~AsymKeyOpenSsl() override;
62 AsymKeyOpenSsl(crypto::ScopedEVP_PKEY key,
63 const CryptoData& serialized_key_data);
65 static AsymKeyOpenSsl* Cast(const blink::WebCryptoKey& key);
67 AsymKeyOpenSsl* AsAsymKey() override;
69 EVP_PKEY* key() { return key_.get(); }
71 private:
72 crypto::ScopedEVP_PKEY key_;
74 DISALLOW_COPY_AND_ASSIGN(AsymKeyOpenSsl);
77 } // namespace webcrypto
79 #endif // COMPONENTS_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_