OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ |
7 | 7 |
8 #include "content/child/webcrypto/algorithm_implementation.h" | 8 #include <stdint.h> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
9 | 13 |
10 namespace content { | 14 namespace content { |
11 | 15 |
12 namespace webcrypto { | 16 namespace webcrypto { |
13 | 17 |
| 18 class CryptoData; |
14 class SymKeyOpenSsl; | 19 class SymKeyOpenSsl; |
15 | 20 |
16 // Base key class for all OpenSSL keys, used to safely cast between types. Each | 21 // Base key class for all OpenSSL keys, used to safely cast between types. Each |
17 // key maintains a copy of its serialized form in either 'raw', 'pkcs8', or | 22 // key maintains a copy of its serialized form in either 'raw', 'pkcs8', or |
18 // 'spki' format. This is to allow structured cloning of keys synchronously from | 23 // 'spki' format. This is to allow structured cloning of keys synchronously from |
19 // the target Blink thread without having to lock access to the key. | 24 // the target Blink thread without having to lock access to the key. |
20 class KeyOpenSsl : public blink::WebCryptoKeyHandle { | 25 class KeyOpenSsl : public blink::WebCryptoKeyHandle { |
21 public: | 26 public: |
22 explicit KeyOpenSsl(const CryptoData& serialized_key_data); | 27 explicit KeyOpenSsl(const CryptoData& serialized_key_data); |
23 virtual ~KeyOpenSsl(); | 28 virtual ~KeyOpenSsl(); |
24 | 29 |
25 virtual SymKeyOpenSsl* AsSymKey(); | 30 virtual SymKeyOpenSsl* AsSymKey(); |
26 | 31 |
27 const std::vector<uint8>& serialized_key_data() const { | 32 const std::vector<uint8_t>& serialized_key_data() const { |
28 return serialized_key_data_; | 33 return serialized_key_data_; |
29 } | 34 } |
30 | 35 |
31 private: | 36 private: |
32 const std::vector<uint8> serialized_key_data_; | 37 const std::vector<uint8_t> serialized_key_data_; |
33 }; | 38 }; |
34 | 39 |
35 class SymKeyOpenSsl : public KeyOpenSsl { | 40 class SymKeyOpenSsl : public KeyOpenSsl { |
36 public: | 41 public: |
37 virtual ~SymKeyOpenSsl(); | 42 virtual ~SymKeyOpenSsl(); |
38 explicit SymKeyOpenSsl(const CryptoData& raw_key_data); | 43 explicit SymKeyOpenSsl(const CryptoData& raw_key_data); |
39 | 44 |
40 static SymKeyOpenSsl* Cast(const blink::WebCryptoKey& key); | 45 static SymKeyOpenSsl* Cast(const blink::WebCryptoKey& key); |
41 | 46 |
42 virtual SymKeyOpenSsl* AsSymKey() OVERRIDE; | 47 virtual SymKeyOpenSsl* AsSymKey() OVERRIDE; |
43 | 48 |
44 const std::vector<uint8>& raw_key_data() const { | 49 const std::vector<uint8_t>& raw_key_data() const { |
45 return serialized_key_data(); | 50 return serialized_key_data(); |
46 } | 51 } |
47 | 52 |
48 private: | 53 private: |
49 DISALLOW_COPY_AND_ASSIGN(SymKeyOpenSsl); | 54 DISALLOW_COPY_AND_ASSIGN(SymKeyOpenSsl); |
50 }; | 55 }; |
51 | 56 |
52 } // namespace webcrypto | 57 } // namespace webcrypto |
53 | 58 |
54 } // namespace content | 59 } // namespace content |
55 | 60 |
56 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ | 61 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ |
OLD | NEW |