Add a stub __cxa_demangle to disable LLVM's demangler.
[chromium-blink-merge.git] / components / webcrypto / nss / key_nss.cc
blob92f26c3e1ab689e365da68831d643ec2d60977de
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.
5 #include "components/webcrypto/nss/key_nss.h"
7 #include "components/webcrypto/crypto_data.h"
8 #include "components/webcrypto/status.h"
9 #include "components/webcrypto/webcrypto_util.h"
11 namespace webcrypto {
13 KeyNss::KeyNss(const CryptoData& serialized_key_data)
14 : serialized_key_data_(
15 serialized_key_data.bytes(),
16 serialized_key_data.bytes() + serialized_key_data.byte_length()) {
19 KeyNss::~KeyNss() {
22 SymKeyNss* KeyNss::AsSymKey() {
23 return NULL;
26 PublicKeyNss* KeyNss::AsPublicKey() {
27 return NULL;
30 PrivateKeyNss* KeyNss::AsPrivateKey() {
31 return NULL;
34 SymKeyNss::~SymKeyNss() {
37 SymKeyNss* SymKeyNss::Cast(const blink::WebCryptoKey& key) {
38 KeyNss* platform_key = reinterpret_cast<KeyNss*>(key.handle());
39 return platform_key->AsSymKey();
42 SymKeyNss* SymKeyNss::AsSymKey() {
43 return this;
46 SymKeyNss::SymKeyNss(crypto::ScopedPK11SymKey key,
47 const CryptoData& raw_key_data)
48 : KeyNss(raw_key_data), key_(key.Pass()) {
51 PublicKeyNss::~PublicKeyNss() {
54 PublicKeyNss* PublicKeyNss::Cast(const blink::WebCryptoKey& key) {
55 KeyNss* platform_key = reinterpret_cast<KeyNss*>(key.handle());
56 return platform_key->AsPublicKey();
59 PublicKeyNss* PublicKeyNss::AsPublicKey() {
60 return this;
63 PublicKeyNss::PublicKeyNss(crypto::ScopedSECKEYPublicKey key,
64 const CryptoData& spki_data)
65 : KeyNss(spki_data), key_(key.Pass()) {
68 PrivateKeyNss::~PrivateKeyNss() {
71 PrivateKeyNss* PrivateKeyNss::Cast(const blink::WebCryptoKey& key) {
72 KeyNss* platform_key = reinterpret_cast<KeyNss*>(key.handle());
73 return platform_key->AsPrivateKey();
76 PrivateKeyNss* PrivateKeyNss::AsPrivateKey() {
77 return this;
80 PrivateKeyNss::PrivateKeyNss(crypto::ScopedSECKEYPrivateKey key,
81 const CryptoData& pkcs8_data)
82 : KeyNss(pkcs8_data), key_(key.Pass()) {
85 } // namespace webcrypto