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 #include "content/child/webcrypto/nss/key_nss.h" | |
6 | |
7 #include "content/child/webcrypto/crypto_data.h" | |
8 #include "content/child/webcrypto/status.h" | |
9 #include "content/child/webcrypto/webcrypto_util.h" | |
10 | |
11 namespace content { | |
12 | |
13 namespace webcrypto { | |
14 | |
15 KeyNss::KeyNss(const CryptoData& serialized_key_data) | |
16 : serialized_key_data_( | |
17 serialized_key_data.bytes(), | |
18 serialized_key_data.bytes() + serialized_key_data.byte_length()) { | |
19 } | |
20 | |
21 KeyNss::~KeyNss() { | |
22 } | |
23 | |
24 SymKeyNss* KeyNss::AsSymKey() { | |
25 return NULL; | |
26 } | |
27 | |
28 PublicKeyNss* KeyNss::AsPublicKey() { | |
29 return NULL; | |
30 } | |
31 | |
32 PrivateKeyNss* KeyNss::AsPrivateKey() { | |
33 return NULL; | |
34 } | |
35 | |
36 SymKeyNss::~SymKeyNss() { | |
37 } | |
38 | |
39 SymKeyNss* SymKeyNss::Cast(const blink::WebCryptoKey& key) { | |
40 KeyNss* platform_key = reinterpret_cast<KeyNss*>(key.handle()); | |
41 return platform_key->AsSymKey(); | |
42 } | |
43 | |
44 SymKeyNss* SymKeyNss::AsSymKey() { | |
45 return this; | |
46 } | |
47 | |
48 SymKeyNss::SymKeyNss(crypto::ScopedPK11SymKey key, | |
49 const CryptoData& raw_key_data) | |
50 : KeyNss(raw_key_data), key_(key.Pass()) { | |
51 } | |
52 | |
53 PublicKeyNss::~PublicKeyNss() { | |
54 } | |
55 | |
56 PublicKeyNss* PublicKeyNss::Cast(const blink::WebCryptoKey& key) { | |
57 KeyNss* platform_key = reinterpret_cast<KeyNss*>(key.handle()); | |
58 return platform_key->AsPublicKey(); | |
59 } | |
60 | |
61 PublicKeyNss* PublicKeyNss::AsPublicKey() { | |
62 return this; | |
63 } | |
64 | |
65 PublicKeyNss::PublicKeyNss(crypto::ScopedSECKEYPublicKey key, | |
66 const CryptoData& spki_data) | |
67 : KeyNss(spki_data), key_(key.Pass()) { | |
68 } | |
69 | |
70 PrivateKeyNss::~PrivateKeyNss() { | |
71 } | |
72 | |
73 PrivateKeyNss* PrivateKeyNss::Cast(const blink::WebCryptoKey& key) { | |
74 KeyNss* platform_key = reinterpret_cast<KeyNss*>(key.handle()); | |
75 return platform_key->AsPrivateKey(); | |
76 } | |
77 | |
78 PrivateKeyNss* PrivateKeyNss::AsPrivateKey() { | |
79 return this; | |
80 } | |
81 | |
82 PrivateKeyNss::PrivateKeyNss(crypto::ScopedSECKEYPrivateKey key, | |
83 const CryptoData& pkcs8_data) | |
84 : KeyNss(pkcs8_data), key_(key.Pass()) { | |
85 } | |
86 | |
87 } // namespace webcrypto | |
88 | |
89 } // namespace content | |
OLD | NEW |