| Index: content/child/webcrypto/nss/key_nss.h
|
| diff --git a/content/child/webcrypto/nss/key_nss.h b/content/child/webcrypto/nss/key_nss.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f1980e27ad7ff7f4e04a4d506eaf02534834eea1
|
| --- /dev/null
|
| +++ b/content/child/webcrypto/nss/key_nss.h
|
| @@ -0,0 +1,102 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_
|
| +#define CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_
|
| +
|
| +#include "content/child/webcrypto/algorithm_implementation.h"
|
| +
|
| +#include "crypto/scoped_nss_types.h"
|
| +
|
| +namespace content {
|
| +
|
| +namespace webcrypto {
|
| +
|
| +class PrivateKeyNss;
|
| +class PublicKeyNss;
|
| +class SymKeyNss;
|
| +
|
| +// Base key class for all NSS keys, used to safely cast between types. Each key
|
| +// maintains a copy of its serialized form in either 'raw', 'pkcs8', or 'spki'
|
| +// format. This is to allow structured cloning of keys synchronously from the
|
| +// target Blink thread without having to lock access to the key.
|
| +class KeyNss : public blink::WebCryptoKeyHandle {
|
| + public:
|
| + explicit KeyNss(const CryptoData& serialized_key_data);
|
| + virtual ~KeyNss();
|
| +
|
| + virtual SymKeyNss* AsSymKey();
|
| + virtual PublicKeyNss* AsPublicKey();
|
| + virtual PrivateKeyNss* AsPrivateKey();
|
| +
|
| + const std::vector<uint8>& serialized_key_data() const {
|
| + return serialized_key_data_;
|
| + }
|
| +
|
| + private:
|
| + const std::vector<uint8> serialized_key_data_;
|
| +};
|
| +
|
| +class SymKeyNss : public KeyNss {
|
| + public:
|
| + virtual ~SymKeyNss();
|
| + SymKeyNss(crypto::ScopedPK11SymKey key, const CryptoData& raw_key_data);
|
| +
|
| + static SymKeyNss* Cast(const blink::WebCryptoKey& key);
|
| +
|
| + PK11SymKey* key() { return key_.get(); }
|
| + virtual SymKeyNss* AsSymKey() OVERRIDE;
|
| +
|
| + const std::vector<uint8>& raw_key_data() const {
|
| + return serialized_key_data();
|
| + }
|
| +
|
| + private:
|
| + crypto::ScopedPK11SymKey key_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SymKeyNss);
|
| +};
|
| +
|
| +class PublicKeyNss : public KeyNss {
|
| + public:
|
| + virtual ~PublicKeyNss();
|
| + PublicKeyNss(crypto::ScopedSECKEYPublicKey key, const CryptoData& spki_data);
|
| +
|
| + static PublicKeyNss* Cast(const blink::WebCryptoKey& key);
|
| +
|
| + SECKEYPublicKey* key() { return key_.get(); }
|
| + virtual PublicKeyNss* AsPublicKey() OVERRIDE;
|
| +
|
| + const std::vector<uint8>& spki_data() const { return serialized_key_data(); }
|
| +
|
| + private:
|
| + crypto::ScopedSECKEYPublicKey key_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PublicKeyNss);
|
| +};
|
| +
|
| +class PrivateKeyNss : public KeyNss {
|
| + public:
|
| + virtual ~PrivateKeyNss();
|
| + PrivateKeyNss(crypto::ScopedSECKEYPrivateKey key,
|
| + const CryptoData& pkcs8_data);
|
| +
|
| + static PrivateKeyNss* Cast(const blink::WebCryptoKey& key);
|
| +
|
| + SECKEYPrivateKey* key() { return key_.get(); }
|
| + virtual PrivateKeyNss* AsPrivateKey() OVERRIDE;
|
| +
|
| + const std::vector<uint8>& pkcs8_data() const { return serialized_key_data(); }
|
| +
|
| + private:
|
| + crypto::ScopedSECKEYPrivateKey key_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PrivateKeyNss);
|
| +};
|
| +
|
| +} // namespace webcrypto
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_CHILD_WEBCRYPTO_NSS_KEY_NSS_H_
|
|
|