Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: content/child/webcrypto/nss/key_nss.cc

Issue 379383002: Refactor WebCrypto code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase onto master (no longer has BoringSSL) Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/webcrypto/nss/key_nss.h ('k') | content/child/webcrypto/nss/rsa_key_nss.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 bool PlatformSerializeKeyForClone(const blink::WebCryptoKey& key,
88 blink::WebVector<uint8>* key_data) {
89 const KeyNss* nss_key = static_cast<KeyNss*>(key.handle());
90 *key_data = nss_key->serialized_key_data();
91 return true;
92 }
93
94 } // namespace webcrypto
95
96 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/nss/key_nss.h ('k') | content/child/webcrypto/nss/rsa_key_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698