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_NSS_KEY_NSS_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_ |
7 | 7 |
8 #include "content/child/webcrypto/algorithm_implementation.h" | 8 #include "content/child/webcrypto/algorithm_implementation.h" |
Ryan Sleevi
2014/07/18 23:02:55
This doesn't seem appropriate/necessary?
#include
| |
9 | 9 |
10 #include "crypto/scoped_nss_types.h" | 10 #include "crypto/scoped_nss_types.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 namespace webcrypto { | 14 namespace webcrypto { |
15 | 15 |
16 class PrivateKeyNss; | 16 class PrivateKeyNss; |
17 class PublicKeyNss; | 17 class PublicKeyNss; |
18 class SymKeyNss; | 18 class SymKeyNss; |
19 | 19 |
20 // Base key class for all NSS keys, used to safely cast between types. Each key | 20 // Base key class for all NSS keys, used to safely cast between types. Each key |
21 // maintains a copy of its serialized form in either 'raw', 'pkcs8', or 'spki' | 21 // maintains a copy of its serialized form in either 'raw', 'pkcs8', or 'spki' |
22 // format. This is to allow structured cloning of keys synchronously from the | 22 // format. This is to allow structured cloning of keys synchronously from the |
23 // target Blink thread without having to lock access to the key. | 23 // target Blink thread without having to lock access to the key. |
24 class KeyNss : public blink::WebCryptoKeyHandle { | 24 class KeyNss : public blink::WebCryptoKeyHandle { |
Ryan Sleevi
2014/07/18 23:02:55
Where is this defined? This is the header you shou
| |
25 public: | 25 public: |
26 explicit KeyNss(const CryptoData& serialized_key_data); | 26 explicit KeyNss(const CryptoData& serialized_key_data); |
27 virtual ~KeyNss(); | 27 virtual ~KeyNss(); |
28 | 28 |
29 virtual SymKeyNss* AsSymKey(); | 29 virtual SymKeyNss* AsSymKey(); |
30 virtual PublicKeyNss* AsPublicKey(); | 30 virtual PublicKeyNss* AsPublicKey(); |
31 virtual PrivateKeyNss* AsPrivateKey(); | 31 virtual PrivateKeyNss* AsPrivateKey(); |
32 | 32 |
33 const std::vector<uint8>& serialized_key_data() const { | 33 const std::vector<uint8_t>& serialized_key_data() const { |
34 return serialized_key_data_; | 34 return serialized_key_data_; |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 const std::vector<uint8> serialized_key_data_; | 38 const std::vector<uint8_t> serialized_key_data_; |
39 }; | 39 }; |
40 | 40 |
41 class SymKeyNss : public KeyNss { | 41 class SymKeyNss : public KeyNss { |
42 public: | 42 public: |
43 virtual ~SymKeyNss(); | 43 virtual ~SymKeyNss(); |
44 SymKeyNss(crypto::ScopedPK11SymKey key, const CryptoData& raw_key_data); | 44 SymKeyNss(crypto::ScopedPK11SymKey key, const CryptoData& raw_key_data); |
45 | 45 |
46 static SymKeyNss* Cast(const blink::WebCryptoKey& key); | 46 static SymKeyNss* Cast(const blink::WebCryptoKey& key); |
47 | 47 |
48 PK11SymKey* key() { return key_.get(); } | 48 PK11SymKey* key() { return key_.get(); } |
49 virtual SymKeyNss* AsSymKey() OVERRIDE; | 49 virtual SymKeyNss* AsSymKey() OVERRIDE; |
50 | 50 |
51 const std::vector<uint8>& raw_key_data() const { | 51 const std::vector<uint8_t>& raw_key_data() const { |
52 return serialized_key_data(); | 52 return serialized_key_data(); |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 crypto::ScopedPK11SymKey key_; | 56 crypto::ScopedPK11SymKey key_; |
57 | 57 |
58 DISALLOW_COPY_AND_ASSIGN(SymKeyNss); | 58 DISALLOW_COPY_AND_ASSIGN(SymKeyNss); |
59 }; | 59 }; |
60 | 60 |
61 class PublicKeyNss : public KeyNss { | 61 class PublicKeyNss : public KeyNss { |
62 public: | 62 public: |
63 virtual ~PublicKeyNss(); | 63 virtual ~PublicKeyNss(); |
64 PublicKeyNss(crypto::ScopedSECKEYPublicKey key, const CryptoData& spki_data); | 64 PublicKeyNss(crypto::ScopedSECKEYPublicKey key, const CryptoData& spki_data); |
65 | 65 |
66 static PublicKeyNss* Cast(const blink::WebCryptoKey& key); | 66 static PublicKeyNss* Cast(const blink::WebCryptoKey& key); |
67 | 67 |
68 SECKEYPublicKey* key() { return key_.get(); } | 68 SECKEYPublicKey* key() { return key_.get(); } |
69 virtual PublicKeyNss* AsPublicKey() OVERRIDE; | 69 virtual PublicKeyNss* AsPublicKey() OVERRIDE; |
70 | 70 |
71 const std::vector<uint8>& spki_data() const { return serialized_key_data(); } | 71 const std::vector<uint8_t>& spki_data() const { |
72 return serialized_key_data(); | |
73 } | |
72 | 74 |
73 private: | 75 private: |
74 crypto::ScopedSECKEYPublicKey key_; | 76 crypto::ScopedSECKEYPublicKey key_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(PublicKeyNss); | 78 DISALLOW_COPY_AND_ASSIGN(PublicKeyNss); |
77 }; | 79 }; |
78 | 80 |
79 class PrivateKeyNss : public KeyNss { | 81 class PrivateKeyNss : public KeyNss { |
80 public: | 82 public: |
81 virtual ~PrivateKeyNss(); | 83 virtual ~PrivateKeyNss(); |
82 PrivateKeyNss(crypto::ScopedSECKEYPrivateKey key, | 84 PrivateKeyNss(crypto::ScopedSECKEYPrivateKey key, |
83 const CryptoData& pkcs8_data); | 85 const CryptoData& pkcs8_data); |
84 | 86 |
85 static PrivateKeyNss* Cast(const blink::WebCryptoKey& key); | 87 static PrivateKeyNss* Cast(const blink::WebCryptoKey& key); |
86 | 88 |
87 SECKEYPrivateKey* key() { return key_.get(); } | 89 SECKEYPrivateKey* key() { return key_.get(); } |
88 virtual PrivateKeyNss* AsPrivateKey() OVERRIDE; | 90 virtual PrivateKeyNss* AsPrivateKey() OVERRIDE; |
89 | 91 |
90 const std::vector<uint8>& pkcs8_data() const { return serialized_key_data(); } | 92 const std::vector<uint8_t>& pkcs8_data() const { |
93 return serialized_key_data(); | |
94 } | |
91 | 95 |
92 private: | 96 private: |
93 crypto::ScopedSECKEYPrivateKey key_; | 97 crypto::ScopedSECKEYPrivateKey key_; |
94 | 98 |
95 DISALLOW_COPY_AND_ASSIGN(PrivateKeyNss); | 99 DISALLOW_COPY_AND_ASSIGN(PrivateKeyNss); |
96 }; | 100 }; |
97 | 101 |
98 } // namespace webcrypto | 102 } // namespace webcrypto |
99 | 103 |
100 } // namespace content | 104 } // namespace content |
101 | 105 |
102 #endif // CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_ | 106 #endif // CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_ |
OLD | NEW |