| OLD | NEW |
| 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 // Hack: Define+undefine int64 and uint64 to avoid typedef conflict with NSS. | 16 // Hack: Define+undefine int64 and uint64 to avoid typedef conflict with NSS. |
| 17 // TODO(kjellander): Remove when webrtc:4497 is completed. | 17 // TODO(kjellander): Remove when webrtc:4497 is completed. |
| 18 #define uint64 foo_uint64 | 18 #define uint64 foo_uint64 |
| 19 #define int64 foo_int64 | 19 #define int64 foo_int64 |
| 20 #include "cert.h" | 20 #include "cert.h" |
| 21 #undef uint64 | 21 #undef uint64 |
| 22 #undef int64 | 22 #undef int64 |
| 23 #include "nspr.h" | 23 #include "nspr.h" |
| 24 #include "hasht.h" | 24 #include "hasht.h" |
| 25 #include "keythi.h" | 25 #include "keythi.h" |
| 26 | 26 |
| 27 #ifdef NSS_SSL_RELATIVE_PATH |
| 28 #include "ssl.h" |
| 29 #else |
| 30 #include "net/third_party/nss/ssl/ssl.h" |
| 31 #endif |
| 32 |
| 27 #include "webrtc/base/common.h" | 33 #include "webrtc/base/common.h" |
| 28 #include "webrtc/base/logging.h" | 34 #include "webrtc/base/logging.h" |
| 29 #include "webrtc/base/scoped_ptr.h" | 35 #include "webrtc/base/scoped_ptr.h" |
| 30 #include "webrtc/base/sslidentity.h" | 36 #include "webrtc/base/sslidentity.h" |
| 31 | 37 |
| 32 namespace rtc { | 38 namespace rtc { |
| 33 | 39 |
| 34 class NSSKeyPair { | 40 class NSSKeyPair { |
| 35 public: | 41 public: |
| 36 NSSKeyPair(SECKEYPrivateKey* privkey, SECKEYPublicKey* pubkey) : | 42 NSSKeyPair(SECKEYPrivateKey* privkey, SECKEYPublicKey* pubkey) |
| 37 privkey_(privkey), pubkey_(pubkey) {} | 43 : privkey_(privkey), pubkey_(pubkey), ssl_kea_type_(ssl_kea_null) {} |
| 44 NSSKeyPair(SECKEYPrivateKey* privkey, |
| 45 SECKEYPublicKey* pubkey, |
| 46 SSLKEAType ssl_kea_type) |
| 47 : privkey_(privkey), pubkey_(pubkey), ssl_kea_type_(ssl_kea_type) {} |
| 38 ~NSSKeyPair(); | 48 ~NSSKeyPair(); |
| 39 | 49 |
| 40 // Generate a 1024-bit RSA key pair. | 50 // Generate a 1024-bit RSA key pair. |
| 41 static NSSKeyPair* Generate(); | 51 static NSSKeyPair* Generate(KeyType key_type); |
| 42 NSSKeyPair* GetReference(); | 52 NSSKeyPair* GetReference(); |
| 43 | 53 |
| 44 SECKEYPrivateKey* privkey() const { return privkey_; } | 54 SECKEYPrivateKey* privkey() const { return privkey_; } |
| 45 SECKEYPublicKey * pubkey() const { return pubkey_; } | 55 SECKEYPublicKey * pubkey() const { return pubkey_; } |
| 56 SSLKEAType ssl_kea_type() const { return ssl_kea_type_; } |
| 46 | 57 |
| 47 private: | 58 private: |
| 59 SSLKEAType ssl_kea_type_; |
| 48 SECKEYPrivateKey* privkey_; | 60 SECKEYPrivateKey* privkey_; |
| 49 SECKEYPublicKey* pubkey_; | 61 SECKEYPublicKey* pubkey_; |
| 50 | 62 |
| 51 DISALLOW_COPY_AND_ASSIGN(NSSKeyPair); | 63 DISALLOW_COPY_AND_ASSIGN(NSSKeyPair); |
| 52 }; | 64 }; |
| 53 | 65 |
| 54 | 66 |
| 55 class NSSCertificate : public SSLCertificate { | 67 class NSSCertificate : public SSLCertificate { |
| 56 public: | 68 public: |
| 57 static NSSCertificate* FromPEMString(const std::string& pem_string); | 69 static NSSCertificate* FromPEMString(const std::string& pem_string); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 108 |
| 97 CERTCertificate* certificate_; | 109 CERTCertificate* certificate_; |
| 98 scoped_ptr<SSLCertChain> chain_; | 110 scoped_ptr<SSLCertChain> chain_; |
| 99 | 111 |
| 100 DISALLOW_COPY_AND_ASSIGN(NSSCertificate); | 112 DISALLOW_COPY_AND_ASSIGN(NSSCertificate); |
| 101 }; | 113 }; |
| 102 | 114 |
| 103 // Represents a SSL key pair and certificate for NSS. | 115 // Represents a SSL key pair and certificate for NSS. |
| 104 class NSSIdentity : public SSLIdentity { | 116 class NSSIdentity : public SSLIdentity { |
| 105 public: | 117 public: |
| 106 static NSSIdentity* Generate(const std::string& common_name); | 118 static NSSIdentity* Generate(const std::string& common_name, |
| 119 KeyType key_type); |
| 107 static NSSIdentity* GenerateForTest(const SSLIdentityParams& params); | 120 static NSSIdentity* GenerateForTest(const SSLIdentityParams& params); |
| 108 static SSLIdentity* FromPEMStrings(const std::string& private_key, | 121 static SSLIdentity* FromPEMStrings(const std::string& private_key, |
| 109 const std::string& certificate); | 122 const std::string& certificate); |
| 110 ~NSSIdentity() override; | 123 ~NSSIdentity() override; |
| 111 | 124 |
| 112 NSSIdentity* GetReference() const override; | 125 NSSIdentity* GetReference() const override; |
| 113 NSSCertificate& certificate() const override; | 126 NSSCertificate& certificate() const override; |
| 114 | 127 |
| 115 NSSKeyPair* keypair() const { return keypair_.get(); } | 128 NSSKeyPair* keypair() const { return keypair_.get(); } |
| 116 | 129 |
| 117 private: | 130 private: |
| 118 NSSIdentity(NSSKeyPair* keypair, NSSCertificate* cert); | 131 NSSIdentity(NSSKeyPair* keypair, NSSCertificate* cert); |
| 119 | 132 |
| 120 static NSSIdentity* GenerateInternal(const SSLIdentityParams& params); | 133 static NSSIdentity* GenerateInternal(const SSLIdentityParams& params); |
| 121 | 134 |
| 122 rtc::scoped_ptr<NSSKeyPair> keypair_; | 135 rtc::scoped_ptr<NSSKeyPair> keypair_; |
| 123 rtc::scoped_ptr<NSSCertificate> certificate_; | 136 rtc::scoped_ptr<NSSCertificate> certificate_; |
| 124 | 137 |
| 125 DISALLOW_COPY_AND_ASSIGN(NSSIdentity); | 138 DISALLOW_COPY_AND_ASSIGN(NSSIdentity); |
| 126 }; | 139 }; |
| 127 | 140 |
| 128 } // namespace rtc | 141 } // namespace rtc |
| 129 | 142 |
| 130 #endif // WEBRTC_BASE_NSSIDENTITY_H_ | 143 #endif // WEBRTC_BASE_NSSIDENTITY_H_ |
| OLD | NEW |