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

Side by Side Diff: content/child/webcrypto/openssl/key_openssl.h

Issue 353043005: [webcrypto] Wire up {spki, pkcs8} import/export for OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase onto master (which 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 | « no previous file | content/child/webcrypto/openssl/key_openssl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_OPENSSL_KEY_OPENSSL_H_ 5 #ifndef CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_
6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ 6 #define CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_
7 7
8 #include <openssl/ossl_typ.h>
8 #include <stdint.h> 9 #include <stdint.h>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "crypto/scoped_openssl_types.h"
12 #include "third_party/WebKit/public/platform/WebCryptoKey.h" 14 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
13 15
14 namespace content { 16 namespace content {
15 17
16 namespace webcrypto { 18 namespace webcrypto {
17 19
18 class CryptoData; 20 class CryptoData;
21 class AsymKeyOpenSsl;
19 class SymKeyOpenSsl; 22 class SymKeyOpenSsl;
20 23
21 // Base key class for all OpenSSL keys, used to safely cast between types. Each 24 // Base key class for all OpenSSL keys, used to safely cast between types. Each
22 // key maintains a copy of its serialized form in either 'raw', 'pkcs8', or 25 // key maintains a copy of its serialized form in either 'raw', 'pkcs8', or
23 // 'spki' format. This is to allow structured cloning of keys synchronously from 26 // 'spki' format. This is to allow structured cloning of keys synchronously from
24 // the target Blink thread without having to lock access to the key. 27 // the target Blink thread without having to lock access to the key.
25 class KeyOpenSsl : public blink::WebCryptoKeyHandle { 28 class KeyOpenSsl : public blink::WebCryptoKeyHandle {
26 public: 29 public:
27 explicit KeyOpenSsl(const CryptoData& serialized_key_data); 30 explicit KeyOpenSsl(const CryptoData& serialized_key_data);
28 virtual ~KeyOpenSsl(); 31 virtual ~KeyOpenSsl();
29 32
30 virtual SymKeyOpenSsl* AsSymKey(); 33 virtual SymKeyOpenSsl* AsSymKey();
34 virtual AsymKeyOpenSsl* AsAsymKey();
31 35
32 const std::vector<uint8_t>& serialized_key_data() const { 36 const std::vector<uint8_t>& serialized_key_data() const {
33 return serialized_key_data_; 37 return serialized_key_data_;
34 } 38 }
35 39
36 private: 40 private:
37 const std::vector<uint8_t> serialized_key_data_; 41 const std::vector<uint8_t> serialized_key_data_;
38 }; 42 };
39 43
40 class SymKeyOpenSsl : public KeyOpenSsl { 44 class SymKeyOpenSsl : public KeyOpenSsl {
41 public: 45 public:
42 virtual ~SymKeyOpenSsl(); 46 virtual ~SymKeyOpenSsl();
43 explicit SymKeyOpenSsl(const CryptoData& raw_key_data); 47 explicit SymKeyOpenSsl(const CryptoData& raw_key_data);
44 48
45 static SymKeyOpenSsl* Cast(const blink::WebCryptoKey& key); 49 static SymKeyOpenSsl* Cast(const blink::WebCryptoKey& key);
46 50
47 virtual SymKeyOpenSsl* AsSymKey() OVERRIDE; 51 virtual SymKeyOpenSsl* AsSymKey() OVERRIDE;
48 52
49 const std::vector<uint8_t>& raw_key_data() const { 53 const std::vector<uint8_t>& raw_key_data() const {
50 return serialized_key_data(); 54 return serialized_key_data();
51 } 55 }
52 56
53 private: 57 private:
54 DISALLOW_COPY_AND_ASSIGN(SymKeyOpenSsl); 58 DISALLOW_COPY_AND_ASSIGN(SymKeyOpenSsl);
55 }; 59 };
56 60
61 class AsymKeyOpenSsl : public KeyOpenSsl {
62 public:
63 virtual ~AsymKeyOpenSsl();
64 AsymKeyOpenSsl(crypto::ScopedEVP_PKEY key,
65 const CryptoData& serialized_key_data);
66
67 static AsymKeyOpenSsl* Cast(const blink::WebCryptoKey& key);
68
69 virtual AsymKeyOpenSsl* AsAsymKey() OVERRIDE;
70
71 EVP_PKEY* key() { return key_.get(); }
72
73 private:
74 crypto::ScopedEVP_PKEY key_;
75
76 DISALLOW_COPY_AND_ASSIGN(AsymKeyOpenSsl);
77 };
78
57 } // namespace webcrypto 79 } // namespace webcrypto
58 80
59 } // namespace content 81 } // namespace content
60 82
61 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_ 83 #endif // CONTENT_CHILD_WEBCRYPTO_OPENSSL_KEY_OPENSSL_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/openssl/key_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698