| OLD | NEW | 
|---|
|  | (Empty) | 
| 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. |  | 
| 4 |  | 
| 5 #ifndef COMPONENTS_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ |  | 
| 6 #define COMPONENTS_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ |  | 
| 7 |  | 
| 8 #include <openssl/ossl_typ.h> |  | 
| 9 #include <stdint.h> |  | 
| 10 #include <vector> |  | 
| 11 |  | 
| 12 #include "base/macros.h" |  | 
| 13 #include "crypto/scoped_openssl_types.h" |  | 
| 14 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |  | 
| 15 |  | 
| 16 namespace webcrypto { |  | 
| 17 |  | 
| 18 class CryptoData; |  | 
| 19 class AsymKeyOpenSsl; |  | 
| 20 class SymKeyOpenSsl; |  | 
| 21 |  | 
| 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; |  | 
| 30 |  | 
| 31   virtual SymKeyOpenSsl* AsSymKey(); |  | 
| 32   virtual AsymKeyOpenSsl* AsAsymKey(); |  | 
| 33 |  | 
| 34   const std::vector<uint8_t>& serialized_key_data() const { |  | 
| 35     return serialized_key_data_; |  | 
| 36   } |  | 
| 37 |  | 
| 38  private: |  | 
| 39   const std::vector<uint8_t> serialized_key_data_; |  | 
| 40 }; |  | 
| 41 |  | 
| 42 class SymKeyOpenSsl : public KeyOpenSsl { |  | 
| 43  public: |  | 
| 44   ~SymKeyOpenSsl() override; |  | 
| 45   explicit SymKeyOpenSsl(const CryptoData& raw_key_data); |  | 
| 46 |  | 
| 47   static SymKeyOpenSsl* Cast(const blink::WebCryptoKey& key); |  | 
| 48 |  | 
| 49   SymKeyOpenSsl* AsSymKey() override; |  | 
| 50 |  | 
| 51   const std::vector<uint8_t>& raw_key_data() const { |  | 
| 52     return serialized_key_data(); |  | 
| 53   } |  | 
| 54 |  | 
| 55  private: |  | 
| 56   DISALLOW_COPY_AND_ASSIGN(SymKeyOpenSsl); |  | 
| 57 }; |  | 
| 58 |  | 
| 59 class AsymKeyOpenSsl : public KeyOpenSsl { |  | 
| 60  public: |  | 
| 61   ~AsymKeyOpenSsl() override; |  | 
| 62   AsymKeyOpenSsl(crypto::ScopedEVP_PKEY key, |  | 
| 63                  const CryptoData& serialized_key_data); |  | 
| 64 |  | 
| 65   static AsymKeyOpenSsl* Cast(const blink::WebCryptoKey& key); |  | 
| 66 |  | 
| 67   AsymKeyOpenSsl* AsAsymKey() override; |  | 
| 68 |  | 
| 69   EVP_PKEY* key() { return key_.get(); } |  | 
| 70 |  | 
| 71  private: |  | 
| 72   crypto::ScopedEVP_PKEY key_; |  | 
| 73 |  | 
| 74   DISALLOW_COPY_AND_ASSIGN(AsymKeyOpenSsl); |  | 
| 75 }; |  | 
| 76 |  | 
| 77 }  // namespace webcrypto |  | 
| 78 |  | 
| 79 #endif  // COMPONENTS_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ |  | 
| OLD | NEW | 
|---|