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

Side by Side Diff: webrtc/base/nssidentity.h

Issue 1189583002: Support generation of EC keys using P256 curve and support ECDSA certs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_BASE_NSSIDENTITY_H_ 11 #ifndef WEBRTC_BASE_NSSIDENTITY_H_
12 #define WEBRTC_BASE_NSSIDENTITY_H_ 12 #define WEBRTC_BASE_NSSIDENTITY_H_
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "cert.h" 16 #include "cert.h"
17 #include "nspr.h" 17 #include "nspr.h"
18 #include "hasht.h" 18 #include "hasht.h"
19 #include "keythi.h" 19 #include "keythi.h"
20 20
21 #ifdef NSS_SSL_RELATIVE_PATH
22 #include "ssl.h"
23 #else
24 #include "net/third_party/nss/ssl/ssl.h"
25 #endif
26
21 #include "webrtc/base/common.h" 27 #include "webrtc/base/common.h"
22 #include "webrtc/base/logging.h" 28 #include "webrtc/base/logging.h"
23 #include "webrtc/base/scoped_ptr.h" 29 #include "webrtc/base/scoped_ptr.h"
24 #include "webrtc/base/sslidentity.h" 30 #include "webrtc/base/sslidentity.h"
25 31
26 namespace rtc { 32 namespace rtc {
27 33
28 class NSSKeyPair { 34 class NSSKeyPair {
29 public: 35 public:
30 NSSKeyPair(SECKEYPrivateKey* privkey, SECKEYPublicKey* pubkey) : 36 NSSKeyPair(SECKEYPrivateKey* privkey, SECKEYPublicKey* pubkey)
31 privkey_(privkey), pubkey_(pubkey) {} 37 : privkey_(privkey), pubkey_(pubkey), ssl_kea_type_(ssl_kea_null) {}
38 NSSKeyPair(SECKEYPrivateKey* privkey,
39 SECKEYPublicKey* pubkey,
40 SSLKEAType ssl_kea_type)
41 : privkey_(privkey), pubkey_(pubkey), ssl_kea_type_(ssl_kea_type) {}
32 ~NSSKeyPair(); 42 ~NSSKeyPair();
33 43
34 // Generate a 1024-bit RSA key pair. 44 // Generate a 1024-bit RSA key pair.
35 static NSSKeyPair* Generate(); 45 static NSSKeyPair* Generate(KeyType key_type);
36 NSSKeyPair* GetReference(); 46 NSSKeyPair* GetReference();
37 47
38 SECKEYPrivateKey* privkey() const { return privkey_; } 48 SECKEYPrivateKey* privkey() const { return privkey_; }
39 SECKEYPublicKey * pubkey() const { return pubkey_; } 49 SECKEYPublicKey * pubkey() const { return pubkey_; }
50 SSLKEAType ssl_kea_type() const { return ssl_kea_type_; }
40 51
41 private: 52 private:
53 SSLKEAType ssl_kea_type_;
42 SECKEYPrivateKey* privkey_; 54 SECKEYPrivateKey* privkey_;
43 SECKEYPublicKey* pubkey_; 55 SECKEYPublicKey* pubkey_;
44 56
45 DISALLOW_COPY_AND_ASSIGN(NSSKeyPair); 57 DISALLOW_COPY_AND_ASSIGN(NSSKeyPair);
46 }; 58 };
47 59
48 60
49 class NSSCertificate : public SSLCertificate { 61 class NSSCertificate : public SSLCertificate {
50 public: 62 public:
51 static NSSCertificate* FromPEMString(const std::string& pem_string); 63 static NSSCertificate* FromPEMString(const std::string& pem_string);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 102
91 CERTCertificate* certificate_; 103 CERTCertificate* certificate_;
92 scoped_ptr<SSLCertChain> chain_; 104 scoped_ptr<SSLCertChain> chain_;
93 105
94 DISALLOW_COPY_AND_ASSIGN(NSSCertificate); 106 DISALLOW_COPY_AND_ASSIGN(NSSCertificate);
95 }; 107 };
96 108
97 // Represents a SSL key pair and certificate for NSS. 109 // Represents a SSL key pair and certificate for NSS.
98 class NSSIdentity : public SSLIdentity { 110 class NSSIdentity : public SSLIdentity {
99 public: 111 public:
100 static NSSIdentity* Generate(const std::string& common_name); 112 static NSSIdentity* Generate(const std::string& common_name,
101 static NSSIdentity* GenerateForTest(const SSLIdentityParams& params); 113 KeyType key_type);
114 static NSSIdentity* GenerateForTest(const SSLIdentityParams& params,
115 KeyType key_type);
102 static SSLIdentity* FromPEMStrings(const std::string& private_key, 116 static SSLIdentity* FromPEMStrings(const std::string& private_key,
103 const std::string& certificate); 117 const std::string& certificate);
104 ~NSSIdentity() override; 118 ~NSSIdentity() override;
105 119
106 NSSIdentity* GetReference() const override; 120 NSSIdentity* GetReference() const override;
107 NSSCertificate& certificate() const override; 121 NSSCertificate& certificate() const override;
108 122
109 NSSKeyPair* keypair() const { return keypair_.get(); } 123 NSSKeyPair* keypair() const { return keypair_.get(); }
110 124
111 private: 125 private:
112 NSSIdentity(NSSKeyPair* keypair, NSSCertificate* cert); 126 NSSIdentity(NSSKeyPair* keypair, NSSCertificate* cert);
113 127
114 static NSSIdentity* GenerateInternal(const SSLIdentityParams& params); 128 static NSSIdentity* GenerateInternal(const SSLIdentityParams& params,
129 KeyType key_type);
115 130
116 rtc::scoped_ptr<NSSKeyPair> keypair_; 131 rtc::scoped_ptr<NSSKeyPair> keypair_;
117 rtc::scoped_ptr<NSSCertificate> certificate_; 132 rtc::scoped_ptr<NSSCertificate> certificate_;
118 133
119 DISALLOW_COPY_AND_ASSIGN(NSSIdentity); 134 DISALLOW_COPY_AND_ASSIGN(NSSIdentity);
120 }; 135 };
121 136
122 } // namespace rtc 137 } // namespace rtc
123 138
124 #endif // WEBRTC_BASE_NSSIDENTITY_H_ 139 #endif // WEBRTC_BASE_NSSIDENTITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698